Supposed I had a buffer in emacs with 1000 lines, and dotted around in that buffer were unicode references (eg. \u8226
). I want to collect all those references into another buffer, which I can then sort and uniquify.
假设我在拥有1000行的emacs中有一个缓冲区,并且在该缓冲区中点缀了unicode引用(例如。\ u8226)。我想将所有这些引用收集到另一个缓冲区中,然后我可以对其进行排序和统一。
On the (*nix) command line, I can do something like:
在(* nix)命令行上,我可以执行以下操作:
grep -o "\\\\u[0-9]*" tmpfile | sort | uniq
Is this achievable directly within emacs, without saving any buffers to disk?
这是否可以直接在emacs中实现,而无需将任何缓冲区保存到磁盘?
2 个解决方案
#1
6
Go to your buffer, select it all with C-x h
, then do M-| grep -o "\\\\u[0-9]*" | sort | uniq
(this runs shell-command-on-region
). The output will go to *Shell Command Output*
, which will not be shown unless the output is long enough, but it's always created and you can switch to it regardless.
转到缓冲区,用C-x h选择全部,然后执行M- | grep -o“\\\\ u [0-9] *”|排序| uniq(运行shell-command-on-region)。输出将转到* Shell命令输出*,除非输出足够长,否则不会显示,但它始终是创建的,无论如何都可以切换到它。
There is also occur
(M-s o
).
也有(M-s o)。
#2
6
M-x occur RET [[:nonascii:]]+ RET M-x other-window M-x toggle-read-only M-x sort-lines
#1
6
Go to your buffer, select it all with C-x h
, then do M-| grep -o "\\\\u[0-9]*" | sort | uniq
(this runs shell-command-on-region
). The output will go to *Shell Command Output*
, which will not be shown unless the output is long enough, but it's always created and you can switch to it regardless.
转到缓冲区,用C-x h选择全部,然后执行M- | grep -o“\\\\ u [0-9] *”|排序| uniq(运行shell-command-on-region)。输出将转到* Shell命令输出*,除非输出足够长,否则不会显示,但它始终是创建的,无论如何都可以切换到它。
There is also occur
(M-s o
).
也有(M-s o)。
#2
6
M-x occur RET [[:nonascii:]]+ RET M-x other-window M-x toggle-read-only M-x sort-lines