all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Cecil Westerhof <Cecil@decebal.nl>
To: help-gnu-emacs@gnu.org
Subject: Re: How to exclude a major mode from a hook
Date: Wed, 11 Feb 2015 13:31:03 +0100	[thread overview]
Message-ID: <87lhk4wry0.fsf@Equus.decebal.nl> (raw)
In-Reply-To: 86iof86alo.fsf@example.com

Op Wednesday 11 Feb 2015 10:50 CET schreef Fabrice Niessen:

> Cecil Westerhof wrote:
>> 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)))
>
> I do have:
>
> ;; Nuke all trailing whitespaces in the buffer.
> (add-hook 'before-save-hook
> (lambda ()                  ; Except for ...
> (unless (or (eq major-mode 'message-mode)
> ; ... where "-- " is the signature
> ; separator (for when using emacsclient
> ; to compose emails and doing C-x #).
> (eq major-mode 'diff-mode))
> ; ... where the patch file can't be
> ; changed!
> (delete-trailing-whitespace))))

At the moment I do not use diff-mode, but it does not hurt to add it.
;-)

Also your solution is a little more clear. (unless instead of not)

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


  reply	other threads:[~2015-02-11 12:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhk4wry0.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.