unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* How to exclude a major mode from a hook
@ 2015-02-11  9:22 Cecil Westerhof
  2015-02-11  9:50 ` Fabrice Niessen
  2015-02-11 10:15 ` Nicolas Richard
  0 siblings, 2 replies; 5+ messages in thread
From: Cecil Westerhof @ 2015-02-11  9:22 UTC (permalink / raw)
  To: help-gnu-emacs

I had the following in my .emacs:
    (add-hook 'before-save-hook 'delete-trailing-whitespace)

But I also use Gnus and a signature starts with '-- ' and now the
space is deleted and it is not a signature anymore.

So I rewrote it to:
    (add-hook 'before-save-hook (lambda () (when (not (string= major-mode "message-mode"))
                                             'delete-trailing-whitespace)))

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-02-12  2:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-11  9:22 How to exclude a major mode from a hook Cecil Westerhof
2015-02-11  9:50 ` Fabrice Niessen
2015-02-11 12:31   ` Cecil Westerhof
2015-02-11 10:15 ` Nicolas Richard
2015-02-12  2:39   ` Robert Thorpe

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).