diff options
author | Ulrich Müller <ulm@gentoo.org> | 2024-08-22 18:17:39 +0200 |
---|---|---|
committer | Ulrich Müller <ulm@gentoo.org> | 2024-08-22 18:17:39 +0200 |
commit | a6e60afef35c60785cf23f20c27b79cfc74c9cb3 (patch) | |
tree | 869aa80e19920bded5a118ce073625fee627f63e | |
parent | Use push in init value (diff) | |
download | ebuild-mode-a6e60afef35c60785cf23f20c27b79cfc74c9cb3.tar.gz ebuild-mode-a6e60afef35c60785cf23f20c27b79cfc74c9cb3.tar.bz2 ebuild-mode-a6e60afef35c60785cf23f20c27b79cfc74c9cb3.zip |
replace-match in XEmacs clobbers match data
* ebuild-mode.el (ebuild-mode-update-copyright): Save match data,
replace-match in XEmacs 21.4 clobbers it.
Signed-off-by: Ulrich Müller <ulm@gentoo.org>
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ebuild-mode.el | 40 |
2 files changed, 26 insertions, 19 deletions
@@ -1,3 +1,8 @@ +2024-08-22 Ulrich Müller <ulm@gentoo.org> + + * ebuild-mode.el (ebuild-mode-update-copyright): Save match data, + replace-match in XEmacs 21.4 clobbers it. + 2024-08-20 Ulrich Müller <ulm@gentoo.org> * ebuild-mode.el (ebuild-mode-arch-stable-list): Use push. diff --git a/ebuild-mode.el b/ebuild-mode.el index 9c190f8..0ef75b0 100644 --- a/ebuild-mode.el +++ b/ebuild-mode.el @@ -388,26 +388,28 @@ of the elements." (nth 1 ebuild-mode-update-copyright)))) (when (re-search-forward ebuild-mode-copyright-regexp 400 t) (if update-year - (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"))) - (y (string-to-number year))) - (if y2 - ;; Update range of years - (cond ((or (> 1999 y1) (>= y1 y2) (> y2 y)) - ;; XEmacs wants 'warning instead of :warning, - ;; but nil always works (and defaults to :warning) + (save-match-data + (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"))) + (y (string-to-number year))) + (if y2 + ;; Update range of years + (cond ((or (> 1999 y1) (>= y1 y2) (> y2 y)) + ;; XEmacs wants 'warning instead of :warning, + ;; but nil always works (and defaults to :warning) + (lwarn 'ebuild nil + "Suspicious range of copyright years: %d-%d" + y1 y2)) + ((/= y2 y) + (replace-match year t t nil 2))) + ;; Update single year and convert to range if necessary + (cond ((or (> 1999 y1) (> y1 y)) (lwarn 'ebuild nil - "Suspicious range of copyright years: %d-%d" - y1 y2)) - ((/= y2 y) - (replace-match year t t nil 2))) - ;; Update single year and convert to range if necessary - (cond ((or (> 1999 y1) (> y1 y)) - (lwarn 'ebuild nil "Suspicious copyright year: %d" y1)) - ((/= y1 y) - (replace-match (concat "\\1-" year) t nil nil 1)))))) + "Suspicious copyright year: %d" y1)) + ((/= y1 y) + (replace-match (concat "\\1-" year) t nil nil 1))))))) (if update-author ;; Update default author in copyright notice (if (string-equal (match-string 3) "Gentoo Foundation") |