En mis .emacs tengo la siguiente función que transpone una línea.emacs global-set-key y llamar a la función interactiva con el argumento
(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))))
Y vincular una clave para ello como esto
(global-set-key (kbd "M-<down>") 'move-line)
;; this is the same as M-x global-set-key <return>
Sin embargo, quiero unir M-arriba para mover la línea (-1) Pero parece que no puede ser capaz de hacerlo correctamente:
;; M-- M-1 M-x global-set-key <return>
¿Cómo defino lo anterior utilizando global-set-key para llamar a move-line -1?
Just FYI: hay una función transpose-lines integrada en emacs. Pruebe el atajo C-x C-t. – polyglot