小编yrr*_*ral的帖子

.emacs global-set-key并使用参数调用交互式函数

在我的.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))))
Run Code Online (Sandbox Code Playgroud)

我像这样绑定一把钥匙

(global-set-key (kbd "M-<down>") 'move-line)
;; this is the same as M-x global-set-key <return>
Run Code Online (Sandbox Code Playgroud)

但是,我想将M-up绑定到移动线(-1)但是我似乎无法正确地做到:

;; M-- M-1 M-x global-set-key <return>
Run Code Online (Sandbox Code Playgroud)

如何使用global-set-key调用move-line -1来定义上述内容?

emacs elisp

24
推荐指数
2
解决办法
9547
查看次数

标签 统计

elisp ×1

emacs ×1