diff options
author | Ulrich Müller <ulm@gentoo.org> | 2024-11-03 14:25:30 +0100 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2024-11-04 19:50:44 +0100 |
commit | 0f5e5a7288b226594c44cb57c5e8b608916287d8 (patch) | |
tree | 0955571f30eda3b41135aa0c067fe9c1317f403f | |
parent | Add comment in tests (diff) | |
download | ebuild-mode-0f5e5a7288b226594c44cb57c5e8b608916287d8.tar.gz ebuild-mode-0f5e5a7288b226594c44cb57c5e8b608916287d8.tar.bz2 ebuild-mode-0f5e5a7288b226594c44cb57c5e8b608916287d8.zip |
Delete XEmacs 21.4 compat function for format-time-string
* ebuild-mode.el (ebuild-mode-time-string): Delete compatibility
function for XEmacs 21.4.
(ebuild-mode-update-copyright, ebuild-mode-insert-skeleton)
(ebuild-mode-insert-tag-line): Update all callers.
* gentoo-newsitem-mode.el (gentoo-newsitem-insert-skeleton):
* glep-mode.el (glep-mode-update-last-modified)
(glep-mode-insert-skeleton): Update all callers.
* test/ebuild-mode-tests.el
(ebuild-mode-test-run-with-fixed-time): Update macro.
(ebuild-mode-test-time-string): Delete test.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | ChangeLog | 13 | ||||
-rw-r--r-- | ebuild-mode.el | 26 | ||||
-rw-r--r-- | gentoo-newsitem-mode.el | 2 | ||||
-rw-r--r-- | glep-mode.el | 6 | ||||
-rw-r--r-- | test/ebuild-mode-tests.el | 15 |
5 files changed, 23 insertions, 39 deletions
@@ -1,3 +1,16 @@ +2024-11-03 Ulrich Müller <ulm@gentoo.org> + + * ebuild-mode.el (ebuild-mode-time-string): Delete compatibility + function for XEmacs 21.4. + (ebuild-mode-update-copyright, ebuild-mode-insert-skeleton) + (ebuild-mode-insert-tag-line): Update all callers. + * gentoo-newsitem-mode.el (gentoo-newsitem-insert-skeleton): + * glep-mode.el (glep-mode-update-last-modified) + (glep-mode-insert-skeleton): Update all callers. + * test/ebuild-mode-tests.el + (ebuild-mode-test-run-with-fixed-time): Update macro. + (ebuild-mode-test-time-string): Delete test. + 2024-10-23 Ulrich Müller <ulm@gentoo.org> * devbook-mode.el (devbook-locate-schema-file): Be less verbose diff --git a/ebuild-mode.el b/ebuild-mode.el index 589fdaa..520b9a6 100644 --- a/ebuild-mode.el +++ b/ebuild-mode.el @@ -256,26 +256,6 @@ Returns non-nil if A is less than B by Gentoo keyword ordering." `(progn ,@else))) )) -(defun ebuild-mode-time-string (format-string &optional time) - "Use FORMAT-STRING to format the time value TIME. -Calls `format-time-string' (which see) for the UTC time zone. -Compatibility function for XEmacs." - (static-if (and (featurep 'xemacs) - (not (function-allows-args #'format-time-string 3))) - ;; format-time-string in older XEmacs versions can take only two - ;; arguments. Version 21.5.35 still doesn't support a time zone - ;; as third argument, but accepts non-nil to mean Universal Time. - (let ((process-environment (copy-sequence process-environment)) - (tz (getenv "TZ"))) - (unwind-protect - (progn - (setenv "TZ" "UTC") - (format-time-string format-string time)) - ;; This is needed because setenv handles TZ specially. - ;; So, restoring the environment is not enough. - (setenv "TZ" tz))) - (format-time-string format-string time t))) - ;;; Font-lock. (eval-and-compile @@ -386,7 +366,7 @@ of the elements." (let* ((y1 (string-to-number (match-string 1))) (y2 (and (match-string 2) (string-to-number (match-string 2)))) - (year (save-match-data (ebuild-mode-time-string "%Y"))) + (year (save-match-data (format-time-string "%Y" nil t))) (y (string-to-number year))) (if y2 ;; Update range of years @@ -852,7 +832,7 @@ that shall be manipulated." "Insert a statement skeleton for a new ebuild." nil ;; standard header - "# Copyright " (ebuild-mode-time-string "%Y") " Gentoo Authors\n" + "# Copyright " (format-time-string "%Y" nil t) " Gentoo Authors\n" "# Distributed under the terms of the GNU General Public License v2\n" "\n" "EAPI=" @@ -1042,7 +1022,7 @@ in a Gentoo profile." " ")) (format "%s <%s> (%s)\n" ebuild-mode-full-name ebuild-mode-mail-address - (ebuild-mode-time-string "%Y-%m-%d")))) + (format-time-string "%Y-%m-%d" nil t)))) ;;; Key bindings. diff --git a/gentoo-newsitem-mode.el b/gentoo-newsitem-mode.el index f356708..32dc4f7 100644 --- a/gentoo-newsitem-mode.el +++ b/gentoo-newsitem-mode.el @@ -78,7 +78,7 @@ (setq v2 (point-marker)) nil) "Posted: " (skeleton-read "Date of posting: " - (ebuild-mode-time-string "%Y-%m-%d")) + (format-time-string "%Y-%m-%d" nil t)) "\n" "Revision: 1\n" "News-Item-Format: " diff --git a/glep-mode.el b/glep-mode.el index 48590a8..1e03f54 100644 --- a/glep-mode.el +++ b/glep-mode.el @@ -64,7 +64,7 @@ For efficiency only. Unlimited if nil.") "Update the Last-Modified date." (save-excursion (goto-char (point-min)) - (let ((date (ebuild-mode-time-string "%Y-%m-%d")) + (let ((date (format-time-string "%Y-%m-%d" nil t)) (case-fold-search nil)) (and (re-search-forward glep-mode-last-modified-re glep-mode-preamble-limit t) @@ -231,8 +231,8 @@ Calls the external \"glep\" command." nil 'confirm "Draft") "\n" "Version: " (skeleton-read "Version: " "1") "\n" - "Created: " (ebuild-mode-time-string "%Y-%m-%d") "\n" - "Last-Modified: " (ebuild-mode-time-string "%Y-%m-%d") "\n" + "Created: " (format-time-string "%Y-%m-%d" nil t) "\n" + "Last-Modified: " (format-time-string "%Y-%m-%d" nil t) "\n" "Post-History: \n" "Content-Type: text/x-rst\n" ((skeleton-read "Requires: (null string if none): ") "Requires: " str "\n") diff --git a/test/ebuild-mode-tests.el b/test/ebuild-mode-tests.el index f1e8df8..c88a990 100644 --- a/test/ebuild-mode-tests.el +++ b/test/ebuild-mode-tests.el @@ -32,15 +32,12 @@ (let ((encode-time (if (and (fboundp 'func-arity) (>= 1 (car (func-arity 'encode-time)))) ;; new calling convention since Emacs 27 - '(encode-time) '(apply #'encode-time))) - (zone (if (or (not (featurep 'xemacs)) - (function-allows-args #'format-time-string 3)) - (list 'zone)))) + '(encode-time) '(apply #'encode-time)))) `(cl-letf* ((fixed-time (,@encode-time '(0 0 0 10 8 2024 nil nil 0))) (orig-fun (symbol-function 'format-time-string)) ((symbol-function 'format-time-string) - (lambda (fmt-string &optional time ,@zone) - (funcall orig-fun fmt-string (or time fixed-time) ,@zone)))) + (lambda (fmt-string &optional time zone) + (funcall orig-fun fmt-string (or time fixed-time) zone)))) ,@body))) (defmacro ebuild-mode-test-run-silently (&rest body) @@ -60,12 +57,6 @@ (should-not (ebuild-mode-arch-lessp "amd64-linux" "x86")) (should (ebuild-mode-arch-lessp "x86-linux" "ppc-macos"))) -(ert-deftest ebuild-mode-test-time-string () - (ebuild-mode-test-run-with-fixed-time - (should (string-equal - (ebuild-mode-time-string "%Y-%m-%d %H:%M:%S") - "2024-08-10 00:00:00")))) - (ert-deftest ebuild-mode-test-collect-and-split () (let* ((alist '(((a b) z) ((c d) z) ((e) z) ((f) z) ((g h) z) ((i j) y x) ((k) y x) ((l)) ((m) z) ((n o) y x) ((p)) |