changeset 98174:841e92880f11

(diff-find-file-name): Rename `batch' to `noprompt' and be more honest when we don't know. (diff-tell-file-name): Don't prompt before the actual prompt. (diff-mode): Don't prompt in add-log-buffer-file-name-function. (diff-find-source-location): Add `noprompt' argument. (diff-current-defun): Don't prompt.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 14 Sep 2008 21:16:30 +0000
parents c0d486723fb3
children dc54ec9cb542
files lisp/ChangeLog lisp/diff-mode.el
diffstat 2 files changed, 91 insertions(+), 78 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Sep 14 16:44:44 2008 +0000
+++ b/lisp/ChangeLog	Sun Sep 14 21:16:30 2008 +0000
@@ -1,8 +1,17 @@
+2008-09-14  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+	* diff-mode.el (diff-find-file-name): Rename `batch' to `noprompt' and
+	be more honest when we don't know.
+	(diff-tell-file-name): Don't prompt before the actual prompt.
+	(diff-mode): Don't prompt in add-log-buffer-file-name-function.
+	(diff-find-source-location): Add `noprompt' argument.
+	(diff-current-defun): Don't prompt.
+
 2008-09-14  Roland Winkler  <Roland.Winkler@physik.uni-erlangen.de>
 
 	* proced.el (proced-mark-face, proced-marked-face)
-	(proced-sort-header-face): Removed.
-	(proced-font-lock-keywords): Simplified.
+	(proced-sort-header-face): Remove.
+	(proced-font-lock-keywords): Simplify.
 	(proced-format): Use face proced-sort-header.
 	(proced-format-interactive, proced-sort-interactive)
 	(proced-filter-interactive): Only call proced-update if the scheme
@@ -12,8 +21,8 @@
 2008-09-14  Martin Rudalics  <rudalics@gmx.at>
 
 	* add-log.el (change-log-find-window): New variable.
-	(change-log-goto-source-1, change-log-goto-source): Set
-	change-log-find-window to window displaying source.
+	(change-log-goto-source-1, change-log-goto-source):
+	Set change-log-find-window to window displaying source.
 	(change-log-next-error): Select window specified by
 	change-log-find-window.
 
@@ -28,13 +37,13 @@
 
 	* proced.el (proced-sort-header): New face.
 	(proced-sort-header-face): New variable.
-	(proced-format): Allow format value nil.  Use
-	proced-sort-header-face for header of sort column.
+	(proced-format): Allow format value nil.
+	Use proced-sort-header-face for header of sort column.
 	(proced-format-args): New function.
 	(proced-grammar-alist, proced-timer-flag, proced-process-alist)
 	(proced-header-help-echo, proced-field-help-echo, proced-timer)
 	(proced-toggle-timer-flag, proced, proced-mode): Doc fix.
-	(proced-refine): Renamed from proced-filter-attribute.  Doc fix.
+	(proced-refine): Rename from proced-filter-attribute.  Doc fix.
 	(proced-sort-header): Bind also to mouse-1.
 	(proced-move-to-goal-column): Return position of point.
 	(proced-filter-interactive): Always revert listing.
@@ -337,7 +346,7 @@
 
 2008-09-04  Juanma Barranquero  <lekktu@gmail.com>
 
-	* net/tramp-cache.el (tramp-flush-file-function): Fix typo in docstring.
+	* net/tramp-cache.el (tramp-flush-file-function): Fix docstring typo.
 	(tramp-parse-connection-properties): Reflow docstring.
 
 2008-09-04  Kim F. Storm  <storm@cua.dk>
@@ -410,9 +419,9 @@
 
 2008-09-01  Chong Yidong  <cyd@stupidchicken.com>
 
-	* minibuffer.el (completion-pcm--pattern->regex): When
-	completion-ignore-case is non-nil, generate a regexp that ignores
-	case.
+	* minibuffer.el (completion-pcm--pattern->regex):
+	When completion-ignore-case is non-nil, generate a regexp that
+	ignores case.
 
 	* window.el (recenter-top-bottom): Doc fix.
 
@@ -427,7 +436,7 @@
 2008-09-01  Martin Rudalics  <rudalics@gmx.at>
 
 	* help-fns.el (describe-simplify-lib-file-name)
-	(find-source-lisp-file): Removed.
+	(find-source-lisp-file): Remove.
 	(find-lisp-object-file-name): New function giving preference to
 	files found via load-path instead of loaddefs.el.
 	(describe-function-1): Use new function instead of the removed
@@ -439,8 +448,8 @@
 
 	* international/mule-diag.el (font-show-log): Fix previous change.
 
-	* international/mule-cmds.el (set-language-environment): Don't
-	overwrite current-iso639-language if the current language
+	* international/mule-cmds.el (set-language-environment):
+	Don't overwrite current-iso639-language if the current language
 	environment doesn't provide that data.
 	(set-locale-environment): Set current-iso639-language from the
 	locale name.
@@ -483,7 +492,7 @@
 	These changes are to adjust the automatic composition for the new
 	implementation (avoid using text property).
 
-	* composite.el (composition-function-table): Declaration moved to
+	* composite.el (composition-function-table): Move declaration to
 	composite.c.
 	(terminal-composition-base-character-p): Delete it.
 	(terminal-composition-function): Delete it.
@@ -519,8 +528,8 @@
 	(tamil-composable-pattern, kannada-composable-pattern)
 	(malayalam-composable-pattern): New variables.
 
-	* international/characters.el (unicode-category-table): Setup
-	unicode-category-table.
+	* international/characters.el (unicode-category-table):
+	Setup unicode-category-table.
 
 	* international/fontset.el (setup-default-fontset): Prepend
 	iso10646-1 fonts to the fallback font groups instead of appending.
@@ -574,7 +583,7 @@
 
 2008-08-27  Tomas Abrahamsson  <tab@lysator.liu.se>
 
-	* textmodes/artist.el (artist-mode-init): Added comment on the
+	* textmodes/artist.el (artist-mode-init): Add comment on the
 	setting up of the `artist-replacement-table' array.
 	(artist-get-replacement-char): New defsubst.
 	(artist-get-char-at-xy-conv, artist-replace-char)
