From unknown Sun Jun 22 07:51:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found Resent-From: Dima Kogan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Aug 2015 06:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21262 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 21262@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.143961850016315 (code B ref -1); Sat, 15 Aug 2015 06:02:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Aug 2015 06:01:40 +0000 Received: from localhost ([127.0.0.1]:56181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZQUXE-0004F4-4s for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36755) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZQUXB-0004Ew-PQ for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQUXA-0002N0-HK for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQUXA-0002Mw-FU for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQUX9-00063z-JR for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2015 02:01:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQUX3-0002Ip-LH for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2015 02:01:35 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:51126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQUX3-0002Hw-Ch for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2015 02:01:29 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 8BD02209E8 for ; Sat, 15 Aug 2015 02:01:27 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Sat, 15 Aug 2015 02:01:27 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=content-type:date:from:message-id:mime-version:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=fzTCVWV56dqkRdsy2u4c2p/BF3c =; b=FbaKyVQrHeYcFzH0MT9sbqO9+th2dnhJkkrVaQvEPcBzDrjl+sDIP0iAVZN Xl4JRShHyvqkGdujwyihSe4CD/cmPsH2tZc0eOWtmvmQV+Wtu38ElhGLO36XITmC Kn653KuDKXREXPykdIeMyA3pxh35mrm/UpKr9o0dsyDM2e8k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=fz TCVWV56dqkRdsy2u4c2p/BF3c=; b=n9OT+Yw1dDlMG+Hf3bnyP4qRd6fhlYUN4u A6k8m4uZs+dgwgfX1y/EETO5zO41fA5gLoqimfwWclfbxtFtBJ9AboMZ3SYDVmRv /sWJ6KDKgFBuu87HL1nUvSirneT9POnTbIhvsucjUS8Kw2OFewrhKVKO/Sj+g90o N2Kd9sVoU= X-Sasl-enc: WrzzYaART5+RsP5mFFn5Hhx3Ue0AdNaR9OmdVDV6Ls62 1439618487 Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com [50.1.153.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 45DBDC00018 for ; Sat, 15 Aug 2015 02:01:27 -0400 (EDT) Received: from [::1] (helo=shorty) by shorty.local with esmtp (Exim 4.84) (envelope-from ) id 1ZQTlT-00017t-VL for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2015 22:12:20 -0700 From: Dima Kogan Date: Fri, 14 Aug 2015 22:12:09 -0700 Message-ID: <87lhdd5e52.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=tst2.diff 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); } --=-=-=-- From unknown Sun Jun 22 07:51:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found Resent-From: charles@aurox.ch (Charles A. Roelli) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Aug 2017 19:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21262 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Dima Kogan Cc: 21262@debbugs.gnu.org Received: via spool by 21262-submit@debbugs.gnu.org id=B21262.15033450252847 (code B ref 21262); Mon, 21 Aug 2017 19:51:01 +0000 Received: (at 21262) by debbugs.gnu.org; 21 Aug 2017 19:50:25 +0000 Received: from localhost ([127.0.0.1]:48224 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djsiO-0000jq-TJ for submit@debbugs.gnu.org; Mon, 21 Aug 2017 15:50:25 -0400 Received: from sinyavsky.aurox.ch ([37.35.109.145]:39366) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djsiM-0000jc-JN for 21262@debbugs.gnu.org; Mon, 21 Aug 2017 15:50:23 -0400 Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id B927A22506 for <21262@debbugs.gnu.org>; Mon, 21 Aug 2017 19:44:25 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= content-type:content-type:mime-version:references:subject :subject:in-reply-to:to:from:from:message-id:date:date; s=dkim; t=1503344663; x=1504208664; bh=0b7zDHHZLGpEdXv+oFaowOLHKuPMPygf cPpzxnLkJ04=; b=rW1FNNCmRtNZo9a0bYVyoGxfYUvZqU2Y+DQBqIQ3xQ3ihHLm DlHzUPmT/8m0v7RUJJe5eYY+r6Cw+7DvgF0obUWpObJ/A6TjBt+MbFdb4aDuTdhJ SD1EAx9Gi7Sl6sUG7LajIuxJsNLsa07TQy7iTfTffotJLcuEI6FoBZ0/WpI= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id gFYP3Y1m7BPm for <21262@debbugs.gnu.org>; Mon, 21 Aug 2017 19:44:23 +0000 (UTC) Received: from gray (125.85.192.178.dynamic.wline.res.cust.swisscom.ch [178.192.85.125]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id B565B224EB; Mon, 21 Aug 2017 19:44:22 +0000 (UTC) Date: Mon, 21 Aug 2017 21:49:50 +0200 Message-Id: From: charles@aurox.ch (Charles A. Roelli) In-reply-to: <87lhdd5e52.fsf@secretsauce.net> (message from Dima Kogan on Fri, 14 Aug 2015 22:12:09 -0700) References: <87lhdd5e52.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain > From: Dima Kogan > Date: Fri, 14 Aug 2015 22:12:09 -0700 > > 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 > > > > 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 still affects 26.0.50. The attached change fixes it -- but I know nothing of diff-mode, so better ideas are welcome. Note that the buffer will be widened while Emacs asks where to look for the sources, but it will return to the original narrowing after the user has selected a file or hit C-g. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=01-emacs-bug-21262-draft.patch diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index aa8d778..b470406 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -874,52 +874,54 @@ 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-excursion - (unless (looking-at diff-file-header-re) - (or (ignore-errors (diff-beginning-of-file)) - (re-search-forward diff-file-header-re nil t))) - (let ((fs (diff-hunk-file-names old))) - (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs))) - (or - ;; use any previously used preference - (cdr (assoc fs diff-remembered-files-alist)) - ;; try to be clever and use previous choices as an inspiration - (cl-dolist (rf diff-remembered-files-alist) - (let ((newfile (diff-merge-strings (caar rf) (car fs) (cdr rf)))) - (if (and newfile (file-exists-p newfile)) (cl-return newfile)))) - ;; look for each file in turn. If none found, try again but - ;; ignoring the first level of directory, ... - (cl-do* ((files fs (delq nil (mapcar 'diff-filename-drop-dir files))) - (file nil nil)) - ((or (null files) - (setq file (cl-do* ((files files (cdr files)) - (file (car files) (car files))) - ;; Use file-regular-p to avoid - ;; /dev/null, directories, etc. - ((or (null file) (file-regular-p file)) - file)))) - file)) - ;; .rej patches implicitly apply to - (and (string-match "\\.rej\\'" (or buffer-file-name "")) - (let ((file (substring buffer-file-name 0 (match-beginning 0)))) - (when (file-exists-p file) file))) - ;; If we haven't found the file, maybe it's because we haven't paid - ;; attention to the PCL-CVS hint. - (and (not prefix) - (boundp 'cvs-pcl-cvs-dirchange-re) - (save-excursion - (re-search-backward cvs-pcl-cvs-dirchange-re nil t)) - (diff-find-file-name old noprompt (match-string 1))) - ;; if all else fails, ask the user - (unless noprompt - (let ((file (expand-file-name (or (car fs) "")))) - (setq file - (read-file-name (format "Use file %s: " file) - (file-name-directory file) file t - (file-name-nondirectory file))) - (set (make-local-variable 'diff-remembered-files-alist) - (cons (cons fs file) diff-remembered-files-alist)) - file)))))) + (save-restriction + (widen) + (save-excursion + (unless (looking-at diff-file-header-re) + (or (ignore-errors (diff-beginning-of-file)) + (re-search-forward diff-file-header-re nil t))) + (let ((fs (diff-hunk-file-names old))) + (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs))) + (or + ;; use any previously used preference + (cdr (assoc fs diff-remembered-files-alist)) + ;; try to be clever and use previous choices as an inspiration + (cl-dolist (rf diff-remembered-files-alist) + (let ((newfile (diff-merge-strings (caar rf) (car fs) (cdr rf)))) + (if (and newfile (file-exists-p newfile)) (cl-return newfile)))) + ;; look for each file in turn. If none found, try again but + ;; ignoring the first level of directory, ... + (cl-do* ((files fs (delq nil (mapcar 'diff-filename-drop-dir files))) + (file nil nil)) + ((or (null files) + (setq file (cl-do* ((files files (cdr files)) + (file (car files) (car files))) + ;; Use file-regular-p to avoid + ;; /dev/null, directories, etc. + ((or (null file) (file-regular-p file)) + file)))) + file)) + ;; .rej patches implicitly apply to + (and (string-match "\\.rej\\'" (or buffer-file-name "")) + (let ((file (substring buffer-file-name 0 (match-beginning 0)))) + (when (file-exists-p file) file))) + ;; If we haven't found the file, maybe it's because we haven't paid + ;; attention to the PCL-CVS hint. + (and (not prefix) + (boundp 'cvs-pcl-cvs-dirchange-re) + (save-excursion + (re-search-backward cvs-pcl-cvs-dirchange-re nil t)) + (diff-find-file-name old noprompt (match-string 1))) + ;; if all else fails, ask the user + (unless noprompt + (let ((file (expand-file-name (or (car fs) "")))) + (setq file + (read-file-name (format "Use file %s: " file) + (file-name-directory file) file t + (file-name-nondirectory file))) + (set (make-local-variable 'diff-remembered-files-alist) + (cons (cons fs file) diff-remembered-files-alist)) + file))))))) (defun diff-ediff-patch () --=-=-=-- From unknown Sun Jun 22 07:51:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Aug 2017 00:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21262 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: charles@aurox.ch (Charles A. Roelli) Cc: 21262@debbugs.gnu.org, Dima Kogan Received: via spool by 21262-submit@debbugs.gnu.org id=B21262.150336103027450 (code B ref 21262); Tue, 22 Aug 2017 00:18:02 +0000 Received: (at 21262) by debbugs.gnu.org; 22 Aug 2017 00:17:10 +0000 Received: from localhost ([127.0.0.1]:48353 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djwsX-00078f-Lk for submit@debbugs.gnu.org; Mon, 21 Aug 2017 20:17:09 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:34553) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1djwsV-00078Q-MC for 21262@debbugs.gnu.org; Mon, 21 Aug 2017 20:17:08 -0400 Received: by mail-it0-f68.google.com with SMTP id s132so10782603ita.1 for <21262@debbugs.gnu.org>; Mon, 21 Aug 2017 17:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=8XHYMFgSBb5K63TLog6uJ63WdHaVfnLC/SK5IcPhVrs=; b=D7A1R3j3UsHu7zCYpAaFJzP0ubyKIcOtA0Rf6y8cbIT/dENpZCMvxuvQYE/PiwQqyb Ot64UkM7X4/zmarRmVVoe/HpjjdphQm1MN7lMm7AIUL5pX00lecrHvlZUsPdSJYTILuJ j1qA1KrhwlL01NdDcRkg6q/D30gGD7LP3DTqLRAbTFb0+arg8v6LzSyfou2JxM56jSad hkpHxJFq63PgwH5d5hY4dhSDYGdm1IlnzZEb70bBvsgkwT4QK4O9QNnzrHAKl85Ykwqv llYFiGGLBLvSX7hL6jUgj0GE7tn06kFg7G875hMcTawayJ+1C1NUvdqDlwzNSI1Ji4sx DByQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=8XHYMFgSBb5K63TLog6uJ63WdHaVfnLC/SK5IcPhVrs=; b=Mo8fPQY6SSPQw/lXTq2esJ0Pm2hikVYWZP2FqpQryCsjxRo6jeL0n7SHPYig/4F2wK DYkMFhG8ZJR3iG//S7eBu9G9dmy7AWUz/cy7XSiXMhi2jyKQaUiFL0HY+GmRLx4xNsOk 9owYxPGFHaB5N/1HpSu0W8KiNXKgLUGoIo7OWs0PblZ7vW8ovNU/XeAfw2gbD9BOvsKP 2fz7dxqIG9hW5+IibBY9Lw/VjgnCBzmqk/pfpQGvtrskIBU/m/0OoAwAZX0c9Sg0G8SR HEnc1qC7HRlcvuUwgPdlqn2Udgn5RIVjPOQW30Y4D/UYTEtvHjr0wsQwQSrt8/VBN4HJ QhRg== X-Gm-Message-State: AHYfb5h1I9l7h8aJHinJ68s3PSkb6w0mXZVCtPmks/qBz/YB3jOHqLh4 ACZzRhygKdKMg7bc X-Received: by 10.36.190.132 with SMTP id i126mr1757885itf.165.1503361022056; Mon, 21 Aug 2017 17:17:02 -0700 (PDT) Received: from zony ([45.2.119.49]) by smtp.googlemail.com with ESMTPSA id r186sm6228322iod.6.2017.08.21.17.17.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 Aug 2017 17:17:01 -0700 (PDT) From: npostavs@users.sourceforge.net References: <87lhdd5e52.fsf@secretsauce.net> Date: Mon, 21 Aug 2017 20:18:39 -0400 In-Reply-To: (Charles A. Roelli's message of "Mon, 21 Aug 2017 21:49:50 +0200") Message-ID: <87o9r8bgkg.fsf@users.sourceforge.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.7 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) charles@aurox.ch (Charles A. Roelli) writes: > This still affects 26.0.50. > > The attached change fixes it -- but I know nothing of diff-mode, so > better ideas are welcome. Note that the buffer will be widened while > Emacs asks where to look for the sources, but it will return to the > original narrowing after the user has selected a file or hit C-g. 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. From unknown Sun Jun 22 07:51:46 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found Resent-From: charles@aurox.ch (Charles A. Roelli) Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Aug 2017 14:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21262 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: npostavs@users.sourceforge.net Cc: 21262@debbugs.gnu.org, dima@secretsauce.net Received: via spool by 21262-submit@debbugs.gnu.org id=B21262.150341056425475 (code B ref 21262); Tue, 22 Aug 2017 14:03:01 +0000 Received: (at 21262) by debbugs.gnu.org; 22 Aug 2017 14:02:44 +0000 Received: from localhost ([127.0.0.1]:49648 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dk9lU-0006cp-A5 for submit@debbugs.gnu.org; Tue, 22 Aug 2017 10:02:44 -0400 Received: from sinyavsky.aurox.ch ([37.35.109.145]:39825) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dk9lS-0006ca-67 for 21262@debbugs.gnu.org; Tue, 22 Aug 2017 10:02:43 -0400 Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id AFAFE2250B for <21262@debbugs.gnu.org>; Tue, 22 Aug 2017 13:56:44 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= content-type:content-type:mime-version:references:subject :subject:in-reply-to:to:from:from:message-id:date:date; s=dkim; t=1503410202; x=1504274203; bh=0lMtStlkuvsCISArvttxQxd4gXpN4/b4 fKuHWajuh6s=; b=FdJdkr1V1YTpNlPk6vEL+cC+iRX6qn9huiRG1VYHB/mWfOvm hpTvslsnUN9fuMu5s8ZdDH9EQSx05kwX1193W9xEcifSlErfy79U3JcvVFjn9whF oN3S1jNSiSz7U+ToObkLwCm1J6By/r27Hb2BStFP9I7VnC+2AB6hE3arJS4= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id i0pYIkmmcQdv for <21262@debbugs.gnu.org>; Tue, 22 Aug 2017 13:56:42 +0000 (UTC) Received: from gray (125.85.192.178.dynamic.wline.res.cust.swisscom.ch [178.192.85.125]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id B692A224F8; Tue, 22 Aug 2017 13:56:40 +0000 (UTC) Date: Tue, 22 Aug 2017 16:02:17 +0200 Message-Id: From: charles@aurox.ch (Charles A. Roelli) In-reply-to: <87o9r8bgkg.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) References: <87lhdd5e52.fsf@secretsauce.net> <87o9r8bgkg.fsf@users.sourceforge.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) --=-=-= Content-Type: text/plain > From: npostavs@users.sourceforge.net > Cc: Dima Kogan , 21262@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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-diff-goto-source-when-buffer-is-narrowed-Bug-212.patch >From aac6f9eb7aba0cc6b67b56a748e8ee25f755e8f5 Mon Sep 17 00:00:00 2001 From: "Charles A. Roelli" Date: Tue, 22 Aug 2017 15:57:01 +0200 Subject: [PATCH] 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. --- lisp/vc/diff-mode.el | 92 +++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 45 deletions(-) diff --git a/lisp/vc/diff-mode.el b/lisp/vc/diff-mode.el index aa8d778..1d4af54 100644 --- a/lisp/vc/diff-mode.el +++ b/lisp/vc/diff-mode.el @@ -875,51 +875,53 @@ diff-find-file-name (set (make-local-variable 'diff-remembered-defdir) default-directory) (set (make-local-variable 'diff-remembered-files-alist) nil)) (save-excursion - (unless (looking-at diff-file-header-re) - (or (ignore-errors (diff-beginning-of-file)) - (re-search-forward diff-file-header-re nil t))) - (let ((fs (diff-hunk-file-names old))) - (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs))) - (or - ;; use any previously used preference - (cdr (assoc fs diff-remembered-files-alist)) - ;; try to be clever and use previous choices as an inspiration - (cl-dolist (rf diff-remembered-files-alist) - (let ((newfile (diff-merge-strings (caar rf) (car fs) (cdr rf)))) - (if (and newfile (file-exists-p newfile)) (cl-return newfile)))) - ;; look for each file in turn. If none found, try again but - ;; ignoring the first level of directory, ... - (cl-do* ((files fs (delq nil (mapcar 'diff-filename-drop-dir files))) - (file nil nil)) - ((or (null files) - (setq file (cl-do* ((files files (cdr files)) - (file (car files) (car files))) - ;; Use file-regular-p to avoid - ;; /dev/null, directories, etc. - ((or (null file) (file-regular-p file)) - file)))) - file)) - ;; .rej patches implicitly apply to - (and (string-match "\\.rej\\'" (or buffer-file-name "")) - (let ((file (substring buffer-file-name 0 (match-beginning 0)))) - (when (file-exists-p file) file))) - ;; If we haven't found the file, maybe it's because we haven't paid - ;; attention to the PCL-CVS hint. - (and (not prefix) - (boundp 'cvs-pcl-cvs-dirchange-re) - (save-excursion - (re-search-backward cvs-pcl-cvs-dirchange-re nil t)) - (diff-find-file-name old noprompt (match-string 1))) - ;; if all else fails, ask the user - (unless noprompt - (let ((file (expand-file-name (or (car fs) "")))) - (setq file - (read-file-name (format "Use file %s: " file) - (file-name-directory file) file t - (file-name-nondirectory file))) - (set (make-local-variable 'diff-remembered-files-alist) - (cons (cons fs file) diff-remembered-files-alist)) - file)))))) + (save-restriction + (widen) + (unless (looking-at diff-file-header-re) + (or (ignore-errors (diff-beginning-of-file)) + (re-search-forward diff-file-header-re nil t))) + (let ((fs (diff-hunk-file-names old))) + (if prefix (setq fs (mapcar (lambda (f) (concat prefix f)) fs))) + (or + ;; use any previously used preference + (cdr (assoc fs diff-remembered-files-alist)) + ;; try to be clever and use previous choices as an inspiration + (cl-dolist (rf diff-remembered-files-alist) + (let ((newfile (diff-merge-strings (caar rf) (car fs) (cdr rf)))) + (if (and newfile (file-exists-p newfile)) (cl-return newfile)))) + ;; look for each file in turn. If none found, try again but + ;; ignoring the first level of directory, ... + (cl-do* ((files fs (delq nil (mapcar 'diff-filename-drop-dir files))) + (file nil nil)) + ((or (null files) + (setq file (cl-do* ((files files (cdr files)) + (file (car files) (car files))) + ;; Use file-regular-p to avoid + ;; /dev/null, directories, etc. + ((or (null file) (file-regular-p file)) + file)))) + file)) + ;; .rej patches implicitly apply to + (and (string-match "\\.rej\\'" (or buffer-file-name "")) + (let ((file (substring buffer-file-name 0 (match-beginning 0)))) + (when (file-exists-p file) file))) + ;; If we haven't found the file, maybe it's because we haven't paid + ;; attention to the PCL-CVS hint. + (and (not prefix) + (boundp 'cvs-pcl-cvs-dirchange-re) + (save-excursion + (re-search-backward cvs-pcl-cvs-dirchange-re nil t)) + (diff-find-file-name old noprompt (match-string 1))) + ;; if all else fails, ask the user + (unless noprompt + (let ((file (expand-file-name (or (car fs) "")))) + (setq file + (read-file-name (format "Use file %s: " file) + (file-name-directory file) file t + (file-name-nondirectory file))) + (set (make-local-variable 'diff-remembered-files-alist) + (cons (cons fs file) diff-remembered-files-alist)) + file))))))) (defun diff-ediff-patch () -- 2.9.4 --=-=-=-- From unknown Sun Jun 22 07:51:46 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Dima Kogan Subject: bug#21262: closed (Re: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found) Message-ID: References: <87lhdd5e52.fsf@secretsauce.net> X-Gnu-PR-Message: they-closed 21262 X-Gnu-PR-Package: emacs Reply-To: 21262@debbugs.gnu.org Date: Sun, 27 Aug 2017 12:22:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1503836522-17014-1" This is a multi-part message in MIME format... ------------=_1503836522-17014-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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@debbugs.gnu.org. --=20 21262: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21262 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1503836522-17014-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 21262-done) by debbugs.gnu.org; 27 Aug 2017 12:21:31 +0000 Received: from localhost ([127.0.0.1]:57117 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlwZG-0004Pf-OZ for submit@debbugs.gnu.org; Sun, 27 Aug 2017 08:21:30 -0400 Received: from sinyavsky.aurox.ch ([37.35.109.145]:44295) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dlwZF-0004PR-D0 for 21262-done@debbugs.gnu.org; Sun, 27 Aug 2017 08:21:29 -0400 Received: from sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) by sinyavsky.aurox.ch (Postfix) with ESMTP id DB60E2250C for <21262-done@debbugs.gnu.org>; Sun, 27 Aug 2017 12:15:28 +0000 (UTC) Authentication-Results: sinyavsky.aurox.ch (amavisd-new); dkim=pass (1024-bit key) reason="pass (just generated, assumed good)" header.d=aurox.ch DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aurox.ch; h= references:subject:subject:in-reply-to:to:from:from:message-id :date:date; s=dkim; t=1503836124; x=1504700125; bh=o+fIxC8GKkm4b UswxicdYfMNoHRGLbXwDMByMgmiFVI=; b=s3lVjdyRh/w09BFiU/Dp8UhtYMalm /RsbM3FjOvx2NO3UUAZf3yKlkM4wpZFGQ0HZCHcFE3MNZxpgccBjfpwxB+eFa1m+ nl2PyFwEq++vrdL//hcK1ABqfotK6OqpROXyUrSUgISxllT4BVafxDQ9UE5TPFgZ i8VRHeFMhX28fU= X-Virus-Scanned: Debian amavisd-new at test.virtualizor.com Received: from sinyavsky.aurox.ch ([127.0.0.1]) by sinyavsky.aurox.ch (sinyavsky.aurox.ch [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id X_IEdsUvBVCG for <21262-done@debbugs.gnu.org>; Sun, 27 Aug 2017 12:15:24 +0000 (UTC) Received: from gray (125.85.192.178.dynamic.wline.res.cust.swisscom.ch [178.192.85.125]) by sinyavsky.aurox.ch (Postfix) with ESMTPSA id 82EE422502; Sun, 27 Aug 2017 12:15:24 +0000 (UTC) Date: Sun, 27 Aug 2017 14:21:05 +0200 Message-Id: From: charles@aurox.ch (Charles A. Roelli) To: npostavs@users.sourceforge.net In-reply-to: (charles@aurox.ch) Subject: Re: bug#21262: 25.0.50; Diff-mode gets confused about its narrowing if hunk source not found References: <87lhdd5e52.fsf@secretsauce.net> <87o9r8bgkg.fsf@users.sourceforge.net> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 21262-done Cc: 21262-done@debbugs.gnu.org, dima@secretsauce.net X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.3 (--) > Date: Tue, 22 Aug 2017 16:02:17 +0200 > From: charles@aurox.ch (Charles A. Roelli) > > > From: npostavs@users.sourceforge.net > > Cc: Dima Kogan , 21262@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. ------------=_1503836522-17014-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Aug 2015 06:01:40 +0000 Received: from localhost ([127.0.0.1]:56181 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZQUXE-0004F4-4s for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:40 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36755) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZQUXB-0004Ew-PQ for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQUXA-0002N0-HK for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:37 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:56121) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQUXA-0002Mw-FU for submit@debbugs.gnu.org; Sat, 15 Aug 2015 02:01:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46760) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQUX9-00063z-JR for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2015 02:01:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZQUX3-0002Ip-LH for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2015 02:01:35 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:51126) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZQUX3-0002Hw-Ch for bug-gnu-emacs@gnu.org; Sat, 15 Aug 2015 02:01:29 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 8BD02209E8 for ; Sat, 15 Aug 2015 02:01:27 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Sat, 15 Aug 2015 02:01:27 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=secretsauce.net; h=content-type:date:from:message-id:mime-version:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=fzTCVWV56dqkRdsy2u4c2p/BF3c =; b=FbaKyVQrHeYcFzH0MT9sbqO9+th2dnhJkkrVaQvEPcBzDrjl+sDIP0iAVZN Xl4JRShHyvqkGdujwyihSe4CD/cmPsH2tZc0eOWtmvmQV+Wtu38ElhGLO36XITmC Kn653KuDKXREXPykdIeMyA3pxh35mrm/UpKr9o0dsyDM2e8k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:message-id :mime-version:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=fz TCVWV56dqkRdsy2u4c2p/BF3c=; b=n9OT+Yw1dDlMG+Hf3bnyP4qRd6fhlYUN4u A6k8m4uZs+dgwgfX1y/EETO5zO41fA5gLoqimfwWclfbxtFtBJ9AboMZ3SYDVmRv /sWJ6KDKgFBuu87HL1nUvSirneT9POnTbIhvsucjUS8Kw2OFewrhKVKO/Sj+g90o N2Kd9sVoU= X-Sasl-enc: WrzzYaART5+RsP5mFFn5Hhx3Ue0AdNaR9OmdVDV6Ls62 1439618487 Received: from shorty.local (50-1-153-216.dsl.dynamic.fusionbroadband.com [50.1.153.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 45DBDC00018 for ; Sat, 15 Aug 2015 02:01:27 -0400 (EDT) Received: from [::1] (helo=shorty) by shorty.local with esmtp (Exim 4.84) (envelope-from ) id 1ZQTlT-00017t-VL for bug-gnu-emacs@gnu.org; Fri, 14 Aug 2015 22:12:20 -0700 From: Dima Kogan To: bug-gnu-emacs@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-ID: <87lhdd5e52.fsf@secretsauce.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=tst2.diff 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); } --=-=-=-- ------------=_1503836522-17014-1--