]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/grep.el
Merge from origin/emacs-25
[gnu-emacs] / lisp / progmodes / grep.el
index fd55576e13513458d3957c5e1aceb749f144299a..2b44b58f245e162e45ce6de4f7ca95989e619d5e 100644 (file)
@@ -271,8 +271,6 @@ See `compilation-error-screen-columns'"
     (define-key map "{" 'compilation-previous-file)
     (define-key map "}" 'compilation-next-file)
     (define-key map "\t" 'compilation-next-error)
-    (define-key map "r" 'grep-forward-history)
-    (define-key map "l" 'grep-backward-history)
     (define-key map [backtab] 'compilation-previous-error)
 
     ;; Set up the menu-bar
@@ -311,12 +309,6 @@ See `compilation-error-screen-columns'"
     (define-key map [menu-bar grep compilation-next-error]
       '(menu-item "Next Match" next-error
                  :help "Visit the next match and corresponding location"))
-    (define-key map [menu-bar grep grep-backward-history]
-      '(menu-item "Previous Command" grep-backward-history
-                 :help "Run the previous grep command from the command history"))
-    (define-key map [menu-bar grep grep-forward-history]
-      '(menu-item "Next Command" grep-forward-history
-                 :help "Run the next grep command from the command history"))
     map)
   "Keymap for grep buffers.
 `compilation-minor-mode-map' is a cdr of this.")
@@ -472,12 +464,9 @@ This variable's value takes effect when `grep-compute-defaults' is called.")
 (defvar grep-files-history nil)
 
 ;;;###autoload
-(defun grep-process-setup (&optional point)
+(defun grep-process-setup ()
   "Setup compilation variables and buffer for `grep'.
-Set up `compilation-exit-message-function' and run
-`grep-setup-hook'.  If the optional parameter POINT is given,
-point will be moved to this vicinity when the grep command has
-finished."
+Set up `compilation-exit-message-function' and run `grep-setup-hook'."
   (when (eq grep-highlight-matches 'auto-detect)
     (grep-compute-defaults))
   (unless (or (eq grep-highlight-matches 'auto-detect)
@@ -498,14 +487,12 @@ finished."
             ;; This relies on the fact that `compilation-start'
             ;; sets buffer-modified to nil before running the command,
             ;; so the buffer is still unmodified if there is no output.
-             (progn
-               (goto-char (min point (point-max)))
-               (cond ((and (zerop code) (buffer-modified-p))
-                      '("finished (matches found)\n" . "matched"))
-                     ((not (buffer-modified-p))
-                      '("finished with no matches found\n" . "no match"))
-                     (t
-                      (cons msg code))))
+            (cond ((and (zerop code) (buffer-modified-p))
+                   '("finished (matches found)\n" . "matched"))
+                  ((not (buffer-modified-p))
+                   '("finished with no matches found\n" . "no match"))
+                  (t
+                   (cons msg code)))
           (cons msg code))))
   (run-hooks 'grep-setup-hook))
 
@@ -737,10 +724,6 @@ This function is called from `compilation-filter-hook'."
       ;; Now replace the pattern with the default tag.
       (replace-match tag-default t t grep-default 1))))
 
-(defvar grep--command-history nil)
-(defvar grep--history-inhibit nil)
-(defvar grep--history-place 0)
-(defvar grep--history-point 0)
 
 ;;;###autoload
 (define-compilation-mode grep-mode "Grep"
@@ -755,53 +738,12 @@ This function is called from `compilation-filter-hook'."
   ;; can never match.
   (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`"))
   (set (make-local-variable 'compilation-process-setup-function)
-       (lambda ()
-         (grep-process-setup grep--history-point)))
+       'grep-process-setup)
   (set (make-local-variable 'compilation-disable-input) t)
   (set (make-local-variable 'compilation-error-screen-columns)
        grep-error-screen-columns)
   (add-hook 'compilation-filter-hook 'grep-filter nil t))
 
-(defun grep--save-history (command)
-  (unless grep--history-inhibit
-    (when grep--command-history
-      (setcar (cdr (car grep--command-history)) (point)))
-    (push (list default-directory 0 command)
-          grep--command-history)
-    (setq grep--history-place 0)
-    ;; Don't let the history grow without bounds.
-    (when (> (length grep--command-history) 100)
-      (setcdr (nthcdr 100 grep--command-history) nil))))
-
-(defun grep-forward-history ()
-  "Go to the next result in the grep command history.
-Also see `grep-backward-history'."
-  (interactive)
-  (let ((elem (and (> grep--history-place 0)
-                   (nth (1- grep--history-place) grep--command-history)))
-        (grep--history-inhibit t))
-    (unless elem
-      (error "Nothing further in the command history"))
-    (setcar (cdr (nth grep--history-place grep--command-history)) (point))
-    (cl-decf grep--history-place)
-    (let ((default-directory (car elem))
-          (grep--history-point (nth 1 elem)))
-      (grep (nth 2 elem)))))
-
-(defun grep-backward-history ()
-  "Go to the previous result in the grep command history.
-Also see `grep-forward-history'."
-  (interactive)
-  (let ((elem (nth (1+ grep--history-place) grep--command-history))
-        (grep--history-inhibit t))
-    (unless elem
-      (error "Nothing further in the command history"))
-    (setcar (cdr (nth grep--history-place grep--command-history)) (point))
-    (cl-incf grep--history-place)
-    (let ((default-directory (car elem))
-          (grep--history-point (nth 1 elem)))
-      (grep (nth 2 elem)))))
-
 (defun grep--save-buffers ()
   (when grep-save-buffers
     (save-some-buffers (and (not (eq grep-save-buffers 'ask))
@@ -838,7 +780,7 @@ list is empty)."
                                  (if current-prefix-arg default grep-command)
                                  'grep-history
                                  (if current-prefix-arg nil default))))))
-  (grep--save-history command-args)
+
   (grep--save-buffers)
   ;; Setting process-setup-function makes exit-message-function work
   ;; even when async processes aren't supported.