@@ -582,7 +591,7 @@
 	accessing `artist-replacement-table' directly.
 	Reported by Rubén Berenguel <ruben@maia.ub.es>.
 
-	(artist-mt): Fixed structures for cut and copy operations.
+	(artist-mt): Fix structures for cut and copy operations.
 
 2008-08-27  Chong Yidong  <cyd@stupidchicken.com>
 
@@ -646,10 +655,10 @@
 	(newsticker-treeview-treewindow-width): New.
 	(newsticker-treeview-listwindow-height): New.
 	(newsticker-treeview-browse-url-item): New.
-	(newsticker-treeview-mode-map): Added
-	newsticker-treeview-browse-url-item.
-	(newsticker--treeview-window-init): Use
-	newsticker-treeview-treewindow-width and
+	(newsticker-treeview-mode-map):
+	Add newsticker-treeview-browse-url-item.
+	(newsticker--treeview-window-init):
+	Use newsticker-treeview-treewindow-width and
 	newsticker-treeview-listwindow-height.
 
 	* net/newst-reader.el (newsticker-browse-url-item): New.
@@ -685,7 +694,7 @@
 	keys we will be remapping via local-function-key-map.
 	(msdos-setup-keyboard): New function.
 
-	* term/pc-win.el (msdos-create-frame-with-faces): Renamed from
+	* term/pc-win.el (msdos-create-frame-with-faces): Rename from
 	make-msdos-frame.
 	(terminal-init-internal): New function, errors out if called.
 	(msdos-initialize-window-system): New function.
@@ -745,9 +754,9 @@
 
 2008-08-21  Chong Yidong  <cyd@stupidchicken.com>
 
-	* minibuffer.el (completion--try-word-completion): Disable
-	partial-completion when considering the addition of a space or
-	hyphen.
+	* minibuffer.el (completion--try-word-completion):
+	Disable partial-completion when considering the addition of a space
+	or hyphen.
 
 2008-08-21  John Paul Wallington  <jpw@pobox.com>
 
@@ -803,8 +812,8 @@
 
 2008-08-18  Chong Yidong  <cyd@stupidchicken.com>
 
-	* emulation/edt.el (edt-default-emulation-setup): Share
-	global-buffers-menu-map with the emulated global map.
+	* emulation/edt.el (edt-default-emulation-setup):
+	Share global-buffers-menu-map with the emulated global map.
 
 2008-08-18  Adrian Robert  <Adrian.B.Robert@gmail.com>
 
@@ -833,10 +842,10 @@
 	(proced-log-buffer): New variable.
 	(proced-mark-all, proced-unmark-all, proced-do-mark-al): Operate on
 	region if transient-mark-mode is turned on and the region is active.
-	(proced-omit-processes): Renamed from proced-hide-processes to
+	(proced-omit-processes): Rename from proced-hide-processes to
 	avoid key clash with describe-mode (bound to h).  Search for
 	marked processes starting from point-min.
-	(proced-header-space): Removed.
+	(proced-header-space): Remove.
 	(proced-send-signal): Handle errors.  Operate on current process
 	if no process is marked.
 	(proced-why): New command.
@@ -902,8 +911,8 @@
 
 2008-08-13  Glenn Morris  <rgm@gnu.org>
 
-	* eshell/esh-cmd.el (eshell/which): Handle the case where no description
-	is found.
+	* eshell/esh-cmd.el (eshell/which): Handle the case where no
+	description is found.
 
 2008-08-12  Alan Mackenzie  <acm@muc.de>
 
@@ -923,8 +932,8 @@
 
 2008-08-11  Chong Yidong  <cyd@stupidchicken.com>
 
-	* progmodes/cc-defs.el (c-emacs-features): Check
-	beginning-of-defun-raw instead of beginning-of-defun, and avoid
+	* progmodes/cc-defs.el (c-emacs-features):
+	Check beginning-of-defun-raw instead of beginning-of-defun, and avoid
 	moving point during the test.
 
 	* emacs-lisp/lisp.el (beginning-of-defun): Doc fix.
@@ -962,7 +971,7 @@
 	* net/xesam.el (xesam-search-engines): Add Debbugs hit fields.
 	(xesam-refresh-entry): Add Debbugs handling.  Insert a widget
 	"DONE", when all hits are retrieved.
-	(xesam-search): autoload it.
+	(xesam-search): Autoload it.
 
 2008-08-11  John Paul Wallington  <jpw@pobox.com>
 
@@ -1200,8 +1209,8 @@
 	Extend docstring.  Adapt implementation according to new
 	`dbus-event' layout.
 	(dbus-event-service-name, dbus-event-path-name)
