unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* fix for bug#29935 copyright-update inserts year at random places
@ 2018-01-01 23:29 Stephen Leake
  2018-01-02  9:21 ` Lele Gaifax
  2018-01-02 16:03 ` Eli Zaretskii
  0 siblings, 2 replies; 22+ messages in thread
From: Stephen Leake @ 2018-01-01 23:29 UTC (permalink / raw)
  To: emacs-devel

I filed bug#29935 because copyright-update sometimes inserts the new
year at random places (happy new year! :).

This was discussed last April, but no bug report was filed, and both
master and emacs-26 still have the bug: see
https://lists.gnu.org/archive/html/emacs-devel/2017-10/msg00848.html

I improved the fix posted there; see below.

Ok to commit to emacs-26?

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=29935
diff --git a/lisp/emacs-lisp/copyright.el b/lisp/emacs-lisp/copyright.el
index 69c5ebd45d..dcbee62af6 100644
--- a/lisp/emacs-lisp/copyright.el
+++ b/lisp/emacs-lisp/copyright.el
@@ -181,19 +181,22 @@ copyright-update-year
   ;; This uses the match-data from copyright-find-copyright/end.
   (goto-char (match-end 1))
   (copyright-find-end)
-  (setq copyright-current-year (format-time-string "%Y"))
-  (unless (string= (buffer-substring (- (match-end 3) 2) (match-end 3))
-		   (substring copyright-current-year -2))
-    (if (or noquery
-	    (save-window-excursion
-	      (switch-to-buffer (current-buffer))
-	      ;; Fixes some point-moving oddness (bug#2209).
-	      (save-excursion
-		(y-or-n-p (if replace
-			      (concat "Replace copyright year(s) by "
-				      copyright-current-year "? ")
-			    (concat "Add " copyright-current-year
-				    " to copyright? "))))))
+  (let ((copyright-end (point)))
+    (setq copyright-current-year (format-time-string "%Y"))
+    (unless (string= (buffer-substring (- (match-end 3) 2) (match-end 3))
+		     (substring copyright-current-year -2))
+      (if (or noquery
+	      (save-window-excursion
+	        ;; Fixes some point-moving oddness (bug#2209, bug#29935).
+	        (save-excursion
+	          (switch-to-buffer (current-buffer))
+                  ;; Ensure the copyright line is displayed.
+                  (goto-char copyright-end)
+		  (y-or-n-p (if replace
+			        (concat "Replace copyright year(s) by "
+				        copyright-current-year "? ")
+			      (concat "Add " copyright-current-year
+				      " to copyright? "))))))
 	(if replace
 	    (replace-match copyright-current-year t t nil 3)
 	  (let ((size (save-excursion (skip-chars-backward "0-9"))))
@@ -218,7 +221,8 @@ copyright-update-year
 	      (if (eq (char-after (+ (point) size -3)) ?')
 		  (insert ?')))
 	    ;; Finally insert the new year.
-	    (insert (substring copyright-current-year size)))))))
+	    (insert (substring copyright-current-year size))))
+        ))))
 
 ;;;###autoload
 (defun copyright-update (&optional arg interactivep)

-- 
-- Stephe



^ permalink raw reply related	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-01-11 16:48 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-01 23:29 fix for bug#29935 copyright-update inserts year at random places Stephen Leake
2018-01-02  9:21 ` Lele Gaifax
2018-01-02 16:03 ` Eli Zaretskii
2018-01-03 22:52   ` Stephen Leake
2018-01-04  1:01     ` Stefan Monnier
2018-01-04  3:21       ` Stephen Leake
2018-01-04  5:34         ` Stefan Monnier
2018-01-04 12:47           ` Stephen Leake
2018-01-04 18:23             ` Stefan Monnier
2018-01-07 16:08             ` martin rudalics
2018-01-07 17:34               ` Stefan Monnier
2018-01-08  9:53                 ` martin rudalics
2018-01-08 13:15                   ` Stefan Monnier
2018-01-08 16:56                     ` Stephen Leake
2018-01-08 18:37                       ` martin rudalics
2018-01-08 19:05                       ` Eli Zaretskii
2018-01-11 16:48                         ` Stephen Leake
2018-01-08 18:18                     ` martin rudalics
2018-01-08 22:18                       ` Stefan Monnier
2018-01-09  9:42                         ` martin rudalics
2018-01-09 13:07                           ` Stefan Monnier
2018-01-10 10:19                             ` martin rudalics

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).