unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Cecil Westerhof <Cecil@decebal.nl>
To: help-gnu-emacs@gnu.org
Subject: How to exclude a major mode from a hook
Date: Wed, 11 Feb 2015 10:22:40 +0100	[thread overview]
Message-ID: <87twysx0nz.fsf@Equus.decebal.nl> (raw)

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


             reply	other threads:[~2015-02-11  9:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-11  9:22 Cecil Westerhof [this message]
2015-02-11  9:50 ` How to exclude a major mode from a hook Fabrice Niessen
2015-02-11 12:31   ` Cecil Westerhof
2015-02-11 10:15 ` Nicolas Richard
2015-02-12  2:39   ` Robert Thorpe

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=87twysx0nz.fsf@Equus.decebal.nl \
    --to=cecil@decebal.nl \
    --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).