我的.emacs文件中有这段代码,应该向上或向下移动代码行。这在24.3.1上工作正常但在24.4上没有完全正常工作。
将线移动工作,因为线将与底线交换,“光标”也会移动。
然后移动线,它会交换,但光标保持在同一条线上,而不会随着线向上移动。
这是否有原因?
;; Moving a line up or down
(defun move-text-internal (arg)
(cond
((and mark-active transient-mark-mode)
(if (> (point) (mark))
(exchange-point-and-mark))
(let ((column (current-column))
(text (delete-and-extract-region (point) (mark))))
(forward-line arg)
(move-to-column column t)
(set-mark (point))
(insert text)
(exchange-point-and-mark)
(setq deactivate-mark nil)))
(t
(let ((column (current-column)))
(beginning-of-line)
(when (or (> arg 0) (not (bobp)))
(forward-line)
(when (or (< arg 0) (not (eobp)))
(transpose-lines arg))
(forward-line -1))
(move-to-column column t)))))
(defun move-text-down (arg)
"Move region (transient-mark-mode active) or current line
arg lines down."
(interactive "*p")
(move-text-internal arg))
;(global-set-key [M-S-down] 'move-text-down)
(global-set-key [A-M-down] 'move-text-down)
(defun move-text-up (arg)
"Move region (transient-mark-mode active) or current line
arg lines up."
(interactive "*p")
(move-text-internal (- arg)))
;(global-set-key [M-S-up] 'move-text-up)
(global-set-key [A-M-up] 'move-text-up)