Hi,

I complained awhile ago about the time stamps in Gnulib files. This was
because in my Emacs init file I have:

    (setq enable-local-variables :safe)

Which allows Emacs to enable safe local variables but ignore unsafe ones
(mostly 'eval' AFAIK) instead of doing annoying popups every time.

As a side effect the lines in Gnulib files:

    # eval: (add-hook 'before-save-hook 'time-stamp)

no longer worked. This issue could be fixed with:

    (add-to-list 'safe-local-eval-forms
        '(add-hook 'before-save-hook 'time-stamp))

I was originally confused because the default value of
'safe-local-eval-forms' has a different variation of that function call.
The reasoning is explained in the documentation for 'time-stamp':

> A time stamp can be automatically updated with current information
> every time you save a file.  To enable time-stamping for all files,
> customize option ‘before-save-hook’ or add this line to your init file:
>     (add-hook 'before-save-hook 'time-stamp)
>
> To enable automatic time-stamping for only a specific file, add
> this line to a local variables list near the end of the file:
>     eval: (add-hook 'before-save-hook 'time-stamp nil t)

I've confirmed this behavior and I think it is best not to mess with
users settings even if it is mostly harmless. Therefore I've applied the
attached patch.

Some files pulled from other places still have the "unsafe" version.
I've left them since they will get autoupdated anyways. But if anyone
wants to fix them:

    $ grep -rl "'time-stamp)"
    build-aux/mdate-sh
    build-aux/install-sh
    build-aux/mkinstalldirs
    build-aux/config.guess
    build-aux/config.sub
    build-aux/compile
    build-aux/depcomp
    doc/maintain.texi
    doc/standards.texi

Collin

>From 71dd87c3723e9c9dd3ae50d562b9ff04ff0ee660 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 4 Jul 2024 04:04:11 -0700
Subject: [PATCH] Make time-stamp after-save-hooks buffer-local.

* build-aux/announce-gen: Pass optional arguments to 'add-hook'.
* build-aux/bootstrap: Likewise.
* build-aux/do-release-commit-and-tag: Likewise.
* build-aux/gendocs.sh: Likewise.
* build-aux/git-version-gen: Likewise.
* build-aux/gitlog-to-changelog: Likewise.
* build-aux/gnu-web-doc-update: Likewise.
* build-aux/gnupload: Likewise.
* build-aux/move-if-change: Likewise.
* build-aux/prefix-gnulib-mk: Likewise.
* build-aux/update-copyright: Likewise.
* build-aux/useless-if-before-free: Likewise.
* build-aux/vc-list-files: Likewise.
* top/bootstrap: Likewise.
* top/bootstrap-funclib.sh: Likewise.
---
 ChangeLog                           | 19 +++++++++++++++++++
 build-aux/announce-gen              |  4 ++--
 build-aux/bootstrap                 |  6 +++---
 build-aux/do-release-commit-and-tag |  4 ++--
 build-aux/gendocs.sh                |  4 ++--
 build-aux/git-version-gen           |  4 ++--
 build-aux/gitlog-to-changelog       |  4 ++--
 build-aux/gnu-web-doc-update        |  4 ++--
 build-aux/gnupload                  |  4 ++--
 build-aux/move-if-change            |  4 ++--
 build-aux/prefix-gnulib-mk          |  4 ++--
 build-aux/update-copyright          |  4 ++--
 build-aux/useless-if-before-free    |  4 ++--
 build-aux/vc-list-files             |  4 ++--
 top/bootstrap                       |  4 ++--
 top/bootstrap-funclib.sh            |  4 ++--
 16 files changed, 50 insertions(+), 31 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b19c2a482a..d480df5a25 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2024-07-04  Collin Funk  <collin.fu...@gmail.com>
+
+	Make time-stamp after-save-hooks buffer-local.
+	* build-aux/announce-gen: Pass optional arguments to 'add-hook'.
+	* build-aux/bootstrap: Likewise.
+	* build-aux/do-release-commit-and-tag: Likewise.
+	* build-aux/gendocs.sh: Likewise.
+	* build-aux/git-version-gen: Likewise.
+	* build-aux/gitlog-to-changelog: Likewise.
+	* build-aux/gnu-web-doc-update: Likewise.
+	* build-aux/gnupload: Likewise.
+	* build-aux/move-if-change: Likewise.
+	* build-aux/prefix-gnulib-mk: Likewise.
+	* build-aux/update-copyright: Likewise.
+	* build-aux/useless-if-before-free: Likewise.
+	* build-aux/vc-list-files: Likewise.
+	* top/bootstrap: Likewise.
+	* top/bootstrap-funclib.sh: Likewise.
+
 2024-07-03  Collin Funk  <collin.fu...@gmail.com>
 
 	gitlog-to-changelog: Add a new --commit-timezone option.
diff --git a/build-aux/announce-gen b/build-aux/announce-gen
index f9e20129dd..9728aeee9e 100755
--- a/build-aux/announce-gen
+++ b/build-aux/announce-gen
@@ -35,7 +35,7 @@
 eval 'exec perl -wSx "$0" "$@"'
      if 0;
 
-my $VERSION = '2023-12-29 18:26'; # UTC
+my $VERSION = '2024-07-04 10:55'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -695,7 +695,7 @@ EOF
 ## perl-label-offset: -2
 ## perl-extra-newline-before-brace: t
 ## perl-merge-trailing-else: nil
-## eval: (add-hook 'before-save-hook 'time-stamp)
+## eval: (add-hook 'before-save-hook 'time-stamp nil t)
 ## time-stamp-line-limit: 50
 ## time-stamp-start: "my $VERSION = '"
 ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index ac9433e3fd..d78c8c3064 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -3,7 +3,7 @@
 
 # Bootstrap this package from checked-out sources.
 
-scriptversion=2024-04-13.15; # UTC
+scriptversion=2024-07-04.10; # UTC
 
 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
 #
@@ -1352,7 +1352,7 @@ autogen()
 # ----------------------------------------------------------------------------
 
 # Local Variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptlibversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
@@ -1562,7 +1562,7 @@ fi
 # ----------------------------------------------------------------------------
 
 # Local Variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
diff --git a/build-aux/do-release-commit-and-tag b/build-aux/do-release-commit-and-tag
index 6876fe040f..6584a5a519 100755
--- a/build-aux/do-release-commit-and-tag
+++ b/build-aux/do-release-commit-and-tag
@@ -3,7 +3,7 @@
 # controlled .prev-version file, automate the procedure by which we record
 # the date, release-type and version string in the NEWS file.  That commit
 # will serve to identify the release, so apply a signed tag to it as well.
-VERSION=2018-03-07.03 # UTC
+VERSION=2024-07-04.10 # UTC
 
 # Note: this is a bash script (could be zsh or dash)
 
@@ -171,7 +171,7 @@ git tag -s -m "$pkg $ver" v$ver HEAD || die 'git tag failed'
 
 # Local variables:
 # indent-tabs-mode: nil
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "VERSION="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
diff --git a/build-aux/gendocs.sh b/build-aux/gendocs.sh
index 036302b7fa..f93e5123ad 100755
--- a/build-aux/gendocs.sh
+++ b/build-aux/gendocs.sh
@@ -2,7 +2,7 @@
 # gendocs.sh -- generate a GNU manual in many formats.  This script is
 #   mentioned in maintain.texi.  See the help message below for usage details.
 
-scriptversion=2024-06-07.07
+scriptversion=2024-07-04.03
 
 # Copyright 2003-2024 Free Software Foundation, Inc.
 #
@@ -555,7 +555,7 @@ $GENDOCS_TEMPLATE_DIR/gendocs_template >"$outdir/index.html"
 echo "Done, see $outdir/ subdirectory for new files."
 
 # Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-end: "$"
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index aa168e194d..780b7e99f7 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -1,6 +1,6 @@
 #!/bin/sh
 # Print a version string.
-scriptversion=2022-07-09.08; # UTC
+scriptversion=2024-07-04.10; # UTC
 
 # Copyright (C) 2007-2024 Free Software Foundation, Inc.
 #
@@ -219,7 +219,7 @@ fi
 printf %s "$v"
 
 # Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index 32b3a6264c..a2c348e2cf 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -35,7 +35,7 @@
 eval 'exec perl -wSx "$0" "$@"'
      if 0;
 
-my $VERSION = '2024-07-04 04:42'; # UTC
+my $VERSION = '2024-07-04 10:56'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -526,7 +526,7 @@ sub git_dir_option($)
 # Local Variables:
 # mode: perl
 # indent-tabs-mode: nil
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-line-limit: 50
 # time-stamp-start: "my $VERSION = '"
 # time-stamp-format: "%:y-%02m-%02d %02H:%02M"
diff --git a/build-aux/gnu-web-doc-update b/build-aux/gnu-web-doc-update
index b51fc10119..a268e2d1f5 100755
--- a/build-aux/gnu-web-doc-update
+++ b/build-aux/gnu-web-doc-update
@@ -2,7 +2,7 @@
 # Run this after each non-alpha release, to update the web documentation at
 # https://www.gnu.org/software/$pkg/manual/
 
-VERSION=2023-09-11.20; # UTC
+VERSION=2024-07-04.10; # UTC
 
 # Copyright (C) 2009-2024 Free Software Foundation, Inc.
 
@@ -208,7 +208,7 @@ $RSYNC -avP "$builddir"/doc/manual/ $tmp/$pkg/manual
 )
 
 # Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "VERSION="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
