我想将标记的文本区域更改为由下划线连接的所有小写单词.例如:
A fox caught a bird => a_fox_caught_a_bird
Run Code Online (Sandbox Code Playgroud)
Emacs 23 的功能是什么?
没有内置函数可以执行您想要的操作,但是这个代码片段可以解决问题.
(defun lower-and-concat (b e)
(interactive "r")
(save-restriction
(narrow-to-region b e)
(goto-char (point-min))
(downcase-region b e)
(while (re-search-forward "[ \t]+" nil t)
(replace-match "_"))))
Run Code Online (Sandbox Code Playgroud)