mayer@hplabsz.UUCP (08/31/87)
a few examples of where the mode-class property is used:
blackbox.el :: (put 'blackbox-mode 'mode-class 'special)
buff-menu.el :: (put 'buffer-menu-mode 'mode-class 'special)
dired.el :: (put 'dired-mode 'mode-class 'special)
ebuff-menu.el :: (put 'Electric-buffer-menu-mode 'mode-class 'special)
Can someone explain why this is done?
Oh yeah, and while I've got your attention let me ask another question:
what is it about the buffers created by shell-command, dired, etc. that allows
kill-buffer to delete the buffer without querying the user with
"Buffer xyzzy modified; kill anyway?". If one evals buffer-modified-p
in that buffer, it will return 't', yet kill-buffer rightly kills these
buffers without asking.
In buffer.c, buffer-modified-p does
bf_cur->text.modified = bf_modified;
return buf->save_modified < buf->text.modified ? Qt : Qnil;
to return 't' or 'nil' depending on whether the buffer has been modified.
kill-buffer does
/* Make sure b->text.modified is correct
even if buffer is selected now. */
bf_cur->text.modified = bf_modified;
if (INTERACTIVE && !NULL (b->filename)
&& b->text.modified > b->save_modified)
{
tem = Fyes_or_no_p (format1 ("Buffer %s modified; kill anyway? ",
XSTRING (b->name)->data));
if (NULL (tem))
return Qnil;
}
in order to query the user about killing a modified buffer.
-- Niels Mayer
Hewlett-Packard Laboratories.
PS: Please post any followups to this article. There's no point in keeping
this information a secret.
hammer@uiucdcsb.UUCP (09/01/87)
/* Written 8:12 pm Aug 30, 1987 by mayer@hplabsz.HPL.HP.COM in uiucdcsb:comp.emacs */
/* ---------- "gnuemacs quesion: what does (put 'x" ---------- */
<...>
Oh yeah, and while I've got your attention let me ask another question:
what is it about the buffers created by shell-command, dired, etc. that allows
kill-buffer to delete the buffer without querying the user with
"Buffer xyzzy modified; kill anyway?". If one evals buffer-modified-p
in that buffer, it will return 't', yet kill-buffer rightly kills these
buffers without asking.
<...>
kill-buffer does
/* Make sure b->text.modified is correct
even if buffer is selected now. */
bf_cur->text.modified = bf_modified;
if (INTERACTIVE && !NULL (b->filename)
&& b->text.modified > b->save_modified)
{
tem = Fyes_or_no_p (format1 ("Buffer %s modified; kill anyway? ",
XSTRING (b->name)->data));
if (NULL (tem))
return Qnil;
}
in order to query the user about killing a modified buffer.
-- Niels Mayer
Hewlett-Packard Laboratories.
PS: Please post any followups to this article. There's no point in keeping
this information a secret.
/* End of text from uiucdcsb:comp.emacs */
You answered your own question. A *shell* buffer (for example) has no
associated file, so b->filename is null.
David Hammerslag
University of Illinois at Urbana-Champaign
hammer@a.cs.uiuc.edu (ARPA)
hammer@uiuc.csnet (CSNET)
{pur-ee, ihnp4}!uiucdcs!hammer (USENET)
drw@cullvax.UUCP (Dale Worley) (09/01/87)
mayer@hplabsz.HPL.HP.COM (Niels Mayer) writes: > Oh yeah, and while I've got your attention let me ask another question: > what is it about the buffers created by shell-command, dired, etc. that allows > kill-buffer to delete the buffer without querying the user with > "Buffer xyzzy modified; kill anyway?". I think it's the fact that the buffer name starts with '*'. At least, if I manually make such a buffer (via c-X B), I can delete it without it questioning me. Dale -- Dale Worley Cullinet Software ARPA: cullvax!drw@eddie.mit.edu UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw Apollo was the doorway to the stars - next time we should open it. Disclaimer: Don't sue me, sue my company - they have more money.
tom@uw-warp.UUCP (F. Thomas May) (09/05/87)
In article <740@hplabsz.HPL.HP.COM> mayer@hplabsz.HPL.HP.COM (Niels Mayer) writes: a few examples of where the mode-class property is used: blackbox.el :: (put 'blackbox-mode 'mode-class 'special) buff-menu.el :: (put 'buffer-menu-mode 'mode-class 'special) dired.el :: (put 'dired-mode 'mode-class 'special) ebuff-menu.el :: (put 'Electric-buffer-menu-mode 'mode-class 'special) Can someone explain why this is done? This is not at all obvious, but if you look at the documentation for the variable default-major-mode it says: *Major mode for new buffers. Defaults to fundamental-mode. nil here means use current buffer's major mode. What it should say is: *Major mode for new buffers. Defaults to fundamental-mode. nil here means use current buffer's major mode, unless the mode-class property of the current buffer's major mode is non-nil, in which case use fundamental-mode. This just keeps newly created buffers from being in modes, such as blackbox-mode, that are useful only for specially formatted data or for doing special things. The result is that if you C-x b to a new buffer in the middle of a blackbox game to write yourself a note or something, the buffer ends up in a mode you can use for editing. -- Tom May uw-nsr!uw-warp!tom@beaver.cs.washington.edu uw-beaver!uw-nsr!uw-warp!tom