GNU bug report logs - #65864
[PATCH] Add option to save a buffer without running save hooks

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: Daniel Martín <mardani29@HIDDEN>; Keywords: patch; dated Mon, 11 Sep 2023 10:28:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefankangas@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 65864 <at> debbugs.gnu.org:


Received: (at 65864) by debbugs.gnu.org; 13 Sep 2023 17:17:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 13 13:17:20 2023
Received: from localhost ([127.0.0.1]:35884 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qgTUN-0005ZF-M9
	for submit <at> debbugs.gnu.org; Wed, 13 Sep 2023 13:17:19 -0400
Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]:59449)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1qgTUJ-0005Z0-5Y
 for 65864 <at> debbugs.gnu.org; Wed, 13 Sep 2023 13:17:18 -0400
Received: by mail-lf1-x133.google.com with SMTP id
 2adb3069b0e04-500913779f5so12260910e87.2
 for <65864 <at> debbugs.gnu.org>; Wed, 13 Sep 2023 10:17:09 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1694625424; x=1695230224; darn=debbugs.gnu.org;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=fiKrm0ruy8M/Ye3H7+stMoWAJSBeaqctgtf2E/f6vDQ=;
 b=OVTVoNYi1GnDjbDsKCPG4o7mPOpV/LreTmlD/u1h3n63yWSl0qtsrGwGmaDq/ADbH/
 VEWnXtnCNIlpfY8UGvhw+vTCShlbSnVONDs2XzNfcZt9IeHuAqdy4t0z6F78dh+o5DJg
 cWbuzj/ENwEWa8FrteYBZePzcdPV+saP/7LS2J1+Ix/pZD0xucfvaR4tAYpfq5MUJ7K/
 k5QKtk030gdqBSVKGXX4zu65Ev2jyWTK4Xj9UGmGU/en0w659vc8zWLSkpjrmc/iTZXH
 BWHla6WKCM7Zn8VJNymP/Kfkvp3Ugyf/KOw5iSF2elwHjapUjYLtPYZUL+YdDF72A1ng
 QmOg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1694625424; x=1695230224;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=fiKrm0ruy8M/Ye3H7+stMoWAJSBeaqctgtf2E/f6vDQ=;
 b=aZi7U8pdTHceIuLSHNSBZKhne11kh4Hhi5LYh773jga2uABgSzdiM5kfD4mKXZ3SNI
 uZuNdbLa8GQ0nDZc/75SbD+CmUMCcEcmJlI36jE1TwYkqPs+BT9eCqezPSA2qfDd9Lnk
 qGRR5ghOr/SYP/iZokI/GVMjuGLqpKEAAJJv67AeDATdKDdvBnQYbz7L4ySdP2iRAsWP
 pdaAuHgCRIokZi6t5I2x9Xw68OpmC2MM0n3liFvXu5aR9pRwrTBv3DfuVCFpQP48ajum
 lgQp0UduWqD0D1PZqTV/n2v0ZOCftQF+d6WacZh/emV+xRb5IniCMuEttai+F2p8dPQm
 MowA==
X-Gm-Message-State: AOJu0YznBvrHZYnZRxB9pQ/aNLoY90s1wXzrrpOMF435gBp1tAttAXt3
 TG7aiqC+S/yYoDy9cKMtQxX+ETeVygAsAT/489A=
X-Google-Smtp-Source: AGHT+IGCK92uGKrx2esbLwU4FC75vV05qx30EqiWqUb/xCzbGDo4mg8DbvB9v23vcnbZBxx0HnU3LePohNFeUEbq09M=
X-Received: by 2002:ac2:4c3c:0:b0:500:8146:9ebc with SMTP id
 u28-20020ac24c3c000000b0050081469ebcmr2471936lfq.47.1694625423534; Wed, 13
 Sep 2023 10:17:03 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Wed, 13 Sep 2023 10:17:03 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <86zg1qrsxi.fsf@HIDDEN>
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
 <83h6o0ri8c.fsf@HIDDEN> <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN>
 <m1h6nzke03.fsf@HIDDEN> <86zg1qrsxi.fsf@HIDDEN>
MIME-Version: 1.0
Date: Wed, 13 Sep 2023 10:17:02 -0700
Message-ID: <CADwFkmm3uF5mpXf2LjKMwwwkHn5svEoBaeRBTPwRpPsz+5maBQ@HIDDEN>
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
To: Juri Linkov <juri@HIDDEN>, 65864 <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 65864
Cc: eliz@HIDDEN, monnier@HIDDEN, mardani29@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Juri Linkov <juri@HIDDEN> writes:

> I confirm that 'C-u - C-x C-s' will save me from trouble that I have with
>
>   (add-hook 'before-save-hook 'time-stamp nil t)
>
> because often I don't need to update the timestamp for a small fix.
> It takes too much time to revisit the file with M-x find-file-literally,
> then manually restore the previous timestamp (to not commit unnecessary change),
> and save the file again.  Your patch will help substantially, thanks for this.

Same here, FWIW.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at 65864 <at> debbugs.gnu.org:


Received: (at 65864) by debbugs.gnu.org; 13 Sep 2023 16:49:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 13 12:49:31 2023
Received: from localhost ([127.0.0.1]:35812 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qgT3S-0002CF-Mf
	for submit <at> debbugs.gnu.org; Wed, 13 Sep 2023 12:49:31 -0400
Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]:43579)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1qgT3Q-0002Bp-9x
 for 65864 <at> debbugs.gnu.org; Wed, 13 Sep 2023 12:49:29 -0400
