【发布时间】:2009-06-23 02:33:51
【问题描述】:
在我的 .emacs 中,我有以下转置一行的函数
(defun move-line (n)
"Move the current line up or down by N lines."
(interactive "p")
(let ((col (current-column))
start
end)
(beginning-of-line)
(setq start (point))
(end-of-line)
(forward-char)
(setq end (point))
(let ((line-text (delete-and-extract-region start end)))
(forward-line n)
(insert line-text)
;; restore point to original column in moved line
(forward-line -1)
(forward-char col))))
我像这样绑定一个键
(global-set-key (kbd "M-<down>") 'move-line)
;; this is the same as M-x global-set-key <return>
但是,我想将 M-up 绑定到移动线 (-1) 但我似乎无法正确执行:
;; M-- M-1 M-x global-set-key <return>
如何定义上述使用 global-set-key 调用 move-line -1?
【问题讨论】:
-
仅供参考:emacs 中内置了转置线函数。试试快捷键 C-x C-t。