* diff mode weirdness
@ 2008-09-12 7:47 joakim
2008-09-12 14:37 ` Stefan Monnier
` (2 more replies)
0 siblings, 3 replies; 12+ messages in thread
From: joakim @ 2008-09-12 7:47 UTC (permalink / raw
To: Emacs Development
I wanted to look at a diff file, and it opened nicely in diff mode, with
font-lock etc. Then I had some issues:
- diff mode repeatedly asks me where the diff source is. In this case I
only had the diff, not the source. This was very annoying.
- after a while the diff buffer was automatically killed, to my
surprise.
Do others experience the same problems? If so I can find out more
information.
--
Joakim Verona
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 7:47 diff mode weirdness joakim
@ 2008-09-12 14:37 ` Stefan Monnier
2008-09-12 15:46 ` joakim
2008-09-12 20:15 ` Peter Lee
2008-09-13 3:11 ` Tetsurou Okazaki
2 siblings, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2008-09-12 14:37 UTC (permalink / raw
To: joakim; +Cc: Emacs Development
> I wanted to look at a diff file, and it opened nicely in diff mode, with
> font-lock etc. Then I had some issues:
> - diff mode repeatedly asks me where the diff source is. In this case I
> only had the diff, not the source. This was very annoying.
When does it do that? Normally, it only does that if you request an
operation like "apply" or "jump to source".
> - after a while the diff buffer was automatically killed, to my
> surprise.
> Do others experience the same problems? If so I can find out more
> information.
Never heard of this, no.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 14:37 ` Stefan Monnier
@ 2008-09-12 15:46 ` joakim
2008-09-12 17:11 ` Stefan Monnier
0 siblings, 1 reply; 12+ messages in thread
From: joakim @ 2008-09-12 15:46 UTC (permalink / raw
To: Stefan Monnier; +Cc: Emacs Development
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> I wanted to look at a diff file, and it opened nicely in diff mode, with
>> font-lock etc. Then I had some issues:
>
>> - diff mode repeatedly asks me where the diff source is. In this case I
>> only had the diff, not the source. This was very annoying.
>
> When does it do that? Normally, it only does that if you request an
> operation like "apply" or "jump to source".
It happens for me whenever the cursor is on a "diff" line, the first
line of a unified diff file for instance.
>> - after a while the diff buffer was automatically killed, to my
>> surprise.
>
>> Do others experience the same problems? If so I can find out more
>> information.
>
> Never heard of this, no.
Ok, I'll see if I can reproduce it with emacs -q then.
>
> Stefan
--
Joakim Verona
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 15:46 ` joakim
@ 2008-09-12 17:11 ` Stefan Monnier
0 siblings, 0 replies; 12+ messages in thread
From: Stefan Monnier @ 2008-09-12 17:11 UTC (permalink / raw
To: joakim; +Cc: Emacs Development
>>> I wanted to look at a diff file, and it opened nicely in diff mode, with
>>> font-lock etc. Then I had some issues:
>>
>>> - diff mode repeatedly asks me where the diff source is. In this case I
>>> only had the diff, not the source. This was very annoying.
>>
>> When does it do that? Normally, it only does that if you request an
>> operation like "apply" or "jump to source".
> It happens for me whenever the cursor is on a "diff" line, the first
> line of a unified diff file for instance.
Can you provide a recipe starting from "emacs -Q". It really sounds odd.
Stefan
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 7:47 diff mode weirdness joakim
2008-09-12 14:37 ` Stefan Monnier
@ 2008-09-12 20:15 ` Peter Lee
2008-09-12 20:50 ` joakim
2008-09-13 1:53 ` Stefan Monnier
2008-09-13 3:11 ` Tetsurou Okazaki
2 siblings, 2 replies; 12+ messages in thread
From: Peter Lee @ 2008-09-12 20:15 UTC (permalink / raw
To: emacs-devel
>>>> joakim writes:
joakim> I wanted to look at a diff file, and it opened nicely in diff mode, with
joakim> font-lock etc. Then I had some issues:
joakim> - diff mode repeatedly asks me where the diff source is. In this case I
joakim> only had the diff, not the source. This was very annoying.
joakim> - after a while the diff buffer was automatically killed, to my
joakim> surprise.
joakim> Do others experience the same problems? If so I can find out more
joakim> information.
I've seen this as well... I have to C-g several times and quickly "move
off" the header line.
It doesn't happen when I use diff for code under cvs. However, a
standalone .diff file in a directory where the file "test" doesn't exist
will happen everytime.
>>> snip
Index: test
===================================================================
RCS file: /home/cvsroot.2/testmod/test,v
retrieving revision 1.1956.2.122.4.437.4.228
retrieving revision 1.1956.2.122.4.437.4.229
diff -u -r1.1956.2.122.4.437.4.228 -r1.1956.2.122.4.437.4.229
--- Version 12 Sep 2008 00:59:19 -0000 1.1956.2.122.4.437.4.228
+++ Version 12 Sep 2008 14:59:22 -0000 1.1956.2.122.4.437.4.229
@@ -1,4 +1,4 @@
-xx_build="206"
+xx_build="207"
xx_version="1.1.1"
xx_branch=""
# zzzz
<<< snip
copy between the snips and save as /tmp/test.diff
Then open the file...
The modeline will continuously prompt for:
Use file Version: /tmp/test
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 20:15 ` Peter Lee
@ 2008-09-12 20:50 ` joakim
2008-09-12 21:02 ` Glenn Morris
2008-09-13 1:53 ` Stefan Monnier
1 sibling, 1 reply; 12+ messages in thread
From: joakim @ 2008-09-12 20:50 UTC (permalink / raw
To: Peter Lee; +Cc: emacs-devel
Peter Lee <pete.a.lee@gmail.com> writes:
>>>>> joakim writes:
>
> joakim> I wanted to look at a diff file, and it opened nicely in diff mode, with
> joakim> font-lock etc. Then I had some issues:
>
> joakim> - diff mode repeatedly asks me where the diff source is. In this case I
> joakim> only had the diff, not the source. This was very annoying.
> joakim> - after a while the diff buffer was automatically killed, to my
> joakim> surprise.
>
> joakim> Do others experience the same problems? If so I can find out more
> joakim> information.
>
> I've seen this as well... I have to C-g several times and quickly "move
> off" the header line.
>
> It doesn't happen when I use diff for code under cvs. However, a
> standalone .diff file in a directory where the file "test" doesn't exist
> will happen everytime.
Yes this is exactly what I am seeing as well. However, I dont get this
behaviour with emacs -Q. I havent managed to diagnose it further.
>
>>>> snip
> Index: test
> ===================================================================
> RCS file: /home/cvsroot.2/testmod/test,v
> retrieving revision 1.1956.2.122.4.437.4.228
> retrieving revision 1.1956.2.122.4.437.4.229
> diff -u -r1.1956.2.122.4.437.4.228 -r1.1956.2.122.4.437.4.229
> --- Version 12 Sep 2008 00:59:19 -0000 1.1956.2.122.4.437.4.228
> +++ Version 12 Sep 2008 14:59:22 -0000 1.1956.2.122.4.437.4.229
> @@ -1,4 +1,4 @@
> -xx_build="206"
> +xx_build="207"
> xx_version="1.1.1"
> xx_branch=""
> # zzzz
> <<< snip
>
> copy between the snips and save as /tmp/test.diff
>
> Then open the file...
>
> The modeline will continuously prompt for:
> Use file Version: /tmp/test
>
>
>
--
Joakim Verona
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 20:50 ` joakim
@ 2008-09-12 21:02 ` Glenn Morris
2008-09-12 21:24 ` joakim
0 siblings, 1 reply; 12+ messages in thread
From: Glenn Morris @ 2008-09-12 21:02 UTC (permalink / raw
To: joakim; +Cc: Peter Lee, emacs-devel
joakim@verona.se wrote:
> Yes this is exactly what I am seeing as well. However, I dont get this
> behaviour with emacs -Q. I havent managed to diagnose it further.
which-func-mode?
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 21:02 ` Glenn Morris
@ 2008-09-12 21:24 ` joakim
0 siblings, 0 replies; 12+ messages in thread
From: joakim @ 2008-09-12 21:24 UTC (permalink / raw
To: Glenn Morris; +Cc: Peter Lee, emacs-devel
Glenn Morris <rgm@gnu.org> writes:
> joakim@verona.se wrote:
>
>> Yes this is exactly what I am seeing as well. However, I dont get this
>> behaviour with emacs -Q. I havent managed to diagnose it further.
>
> which-func-mode?
Yes, if I dissable which-func-mode in my normal emacs, the problem goes
away!
--
Joakim Verona
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 20:15 ` Peter Lee
2008-09-12 20:50 ` joakim
@ 2008-09-13 1:53 ` Stefan Monnier
2008-09-14 21:01 ` joakim
1 sibling, 1 reply; 12+ messages in thread
From: Stefan Monnier @ 2008-09-13 1:53 UTC (permalink / raw
To: Peter Lee; +Cc: emacs-devel
> copy between the snips and save as /tmp/test.diff
> Then open the file...
> The modeline will continuously prompt for:
> Use file Version: /tmp/test
Does the patch below fix the problem for you?
Stefan
--- diff-mode.el.~1.150.~ 2008-08-13 17:49:14.000000000 -0400
+++ diff-mode.el 2008-09-12 21:52:53.000000000 -0400
@@ -723,7 +723,7 @@
(fs (diff-hunk-file-names current-prefix-arg)))
(unless fs (error "No file name to look for"))
(list old (read-file-name (format "File for %s: " (car fs))
- nil (diff-find-file-name old) t))))
+ nil (diff-find-file-name old 'noprompt) t))))
(let ((fs (diff-hunk-file-names old)))
(unless fs (error "No file name to look for"))
(push (cons fs name) diff-remembered-files-alist)))
@@ -756,11 +756,10 @@
(list (if old (match-string 2) (match-string 4))
(if old (match-string 4) (match-string 2)))))))))
-(defun diff-find-file-name (&optional old batch prefix)
+(defun diff-find-file-name (&optional old noprompt prefix)
"Return the file corresponding to the current patch.
Non-nil OLD means that we want the old file.
-Non-nil BATCH means to prefer returning an incorrect answer than to prompt
-the user.
+Non-nil NOPROMPT means to prefer returning nil than to prompt the user.
PREFIX is only used internally: don't use it."
(unless (equal diff-remembered-defdir default-directory)
;; Flush diff-remembered-files-alist if the default-directory is changed.
@@ -801,16 +800,15 @@
(boundp 'cvs-pcl-cvs-dirchange-re)
(save-excursion
(re-search-backward cvs-pcl-cvs-dirchange-re nil t))
- (diff-find-file-name old batch (match-string 1)))
- ;; Invent something, if necessary.
- (when batch
- (or (car fs) default-directory))
+ (diff-find-file-name old noprompt (match-string 1)))
;; if all else fails, ask the user
- (let ((file (read-file-name (format "Use file %s: " (or (first fs) ""))
+ (unless noprompt
+ (let ((file (read-file-name (format "Use file %s: "
+ (or (first fs) ""))
nil (first fs) t (first fs))))
(set (make-local-variable 'diff-remembered-files-alist)
(cons (cons fs file) diff-remembered-files-alist))
- file)))))
+ file))))))
(defun diff-ediff-patch ()
@@ -1286,7 +1284,7 @@
(set (make-local-variable 'add-log-current-defun-function)
'diff-current-defun)
(set (make-local-variable 'add-log-buffer-file-name-function)
- 'diff-find-file-name))
+ (lambda () (diff-find-file-name nil 'noprompt))))
;;;###autoload
(define-minor-mode diff-minor-mode
@@ -1547,7 +1545,7 @@
(defsubst diff-xor (a b) (if a (if (not b) a) b))
-(defun diff-find-source-location (&optional other-file reverse)
+(defun diff-find-source-location (&optional other-file reverse noprompt)
"Find out (BUF LINE-OFFSET POS SRC DST SWITCHED).
BUF is the buffer corresponding to the source file.
LINE-OFFSET is the offset between the expected and actual positions
@@ -1555,7 +1553,8 @@
POS is a pair (BEG . END) indicating the position of the text in the buffer.
SRC and DST are the two variants of text as returned by `diff-hunk-text'.
SRC is the variant that was found in the buffer.
-SWITCHED is non-nil if the patch is already applied."
+SWITCHED is non-nil if the patch is already applied.
+NOPROMPT, if non-nil, means not to prompt the user."
(save-excursion
(let* ((other (diff-xor other-file diff-jump-to-old-file))
(char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder)
@@ -1565,8 +1564,8 @@
;; (e.g. because an empty line truncates the hunk mid-course),
;; leading to potentially nasty surprises for the user.
(_ (diff-sanity-check-hunk))
- (hunk (buffer-substring (point)
- (save-excursion (diff-end-of-hunk) (point))))
+ (hunk (buffer-substring
+ (point) (save-excursion (diff-end-of-hunk) (point))))
(old (diff-hunk-text hunk reverse char-offset))
(new (diff-hunk-text hunk (not reverse) char-offset))
;; Find the location specification.
@@ -1578,7 +1577,8 @@
diff-context-mid-hunk-header-re nil t)
(error "Can't find the hunk separator"))
(match-string 1)))))
- (file (or (diff-find-file-name other) (error "Can't find the file")))
+ (file (or (diff-find-file-name other noprompt)
+ (error "Can't find the file")))
(buf (find-file-noselect file)))
;; Update the user preference if he so wished.
(when (> (prefix-numeric-value other-file) 8)
@@ -1718,14 +1718,18 @@
(when (looking-at diff-hunk-header-re)
(forward-line 1)
(re-search-forward "^[^ ]" nil t))
- (destructuring-bind (buf line-offset pos src dst &optional switched)
- (diff-find-source-location)
+ (destructuring-bind (&optional buf line-offset pos src dst switched)
+ ;; Use `noprompt' since this is used in which-func-mode and such.
+ (ignore-errors ;Signals errors in place of prompting.
+ (diff-find-source-location nil nil 'noprompt))
+ (when buf
(beginning-of-line)
(or (when (memq (char-after) '(?< ?-))
;; Cursor is pointing at removed text. This could be a removed
;; function, in which case, going to the source buffer will
;; not help since the function is now removed. Instead,
- ;; try to figure out the function name just from the code-fragment.
+ ;; try to figure out the function name just from the
+ ;; code-fragment.
(let ((old (if switched dst src)))
(with-temp-buffer
(insert (car old))
@@ -1734,7 +1738,7 @@
(add-log-current-defun))))
(with-current-buffer buf
(goto-char (+ (car pos) (cdr src)))
- (add-log-current-defun))))))
+ (add-log-current-defun)))))))
(defun diff-ignore-whitespace-hunk ()
"Re-diff the current hunk, ignoring whitespace differences."
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-12 7:47 diff mode weirdness joakim
2008-09-12 14:37 ` Stefan Monnier
2008-09-12 20:15 ` Peter Lee
@ 2008-09-13 3:11 ` Tetsurou Okazaki
2 siblings, 0 replies; 12+ messages in thread
From: Tetsurou Okazaki @ 2008-09-13 3:11 UTC (permalink / raw
To: joakim; +Cc: Emacs Development
At Fri, 12 Sep 2008 09:47:25 +0200,
joakim@verona.se wrote:
>
> I wanted to look at a diff file, and it opened nicely in diff mode, with
> font-lock etc. Then I had some issues:
>
> - diff mode repeatedly asks me where the diff source is. In this case I
> only had the diff, not the source. This was very annoying.
>
> - after a while the diff buffer was automatically killed, to my
> surprise.
Do you use CEDET?
Developement versions of CEDET around June or July had such a bug.
http://sourceforge.net/mailarchive/forum.php?thread_name=g4kc76%2425t%241%40ger.gmane.org&forum_name=cedet-devel
--
Tetsurou Okazaki
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-13 1:53 ` Stefan Monnier
@ 2008-09-14 21:01 ` joakim
2008-09-14 21:13 ` Pete Lee
0 siblings, 1 reply; 12+ messages in thread
From: joakim @ 2008-09-14 21:01 UTC (permalink / raw
To: Stefan Monnier; +Cc: Peter Lee, emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> copy between the snips and save as /tmp/test.diff
>
>> Then open the file...
>
>> The modeline will continuously prompt for:
>> Use file Version: /tmp/test
>
> Does the patch below fix the problem for you?
Yes this patch appears to work!
Thanks!
>
>
> Stefan
>
>
> --- diff-mode.el.~1.150.~ 2008-08-13 17:49:14.000000000 -0400
> +++ diff-mode.el 2008-09-12 21:52:53.000000000 -0400
> @@ -723,7 +723,7 @@
> (fs (diff-hunk-file-names current-prefix-arg)))
> (unless fs (error "No file name to look for"))
> (list old (read-file-name (format "File for %s: " (car fs))
> - nil (diff-find-file-name old) t))))
> + nil (diff-find-file-name old 'noprompt) t))))
> (let ((fs (diff-hunk-file-names old)))
> (unless fs (error "No file name to look for"))
> (push (cons fs name) diff-remembered-files-alist)))
> @@ -756,11 +756,10 @@
> (list (if old (match-string 2) (match-string 4))
> (if old (match-string 4) (match-string 2)))))))))
>
> -(defun diff-find-file-name (&optional old batch prefix)
> +(defun diff-find-file-name (&optional old noprompt prefix)
> "Return the file corresponding to the current patch.
> Non-nil OLD means that we want the old file.
> -Non-nil BATCH means to prefer returning an incorrect answer than to prompt
> -the user.
> +Non-nil NOPROMPT means to prefer returning nil than to prompt the user.
> PREFIX is only used internally: don't use it."
> (unless (equal diff-remembered-defdir default-directory)
> ;; Flush diff-remembered-files-alist if the default-directory is changed.
> @@ -801,16 +800,15 @@
> (boundp 'cvs-pcl-cvs-dirchange-re)
> (save-excursion
> (re-search-backward cvs-pcl-cvs-dirchange-re nil t))
> - (diff-find-file-name old batch (match-string 1)))
> - ;; Invent something, if necessary.
> - (when batch
> - (or (car fs) default-directory))
> + (diff-find-file-name old noprompt (match-string 1)))
> ;; if all else fails, ask the user
> - (let ((file (read-file-name (format "Use file %s: " (or (first fs) ""))
> + (unless noprompt
> + (let ((file (read-file-name (format "Use file %s: "
> + (or (first fs) ""))
> nil (first fs) t (first fs))))
> (set (make-local-variable 'diff-remembered-files-alist)
> (cons (cons fs file) diff-remembered-files-alist))
> - file)))))
> + file))))))
>
>
> (defun diff-ediff-patch ()
> @@ -1286,7 +1284,7 @@
> (set (make-local-variable 'add-log-current-defun-function)
> 'diff-current-defun)
> (set (make-local-variable 'add-log-buffer-file-name-function)
> - 'diff-find-file-name))
> + (lambda () (diff-find-file-name nil 'noprompt))))
>
> ;;;###autoload
> (define-minor-mode diff-minor-mode
> @@ -1547,7 +1545,7 @@
>
> (defsubst diff-xor (a b) (if a (if (not b) a) b))
>
> -(defun diff-find-source-location (&optional other-file reverse)
> +(defun diff-find-source-location (&optional other-file reverse noprompt)
> "Find out (BUF LINE-OFFSET POS SRC DST SWITCHED).
> BUF is the buffer corresponding to the source file.
> LINE-OFFSET is the offset between the expected and actual positions
> @@ -1555,7 +1553,8 @@
> POS is a pair (BEG . END) indicating the position of the text in the buffer.
> SRC and DST are the two variants of text as returned by `diff-hunk-text'.
> SRC is the variant that was found in the buffer.
> -SWITCHED is non-nil if the patch is already applied."
> +SWITCHED is non-nil if the patch is already applied.
> +NOPROMPT, if non-nil, means not to prompt the user."
> (save-excursion
> (let* ((other (diff-xor other-file diff-jump-to-old-file))
> (char-offset (- (point) (progn (diff-beginning-of-hunk 'try-harder)
> @@ -1565,8 +1564,8 @@
> ;; (e.g. because an empty line truncates the hunk mid-course),
> ;; leading to potentially nasty surprises for the user.
> (_ (diff-sanity-check-hunk))
> - (hunk (buffer-substring (point)
> - (save-excursion (diff-end-of-hunk) (point))))
> + (hunk (buffer-substring
> + (point) (save-excursion (diff-end-of-hunk) (point))))
> (old (diff-hunk-text hunk reverse char-offset))
> (new (diff-hunk-text hunk (not reverse) char-offset))
> ;; Find the location specification.
> @@ -1578,7 +1577,8 @@
> diff-context-mid-hunk-header-re nil t)
> (error "Can't find the hunk separator"))
> (match-string 1)))))
> - (file (or (diff-find-file-name other) (error "Can't find the file")))
> + (file (or (diff-find-file-name other noprompt)
> + (error "Can't find the file")))
> (buf (find-file-noselect file)))
> ;; Update the user preference if he so wished.
> (when (> (prefix-numeric-value other-file) 8)
> @@ -1718,14 +1718,18 @@
> (when (looking-at diff-hunk-header-re)
> (forward-line 1)
> (re-search-forward "^[^ ]" nil t))
> - (destructuring-bind (buf line-offset pos src dst &optional switched)
> - (diff-find-source-location)
> + (destructuring-bind (&optional buf line-offset pos src dst switched)
> + ;; Use `noprompt' since this is used in which-func-mode and such.
> + (ignore-errors ;Signals errors in place of prompting.
> + (diff-find-source-location nil nil 'noprompt))
> + (when buf
> (beginning-of-line)
> (or (when (memq (char-after) '(?< ?-))
> ;; Cursor is pointing at removed text. This could be a removed
> ;; function, in which case, going to the source buffer will
> ;; not help since the function is now removed. Instead,
> - ;; try to figure out the function name just from the code-fragment.
> + ;; try to figure out the function name just from the
> + ;; code-fragment.
> (let ((old (if switched dst src)))
> (with-temp-buffer
> (insert (car old))
> @@ -1734,7 +1738,7 @@
> (add-log-current-defun))))
> (with-current-buffer buf
> (goto-char (+ (car pos) (cdr src)))
> - (add-log-current-defun))))))
> + (add-log-current-defun)))))))
>
> (defun diff-ignore-whitespace-hunk ()
> "Re-diff the current hunk, ignoring whitespace differences."
>
--
Joakim Verona
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: diff mode weirdness
2008-09-14 21:01 ` joakim
@ 2008-09-14 21:13 ` Pete Lee
0 siblings, 0 replies; 12+ messages in thread
From: Pete Lee @ 2008-09-14 21:13 UTC (permalink / raw
To: joakim; +Cc: Stefan Monnier, emacs-devel
[-- Attachment #1: Type: text/plain, Size: 7099 bytes --]
Worked for me as well... Thanks.
On Sun, Sep 14, 2008 at 4:01 PM, <joakim@verona.se> wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
> >> copy between the snips and save as /tmp/test.diff
> >
> >> Then open the file...
> >
> >> The modeline will continuously prompt for:
> >> Use file Version: /tmp/test
> >
> > Does the patch below fix the problem for you?
>
> Yes this patch appears to work!
> Thanks!
>
> >
> >
> > Stefan
> >
> >
> > --- diff-mode.el.~1.150.~ 2008-08-13 17:49:14.000000000 -0400
> > +++ diff-mode.el 2008-09-12 21:52:53.000000000 -0400
> > @@ -723,7 +723,7 @@
> > (fs (diff-hunk-file-names current-prefix-arg)))
> > (unless fs (error "No file name to look for"))
> > (list old (read-file-name (format "File for %s: " (car fs))
> > - nil (diff-find-file-name old) t))))
> > + nil (diff-find-file-name old 'noprompt)
> t))))
> > (let ((fs (diff-hunk-file-names old)))
> > (unless fs (error "No file name to look for"))
> > (push (cons fs name) diff-remembered-files-alist)))
> > @@ -756,11 +756,10 @@
> > (list (if old (match-string 2) (match-string 4))
> > (if old (match-string 4) (match-string 2)))))))))
> >
> > -(defun diff-find-file-name (&optional old batch prefix)
> > +(defun diff-find-file-name (&optional old noprompt prefix)
> > "Return the file corresponding to the current patch.
> > Non-nil OLD means that we want the old file.
> > -Non-nil BATCH means to prefer returning an incorrect answer than to
> prompt
> > -the user.
> > +Non-nil NOPROMPT means to prefer returning nil than to prompt the user.
> > PREFIX is only used internally: don't use it."
> > (unless (equal diff-remembered-defdir default-directory)
> > ;; Flush diff-remembered-files-alist if the default-directory is
> changed.
> > @@ -801,16 +800,15 @@
> > (boundp 'cvs-pcl-cvs-dirchange-re)
> > (save-excursion
> > (re-search-backward cvs-pcl-cvs-dirchange-re nil t))
> > - (diff-find-file-name old batch (match-string 1)))
> > - ;; Invent something, if necessary.
> > - (when batch
> > - (or (car fs) default-directory))
> > + (diff-find-file-name old noprompt (match-string 1)))
> > ;; if all else fails, ask the user
> > - (let ((file (read-file-name (format "Use file %s: " (or (first
> fs) ""))
> > + (unless noprompt
> > + (let ((file (read-file-name (format "Use file %s: "
> > + (or (first fs) ""))
> > nil (first fs) t (first fs))))
> > (set (make-local-variable 'diff-remembered-files-alist)
> > (cons (cons fs file) diff-remembered-files-alist))
> > - file)))))
> > + file))))))
> >
> >
> > (defun diff-ediff-patch ()
> > @@ -1286,7 +1284,7 @@
> > (set (make-local-variable 'add-log-current-defun-function)
> > 'diff-current-defun)
> > (set (make-local-variable 'add-log-buffer-file-name-function)
> > - 'diff-find-file-name))
> > + (lambda () (diff-find-file-name nil 'noprompt))))
> >
> > ;;;###autoload
> > (define-minor-mode diff-minor-mode
> > @@ -1547,7 +1545,7 @@
> >
> > (defsubst diff-xor (a b) (if a (if (not b) a) b))
> >
> > -(defun diff-find-source-location (&optional other-file reverse)
> > +(defun diff-find-source-location (&optional other-file reverse noprompt)
> > "Find out (BUF LINE-OFFSET POS SRC DST SWITCHED).
> > BUF is the buffer corresponding to the source file.
> > LINE-OFFSET is the offset between the expected and actual positions
> > @@ -1555,7 +1553,8 @@
> > POS is a pair (BEG . END) indicating the position of the text in the
> buffer.
> > SRC and DST are the two variants of text as returned by
> `diff-hunk-text'.
> > SRC is the variant that was found in the buffer.
> > -SWITCHED is non-nil if the patch is already applied."
> > +SWITCHED is non-nil if the patch is already applied.
> > +NOPROMPT, if non-nil, means not to prompt the user."
> > (save-excursion
> > (let* ((other (diff-xor other-file diff-jump-to-old-file))
> > (char-offset (- (point) (progn (diff-beginning-of-hunk
> 'try-harder)
> > @@ -1565,8 +1564,8 @@
> > ;; (e.g. because an empty line truncates the hunk
> mid-course),
> > ;; leading to potentially nasty surprises for the user.
> > (_ (diff-sanity-check-hunk))
> > - (hunk (buffer-substring (point)
> > - (save-excursion (diff-end-of-hunk)
> (point))))
> > + (hunk (buffer-substring
> > + (point) (save-excursion (diff-end-of-hunk) (point))))
> > (old (diff-hunk-text hunk reverse char-offset))
> > (new (diff-hunk-text hunk (not reverse) char-offset))
> > ;; Find the location specification.
> > @@ -1578,7 +1577,8 @@
> > diff-context-mid-hunk-header-re nil t)
> > (error "Can't find the hunk separator"))
> > (match-string 1)))))
> > - (file (or (diff-find-file-name other) (error "Can't find the
> file")))
> > + (file (or (diff-find-file-name other noprompt)
> > + (error "Can't find the file")))
> > (buf (find-file-noselect file)))
> > ;; Update the user preference if he so wished.
> > (when (> (prefix-numeric-value other-file) 8)
> > @@ -1718,14 +1718,18 @@
> > (when (looking-at diff-hunk-header-re)
> > (forward-line 1)
> > (re-search-forward "^[^ ]" nil t))
> > - (destructuring-bind (buf line-offset pos src dst &optional switched)
> > - (diff-find-source-location)
> > + (destructuring-bind (&optional buf line-offset pos src dst switched)
> > + ;; Use `noprompt' since this is used in which-func-mode and
> such.
> > + (ignore-errors ;Signals errors in place of
> prompting.
> > + (diff-find-source-location nil nil 'noprompt))
> > + (when buf
> > (beginning-of-line)
> > (or (when (memq (char-after) '(?< ?-))
> > ;; Cursor is pointing at removed text. This could be a removed
> > ;; function, in which case, going to the source buffer will
> > ;; not help since the function is now removed. Instead,
> > - ;; try to figure out the function name just from the
> code-fragment.
> > + ;; try to figure out the function name just from the
> > + ;; code-fragment.
> > (let ((old (if switched dst src)))
> > (with-temp-buffer
> > (insert (car old))
> > @@ -1734,7 +1738,7 @@
> > (add-log-current-defun))))
> > (with-current-buffer buf
> > (goto-char (+ (car pos) (cdr src)))
> > - (add-log-current-defun))))))
> > + (add-log-current-defun)))))))
> >
> > (defun diff-ignore-whitespace-hunk ()
> > "Re-diff the current hunk, ignoring whitespace differences."
> >
> --
> Joakim Verona
>
[-- Attachment #2: Type: text/html, Size: 10926 bytes --]
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-09-14 21:13 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-12 7:47 diff mode weirdness joakim
2008-09-12 14:37 ` Stefan Monnier
2008-09-12 15:46 ` joakim
2008-09-12 17:11 ` Stefan Monnier
2008-09-12 20:15 ` Peter Lee
2008-09-12 20:50 ` joakim
2008-09-12 21:02 ` Glenn Morris
2008-09-12 21:24 ` joakim
2008-09-13 1:53 ` Stefan Monnier
2008-09-14 21:01 ` joakim
2008-09-14 21:13 ` Pete Lee
2008-09-13 3:11 ` Tetsurou Okazaki
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.