1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-05 22:20:24 -08:00
Commit graph

165 commits

Author SHA1 Message Date
Stephen Gildea
7f04e046fb ; time-stamp: factor out two small, internal utilities
* lisp/time-stamp.el (time-stamp--message, time-stamp--system-name):
New utility functions.
(time-stamp, time-stamp-once, time-stamp-string-preprocess):
Call the new functions.
2025-12-03 23:44:45 -08:00
Stephen Gildea
9f2b1c43c9 time-stamp: return quicker when inactive
* lisp/time-stamp.el (time-stamp-once): Do not look for additional
templates once we have displayed the warning about being disabled.
Move earlier the check for arguments being the correct type.
* test/lisp/time-stamp-tests.el (time-stamp-custom-messages): New test.
2025-11-29 09:14:58 -08:00
Stephen Gildea
1f2a161f93 ; * lisp/time-stamp.el: Reformat some doc strings. 2025-11-23 18:32:41 -08:00
Stephen Gildea
435c3948a4 ; * lisp/time-stamp.el: Minor code changes
autoloads: quote function names with #'
(time-stamp-filtered-buffer-file-name): 'member' -> 'memq'
(time-stamp-conv-warn): don't call the formats "forms".
2025-11-23 18:11:18 -08:00
Stephen Gildea
d208502e4c time-stamp: padding composed characters
* lisp/time-stamp.el (time-stamp-string-preprocess): Use
'string-width' instead of 'length' to calculate needed padding.