diff --git a/build-aux/gnupload b/build-aux/gnupload
index 298a6766f0..e87303657b 100755
--- a/build-aux/gnupload
+++ b/build-aux/gnupload
@@ -1,7 +1,7 @@
 #!/bin/sh
 # Sign files and upload them.
 
-scriptversion=2022-01-27.18; # UTC
+scriptversion=2024-07-04.10; # UTC
 
 # Copyright (C) 2004-2024 Free Software Foundation, Inc.
 #
@@ -472,7 +472,7 @@ done
 exit 0
 
 # Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
diff --git a/build-aux/move-if-change b/build-aux/move-if-change
index 18a720735c..a73bd2403c 100755
--- a/build-aux/move-if-change
+++ b/build-aux/move-if-change
@@ -2,7 +2,7 @@
 # Like mv $1 $2, but if the files are the same, just delete $1.
 # Status is zero if successful, nonzero otherwise.
 
-VERSION='2018-03-07 03:47'; # UTC
+VERSION='2024-07-04 10:56'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -76,7 +76,7 @@ else
 fi
 
 ## Local Variables:
-## eval: (add-hook 'before-save-hook 'time-stamp)
+## eval: (add-hook 'before-save-hook 'time-stamp nil t)
 ## time-stamp-start: "VERSION='"
 ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
 ## time-stamp-time-zone: "UTC0"
