bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#5394: 23.1; copyright.el show buffer being changed


From: Kevin Ryde
Subject: bug#5394: 23.1; copyright.el show buffer being changed
Date: Sat, 16 Jan 2010 09:16:08 +1100
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux)

When doing C-x s `save-some-buffers' with copyright-update in
before-save-hook, when copyright-update asks whether to add a copyright
year it'd be good if it showed you the buffer it's asking about.

I tried the couple of lines below for a simple switch-to-buffer.
Perhaps a `perform-replace' or similar would be even better if it
highlighted the part of the buffer that's going to be changed too.


2010-01-15  Kevin Ryde  <user42@zip.com.au>

        * emacs-lisp/copyright.el (copyright-update-year, copyright-update):
        Temporary switch-to-buffer to ensure the buffer change being
        queried is visible.  Good for save-some-buffers when
        copyright-update is in before-save-hook.

--- copyright.el.~1.82.~        2009-07-18 11:16:37.000000000 +1000
+++ copyright.el        2010-01-16 09:08:44.000000000 +1100
@@ -158,13 +158,15 @@
     (unless (string= (buffer-substring (- (match-end 3) 2) (match-end 3))
                     (substring copyright-current-year -2))
       (if (or noquery
-             ;; 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? ")))))
+             (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"))))
@@ -224,8 +226,10 @@
                   (string-to-number copyright-current-gpl-version))
               (or noquery
                    (save-match-data
-                     (y-or-n-p (format "Replace GPL version by %s? "
-                                       copyright-current-gpl-version))))
+                    (save-window-excursion
+                      (switch-to-buffer (current-buffer))
+                      (y-or-n-p (format "Replace GPL version by %s? "
+                                        copyright-current-gpl-version)))))
               (progn
                 (if (match-end 2)
                     ;; Esperanto bilingual comment in two-column.el

In GNU Emacs 23.1.1 (i486-pc-linux-gnu, GTK+ Version 2.16.5)
 of 2009-09-14 on raven, modified by Debian
configured using `configure  '--build=i486-linux-gnu' '--host=i486-linux-gnu' 
'--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' 
'--localstatedir=/var/lib' '--infodir=/usr/share/info' 
'--mandir=/usr/share/man' '--with-pop=yes' 
'--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.1/site-lisp:/usr/share/emacs/site-lisp:/usr/share/emacs/23.1/leim'
 '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 
'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu' 'CFLAGS=-DDEBIAN -g 
-O2' 'LDFLAGS=-g' 'CPPFLAGS=''

reply via email to

[Prev in Thread] Current Thread [Next in Thread]