Thanks to Stefan Monnier for the suggestion.
2025-10-16 15:23:48 -07:00
Stephen Gildea
88c18efb3a time-stamp: padding with mixed uni- and multibyte
* lisp/time-stamp.el (time-stamp-string-preprocess): Use
'length' instead of 'format' to calculate string padding,
so that we consistently count characters, not bytes.
2025-10-15 20:44:47 -07:00
Stephen Gildea
5d620aefae time-stamp source commentary: point to manual section
* lisp/time-stamp.el: Add an Info link in the commentary,
now that the manual has more to say.
* doc/emacs/files.texi (Time Stamps for One File): Expand one
consistent example.
2025-03-29 16:53:23 -07:00
Stephen Gildea
7527e39549 ; Time Stamps doc: expand the explanation of the examples
* doc/emacs/files.texi (Time Stamps): Divide into three sections.
* doc/emacs/emacs.texi: Add new nodes to menu.
* lisp/time-stamp.el: Change reference to new node.
2025-03-28 07:06:11 -07:00
Stephen Gildea
6ab65281c5 time-stamp: optimize resource use
* lisp/time-stamp.el (time-stamp-string-preprocess): Replace
n-squared string 'concat' with linear list 'push'.
2025-03-12 07:02:44 -07:00
Stephen Gildea
1bfbaacc05 time-stamp: refactor for readability
* lisp/time-stamp.el (time-stamp-string-preprocess): Move all of the
big 'while' loop to the end of the function, to better expose its
structure of iterating over the format string.
2025-03-12 06:51:52 -07:00
Stephen Gildea
280b25e009 time-stamp: Better handling of some edge cases
* lisp/time-stamp.el (time-stamp-count): Require confirmation if large.
(time-stamp-once): Correctly handle a start regexp matching 0 chars.
* test/lisp/time-stamp-tests.el (time-stamp-custom-start): New test.
2025-02-07 09:18:04 -08:00
Stephen Gildea
7f10d2680b ; time-stamp: documentation, tests, NEWS
* lisp/time-stamp.el (time-stamp-pattern, time-stamp-count): Document
how to update different time stamps on multiple lines.
* doc/emacs/files.texi (Time stamps): Add an example showing a time
stamp at the end of a file.
* etc/NEWS: Announce time-stamp format additions.
* test/lisp/time-stamp-tests.el: More title-case tests.
2025-02-02 20:15:19 -08:00
Stephen Gildea
29c6dad78d time-stamp: Don't get confused by newline in file name
* lisp/time-stamp.el (time-stamp-filtered-buffer-file-name): New helper
* test/lisp/time-stamp-tests.el: (time-stamp-custom-file-name): New test
2025-01-27 10:46:56 -08:00
Stephen Gildea
a00e6e7143 ; time-stamp: Rename some internal symbols
* lisp/time-stamp.el: (time-stamp-string-preprocess): Rename 'alt-form'
to 'colon-cnt' because it is now an integer.
* test/lisp/time-stamp-tests.el: Rename 'formatz-generate-tests' to
'define-formatz-tests'.
2025-01-24 10:14:30 -08:00
Stephen Gildea
77fe4fbeff ; * lisp/time-stamp.el: Improve two documentation strings 2025-01-24 09:45:50 -08:00
Stephen Gildea
ab3cb717a0 ; "time stamp" also can be spelled "timestamp"
* lisp/time-stamp.el (time-stamp):
* doc/emacs/files.texi (Time Stamps): Be findable as "timestamps".
2025-01-08 10:34:04 -08:00
Stephen Gildea
3de5fcd0a6 time-stamp: lower- and title-case weekday and month names
* lisp/time-stamp.el (time-stamp-string-preprocess): new formats for
lowercase weekday name, lowercase month name, and system name
* test/lisp/time-stamp.el: new tests
(formatz-generate-tests): Better doc strings for generated test fns.
2025-01-06 11:02:21 -08:00
Paul Eggert
4da38c6321 Update copyright year to 2025
Run "TZ=UTC0 admin/update-copyright".
2025-01-01 07:39:17 +00:00
Stephen Gildea
33532c5899 time-stamp: fix search end, more compatibility suggestions
* lisp/time-stamp.el (time-stamp): Use a marker for the
search end limit so we don't insert past it.
(time-stamp-conv-warn): Include a second suggested conversion
that might be what was intended.
Include a link to variable 'time-stamp-format'.
* test/lisp/time-stamp-tests.el: more tests
2024-12-14 10:23:04 -08:00
Eli Zaretskii
567566ca08 Merge from origin/emacs-30
6942599dbb ; * etc/PROBLEMS: Document problem with menu-bar backgrou...
488801baf7 * lisp/time-stamp.el: Limit field width to two digits.
34bedcd58d ; * lisp/progmodes/executable.el: Remove stale comment (b...
327d3e56f6 ; * etc/TODO: Add an item for improving defgroups.
7ae9ccae0c ; * lisp/net/rcirc.el (rcirc-next-active-buffer): Doc fix...
3e51be94ae ; Fix :version tag in browse-url
dffd4a50c6 Revert "Attempt to install package first when upgrading"
fbcb357b9d Fix 'gnus-select-method' custom type
6fd5e02cb9 Fix typo in maps.texi
872a7336dc ; * etc/DEBUG: Mention "handle SIGINT" on MS-Windows.
b4bcbabf95 * doc/misc/tramp.texi (FUSE-based methods): Fix sshfs ref...
f8da72b41c Improve gnus.texi indexing
4a090bd7ea ; * lisp/net/eww.el (eww-browse-with-external-browser): F...
59fa0b1dd6 ; Improve doc strings in compile.el
3d8e49c41a Attempt to install package first when upgrading

# Conflicts:
#	lisp/net/browse-url.el
#	lisp/net/eww.el
2024-12-14 09:39:59 -05:00
Stephen Gildea
488801baf7 * lisp/time-stamp.el: Limit field width to two digits. 2024-12-13 08:56:41 -08:00
Stephen Gildea
7665ec8df8 time-stamp: properly abbreviate instead of truncating names
* lisp/time-stamp (time-stamp-string-preprocess): Stop truncating month
and weekday name strings; it didn't internationalize well.
Some historical conversions, previously accepted quietly, now warn.
(time-stamp-format): Recommend the simpler formats implemented in 2019.
* test/lisp/time-stamp-tests.el: Update tests and comments to match.
Revert commit 83e4559664 (2022-07-01), which was working around the
former confusion between truncation and abbreviation.
2024-12-10 09:11:55 -08:00
Stephen Gildea
766ec1f9e0 time-stamp: minor adjustments to %P and modifier characters
* lisp/time-stamp.el (time-stamp-string-preprocess): %P variations;
allow (and ignore) "*", "E", and "O" as modifier characters.
(time-stamp-inserts-lines): safe-local-variable only if booleanp
2024-11-08 10:45:55 -08:00
Stephen Gildea
ffda8dfe84 ; time-stamp: Reformat some long doc strings for clarity.
* lisp/time-stamp.el (time-stamp-format, time-stamp-pattern): Reformat
doc strings for clarity.
(group time-stamp): is a subgroup of "files", not "data".
The "data" group seems to be for editing non-text files.
* test/lisp/time-stamp-tests.el: Fix tense of some doc strings.
2024-11-01 09:36:07 -07:00
Po Lu
8e1c56ae46 ; Add 2024 to copyright years 2024-01-02 09:47:10 +08:00
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Stephen Gildea
8d81ab374d time-stamp: %F is "file name" not "pathname" + other doc
* lisp/time-stamp.el (time-stamp-format): doc 'file' instead of 'path'.
* test/lisp/time-stamp-tests.el (formatz, format-time-offset):
Clarify the difference and similarity between these two test helpers.
2021-11-09 20:11:07 -08:00
Stephen Gildea
0bb42ef803 ; * lisp/time-stamp.el (time-stamp-format): Doc string. 2021-10-03 12:23:31 -07:00
Stephen Gildea
2895cb8d49 ; * lisp/time-stamp.el: Fix wording in some documentation strings. 2021-10-01 08:56:41 -07:00
Stephen Gildea
4cc4344943 ; Clarify and simplify time-stamp comments
* lisp/time-stamp.el (time-stamp-end, time-stamp-string-preprocess,
time-stamp-formatz-from-parsed-options): Simplify doc.
* test/lisp/time-stamp-tests.el (time-stamp-custom-pattern):
Refactor to set limit-number only once.
2021-09-26 08:23:29 -07:00
Stephen Gildea
a8c803db8e ; * lisp/time-stamp.el: Doc string wording improvements. 2021-08-25 18:17:12 -07:00
Stephen Gildea
ca3e4b3072 ; * lisp/time-stamp.el: Improve doc strings.
Thanks to VEB for her help with the clarity of the documentation.
2021-08-23 20:05:08 -07:00
Stephen Gildea
64dd2b1a2a time-stamp: add principled, expressive %z
* lisp/time-stamp.el (time-stamp-formatz-from-parsed-options): New
function for time zone offset formatting ("%z" variants).

* test/lisp/time-stamp-tests.el (formatz*): New unit tests to cover
the new implementation of %5z.
2021-06-21 21:30:19 -07:00
Stephen Gildea
a5b57fc6af time-stamp: fix minor bug when parsing option combos
* lisp/time-stamp.el (time-stamp-string-preprocess): Handle digit
options correctly to avoid overcounting colon options.

* test/lisp/time-stamp-tests.el (time-stamp-format-time-zone-offset):
Add a new test case that would have caught the option-parsing error.
2021-05-30 11:05:42 -07:00
Stephen Gildea
d6dc66053d time-stamp: refactor time-stamp-string-preprocess
* lisp/time-stamp.el (time-stamp-string-preprocess):  Reduce lifetime of
some loop-local variables to be less error-prone.
2021-05-30 09:11:03 -07:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Stefan Kangas
7dd671f7f2 Use lexical-binding in time-stamp.el
* lisp/time-stamp.el: Use lexical-binding.  Remove redundant :group
args.
2020-11-16 19:38:14 +01:00
Stephen Gildea
fd09196781 ; Clarify what time-stamp-active enables
Fix documentation strings and comments for time-stamp.  Most notably:
* lisp/time-stamp.el (time-stamp-active): in the doc string, clarify
that time-stamp-active does not add time-stamp to any hook.
2020-01-24 09:16:19 -08:00
Paul Eggert
365e01cc9f Update copyright year to 2020
Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
2020-01-01 00:59:52 +00:00
Stephen Gildea
1d189843bb time-stamp: update support for time zone numeric offset
* time-stamp.el (time-stamp-string-preprocess): Change new format for
numeric time zone from %:z to %5z to match format-time-string better.
(time-stamp-format): Document support for numeric time zone.
See discussion in bug#32931.

* NEWS: Mention time-stamp-format %5z.
2019-11-13 21:11:28 -08:00
Stephen Gildea
9ce67baa9a time-stamp: add support for time zone numeric offset
* time-stamp.el: Implement %:z as expanding to the numeric time zone
offset, to address the feature request of bug#32931.  Do not document it
yet, to discourage compatibility problems in mixed Emacs 26 and Emacs 27
environments.  Documentation will be added in a subsequent release at
least two years later.  (We cannot yet use %z for numeric time zone
because in Emacs 26 it was documented to do something else.)

* time-stamp-tests.el (time-stamp-test-format-time-zone): expand this
test and break it into two tests, time-stamp-test-format-time-zone-name
and time-stamp-test-format-time-zone-offset.
2019-11-06 08:33:51 -08:00
Stephen Gildea
113ff954db time-stamp-time-zone: update customization
* time-stamp.el (time-stamp-time-zone): Support customization with
an integer offset (a new possible value of the ZONE argument to
format-time-string in Emacs 27).
Update the safe-local-variable predicate from string-or-null-p
(describing time-stamp-time-zone's domain before 2015) to new
predicate time-stamp-zone-type-p (describing the current domain).

* time-stamp-tests.el (time-stamp-test-helper-zone-type-p): New test.
2019-10-27 08:21:16 -07:00
Stephen Gildea
d9a01dcd9f Minor tweaks to time-stamp documentation strings
* time-stamp.el (time-stamp): Reformat the explanation of the
variables that affect time-stamp, for easier reading.  In particular,
wrap the documentation to 75 characters, so that it displays neatly as
a before-save-hook customization option.

* time-stamp-tests.el (with-time-stamp-test-env): Use imperative voice,
per checkdoc.
2019-10-13 07:59:59 -07:00
Stephen Gildea
fc7b20056a Remove tabs from time-stamp-format documentation
* time-stamp.el (time-stamp-format): Untabify the doc string, so
the two-column layout displays consistently in several contexts,
in particular when displayed by customize-variable.
2019-10-10 09:22:52 -07:00
Stephen Gildea
600bcde608 time-stamp: revert recent change to "%04y"
* time-stamp.el (time-stamp-string-preprocess): Revert change to "%04y"
format made 2 weeks ago by commit 0e56883878 (the previous commit to
this file).  Although undocumented, "%04y" was discovered to be in use
in the wild (2016) and had not issued a warning that it would change.
Add a warning that it will change.

* time-stamp-tests.el (time-stamp-test-year-2digit): add test of "%04y"
2019-10-09 09:19:10 -07:00
Stephen Gildea
0e56883878 Move undocumented time-stamp formats closer to format-time-string
* time-stamp.el (time-stamp-string-preprocess): Update some undocumented
formatting characters of time-stamp format for closer (still incomplete)
alignment with format-time-string.  They have displayed a warning since
Emacs 20 (released in 1997), so it is unlikely anyone is using them.

* time-stamp-tests.el: Update tests to match new expectations.
2019-09-30 20:22:51 -07:00
Stephen Gildea
8ba1ca54f3 time-stamp doc: recommend formats closer to format-time-string
* time-stamp.el (time-stamp-format, time-stamp-pattern): Update
recommended (documented) formats.  No code changes, just documentation.
All recommended formats are compatible at least as far back as Emacs
22.1 (released in 2007) and are now closer to compatibility with
format-time-string.

* time-stamp-tests.el: Update test comments to match.
2019-09-30 20:08:12 -07:00
Stephen Gildea
a33cda168e Expand time-stamp unit tests to cover all formatting options
* time-stamp-tests.el: Expand unit tests to cover all formatting options.
These tests validate time-stamp-pattern formatting that has existed
since at least Emacs 22 (released in 2007).  The tests cover both
documented behavior and behavior implemented to support future migrations.

* time-stamp.el (time-stamp-string): Add a second argument (TIME) to
open a testing seam.  Have the unit tests call this public function.

* time-stamp.el (time-stamp-string, time-stamp-string-preprocess):
Remove the second pass through time-string--format.  (Previously both
functions called it.)  It was used only to handle "%", but this is now
handled by having time-stamp-string-preprocess not double it.
Not doubling the "%" in time-stamp-string-preprocess fixes the padding
of "%2%", which was discovered by the new unit tests to be wrong.
2019-09-22 20:31:59 -07:00
Lars Ingebrigtsen
e2f2745eb8 Doc clarification in time-stamp-pattern
* lisp/time-stamp.el (time-stamp-pattern): Try to document what
the examples mean (bug#26335).
2019-07-26 12:38:28 +02:00