2
我想設置一個命令,在兩個§
字符之間放置行的內容而不移動點(不包括包含§
的行)。在Emacs中定義一個複製段命令
這裏是我當前的嘗試
(defun copy-section()
"Copy current section, that is lines between two §."
(interactive)
(save-excursion
(when (not (search-backward-regexp "§" nil t))
(goto-char (point-min)))
(forward-line 1)
(when (not (search-forward-regexp "§" nil t))
(goto-char (point-max)))
(move-beginning-of-line nil)
(kill-ring-save (mark) (point))))
它運作良好,但對周圍的標記移動是壞的風格讓我覺得taht有一個更好的方式來達到同樣的結果文檔中的言論。 將位置保存到變量中(我不知道如何去做)可以實現更清晰的功能。
上述代碼的一部分來自ergoemacs。