From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Cecil Westerhof Newsgroups: gmane.emacs.help Subject: Re: How to exclude a major mode from a hook Date: Wed, 11 Feb 2015 13:31:03 +0100 Organization: Decebal Computing Message-ID: <87lhk4wry0.fsf@Equus.decebal.nl> References: <87twysx0nz.fsf@Equus.decebal.nl> <86iof86alo.fsf@example.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1423659330 18405 80.91.229.3 (11 Feb 2015 12:55:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Feb 2015 12:55:30 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 11 13:55:26 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YLWpB-00073E-MC for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Feb 2015 13:55:25 +0100 Original-Received: from localhost ([::1]:44664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YLWpB-00041K-0f for geh-help-gnu-emacs@m.gmane.org; Wed, 11 Feb 2015 07:55:25 -0500 Original-Path: usenet.stanford.edu!goblin1!goblin.stu.neva.ru!feed.xsnews.nl!border02.ams.xsnews.nl!feeder04.ams.xsnews.nl!abp001.ams.xsnews.nl!frontend-F09-06.ams.news.kpn.nl Original-Newsgroups: gnu.emacs.help X-Face: "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR,v+Pti8=Vi/Z"g^?b"E X-Homepage: http://www.decebal.nl/ User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) Cancel-Lock: sha1:amiDSd83Y17lw0rQyWY+bI8m6qM= Original-Lines: 36 Original-NNTP-Posting-Host: 77.171.42.144 Original-X-Trace: 1423658624 news.kpn.nl 20455 77.171.42.144@kpn/77.171.42.144:39851 Original-Xref: usenet.stanford.edu gnu.emacs.help:210360 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102637 Archived-At: 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