-	(dbus-event-interface-name, dbus-event-member-name): Adapt
-	implementation according to new `dbus-event' layout.
+	(dbus-event-interface-name, dbus-event-member-name):
+	Adapt implementation according to new `dbus-event' layout.
 	(dbus-set-property): Correct `dbus-introspect-get-attribute' call.
 
 	* net/xesam.el (xesam-type, xesam-query, xesam-xml-string): New defvar.
@@ -1232,13 +1241,13 @@
 
 	* mb-depth.el: Unify all names under one common name prefix
 	`minibuffer-depth-'.
-	(minibuffer-depth-indicator-function): Renamed from
+	(minibuffer-depth-indicator-function): Rename from
 	`minibuf-depth-indicator-function'.
-	(minibuffer-depth-overlay): Renamed from
+	(minibuffer-depth-overlay): Rename from
 	`minibuf-depth-overlay'.
-	(minibuffer-depth-setup): Renamed from
+	(minibuffer-depth-setup): Rename from
 	`minibuf-depth-setup-minibuffer'.
-	(minibuffer-depth-indicate-mode): Renamed from
+	(minibuffer-depth-indicate-mode): Rename from
 	`minibuffer-indicate-depth-mode'.
 
 2008-07-31  Juri Linkov  <juri@jurta.org>
--- a/lisp/diff-mode.el	Sun Sep 14 16:44:44 2008 +0000
+++ b/lisp/diff-mode.el	Sun Sep 14 21:16:30 2008 +0000
@@ -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) ""))
-				   nil (first fs) t (first fs))))
-	 (set (make-local-variable 'diff-remembered-files-alist)
-	      (cons (cons fs file) diff-remembered-files-alist))
-	 file)))))
+       (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))))))
 
 
 (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,23 +1718,27 @@
     (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)
-      (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.
-	    (let ((old (if switched dst src)))
-	      (with-temp-buffer
-		(insert (car old))
-		(funcall (buffer-local-value 'major-mode buf))
-		(goto-char (+ (point-min) (cdr old)))
-		(add-log-current-defun))))
-	  (with-current-buffer buf
-	    (goto-char (+ (car pos) (cdr src)))
-	    (add-log-current-defun))))))
+    (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.
+              (let ((old (if switched dst src)))
+                (with-temp-buffer
+                  (insert (car old))
+                  (funcall (buffer-local-value 'major-mode buf))
+                  (goto-char (+ (point-min) (cdr old)))
+                  (add-log-current-defun))))
+            (with-current-buffer buf
+              (goto-char (+ (car pos) (cdr src)))
+              (add-log-current-defun)))))))
 
 (defun diff-ignore-whitespace-hunk ()
   "Re-diff the current hunk, ignoring whitespace differences."