all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lele Gaifax <lele@metapensiero.it>
To: emacs-devel@gnu.org
Subject: Re: Strange problem with emacs-lisp/copyright.el
Date: Tue, 31 Oct 2017 19:14:02 +0100	[thread overview]
Message-ID: <87d153mbh1.fsf@metapensiero.it> (raw)
In-Reply-To: 8737cj63wt.fsf@metapensiero.it

[-- Attachment #1: Type: text/plain, Size: 2697 bytes --]

Hi all,

this is just to properly end the thread [1], and ask whether I should open an
issue, or add an annotation to the existing (but not exactly the same) issue
#7179 [2], or what.

Back in April I applied Johan Bockgård's suggestion and since then I haven't
seen the reported problem again:

>> Johan Bockgård <bojohan@gnu.org> writes:
>>
>>>
>>> Does it work correctly if you change
>>>
>>>   (switch-to-buffer (current-buffer))
>>>   ;; Fixes some point-moving oddness (bug#2209).
>>>   (save-excursion
>>>     (y-or-n-p (if replace
>>>
>>> to
>>>
>>>   (save-excursion
>>>     (switch-to-buffer (current-buffer))
>>>     (y-or-n-p (if replace
>>>
>>> ?

To summarize, I shuffled just a couple of lines: the attached `diff -u` does
not make that clear, but hopefully the following `diff -u --ignore-space-change` 
gives a better idea since it ignores the indentation changes:

  --- copyright-orig.el	2017-10-31 18:54:20.957330092 +0100
  +++ copyright.el	2017-10-31 18:55:11.624754452 +0100
  @@ -181,19 +181,22 @@
     ;; This uses the match-data from copyright-find-copyright/end.
     (goto-char (match-end 1))
     (copyright-find-end)
  +  (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
  +                (save-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? "))))))
  +          (progn
  +            (goto-char copyright-end)
           (if replace
               (replace-match copyright-current-year t t nil 3)
             (let ((size (save-excursion (skip-chars-backward "0-9"))))
  @@ -218,7 +221,7 @@
                 (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)

thanks&bye, lele.

[1] http://lists.gnu.org/archive/html/emacs-devel/2017-04/msg00271.html
[2] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=7179


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: copyright.el.patch --]
[-- Type: text/x-diff, Size: 4607 bytes --]

--- copyright-orig.el	2017-10-31 18:54:20.957330092 +0100
+++ copyright.el	2017-10-31 18:55:11.624754452 +0100
@@ -181,44 +181,47 @@
   ;; 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? "))))))
-        (if replace
-            (replace-match copyright-current-year t t nil 3)
-          (let ((size (save-excursion (skip-chars-backward "0-9"))))
-            (if (and (eq (% (- (string-to-number copyright-current-year)
-                               (string-to-number (buffer-substring
-                                                  (+ (point) size)
-                                                  (point))))
-                            100)
-                         1)
-                     (or (eq (char-after (+ (point) size -1)) ?-)
-                         (eq (char-after (+ (point) size -2)) ?-)))
-                ;; This is a range so just replace the end part.
-                (delete-char size)
-              ;; Insert a comma with the preferred number of spaces.
-              (insert
-               (save-excursion
-                 (if (re-search-backward "[0-9]\\( *, *\\)[0-9]"
-                                         (line-beginning-position) t)
-                     (match-string 1)
-                   ", ")))
-              ;; If people use the '91 '92 '93 scheme, do that as well.
-              (if (eq (char-after (+ (point) size -3)) ?')
-                  (insert ?')))
-            ;; Finally insert the new year.
-            (insert (substring copyright-current-year size)))))))
+  (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
+                (save-excursion
+                  (switch-to-buffer (current-buffer))
+                ;; Fixes some point-moving oddness (bug#2209).
+                  (y-or-n-p (if replace
+                                (concat "Replace copyright year(s) by "
+                                        copyright-current-year "? ")
+                              (concat "Add " copyright-current-year
+                                      " to copyright? "))))))
+          (progn
+            (goto-char copyright-end)
+            (if replace
+                (replace-match copyright-current-year t t nil 3)
+              (let ((size (save-excursion (skip-chars-backward "0-9"))))
+                (if (and (eq (% (- (string-to-number copyright-current-year)
+                                   (string-to-number (buffer-substring
+                                                      (+ (point) size)
+                                                      (point))))
+                                100)
+                             1)
+                         (or (eq (char-after (+ (point) size -1)) ?-)
+                             (eq (char-after (+ (point) size -2)) ?-)))
+                    ;; This is a range so just replace the end part.
+                    (delete-char size)
+                  ;; Insert a comma with the preferred number of spaces.
+                  (insert
+                   (save-excursion
+                     (if (re-search-backward "[0-9]\\( *, *\\)[0-9]"
+                                             (line-beginning-position) t)
+                         (match-string 1)
+                       ", ")))
+                  ;; If people use the '91 '92 '93 scheme, do that as well.
+                  (if (eq (char-after (+ (point) size -3)) ?')
+                      (insert ?')))
+                ;; Finally insert the new year.
+                (insert (substring copyright-current-year size)))))))))
 
 ;;;###autoload
 (defun copyright-update (&optional arg interactivep)

[-- Attachment #3: Type: text/plain, Size: 206 bytes --]


-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele@metapensiero.it  |                 -- Fortunato Depero, 1929.

  reply	other threads:[~2017-10-31 18:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-11  6:53 Strange problem with emacs-lisp/copyright.el Lele Gaifax
2017-04-11  9:28 ` Alan Third
2017-04-17 17:29 ` Lele Gaifax
2017-04-21 17:49   ` Lele Gaifax
2017-04-22 13:21     ` Johan Bockgård
2017-04-23 21:00       ` Lele Gaifax
2017-05-05  9:36         ` Lele Gaifax
2017-10-31 18:14           ` Lele Gaifax [this message]
2017-11-01  2:19             ` Noam Postavsky
2017-11-05 11:36             ` Johan Bockgård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d153mbh1.fsf@metapensiero.it \
    --to=lele@metapensiero.it \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.