diff options
| author | John Wiegley | 2016-04-03 15:46:52 -0700 |
|---|---|---|
| committer | John Wiegley | 2016-04-03 15:46:52 -0700 |
| commit | 3a5f146e5abd79c7fb1810f5af99c7d448012604 (patch) | |
| tree | 251332f60a31724ada26d36ffaa124ae6a15c583 /lisp | |
| parent | 969c8a388a859e4366a1fe75ae57939a765874aa (diff) | |
| download | emacs-3a5f146e5abd79c7fb1810f5af99c7d448012604.tar.gz emacs-3a5f146e5abd79c7fb1810f5af99c7d448012604.zip | |
Revert "Restore the point in grep buffers when traversing the history"
This reverts commit f7c5f79ca565d3ef3feeb1e0af5ca261f1bcf58a.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/progmodes/grep.el | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/lisp/progmodes/grep.el b/lisp/progmodes/grep.el index fd55576e135..7ce787e7284 100644 --- a/lisp/progmodes/grep.el +++ b/lisp/progmodes/grep.el | |||
| @@ -472,12 +472,9 @@ This variable's value takes effect when `grep-compute-defaults' is called.") | |||
| 472 | (defvar grep-files-history nil) | 472 | (defvar grep-files-history nil) |
| 473 | 473 | ||
| 474 | ;;;###autoload | 474 | ;;;###autoload |
| 475 | (defun grep-process-setup (&optional point) | 475 | (defun grep-process-setup () |
| 476 | "Setup compilation variables and buffer for `grep'. | 476 | "Setup compilation variables and buffer for `grep'. |
| 477 | Set up `compilation-exit-message-function' and run | 477 | Set up `compilation-exit-message-function' and run `grep-setup-hook'." |
| 478 | `grep-setup-hook'. If the optional parameter POINT is given, | ||
| 479 | point will be moved to this vicinity when the grep command has | ||
| 480 | finished." | ||
| 481 | (when (eq grep-highlight-matches 'auto-detect) | 478 | (when (eq grep-highlight-matches 'auto-detect) |
| 482 | (grep-compute-defaults)) | 479 | (grep-compute-defaults)) |
| 483 | (unless (or (eq grep-highlight-matches 'auto-detect) | 480 | (unless (or (eq grep-highlight-matches 'auto-detect) |
| @@ -498,14 +495,12 @@ finished." | |||
| 498 | ;; This relies on the fact that `compilation-start' | 495 | ;; This relies on the fact that `compilation-start' |
| 499 | ;; sets buffer-modified to nil before running the command, | 496 | ;; sets buffer-modified to nil before running the command, |
| 500 | ;; so the buffer is still unmodified if there is no output. | 497 | ;; so the buffer is still unmodified if there is no output. |
| 501 | (progn | 498 | (cond ((and (zerop code) (buffer-modified-p)) |
| 502 | (goto-char (min point (point-max))) | 499 | '("finished (matches found)\n" . "matched")) |
| 503 | (cond ((and (zerop code) (buffer-modified-p)) | 500 | ((not (buffer-modified-p)) |
| 504 | '("finished (matches found)\n" . "matched")) | 501 | '("finished with no matches found\n" . "no match")) |
| 505 | ((not (buffer-modified-p)) | 502 | (t |
| 506 | '("finished with no matches found\n" . "no match")) | 503 | (cons msg code))) |
| 507 | (t | ||
| 508 | (cons msg code)))) | ||
| 509 | (cons msg code)))) | 504 | (cons msg code)))) |
| 510 | (run-hooks 'grep-setup-hook)) | 505 | (run-hooks 'grep-setup-hook)) |
| 511 | 506 | ||
| @@ -737,10 +732,6 @@ This function is called from `compilation-filter-hook'." | |||
| 737 | ;; Now replace the pattern with the default tag. | 732 | ;; Now replace the pattern with the default tag. |
| 738 | (replace-match tag-default t t grep-default 1)))) | 733 | (replace-match tag-default t t grep-default 1)))) |
| 739 | 734 | ||
| 740 | (defvar grep--command-history nil) | ||
| 741 | (defvar grep--history-inhibit nil) | ||
| 742 | (defvar grep--history-place 0) | ||
| 743 | (defvar grep--history-point 0) | ||
| 744 | 735 | ||
| 745 | ;;;###autoload | 736 | ;;;###autoload |
| 746 | (define-compilation-mode grep-mode "Grep" | 737 | (define-compilation-mode grep-mode "Grep" |
| @@ -755,19 +746,19 @@ This function is called from `compilation-filter-hook'." | |||
| 755 | ;; can never match. | 746 | ;; can never match. |
| 756 | (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`")) | 747 | (set (make-local-variable 'compilation-directory-matcher) '("\\`a\\`")) |
| 757 | (set (make-local-variable 'compilation-process-setup-function) | 748 | (set (make-local-variable 'compilation-process-setup-function) |
| 758 | (lambda () | 749 | 'grep-process-setup) |
| 759 | (grep-process-setup grep--history-point))) | ||
| 760 | (set (make-local-variable 'compilation-disable-input) t) | 750 | (set (make-local-variable 'compilation-disable-input) t) |
| 761 | (set (make-local-variable 'compilation-error-screen-columns) | 751 | (set (make-local-variable 'compilation-error-screen-columns) |
| 762 | grep-error-screen-columns) | 752 | grep-error-screen-columns) |
| 763 | (add-hook 'compilation-filter-hook 'grep-filter nil t)) | 753 | (add-hook 'compilation-filter-hook 'grep-filter nil t)) |
| 764 | 754 | ||
| 755 | (defvar grep--command-history nil) | ||
| 756 | (defvar grep--history-inhibit nil) | ||
| 757 | (defvar grep--history-place 0) | ||
| 758 | |||
| 765 | (defun grep--save-history (command) | 759 | (defun grep--save-history (command) |
| 766 | (unless grep--history-inhibit | 760 | (unless grep--history-inhibit |
| 767 | (when grep--command-history | 761 | (push (cons default-directory command) grep--command-history) |
| 768 | (setcar (cdr (car grep--command-history)) (point))) | ||
| 769 | (push (list default-directory 0 command) | ||
| 770 | grep--command-history) | ||
| 771 | (setq grep--history-place 0) | 762 | (setq grep--history-place 0) |
| 772 | ;; Don't let the history grow without bounds. | 763 | ;; Don't let the history grow without bounds. |
| 773 | (when (> (length grep--command-history) 100) | 764 | (when (> (length grep--command-history) 100) |
| @@ -782,11 +773,9 @@ Also see `grep-backward-history'." | |||
| 782 | (grep--history-inhibit t)) | 773 | (grep--history-inhibit t)) |
| 783 | (unless elem | 774 | (unless elem |
| 784 | (error "Nothing further in the command history")) | 775 | (error "Nothing further in the command history")) |
| 785 | (setcar (cdr (nth grep--history-place grep--command-history)) (point)) | ||
| 786 | (cl-decf grep--history-place) | 776 | (cl-decf grep--history-place) |
| 787 | (let ((default-directory (car elem)) | 777 | (let ((default-directory (car elem))) |
| 788 | (grep--history-point (nth 1 elem))) | 778 | (grep (cdr elem))))) |
| 789 | (grep (nth 2 elem))))) | ||
| 790 | 779 | ||
| 791 | (defun grep-backward-history () | 780 | (defun grep-backward-history () |
| 792 | "Go to the previous result in the grep command history. | 781 | "Go to the previous result in the grep command history. |
| @@ -796,11 +785,9 @@ Also see `grep-forward-history'." | |||
| 796 | (grep--history-inhibit t)) | 785 | (grep--history-inhibit t)) |
| 797 | (unless elem | 786 | (unless elem |
| 798 | (error "Nothing further in the command history")) | 787 | (error "Nothing further in the command history")) |
| 799 | (setcar (cdr (nth grep--history-place grep--command-history)) (point)) | ||
| 800 | (cl-incf grep--history-place) | 788 | (cl-incf grep--history-place) |
| 801 | (let ((default-directory (car elem)) | 789 | (let ((default-directory (car elem))) |
| 802 | (grep--history-point (nth 1 elem))) | 790 | (grep (cdr elem))))) |
| 803 | (grep (nth 2 elem))))) | ||
| 804 | 791 | ||
| 805 | (defun grep--save-buffers () | 792 | (defun grep--save-buffers () |
| 806 | (when grep-save-buffers | 793 | (when grep-save-buffers |