samedi 1 mai 2010

emacs -nw

emacs --help
--no-window-system, -nw do not communicate with X, ignoring $DISPLAY
也就是使用命令:emacs -nw ,就可以在terminal中打开emacs。

但是发现打开的frame无法使用快捷键C-x C-c关闭。借用网络上牛人的lisp,如下。也就是使用M-x ic关闭frame。


;;This method, when bound to C-x C-c, allows you to close an emacs frame the
;;same way, whether it's the sole window you have open, or whether it's
;;a "child" frame of a "parent" frame. If you're like me, and use emacs in
;;a windowing environment, you probably have lots of frames open at any given
;;time. Well, it's a pain to remember to do Ctrl-x 5 0 to dispose of a child
;;frame, and to remember to do C-x C-x to close the main frame (and if you're
;;not careful, doing so will take all the child frames away with it). This
;;is my solution to that: an intelligent close-frame operation that works in
;;all cases (even in an emacs -nw session).
;;(global-set-key "\C-x\C-c" 'ic) ;forward reference
(defun ic ()
"quit a frame the same way no matter what kind of frame you are on"
(interactive)
(if (eq (car (visible-frame-list)) (selected-frame))
;;for parent/master frame...
(if (> (length (visible-frame-list)) 1)
;;close a parent with children present
(delete-frame (selected-frame))
;;close a parent with no children present
(save-buffers-kill-emacs))
;;close a child frame
(delete-frame (selected-frame))))

Aucun commentaire:

Enregistrer un commentaire