Some buffers are created by Emacs and is set in fundamental mode, like the *Org-Babel results*
. I think it is more convenient to set them in special mode, which can be closed with key q
. How do set the mode for those automatic buffers or if the name contains *
?
Lawlist and Drew's comments below show possible ways to do it, what I want is a special-display buffers for some buffers with *...*
names. The appropriate way of course is to find the function for creating the buffer and change it in the package, but it doesn't suit everybody.
Since special-display-regexps
is obsolete, can anyone help me on an display-buffer-alist
with a custom function to look for *Org-Babel Results*
and set it to special mode?
get-buffer-create
,display-buffer
,pop-to-buffer
, etc. – lawlist Jun 16 '15 at 23:56ob-core.el
and a line of code that looks like:(pop-to-buffer (get-buffer-create "*Org-Babel Results*"))
Now, I don't use that library and have no idea what it is used for, but I'll bet my lunch money that either that line or something similar to that line would be a prospective location to make modifications. A new function can be created in the.emacs
file by having a preceding require statement -- e.g.,(require 'ob-core)
and then the new function with the same name -- i.e.,(defun org-babel-open-src-block-result (&optional re-run) . . .
– lawlist Jun 17 '15 at 00:07(pop-to-buffer (get-buffer-create "*Org-Babel Results*"))
or after the next line -- i.e.,(delete-region (point-min) (point-max))
-- you could add a line(with-current-buffer (get-buffer "*Org-Babel Results*") (enable-my-custom-major-mode))
In my opinion, this is much more precise/localized than customizing thedisplay-buffer-alist
with a custom function to look for*Org-Babel Results*
, which is another possibility, but I don't recommend broad brush approaches like that. – lawlist Jun 17 '15 at 00:18special-display-regexps
to("[ ]?[*][^*]+[*]")
, for buffers with*...*
names? Are you looking for buffers whose mode inherits fromspecial-mode
, so thatq
quits them? There's no guessing what you are really asking for? What happened to software people being able to specify something? ;-) – Drew Jun 17 '15 at 01:21(special-mode)
at the right location in the elisp code after the buffer is created. – Kaushal Modi Jun 17 '15 at 17:14paradox
package of what I am talking about above. – Kaushal Modi Jun 17 '15 at 17:24display-buffer-alist
on a let-bound basis to examine (among other criteria) the buffer name matching certain predefined regexp -- the comments indicate how to set this globally usingsetq
-- the thread title is How to intercept a file before it opens and decide which frame: http://stackoverflow.com/a/18371427/2112489 – lawlist Jun 17 '15 at 17:28