From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Skip Montanaro Newsgroups: gmane.emacs.help Subject: Re: Temporarily suppress a hook? Date: Mon, 9 Jul 2018 06:01:16 -0500 Message-ID: References: <87tvp97znb.fsf@telefonica.net> <20180709060011.GB15665@tuxteam.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1531134003 18696 195.159.176.226 (9 Jul 2018 11:00:03 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 9 Jul 2018 11:00:03 +0000 (UTC) Cc: =?UTF-8?Q?=C3=93scar_Fuentes?= , Help GNU Emacs To: tomas@tuxteam.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 09 12:59:59 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 1fcTte-0004l5-PS for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Jul 2018 12:59:58 +0200 Original-Received: from localhost ([::1]:40471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcTvj-0004ph-Qy for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Jul 2018 07:02:07 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcTvB-0004pW-EC for help-gnu-emacs@gnu.org; Mon, 09 Jul 2018 07:01:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcTv7-0005od-C5 for help-gnu-emacs@gnu.org; Mon, 09 Jul 2018 07:01:33 -0400 Original-Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:41608) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fcTv7-0005mV-3n for help-gnu-emacs@gnu.org; Mon, 09 Jul 2018 07:01:29 -0400 Original-Received: by mail-pg1-x532.google.com with SMTP id l65-v6so1189608pgl.8 for ; Mon, 09 Jul 2018 04:01:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rH1rVpY6QSiC6u3bCRpK0njWNLt89rW7BXhqS0uGDVo=; b=uUEQiBgfoae6dJ3JIlro/JfOev+kDpdaQuEVhgUnPmxrn1sLY4Jk9BhFCFXVwlH+Ws enUJ1xtjPsI7jqQ4k/Lqz9ElDSwklHD9PKUoe15OMQ6RA3WPRt8gpPAkH1Mx+pzeMMUI STxr4nXfNn+KmrUUnopbX+AGpN9j/Dk1oobgEHostIfiJxl4FQ7atEimRxai6djJkuHM YAPzIRYTB1wQa7kVXUBgfRSreIlLmjcosrK/tMh4vvsl6YsTynpwZJVVz6DhNWzshSXT p8Bdy94RWtCeCgvC62mG5heWORKJ2y4jHQpMMz+JLQyuaWKR88oU2hYmyWJJl9cC2YrF EfAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rH1rVpY6QSiC6u3bCRpK0njWNLt89rW7BXhqS0uGDVo=; b=jswQ9+A1KnBy4U3STFrf0L7isOhcGJ6rB8zXQcgDVRqOdiy2eTqdOPDK4WrgnAplad fjxMPRKa0gKDnmqUWe9/PjCcFHWDtyI6KCfQKLpgBa3jcmMKnXBzeRLv5sFAtjcpk48W NscGc/XKJRC9Y9Yz/tKb4ar4Q3LLplFML5PIyAQTvO2cfI6h8zeVWY6s4an7KHF+dWVd OWZ/IC0B/mc3112Dk8Y/Gne+pSpGTJ2Qs0GxogLcvvv6fVYr0yRaR1HswSfGD8ig++zg 7vA1IwRrXZQMGnd01yiNrIS90TU2r2FC4uXVVLrPN1eh6+WAcqEnXKVRhTOOE6QfUhWX Ujsg== X-Gm-Message-State: APt69E1G62IvQnB9aaQVwWyKUuGvewPUuVQ6DRs6AhGzO5bx8b04gDql otNKWJe4stw+yzDgXeexTrjfgpH8qAeBoHIuARAS4ls= X-Google-Smtp-Source: AAOMgpdsDHt0ESf+A2k82ExSZ4UzeX99JISp18MGGY9gbHZrdT8innoQr90tG2YGcPK3L75sE5XxHcibfA5QzSMbObA= X-Received: by 2002:a63:6d8b:: with SMTP id i133-v6mr18852537pgc.215.1531134087894; Mon, 09 Jul 2018 04:01:27 -0700 (PDT) In-Reply-To: <20180709060011.GB15665@tuxteam.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::532 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:117396 Archived-At: On Mon, Jul 9, 2018, 1:00 AM wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Mon, Jul 09, 2018 at 07:21:12AM +0200, =C3=93scar Fuentes wrote: > > Skip Montanaro writes: > > [...] > > > 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. > > Or perhaps make the hook read a local variable you set in > the file (see "file local variables") and act accordingly. > > This way you could declare whithin those special files that you > don't want trailing space removed. > Thanks all. =C3=93scar's idea seems to come closest to a solution. I might = use that to suppress the hook for files with, say, a ".txt" extension. Those would benefit least from scrubbing all trailing whitespace. Or... I could use a prefix argument and check to see if it's been set to a magic value. C-u -7 C-x C-s. Assuming I can read any prefix arg set by the user. Unfortunately, file local variables aren't too helpful here. "grep -f file" reads a series of patterns from the named file, so interprets every line as a pattern. While it might work to track on a file local variable section, you run the risk of a line being a false positive match for a line in the file(s) you're running grep against. Skip >