diff --git a/build-aux/prefix-gnulib-mk b/build-aux/prefix-gnulib-mk
index 1473594267..d38ffb8ada 100755
--- a/build-aux/prefix-gnulib-mk
+++ b/build-aux/prefix-gnulib-mk
@@ -26,7 +26,7 @@
 eval 'exec perl -wSx "$0" "$@"'
      if 0;
 
-my $VERSION = '2020-04-04 15:07'; # UTC
+my $VERSION = '2024-07-04 10:56'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -287,7 +287,7 @@ sub prefix ($)
 ## cperl-extra-newline-before-brace: t
 ## cperl-merge-trailing-else: nil
 ## cperl-continued-statement-offset: 2
-## eval: (add-hook 'before-save-hook 'time-stamp)
+## eval: (add-hook 'before-save-hook 'time-stamp nil t)
 ## time-stamp-line-limit: 50
 ## time-stamp-start: "my $VERSION = '"
 ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
diff --git a/build-aux/update-copyright b/build-aux/update-copyright
index ea3e46fe60..42f2693383 100755
--- a/build-aux/update-copyright
+++ b/build-aux/update-copyright
@@ -138,7 +138,7 @@
 eval 'exec perl -wSx -0777 -pi "$0" "$@"'
      if 0;
 
-my $VERSION = '2024-01-15.18:30'; # UTC
+my $VERSION = '2024-07-04.10:56'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -298,7 +298,7 @@ if (!$found)
 # coding: utf-8
 # mode: perl
 # indent-tabs-mode: nil
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-line-limit: 200
 # time-stamp-start: "my $VERSION = '"
 # time-stamp-format: "%:y-%02m-%02d.%02H:%02M"