Received: by mail.gandi.net (Postfix) with ESMTPSA id 6C4D21C0004;
 Wed, 13 Sep 2023 16:49:13 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Daniel =?iso-8859-1?Q?Mart=EDn?= via "Bug reports for GNU Emacs, the
 Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
In-Reply-To: <m1h6nzke03.fsf@HIDDEN> ("Daniel =?iso-8859-1?Q?Mart=EDn?=
 via \"Bug reports for
 GNU Emacs, the Swiss army knife of text editors\""'s message of "Tue,
 12 Sep 2023 10:11:08 +0200")
Organization: LINKOV.NET
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
 <83h6o0ri8c.fsf@HIDDEN> <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN>
 <m1h6nzke03.fsf@HIDDEN>
Date: Wed, 13 Sep 2023 19:44:20 +0300
Message-ID: <86zg1qrsxi.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-Sasl: juri@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 65864
Cc: 65864 <at> debbugs.gnu.org, eliz@HIDDEN, monnier@HIDDEN,
 Daniel =?iso-8859-1?Q?Mart=EDn?= <mardani29@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

> For example, I have `delete-trailing-whitespace' in my
> `before-save-hook', but for a particular buffer I wanted to save it
> without removing the trailing whitespace, because trailing whitespace
> was syntactically meaningful in that case (the buffer contained some
> Markdown-like source code).
>
> I searched the Internet for some solutions and what I ended up doing is
> C-x C-q (to make the buffer read-only), C-x C-s, and C-x C-q to make the
> buffer writable again (from
> https://stackoverflow.com/questions/14913398/in-emacs-how-do-i-save-without-running-save-hooks).
> It felt a bit like a "hack".

I confirm that 'C-u - C-x C-s' will save me from trouble that I have with

  (add-hook 'before-save-hook 'time-stamp nil t)

because often I don't need to update the timestamp for a small fix.
It takes too much time to revisit the file with M-x find-file-literally,
then manually restore the previous timestamp (to not commit unnecessary change),
and save the file again.  Your patch will help substantially, thanks for this.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 Sep 2023 16:49:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Sep 13 12:49:43 2023
Received: from localhost ([127.0.0.1]:35815 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qgT3f-0002Cf-9D
	for submit <at> debbugs.gnu.org; Wed, 13 Sep 2023 12:49:43 -0400
Received: from lists.gnu.org ([2001:470:142::17]:58912)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1qgT3c-0002CH-UM
 for submit <at> debbugs.gnu.org; Wed, 13 Sep 2023 12:49:41 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1qgT3M-0007xV-C1
 for bug-gnu-emacs@HIDDEN; Wed, 13 Sep 2023 12:49:25 -0400
Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>)
 id 1qgT3I-0002sz-8G; Wed, 13 Sep 2023 12:49:24 -0400
Received: by mail.gandi.net (Postfix) with ESMTPSA id 6C4D21C0004;
 Wed, 13 Sep 2023 16:49:13 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Daniel =?iso-8859-1?Q?Mart=EDn?= via "Bug reports for GNU Emacs, the
 Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
In-Reply-To: <m1h6nzke03.fsf@HIDDEN> ("Daniel =?iso-8859-1?Q?Mart=EDn?=
 via \"Bug reports for
 GNU Emacs, the Swiss army knife of text editors\""'s message of "Tue,
 12 Sep 2023 10:11:08 +0200")
Organization: LINKOV.NET
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
 <83h6o0ri8c.fsf@HIDDEN> <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN>
 <m1h6nzke03.fsf@HIDDEN>
Date: Wed, 13 Sep 2023 19:44:20 +0300
Message-ID: <86zg1qrsxi.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-Sasl: juri@HIDDEN
Received-SPF: pass client-ip=2001:4b98:dc4:8::225;
 envelope-from=juri@HIDDEN; helo=relay5-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
Cc: 65864 <at> debbugs.gnu.org, eliz@HIDDEN, monnier@HIDDEN,
 Daniel =?iso-8859-1?Q?Mart=EDn?= <mardani29@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.3 (/)

> For example, I have `delete-trailing-whitespace' in my
> `before-save-hook', but for a particular buffer I wanted to save it
> without removing the trailing whitespace, because trailing whitespace
> was syntactically meaningful in that case (the buffer contained some
> Markdown-like source code).
>
> I searched the Internet for some solutions and what I ended up doing is
> C-x C-q (to make the buffer read-only), C-x C-s, and C-x C-q to make the
> buffer writable again (from
> https://stackoverflow.com/questions/14913398/in-emacs-how-do-i-save-without-running-save-hooks).
> It felt a bit like a "hack".

I confirm that 'C-u - C-x C-s' will save me from trouble that I have with

  (add-hook 'before-save-hook 'time-stamp nil t)

because often I don't need to update the timestamp for a small fix.
It takes too much time to revisit the file with M-x find-file-literally,
then manually restore the previous timestamp (to not commit unnecessary change),
and save the file again.  Your patch will help substantially, thanks for this.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at 65864 <at> debbugs.gnu.org:


Received: (at 65864) by debbugs.gnu.org; 12 Sep 2023 12:59:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 12 08:59:54 2023
Received: from localhost ([127.0.0.1]:56450 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qg2zi-00042o-4F
	for submit <at> debbugs.gnu.org; Tue, 12 Sep 2023 08:59:54 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:11172)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1qg2zf-00042Z-I3
 for 65864 <at> debbugs.gnu.org; Tue, 12 Sep 2023 08:59:53 -0400
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 60684100106;
 Tue, 12 Sep 2023 08:59:41 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1694523580;
 bh=0ivzoZ2mIfHKV6wKk9l10aPexcSR71ipaCKWSbdYtLc=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=R2sV5KbYox6761iY+M5QVjTCmILHGB47qXCVnRIVyumI+B3bAIJzb9XkgCjfMPV/s
 AJBVrE8FpwM36vXkC1aEhwJMj81Y+WDJKQPMOFn33dCgT4xFU3a8eF1iQkeJsLhpeK
 vOa8KmqQy7x2DNjZmPTL4DcjedmE1Ev0fXtCidVQHrhjKJukG7zfB9PkxyyxcA8M09
 wPCnBgs/vrJbmAf956HPDebpjfdlfqZkepePIuu4kXHjFvMBI2bLFihW0p+/xqFZEP
 oIyi57QqHpsXHfQ6kHVS9Y84vav6ytKjHI1t6/RybWfo0dXQF0r51qXDNLEh0anCmB
 TdRPnpyUYbEsw==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4C8511000A3;
 Tue, 12 Sep 2023 08:59:40 -0400 (EDT)
Received: from pastel (unknown [104.247.229.91])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 1EFBA1201DD;
 Tue, 12 Sep 2023 08:59:40 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Daniel =?windows-1252?Q?Mart=EDn?= <mardani29@HIDDEN>
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
In-Reply-To: <m1h6nzke03.fsf@HIDDEN> ("Daniel =?windows-1252?Q?Mart=EDn?=
 =?windows-1252?Q?=22's?= message of "Tue, 12
 Sep 2023 10:11:08 +0200")
Message-ID: <jwvmsxr4kj4.fsf-monnier+emacs@HIDDEN>
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
 <83h6o0ri8c.fsf@HIDDEN> <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN>
 <m1h6nzke03.fsf@HIDDEN>
Date: Tue, 12 Sep 2023 08:59:39 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.061 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 65864
Cc: 65864 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> For example, I have `delete-trailing-whitespace' in my
> `before-save-hook', but for a particular buffer I wanted to save it
> without removing the trailing whitespace, because trailing whitespace
> was syntactically meaningful in that case (the buffer contained some
> Markdown-like source code).

So you needed it for use by a human rather than for use by ELisp code?

> I searched the Internet for some solutions and what I ended up doing is
> C-x C-q (to make the buffer read-only), C-x C-s, and C-x C-q to make the
> buffer writable again (from
> https://stackoverflow.com/questions/14913398/in-emacs-how-do-i-save-without-running-save-hooks).
> It felt a bit like a "hack".

It's a hack, indeed, and it could fail if the hook function was careful to
let-bind `inhibit-read-only`.

Personally I think I would have used `C-x h M-x write-region RET` (or
fixed my config since clearly having this hook function active for this
file is wrong).


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at 65864 <at> debbugs.gnu.org:


Received: (at 65864) by debbugs.gnu.org; 12 Sep 2023 08:13:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 12 04:13:27 2023
Received: from localhost ([127.0.0.1]:56077 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qfyWU-0007hv-PY
	for submit <at> debbugs.gnu.org; Tue, 12 Sep 2023 04:13:27 -0400
Received: from sonic307-32.consmr.mail.ir2.yahoo.com ([87.248.110.57]:38102)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mardani29@HIDDEN>) id 1qfyWS-0007hf-IV
 for 65864 <at> debbugs.gnu.org; Tue, 12 Sep 2023 04:13:25 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048;
 t=1694506394; bh=vsrrUToDPEzjyYdwlbb/He+clFByFLQMEfawfCdLp5s=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To;
 b=QasfvHrhZ1r024Gmm6Vv9AlQMCcasHvmZpb9o33LQJVRl1qPU534gEQbrLZiMBmCZFzHqrwQ11py+ADCojisSzMwoaCvt+iyfKR5oGLNySSKPQykT0eS0Bs6A4r1UaHTQyeCevwEV+SU50S+Ed2PFmiUarjLXRsmAVXcMdec5Kdnhxz1XJp4++WGLMnJvhb4QSkigs6zeC8MUTVGp57Urg446fPL+zvn29RS9+s/NuzLpB1vQpJ6DcrjpDP9/sXf2MScK0n3mx1fFbhz1s+yn7GUpwbRULy5CK+q/00s20Hz00q/KS3FAXkAG5GSdPLHx6+kL5fjUlZEcychgTFtYQ==
X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048;
 t=1694506394; bh=vdFhUcx1TZFTtpDtuH1MT/Q0YU1eA8w5IALOOhW2ABh=;
 h=X-Sonic-MF:From:To:Subject:Date:From:Subject;
 b=kMekaGaWEJcRryLBSIo0LmOqEZSZG5m1bQOAwHT3C/2yC21wTsReqsAiiF4JgOH2dNgwfFjJD9NU2v1jgHZeBRH/rfc7iFCFo2YdRi72MDQf3MTAeEDMKz5yY7o0MZgGJkvgTytts8FHW8lk8Ox9d08SR91MuMNFfzdhr8LqaryndSeIXS3I5V9FR3SJQBBWO5QpU4vJcOsfQJ/lGIoR9o1Jxut/H1KGMZ1LTt2V1ZMjeGhEPcUM5cuC5xO1cqIV1Ju4mTCjEBK8aKLpMGad5AwrLI8jGrzSqCOHyYlo2aXPMQqaINlJ8DGJXMwmByY9NQJWRhrJe9KtsOXA0lwLEA==
X-YMail-OSG: ByTu81gVM1lDLNX5XBeRxRIvxfKuOaraZL4X00Habw3IvoWA3.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U9CImCaaPXwH.L6EdwbRpRpBQOSWSO3uj7VEyzyncCA1Mw0XypomEClblUWoc
 Oj.4_JiAG4qs8Kvy2mwvWkNToZZ8Na2N5WYNnfY9odRTlq9SXclcAj6AW4h6WUtTzu9X13o9HYzf
 fOuFTCMczFGDqqq0DVyxeBpN0PzJ.KpB32i9IuZSp3Fr_m4IChtVGjA--
X-Sonic-MF: <mardani29@HIDDEN>
X-Sonic-ID: 0147d4ab-0e9a-42a8-a535-ba60a5ed0ffc
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic307.consmr.mail.ir2.yahoo.com with HTTP; Tue, 12 Sep 2023 08:13:14 +0000
Received: by hermes--production-ir2-5cc57b9c45-ww426 (Yahoo Inc. Hermes SMTP
 Server) with ESMTPA ID 67278f9e5a512ea20398da2cb4f8e0b4; 
 Tue, 12 Sep 2023 08:11:09 +0000 (UTC)
From: =?utf-8?Q?Daniel_Mart=C3=ADn?= <mardani29@HIDDEN>
To: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
In-Reply-To: <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN> (Stefan Monnier via's
 message of "Mon, 11 Sep 2023 18:28:59 -0400")
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
 <83h6o0ri8c.fsf@HIDDEN> <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN>
Date: Tue, 12 Sep 2023 10:11:08 +0200
Message-ID: <m1h6nzke03.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Mailer: WebService/1.1.21797
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 1129
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 65864
Cc: 65864 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.8 (/)

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@HIDDEN> writes:

>>> Users can customize `before-save-hook' to add things like
>>> `delete-trailing-whitespace' or `copyright-update'.  However, there are
>>> cases where you want to save a buffer without running any save hooks
>>> without changing your configuration and then changing it back.
>
> Do you have concrete examples, to helps us assess what's really at stake
> here?  Maybe there are other ways to look at the problem :-)
>

For example, I have `delete-trailing-whitespace' in my
`before-save-hook', but for a particular buffer I wanted to save it
without removing the trailing whitespace, because trailing whitespace
was syntactically meaningful in that case (the buffer contained some
Markdown-like source code).

I searched the Internet for some solutions and what I ended up doing is
C-x C-q (to make the buffer read-only), C-x C-s, and C-x C-q to make the
buffer writable again (from
https://stackoverflow.com/questions/14913398/in-emacs-how-do-i-save-without-running-save-hooks).
It felt a bit like a "hack".




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 12 Sep 2023 08:13:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Sep 12 04:13:32 2023
Received: from localhost ([127.0.0.1]:56081 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qfyWa-0007iC-59
	for submit <at> debbugs.gnu.org; Tue, 12 Sep 2023 04:13:32 -0400
Received: from lists.gnu.org ([2001:470:142::17]:38902)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mardani29@HIDDEN>) id 1qfyWY-0007ho-It
 for submit <at> debbugs.gnu.org; Tue, 12 Sep 2023 04:13:31 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mardani29@HIDDEN>)
 id 1qfyWO-00027Z-Kx
 for bug-gnu-emacs@HIDDEN; Tue, 12 Sep 2023 04:13:20 -0400
Received: from sonic307-32.consmr.mail.ir2.yahoo.com ([87.248.110.57])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <mardani29@HIDDEN>)
 id 1qfyWL-0001zV-Jg
 for bug-gnu-emacs@HIDDEN; Tue, 12 Sep 2023 04:13:20 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048;
 t=1694506394; bh=vsrrUToDPEzjyYdwlbb/He+clFByFLQMEfawfCdLp5s=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From:Subject:Reply-To;
 b=QasfvHrhZ1r024Gmm6Vv9AlQMCcasHvmZpb9o33LQJVRl1qPU534gEQbrLZiMBmCZFzHqrwQ11py+ADCojisSzMwoaCvt+iyfKR5oGLNySSKPQykT0eS0Bs6A4r1UaHTQyeCevwEV+SU50S+Ed2PFmiUarjLXRsmAVXcMdec5Kdnhxz1XJp4++WGLMnJvhb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f6bZBaEQt2nN3Zzq9osHhEeN8lj7Ozso1gOhpVkAPvXxXhFZHfuSafht3JAbkyBNnyh95jEqmPLp
 FI6NEfPp9u3.emHZIWU46o4eKCPoJOvPOwG7cYT6pFbRhrn8kr0DXz2aEhrFqxS0hMkqt6Lm5L2V
 7qgfy.uulO5uWWF5sEIzWLfFPKuPBTST8Tv7T5E8W6nQpWJI3OqB98U3BDGnnK9Ggax5aV8n3X.8
 fliWQtJZyr9sj_ZZPj7nSqGVC9ppg0PhJsTT8Uh3GSBdps5IWS1xig7PG706QXT7BWcCyTSd5cxB
 XllIdpzhSEMrnZJhdDvFEGgGIRygu45BDKgjgkYvdvSUaIG1h5y0c7RN57V8GtC7QSuFi.T39PiH
 ajdqVvB5EQ6lOH.gs.uEMeOZ6KTtTtEvZ2eoD3SdZwPhRjb6ZA.iNmSjOUkKLrqbT6s306xhrn_n
 V2lw2TrHg9zM4qHHt5_g66jaIbpyB6phk0icfCmCKtG24r4wHqnTYYyBiZ1tAmF47gHb.zf8OQib
 9XD70yYeyT541K3cu.S.sBemKhf07vK2sy3Y.D3HWgOroksRaxed8xbhoIWBvTBdHs47m4nLlYSd
 csG0KrmE5dSptXXDJVLEPO2zPFGAvcCSOOBvO_nbNxfc_kOciiiStEtFfPqKabe8uRAxa0BLdXvH
 1PVzM3QWfBptNA2U9CImCaaPXwH.L6EdwbRpRpBQOSWSO3uj7VEyzyncCA1Mw0XypomEClblUWoc
 Oj.4_JiAG4qs8Kvy2mwvWkNToZZ8Na2N5WYNnfY9odRTlq9SXclcAj6AW4h6WUtTzu9X13o9HYzf
 fOuFTCMczFGDqqq0DVyxeBpN0PzJ.KpB32i9IuZSp3Fr_m4IChtVGjA--
X-Sonic-MF: <mardani29@HIDDEN>
X-Sonic-ID: 0147d4ab-0e9a-42a8-a535-ba60a5ed0ffc
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic307.consmr.mail.ir2.yahoo.com with HTTP; Tue, 12 Sep 2023 08:13:14 +0000
Received: by hermes--production-ir2-5cc57b9c45-ww426 (Yahoo Inc. Hermes SMTP
 Server) with ESMTPA ID 67278f9e5a512ea20398da2cb4f8e0b4; 
 Tue, 12 Sep 2023 08:11:09 +0000 (UTC)
From: =?utf-8?Q?Daniel_Mart=C3=ADn?= <mardani29@HIDDEN>
To: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs@HIDDEN>
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
In-Reply-To: <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN> (Stefan Monnier via's
 message of "Mon, 11 Sep 2023 18:28:59 -0400")
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
 <83h6o0ri8c.fsf@HIDDEN> <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN>
Date: Tue, 12 Sep 2023 10:11:08 +0200
Message-ID: <m1h6nzke03.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Mailer: WebService/1.1.21797
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 1129
Received-SPF: pass client-ip=87.248.110.57; envelope-from=mardani29@HIDDEN;
 helo=sonic307-32.consmr.mail.ir2.yahoo.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H2=-0.001,
 SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
Cc: 65864 <at> debbugs.gnu.org, Eli Zaretskii <eliz@HIDDEN>,
 Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs@HIDDEN> writes:

>>> Users can customize `before-save-hook' to add things like
>>> `delete-trailing-whitespace' or `copyright-update'.  However, there are
>>> cases where you want to save a buffer without running any save hooks
>>> without changing your configuration and then changing it back.
>
> Do you have concrete examples, to helps us assess what's really at stake
> here?  Maybe there are other ways to look at the problem :-)
>

For example, I have `delete-trailing-whitespace' in my
`before-save-hook', but for a particular buffer I wanted to save it
without removing the trailing whitespace, because trailing whitespace
was syntactically meaningful in that case (the buffer contained some
Markdown-like source code).

I searched the Internet for some solutions and what I ended up doing is
C-x C-q (to make the buffer read-only), C-x C-s, and C-x C-q to make the
buffer writable again (from
https://stackoverflow.com/questions/14913398/in-emacs-how-do-i-save-without-running-save-hooks).
It felt a bit like a "hack".




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at 65864 <at> debbugs.gnu.org:


Received: (at 65864) by debbugs.gnu.org; 11 Sep 2023 22:30:20 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 11 18:30:20 2023
Received: from localhost ([127.0.0.1]:55066 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qfpQC-0001ca-C6
	for submit <at> debbugs.gnu.org; Mon, 11 Sep 2023 18:30:20 -0400
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45429)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1qfpQA-0001cF-HF
 for 65864 <at> debbugs.gnu.org; Mon, 11 Sep 2023 18:30:19 -0400
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 897B38071E;
 Mon, 11 Sep 2023 18:30:08 -0400 (EDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1694471407;
 bh=2Zp+fIRi9JxIAFhDU59qvSe9wKDG//z3YqudarSHj2A=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=G0ABmeTCca9VdX6osTdbwOQdTrwM/1BnbiuK8NGUEZl3Wx/hSNyf2FNCurNXIGjLy
 MUqXTkJtq/YuWmByJqBIP3Nx2FGzeDiK3h19sBGCj0SqO8HTwLvvQK+KTM9YzFesBF
 L5fVclH4C7Ja6EJbPl+VGKL71ELvm/kN/5YtHpuqa3y0QX39SaaO5SwBl+E3+AUsce
 SWAcqr8/EwZzcWd/2bbB2cT7V+OzOagM7yzW7Rw9LWdJ6jjizc5POTgoQb32ODyFOr
 zXLaUhGzXwh2DGRYXP09q/RrIpdQc9ML67Q0ZLEzFiTO4ecFc/X5guB2tsYjpS00U/
 4oPXGW58Ah9Tg==
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 4C60C802BB;
 Mon, 11 Sep 2023 18:30:07 -0400 (EDT)
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3C5B8120506;
 Mon, 11 Sep 2023 18:30:07 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
In-Reply-To: <83h6o0ri8c.fsf@HIDDEN> (Eli Zaretskii's message of "Mon, 11 Sep
 2023 15:45:39 +0300")
Message-ID: <jwv8r9cmjwq.fsf-monnier+emacs@HIDDEN>
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
 <83h6o0ri8c.fsf@HIDDEN>
Date: Mon, 11 Sep 2023 18:28:59 -0400
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.100 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
 DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 65864
Cc: 65864 <at> debbugs.gnu.org,
 Daniel =?windows-1252?Q?Mart=EDn?= <mardani29@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> Users can customize `before-save-hook' to add things like
>> `delete-trailing-whitespace' or `copyright-update'.  However, there are
>> cases where you want to save a buffer without running any save hooks
>> without changing your configuration and then changing it back.

Do you have concrete examples, to helps us assess what's really at stake
here?  Maybe there are other ways to look at the problem :-)

"without running any save hooks" at all really?  Like without running
`write-contents-functions`, nor `write-file-functions`, nor
`write-region-annotat-functions`, nor `make-backup-file-name-function`, ...?
How 'bout the file-name-handlers, then?

Maybe `write-region` would be a better starting point than `buffer-save`?

>> I've attached a patch to make `save-buffer', when invoked with a
>> negative argument (C-u - C-x C-s), temporarily avoid running any save
>> hooks.
>
> Should we perhaps consider a more general approach: run a command
> while disabling the hooks it calls?  It sounds strange to me to single
> out just this one command.

Hmm... sounds iffy.  I generally prefer ordering a plain burger than
ordering a "cheeseburger but hold the cheese" :-)

IOW, provide *another* function which performs the core operation.
[ And we usually do that.  ]


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at 65864 <at> debbugs.gnu.org:


Received: (at 65864) by debbugs.gnu.org; 11 Sep 2023 12:46:16 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 11 08:46:16 2023
Received: from localhost ([127.0.0.1]:52322 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qfgIv-0003fO-GE
	for submit <at> debbugs.gnu.org; Mon, 11 Sep 2023 08:46:16 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:60460)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1qfgIp-0003es-Si
 for 65864 <at> debbugs.gnu.org; Mon, 11 Sep 2023 08:46:11 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1qfgIe-00061t-58; Mon, 11 Sep 2023 08:45:57 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=7OAijHL9K/lzfPyBB3GARWC9I1cTlHqrY2T6jS8G8/o=; b=d6J4vfrLD6wzjKQ02rVb
 PsXR/DOuyuRA2BA/QX/dOGfGube6bQjZi1uecK4ZmlC6on6E+dIcnXqvzO/cUAK6P08NEi87cSGET
 F6VhoIX41uHzs56iGH9YzTEjgvOeMCvnHG8YTzkKio5iVs2S3sd89IOU+xAZQ/nDWylTl+cl34sf+
 NuNjjprfX2RQ0VLcFp0xmtZIRhVud8L4ZQLO2eBSX803FhsfvnGKnvC6Oc1YAbSvElIrlDDJzq2g2
 xewBs11c2VBC85IUn5vzATcK1GwpeEpX/HdDhHZGzwz+0UFq6ylfC0Pqt7zQuBaP7C7FtSf7IL2IW
 PjWeyEa1HJYNkQ==;
Date: Mon, 11 Sep 2023 15:45:39 +0300
Message-Id: <83h6o0ri8c.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Daniel =?utf-8?Q?Mart=C3=ADn?= <mardani29@HIDDEN>
In-Reply-To: <m1y1hdm2hj.fsf@HIDDEN> (bug-gnu-emacs@HIDDEN)
Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running
 save hooks
References: <m1y1hdm2hj.fsf.ref@HIDDEN> <m1y1hdm2hj.fsf@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 65864
Cc: 65864 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Date: Mon, 11 Sep 2023 12:24:40 +0200
> From:  Daniel Martín via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <bug-gnu-emacs@HIDDEN>
> 
> Users can customize `before-save-hook' to add things like
> `delete-trailing-whitespace' or `copyright-update'.  However, there are
> cases where you want to save a buffer without running any save hooks
> without changing your configuration and then changing it back.
> 
> I've attached a patch to make `save-buffer', when invoked with a
> negative argument (C-u - C-x C-s), temporarily avoid running any save
> hooks.

Should we perhaps consider a more general approach: run a command
while disabling the hooks it calls?  It sounds strange to me to single
out just this one command.

I'm interested in hearing Stefan's opinions on this (as well as those
of anyone else who wants to speak up).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 11 Sep 2023 10:27:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 11 06:27:13 2023
Received: from localhost ([127.0.0.1]:52187 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qfe8O-00062M-E2
	for submit <at> debbugs.gnu.org; Mon, 11 Sep 2023 06:27:12 -0400
Received: from lists.gnu.org ([2001:470:142::17]:36222)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mardani29@HIDDEN>) id 1qfe8K-00061n-C4
 for submit <at> debbugs.gnu.org; Mon, 11 Sep 2023 06:27:10 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <mardani29@HIDDEN>)
 id 1qfe84-0004Wi-E0
 for bug-gnu-emacs@HIDDEN; Mon, 11 Sep 2023 06:26:54 -0400
Received: from sonic301-47.consmr.mail.ir2.yahoo.com ([77.238.176.124])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <mardani29@HIDDEN>)
 id 1qfe80-0003lO-BM
 for bug-gnu-emacs@HIDDEN; Mon, 11 Sep 2023 06:26:52 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.es; s=s2048;
 t=1694428003; bh=OUm1zonhvONycADP5RjZu8hxGRwIyeNgEQqJ0yTxOD8=;
 h=From:To:Subject:Date:References:From:Subject:Reply-To;
 b=bVJGKKnG55suPAhW6slLPG2g5JJv/AhnzbYreH/UVUuPiZSOCXV3bFBSRITsHVlNPucdtp7BxtK8J0qlranx8StEIgObvaEnnHb1uj3kfMf71l6zf++/CjUKA15XJ7E0l0nXFP96sOzUIn3qf/cHNn/Ovz5p5aEUNMuAtZDLhI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_eppcBGKqhRrN_NDmY5JNIvV_DZDaZMLol2RdnBzjw6MRanbczJatQIXnKlNGng1uU
 hicrFuHBp5RI_UHm0IhFxoftDxFRKUDjjINub6NBMvHW_4rNkcFOEZqOTIuETCWvQpGaRTuN8TuY
 g6Wd2hm_CO.td3UmvYLmZlpDvZsZdu7llKzQs4o3tuvMvpRFIgxceZ_g1woEo8e7oPAUcWeyQ13f
 AC1bLd5FFtRJcOBx6xPTUHTPlsaGtLmRLiTpK2LIOqnbg8sJ7xnqUkrfmLln7OaQ8OC_1h.eKsKK
 Ux0TT4GCZGes_6fnQswhFlBEdNN5yRxYhAb9ke3mq2BrbdC8bdUcN7YLutT60YXrat55fkJwZV54
 kFqG7N7VDs.ucZVqTpRAsSa7.Yds7QXE4Xkx2nswJeF4ZOnaTgy0VYEQRbfQBWMvNO0DR9AnIDin
 HVll17SvqweZB8dipOFRDPqz9jwoyatpUczRLjYS83S_Hafqevp99gCYAAWJy97qkifPtCl.r4eo
 vw_cWj6Rp70sc1Nuaqnpem2_ewTyu_nfNp5XxEPbwsDPnjNNqPat_OUBtYxnKyaYX3dJlcJQW1It
 IgPVBFfHtJg8dpiBr4BovRtrIMg6neGtsM4qq9NLmnzf.aKO2wQRv2n2PeDzY4m2A1DPoaSVP2Y0
 WiV7Aip_ix90YdJt0SOHeLI_Qx_20pxptCdAq0nADfkke56h_l6c8gJ47d4kIH7gbUPVkWvN6Jra
 G0Pn909Hw1KoCZfwgDoCS.ItZiLJlB6xAQmJWAC41mkB2EyKxPq7VCClqDmEOEucnrrOes0tYTQ8
 WMMJ5ZH77GcrG6GcmBIOOnh6CzW1yYXf.
X-Sonic-MF: <mardani29@HIDDEN>
X-Sonic-ID: 2a0b0489-4af7-419e-ac4d-c1cb7cd3b61e
Received: from sonic.gate.mail.ne1.yahoo.com by
 sonic301.consmr.mail.ir2.yahoo.com with HTTP; Mon, 11 Sep 2023 10:26:43 +0000
Received: by hermes--production-ir2-5cc57b9c45-xh7tc (Yahoo Inc. Hermes SMTP
 Server) with ESMTPA ID c9fbca19c0b0460aa2de0e4d46e07903; 
 Mon, 11 Sep 2023 10:24:41 +0000 (UTC)
From: =?utf-8?Q?Daniel_Mart=C3=ADn?= <mardani29@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: [PATCH] Add option to save a buffer without running save hooks
Date: Mon, 11 Sep 2023 12:24:40 +0200
Message-ID: <m1y1hdm2hj.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
References: <m1y1hdm2hj.fsf.ref@HIDDEN>
X-Mailer: WebService/1.1.21763
 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo
Content-Length: 5437
Received-SPF: pass client-ip=77.238.176.124; envelope-from=mardani29@HIDDEN;
 helo=sonic301-47.consmr.mail.ir2.yahoo.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.9 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -0.1 (/)

--=-=-=
Content-Type: text/plain

Tags: patch


Users can customize `before-save-hook' to add things like
`delete-trailing-whitespace' or `copyright-update'.  However, there are
cases where you want to save a buffer without running any save hooks
without changing your configuration and then changing it back.

I've attached a patch to make `save-buffer', when invoked with a
negative argument (C-u - C-x C-s), temporarily avoid running any save
hooks.


--=-=-=
Content-Type: text/patch
Content-Disposition: attachment;
 filename=0001-Add-option-to-save-a-buffer-without-running-save-hoo.patch

From 6e1f19403937c266acd3d858ecc6c9e0e6b48ade Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@HIDDEN>
Date: Mon, 11 Sep 2023 11:55:00 +0200
Subject: [PATCH] Add option to save a buffer without running save hooks

* lisp/files.el (save-buffer): Set `ignore-save-hooks' when
`save-buffer' is run with a negative argument.
(basic-save-buffer): Do not run `before-save-hook' or
`after-save-hook' if `ignore-save-hooks' is set.
* doc/emacs/files.texi (Save Commands): Update the user manual.
* etc/NEWS: Advertise it.
---
 doc/emacs/files.texi |  5 ++++-
 etc/NEWS             |  5 +++++
 lisp/files.el        | 21 +++++++++++++--------
 3 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 7efb4516d15..c1acd1e80d4 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -457,7 +457,10 @@ Save Commands
 @end example
 
 With a prefix argument, @kbd{C-u C-x C-s}, Emacs also marks the buffer
-to be backed up when the next save is done.  @xref{Backup}.
+to be backed up when the next save is done.  @xref{Backup}.  With a
+negative argument, @kbd{C-u - C-x C-s}, Emacs doesn't run the hook
+@code{before-save-hook} before saving the buffer, and doesn't run the
+hook @code{after-save-hook} after saving the buffer.
 
 @kindex C-x s
 @findex save-some-buffers
diff --git a/etc/NEWS b/etc/NEWS
index 51e89fc96dd..772aa49bc95 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -221,6 +221,11 @@ whereas if the mouse pointer is in the left half of a glyph, point
 will be put in front the buffer position corresponding to that glyph.
 By default this is disabled.
 
++++
+** You can now avoid running save hooks when saving a buffer.
+If you save a buffer with a negative argument, C-u - C-x C-s, Emacs
+won't run the hooks 'before-save-hook' and 'after-save-hook'.
+
 ** Internationalization
 
 ---
diff --git a/lisp/files.el b/lisp/files.el
index b67482a2f74..6ee28f23daa 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5618,8 +5618,10 @@ save-buffer
  to become a backup when the next save is done,
  and makes the previous version into a backup file.
 
-With a numeric prefix argument of 0, never make the previous version
-into a backup file.
+With a numeric prefix argument of 0, never make the previous
+version into a backup file.  With a numeric prefix argument of
+-1, do not run the hooks `before-save-hook' and
+`after-save-hook'.
 
 Note that the various variables that control backups, such
 as `version-control', `backup-enable-predicate', `vc-make-backup-files',
@@ -5649,7 +5651,8 @@ save-buffer
   (interactive "p")
   (let ((modp (buffer-modified-p))
 	(make-backup-files (or (and make-backup-files (not (eq arg 0)))
-			       (memq arg '(16 64)))))
+			       (memq arg '(16 64))))
+        (ignore-save-hooks (eq arg -1)))
     (and modp (memq arg '(16 64)) (setq buffer-backed-up nil))
     ;; We used to display the message below only for files > 50KB, but
     ;; then Rmail-mbox never displays it due to buffer swapping.  If
@@ -5660,7 +5663,7 @@ save-buffer
              (not noninteractive)
              (not save-silently))
 	(message "Saving file %s..." (buffer-file-name)))
-    (basic-save-buffer (called-interactively-p 'any))
+    (basic-save-buffer (called-interactively-p 'any) ignore-save-hooks)
     (and modp (memq arg '(4 64)) (setq buffer-backed-up nil))))
 
 (defun delete-auto-save-file-if-necessary (&optional force)
@@ -5720,7 +5723,7 @@ save-buffer-coding-system
 
 (put 'save-buffer-coding-system 'permanent-local t)
 
-(defun basic-save-buffer (&optional called-interactively)
+(defun basic-save-buffer (&optional called-interactively ignore-save-hooks)
   "Save the current buffer in its visited file, if it has been modified.
 
 The hooks `write-contents-functions', `local-write-file-hooks'
@@ -5769,8 +5772,9 @@ basic-save-buffer
 		     (goto-char (point-max))
 		     (insert ?\n))))
 	    ;; Don't let errors prevent saving the buffer.
-	    (with-demoted-errors "Before-save hook error: %S"
-	      (run-hooks 'before-save-hook))
+            (unless ignore-save-hooks
+	      (with-demoted-errors "Before-save hook error: %S"
+	        (run-hooks 'before-save-hook)))
             ;; Give `write-contents-functions' a chance to
             ;; short-circuit the whole process.
 	    (unless (run-hook-with-args-until-success 'write-contents-functions)
@@ -5834,7 +5838,8 @@ basic-save-buffer
             ;; If the auto-save file was recent before this command,
 	    ;; delete it now.
 	    (delete-auto-save-file-if-necessary recent-save))
-	  (run-hooks 'after-save-hook))
+	  (unless ignore-save-hooks
+            (run-hooks 'after-save-hook)))
       (or noninteractive
           (not called-interactively)
           (files--message "(No changes need to be saved)")))))
-- 
2.40.1


--=-=-=--




Acknowledgement sent to Daniel Martín <mardani29@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#65864; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 15 Sep 2023 11:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.