編輯:我知道有鍵盤退出(這通常綁定到C - G);但我更感興趣的是瞭解如何處理Emacs編輯功能(如本例中的情況)。我偶爾遇到這種情況,當時我只想改變一些內置函數。,keyboard-escape-quit的最佳方式是什麼,不會破壞其他窗口?
在emacs中,當你打M-ESC ESC(或者ESC三次)時,你可以擺脫很多情況,比如transient-mark等等。但是我習慣性地按下了轉義鍵(我實際上將它重映射到一個命中的逃生鍵)超過我的意圖,並最終殺死我的Windows配置,這是很煩人的。功能鍵盤逃逸遷出在simple.el定義:
(defun keyboard-escape-quit()
"Exit the current \"mode\" (in a generalized sense of the word).
This command can exit an interactive command such as `query-replace',
can clear out a prefix argument or a region,
can get out of the minibuffer or other recursive edit,
cancel the use of the current buffer (for special-purpose buffers),
or go back to just one window (by deleting all but the selected window)."
(interactive)
(cond ((eq last-command 'mode-exited) nil)
((> (minibuffer-depth) 0)
(abort-recursive-edit))
(current-prefix-arg
nil)
((and transient-mark-mode mark-active)
(deactivate-mark))
((> (recursion-depth) 0)
(exit-recursive-edit))
(buffer-quit-function
(funcall buffer-quit-function))
((not (one-window-p t))
(delete-other-windows))
((string-match "^ \\*" (buffer-name (current-buffer)))
(bury-buffer))))
而且我可以看到,我不想讓行:
((not (one-window-p t))
(delete-other-windows))
但是,什麼是修改這一目標的最佳方式功能?我只能看到兩種方法:1)修改simple.el 2)將此函數複製到我的.emacs文件並在那裏進行修改。兩種方式都不是真的好;理想情況下,我希望看到defadvice上的一些內容,但我不明白在這種情況下我該怎麼做。
使用flet的更好的單線程版本) (flet((one-window-p(&optional nomini all-frames)t))ad-do-it)) – polyglot 2009-06-20 16:22:05