leoliu pushed a commit to branch master in repository elpa. commit 927bc05e970d844f577576f49e8b2bc5ce2d544a Author: Leo Liu <sdl....@gmail.com> Date: Tue Mar 18 15:21:31 2014 +0800
Simplify ggtags-save-to-register by always re-do the search Fix error in ggtags-global--display-buffer. --- ggtags.el | 66 ++++++++++++++++++++++++++---------------------------------- 1 files changed, 29 insertions(+), 37 deletions(-) diff --git a/ggtags.el b/ggtags.el index f588331..789982a 100644 --- a/ggtags.el +++ b/ggtags.el @@ -673,8 +673,8 @@ non-nil." (ring-insert find-tag-marker-ring ggtags-global-start-marker) (setq ggtags-global-start-marker t))) -(defun ggtags-global-start (command &optional root) - (let* ((default-directory (or root (ggtags-current-project-root))) +(defun ggtags-global-start (command &optional directory) + (let* ((default-directory (or directory (ggtags-current-project-root))) (split-window-preferred-function ggtags-split-window-function) ;; See http://debbugs.gnu.org/13594 (display-buffer-overriding-action @@ -831,41 +831,33 @@ Global and Emacs." "Save current search session to register R. Use \\[jump-to-register] to restore the search session." (interactive (list (ggtags-ensure-global-buffer - (register-read-with-preview - (format "Save search in `%s' to register: " (buffer-name)))))) + (register-read-with-preview "Save search to register: ")))) (ggtags-ensure-global-buffer - (rename-buffer (format "*ggtags %s*" ggtags-current-tag-name) t) - (cl-labels ((move-to-error (buf line) - (with-current-buffer buf - (goto-char (point-min)) - (forward-line (1- line)) - (setq ggtags-global-last-buffer (current-buffer)) - (ggtags-navigation-mode 1) - (setq compilation-current-error (point)) - (compile-goto-error))) - (jump (data) + (cl-labels ((jump (data) + (pcase data + (`(,command ,root ,line) + (with-current-buffer + (let ((ggtags-auto-jump-to-first-match nil) + ;; Switch current project to ROOT. + (default-directory root) + (ggtags-project-root root)) + (ggtags-global-start command root)) + (add-hook 'compilation-finish-functions + (lambda (buf _msg) + (with-current-buffer buf + (goto-char (point-min)) + (forward-line (1- line)) + (compile-goto-error))) + nil t))))) + (prn (data) (pcase data - (`(,buf ,line ,command ,root) - (if (get-buffer buf) - (progn - (ggtags-global--display-buffer buf) - (move-to-error buf line)) - (with-current-buffer - (let ((ggtags-auto-jump-to-first-match nil)) - (ggtags-global-start command root)) - (add-hook 'compilation-finish-functions - (lambda (buf _msg) (move-to-error buf line)) - nil t) - (rename-buffer buf)))))) - (prn (data) - (pcase data - (`(,_buf ,line ,command ,root) - (princ (format "a ggtags search session `%s' in directory `%s' at line %d." - command root line)))))) - (set-register r (registerv-make - (list (buffer-name) (line-number-at-pos) - (car compilation-arguments) default-directory) - :jump-func #'jump :print-func #'prn))))) + (`(,command ,root ,line) + (princ (format "a ggtags search session `%s' in directory `%s' at line %d." + command root line)))))) + (set-register r (registerv-make + (list (car compilation-arguments) default-directory + (line-number-at-pos)) + :jump-func #'jump :print-func #'prn))))) (defun ggtags-delete-tag-files () "Delete the tag files generated by gtags." @@ -1120,7 +1112,7 @@ Use \\[jump-to-register] to restore the search session." (let ((buffer (or buffer (current-buffer)))) (unless (get-buffer-window buffer) (let* ((split-window-preferred-function ggtags-split-window-function) - (w (display-buffer (current-buffer) '(nil (allow-no-window . t))))) + (w (display-buffer buffer '(nil (allow-no-window . t))))) (and w (compilation-set-window-height w)))))) (defvar ggtags-navigation-mode) @@ -1185,7 +1177,7 @@ Use \\[jump-to-register] to restore the search session." (list ggtags-global-output-format)) (setq-local compilation-auto-jump-to-first-error ggtags-auto-jump-to-first-match) - (setq-local compilation-scroll-output 'first-error) + (setq-local compilation-scroll-output nil) ;; See `compilation-move-to-column' for details. (setq-local compilation-first-column 0) (setq-local compilation-error-screen-columns nil)