GNU bug report logs - #21262
25.0.50; Diff-mode gets confused about its narrowing if hunk source not found

Previous Next

Package: emacs;

Reported by: Dima Kogan <dima <at> secretsauce.net>

Date: Sat, 15 Aug 2015 06:02:01 UTC

Severity: normal

Found in version 25.0.50

Done: charles <at> aurox.ch (Charles A. Roelli)

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Dima Kogan <dima <at> secretsauce.net>
Subject: bug#21262: closed (Re: bug#21262: 25.0.50; Diff-mode gets
 confused about its narrowing if hunk source not found)
Date: Sun, 27 Aug 2017 12:22:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 21262 <at> debbugs.gnu.org.

-- 
21262: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21262
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: charles <at> aurox.ch (Charles A. Roelli)
To: npostavs <at> users.sourceforge.net
Cc: 21262-done <at> debbugs.gnu.org, dima <at> secretsauce.net
Subject: Re: bug#21262: 25.0.50;
 Diff-mode gets confused about its narrowing if hunk source not found
Date: Sun, 27 Aug 2017 14:21:05 +0200
> Date: Tue, 22 Aug 2017 16:02:17 +0200
> From: charles <at> aurox.ch (Charles A. Roelli) 
> 
> > From: npostavs <at> users.sourceforge.net
> > Cc: Dima Kogan <dima <at> secretsauce.net>,  21262 <at> debbugs.gnu.org
> > Date: Mon, 21 Aug 2017 20:18:39 -0400
> >
> > Looks like a reasonable fix to me (though I know only a little bit of
> > diff-mode).  Here it is again ignoring whitespace, which I think makes
> > it easier to see what is happening:
> > 
> > modified   lisp/vc/diff-mode.el
> > @@ -874,6 +874,8 @@ diff-find-file-name
> >      ;; Flush diff-remembered-files-alist if the default-directory is changed.
> >      (set (make-local-variable 'diff-remembered-defdir) default-directory)
> >      (set (make-local-variable 'diff-remembered-files-alist) nil))
> > +  (save-restriction
> > +    (widen)
> >      (save-excursion
> >        (unless (looking-at diff-file-header-re)
> >          (or (ignore-errors (diff-beginning-of-file))
> > @@ -919,7 +921,7 @@ diff-find-file-name
> >  				   (file-name-nondirectory file)))
> >               (set (make-local-variable 'diff-remembered-files-alist)
> >                    (cons (cons fs file) diff-remembered-files-alist))
> > -           file))))))
> > +             file)))))))
> > 
> > Perhaps we should swap the save-restriction and save-excursion around
> > though?  The elisp manual says:
> > 
> >      If you use both `save-restriction' and `save-excursion' together,
> >      `save-excursion' should come first (on the outside).  Otherwise,
> >      the old point value would be restored with temporary narrowing
> >      still in effect.
> 
> Good point, thank you.  I'll apply the attached patch in a few days if
> there's no further discussion.

I've pushed the fix, closing the bug now.

  commit 208a3cb05f4d954abc9dd6c8cd858ef2bedd7cb4
  Date:   Tue Aug 22 15:57:01 2017 +0200

  Fix 'diff-goto-source' when buffer is narrowed (Bug#21262)

  * lisp/vc/diff-mode.el (diff-find-file-name): Save the current
  narrowing, and widen the buffer before searching for the name of the
  file corresponding to the diff.

  With thanks to Noam Postavsky.

[Message part 3 (message/rfc822, inline)]
From: Dima Kogan <dima <at> secretsauce.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50;
 Diff-mode gets confused about its narrowing if hunk source not found
Date: Fri, 14 Aug 2015 22:12:09 -0700
[Message part 4 (text/plain, inline)]
Hi. This bug has been there since at least emacs23 it seems like. To
reproduce:

1. emacs -Q

2. Open any patch file that has hunks from more than one file in it. For
instance, the attached patch file works, but it really doesn't matter

3. Narrow to just the second file's diffs. For instance: M-N M-N C-SPC
C-> C-x n n SPC (last SPC to confirm the narrowing)

4. Try to see the source of the hunk. Move the point to the guts of the
hunk, and M-enter. Emacs asks for the directory where the sources live.
In the process, it changes the narrowing to the wrong hunk. This is
wrong. The narrowing shouldn't change.

5. If we cancel with C-g, the wrong narrowing persists



[tst2.diff (text/x-diff, inline)]
diff --git a/src/charset.c b/src/charset.c
index b19e344..eeebf17 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -555,7 +555,7 @@ load_charset_map_from_vector (struct charset *charset, Lisp_Object vec, int cont
 
   if (len % 2 == 1)
     {
-      add_to_log ("Failure in loading charset map: %V", vec, Qnil);
+      add_to_log ("Failure in loading charset map: %V", vec);
       return;
     }
 
diff --git a/src/image.c b/src/image.c
index 066db74..313419b 100644
--- a/src/image.c
+++ b/src/image.c
@@ -629,16 +629,19 @@ valid_image_p (Lisp_Object object)
 }
 
 
-/* Log error message with format string FORMAT and argument ARG.
+/* Log error message with format string FORMAT and trailing arguments.
    Signaling an error, e.g. when an image cannot be loaded, is not a
    good idea because this would interrupt redisplay, and the error
    message display would lead to another redisplay.  This function
    therefore simply displays a message.  */
 
 static void
-image_error (const char *format, Lisp_Object arg1, Lisp_Object arg2)
+image_error (const char *format, ...)
 {
-  add_to_log (format, arg1, arg2);
+  va_list ap;
+  va_start (ap, format);
+  vadd_to_log (format, ap);
+  va_end (ap);
 }
 
 

This bug report was last modified 7 years and 270 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.