1

テキストのマークされた領域を、アンダースコアで連結されたすべての小文字の単語に変更したいと考えています。例えば:

A fox caught a bird => a_fox_caught_a_bird

Emacs 23の機能は何ですか?

4

1 に答える 1

7

必要なことを実行する組み込み関数はありませんが、このスニペットでうまくいきます。

(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 "_"))))
于 2013-03-20T16:13:20.063 に答える