From: leoboiko@gmail.com
To: help-gnu-emacs@gnu.org
Subject: Re: How to apply a minor mode to all buffers
Date: Fri, 02 Feb 2007 17:27:24 -0200 [thread overview]
Message-ID: <87lkjgs6lf.wl%leonardo.boiko@corp.orolix.com> (raw)
In-Reply-To: <jwvejpnc84f.fsf-monnier+gnu.emacs.help@gnu.org>
At Mon, 22 Jan 2007 11:57:35 -0500,
Stefan Monnier wrote:
> You could start with find-file-hook.
find-file-hook won’t apply to buffers unrelated to files, though.
after-change-major-mode-hook almost does the trick, but it still
doesn’t get fundamental-mode.
What I’d like is fundamental-mode-hook.
“Damn vim users”, I said. “Keep leaving those trailing whitespaces
all over the place. It disrupts my mental concentration, for I have
show-trailing-whitespace globally as t, and I have to stop whatever
I’m doing to delete-trailing-whitespace.”
“You could put it in a hook, you know”, said my friend.
“Yes, of course”, I replied, with my best “why I didn’t think of this
before” voice. “But I need to test whether the buffer is read-only,
else we’d generate lots of beeps”:
(setq-default show-trailing-whitespace nil)
(defun leoboiko/delete-and-show-trailing-whitespace ()
"If the buffer is not readonly, delete trailing whitespace and turn on
`show-trailing-whitespace'."
(interactive)
(if (not buffer-read-only)
(progn
(delete-trailing-whitespace)
(setq show-trailing-whitespace t))))
(add-hook 'hook-for-all-buffers ;; what to put here?
'leoboiko/delete-and-show-trailing-whitespace)
My first attempt was find-file-hook, but I want it to apply to
non-file buffers too (like email drafts, etc). My second attempt was
fundamental-mode-hook, but there is no such thing. My third attempt
(after reading fundamental-mode’s source) was
after-change-major-mode-hook, but this still doesn’t work for
fundamental buffers (say, if I simply create a scratch buffer).
The rationale I saw about why there is no fundamental-mode-hook is
that variable customizations on fundamental mode are really global
customizations. That’s nice, but I don’t want to change variables, I
want to be able to run arbitrary functions every time a buffer is
created.
--
Leonardo Boiko
http://namakajiri.net
next prev parent reply other threads:[~2007-02-02 19:27 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.3212.1169056299.2155.help-gnu-emacs@gnu.org>
2007-01-18 3:20 ` How to apply a minor mode to all buffers Stefan Monnier
2007-01-18 21:08 ` Malte Spiess
2007-01-18 22:03 ` Drew Adams
2007-01-18 22:33 ` James Aguilar
2007-01-18 22:40 ` Drew Adams
2007-01-19 10:37 ` Eli Zaretskii
2007-01-19 16:30 ` James Aguilar
2007-01-19 17:06 ` Juanma Barranquero
2007-01-20 16:24 ` Eli Zaretskii
[not found] ` <mailman.3350.1169310294.2155.help-gnu-emacs@gnu.org>
2007-01-20 17:38 ` Robert Thorpe
2007-01-20 18:41 ` Lennart Borgman (gmail)
2007-01-22 6:55 ` Mathias Dahl
[not found] ` <mailman.3356.1169318483.2155.help-gnu-emacs@gnu.org>
2007-01-22 11:48 ` Robert Thorpe
2007-01-22 21:23 ` Eli Zaretskii
[not found] ` <mailman.3429.1169501014.2155.help-gnu-emacs@gnu.org>
2007-01-23 17:48 ` Robert Thorpe
2007-01-23 21:56 ` Eli Zaretskii
2007-01-22 16:59 ` Stefan Monnier
[not found] ` <mailman.3316.1169224240.2155.help-gnu-emacs@gnu.org>
2007-01-22 16:57 ` Stefan Monnier
2007-02-02 19:27 ` leoboiko [this message]
2007-02-03 15:29 ` Juanma Barranquero
2007-02-05 17:07 ` Leonardo Boiko
2007-02-05 22:14 ` Juanma Barranquero
2007-02-07 7:42 ` Kevin Rodgers
2007-02-08 12:10 ` Leonardo Boiko
[not found] ` <mailman.3919.1170444615.2155.help-gnu-emacs@gnu.org>
2007-02-07 17:22 ` Stefan Monnier
2007-02-07 17:51 ` Robert Thorpe
2007-02-08 12:23 ` Leonardo Boiko
2007-02-08 12:20 ` Leonardo Boiko
2007-02-08 12:30 ` Juanma Barranquero
[not found] ` <mailman.4176.1170937835.2155.help-gnu-emacs@gnu.org>
2007-02-08 16:26 ` Robert Thorpe
2007-02-08 22:39 ` Juanma Barranquero
[not found] ` <mailman.4209.1170974375.2155.help-gnu-emacs@gnu.org>
2007-02-09 11:48 ` Robert Thorpe
2007-02-09 12:46 ` Juanma Barranquero
2007-01-17 17:51 James Aguilar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87lkjgs6lf.wl%leonardo.boiko@corp.orolix.com \
--to=leoboiko@gmail.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).