ホームディレクトリの.emacsに
(global-set-key (kbd "M-up") 'move-line-up) (global-set-key (kbd "M-down") 'move-line-down)
と書いて、M-<上矢印>, M-<下矢印>に自作の関数move-line-up, move-line-downを割り当てようとしたのですが、次のようなエラーが出ます。
Warning (initialization): An error occurred while loading `/user/.emacs': error: M- must prefix a single character, not up To ensure normal operation, you should investigate and remove the cause of the error in your initialization file. Start Emacs with the `--debug-init' option to view a complete error backtrace.
M-x-describe-key-brieflyとして、上矢印キーを押すと、
<up> runs the command previous-line
と表示されたので、upという名前を使っています。
move-line-up, move-line-downの中身は以下のようになっています。
(defun move-line-down () (interactive) (let ((col (current-column))) (unless (eq col 0) (move-to-column 0)) (save-excursion (forward-line) (transpose-lines 1)) (forward-line))) (defun move-line-up () (interactive) (let ((col (current-column))) (unless (eq col 0) (move-to-column 0)) (save-excursion (forward-line) (transpose-lines -1)) (if (>= emacs-major-version 24) ;; emacsのバージョンが24以上であるときだけ (forward-line -1)) ;; 1行手前に移動する ))
環境は
emacs23.3.1, emacs23.4.1, emacs24.4.1
の3つを使用しています。
解決方法のわかる方いらっしゃったらご教示ください。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/13 07:57