From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: =?utf-8?Q?=C3=93scar_Fuentes?= Newsgroups: gmane.emacs.help Subject: Re: Temporarily suppress a hook? Date: Mon, 09 Jul 2018 07:21:12 +0200 Message-ID: <87tvp97znb.fsf@telefonica.net> References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1531113590 15773 195.159.176.226 (9 Jul 2018 05:19:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 9 Jul 2018 05:19:50 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 09 07:19:45 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fcOaP-00040V-Pk for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Jul 2018 07:19:45 +0200 Original-Received: from localhost ([::1]:39295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcOcW-00016d-H6 for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Jul 2018 01:21:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcOc0-00016M-PU for help-gnu-emacs@gnu.org; Mon, 09 Jul 2018 01:21:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcObx-0005xm-If for help-gnu-emacs@gnu.org; Mon, 09 Jul 2018 01:21:24 -0400 Original-Received: from [195.159.176.226] (port=48092 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fcObx-0005x3-BU for help-gnu-emacs@gnu.org; Mon, 09 Jul 2018 01:21:21 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1fcOZn-0003HF-IE for help-gnu-emacs@gnu.org; Mon, 09 Jul 2018 07:19:07 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 26 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:97O0xIy7S05+GNApz5RCKzoetLo= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:117393 Archived-At: Skip Montanaro writes: > I have before-save-hook defined in ~/.emacs > > (add-hook 'before-save-hook 'delete-trailing-whitespace) > > This is useful almost all the time. I just discovered a case where > it's not so helpful (a file full of regular expressions to feed into > "grep -E -f ..." > > I can think of various ways to tweak the regular expressions to not > require trailing whitespace, but let's assume for a moment that's not > possible. Is it possible to suppress the before-save-hook on a > per-file basis? AFAIK, no. But you can use your own function instead of delete-trailing-whitespace: (defun my-delete-trailing-whitespace () (interactive) (unless my-special-buffer (delete-trailing-whitespace))) (add-hook 'before-save-hook 'my-delete-trailing-whitespace) Or advice delete-trailing-whitespace.