elisp - Make emacs next-buffer skip *Messages* buffer -



elisp - Make emacs next-buffer skip *Messages* buffer -

i'd create simple alter emacs next-buffer , previous-buffer commands (which have bound c-x <right> , c-x <left> skip on *messages* buffer.

i'm using emacs 24 , emacs starter kit.

i've read next related questions , answers, not want:

buffer cycling in emacs: avoiding scratch , messages buffer emacs disable *messages* buffer emacs lisp buffer out of focus function?

here of reasons why don't work:

i'd maintain simple possible. fewer configuration changes better. i don't want kill or prevent *messages* altogether. (add-to-list 'ido-ignore-buffers "^\*messages\*" helps c-x b (ido-switch-buffer) not alter how next-buffer , previous-buffer behave.

the simplest can think of defining advice both functions. here next-buffer. previous-buffer. can define configuration variable enable/disable behavior (or activating/deactivating advice):

(defadvice next-buffer (after avoid-messages-buffer-in-next-buffer) "advice around `next-buffer' avoid going *messages* buffer." (when (string= "*messages*" (buffer-name)) (next-buffer))) ;; activate advice (ad-activate 'next-buffer)

maybe can compare buffers in other way instead of string name, work. code previous buffer same. don't know either if there way of calling original function without triggering advice 1 time within advice itself, again, code work if name of buffer tested afterwards (will fail if have one buffer, , messages buffer; code can check if there 1 buffer , don't phone call next-buffer again).

if want utilize standalone function same thing:

(defun my-next-buffer () "next-buffer, skip *messages*" (interactive) (next-buffer) (when (string= "*messages*" (buffer-name)) (next-buffer))) (global-set-key [remap next-buffer] 'my-next-buffer) (global-set-key [remap previous-buffer] 'my-next-buffer)

emacs elisp

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -