Reputation: 3895
I want to change a marked region of text to all lower-case words concatenated by underscores. For example:
A fox caught a bird => a_fox_caught_a_bird
What is the function in Emacs 23?
Upvotes: 1
Views: 166
Reputation: 74480
There is no built-in function that does what you want, but this snippet will do the trick.
(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 "_"))))
Upvotes: 7