diff --git a/build-aux/useless-if-before-free b/build-aux/useless-if-before-free
index 968e53062c..dde64ec215 100755
--- a/build-aux/useless-if-before-free
+++ b/build-aux/useless-if-before-free
@@ -36,7 +36,7 @@
 eval 'exec perl -wSx "$0" "$@"'
      if 0;
 
-my $VERSION = '2024-06-17 03:44'; # UTC
+my $VERSION = '2024-07-04 10:56'; # UTC
 # The definition above must lie within the first 8 lines in order
 # for the Emacs time-stamp write hook (at end) to update it.
 # If you change this file with Emacs, please let the write hook
@@ -231,7 +231,7 @@ EOF
 ## Local Variables:
 ## mode: perl
 ## indent-tabs-mode: nil
-## eval: (add-hook 'before-save-hook 'time-stamp)
+## eval: (add-hook 'before-save-hook 'time-stamp nil t)
 ## time-stamp-line-limit: 50
 ## time-stamp-start: "my $VERSION = '"
 ## time-stamp-format: "%:y-%02m-%02d %02H:%02M"
diff --git a/build-aux/vc-list-files b/build-aux/vc-list-files
index 7036576405..30d445f135 100755
--- a/build-aux/vc-list-files
+++ b/build-aux/vc-list-files
@@ -2,7 +2,7 @@
 # List version-controlled file names.
 
 # Print a version string.
-scriptversion=2018-03-07.03; # UTC
+scriptversion=2024-07-04.10; # UTC
 
 # Copyright (C) 2006-2024 Free Software Foundation, Inc.
 
@@ -105,7 +105,7 @@ do
 done
 
 # Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
diff --git a/top/bootstrap b/top/bootstrap
index 4beae0e912..2136d119e3 100755
--- a/top/bootstrap
+++ b/top/bootstrap
@@ -1,7 +1,7 @@
 #! /bin/sh
 # Bootstrap this package from checked-out sources.
 
-scriptversion=2024-04-13.15; # UTC
+scriptversion=2024-07-04.10; # UTC
 
 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
 #
@@ -237,7 +237,7 @@ fi
 # ----------------------------------------------------------------------------
 
 # Local Variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
diff --git a/top/bootstrap-funclib.sh b/top/bootstrap-funclib.sh
index 5005d9b4a9..226bc8f086 100644
--- a/top/bootstrap-funclib.sh
+++ b/top/bootstrap-funclib.sh
@@ -1,6 +1,6 @@
 # A library of shell functions for autopull.sh, autogen.sh, and bootstrap.
 
-scriptlibversion=2024-06-29.23; # UTC
+scriptlibversion=2024-07-04.10; # UTC
 
 # Copyright (C) 2003-2024 Free Software Foundation, Inc.
 #
@@ -1315,7 +1315,7 @@ autogen()
 # ----------------------------------------------------------------------------
 
 # Local Variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "scriptlibversion="
 # time-stamp-format: "%:y-%02m-%02d.%02H"
 # time-stamp-time-zone: "UTC0"
-- 
2.45.2

Reply via email to