如果没有选择区域,我编写了一个 elisp 函数来复制当前行,但它在 emacs 24.5 上不起作用。当我点击“Mw”键击时,迷你缓冲区中会出现一条消息“Mark set”。我错过了什么?
(defun copy-region-or-current-line (beg end)
"copy current if no region selected, copy the region otherwise"
(interactive "r")
(let ((cur-pos (point)))
(if (region-active-p)
(kill-ring-save beg end)
(progn
(kill-whole-line)
(yank)
(goto-char cur-pos)))))
(global-set-key (kbd "M-w") 'copy-region-or-current-line)