emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 34/38: Support search bookmarks as requested in #39


From: Leo Liu
Subject: [elpa] 34/38: Support search bookmarks as requested in #39
Date: Mon, 24 Mar 2014 09:31:38 +0000

leoliu pushed a commit to branch master
in repository elpa.

commit 8b1709a8b29715a710180a70248abd983d15b97d
Author: Leo Liu <address@hidden>
Date:   Sat Mar 22 16:48:21 2014 +0800

    Support search bookmarks as requested in #39
    
    New variable ggtags-global-history-length.
---
 ggtags.el |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ggtags.el b/ggtags.el
index 6c002d8..37dd826 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -211,6 +211,11 @@ If an integer abbreviate only names longer than that 
number."
   :type 'number
   :group 'ggtags)
 
+(defcustom ggtags-global-history-length history-length
+  "Maximum number of items to keep in `ggtags-global-search-history'."
+  :type 'integer
+  :group 'ggtags)
+
 (defcustom ggtags-find-tag-hook nil
   "Hook run immediately after finding a tag."
   :options '(recenter reposition-window)
@@ -870,7 +875,7 @@ Global and Emacs."
                  (lambda (buf _msg)
                    (with-current-buffer buf
                      (ggtags-forward-to-line line)
-                     (with-demoted-errors (compile-goto-error))))
+                     (compile-goto-error)))
                  nil t)))))
 
 (defvar-local ggtags-global-search-ewoc nil)
@@ -911,6 +916,7 @@ Global and Emacs."
       m)))
 
 (defvar ggtags-navigation-mode)
+(defvar bookmark-make-record-function)
 
 (defun ggtags-global-rerun-search ()
   "Pop up a buffer to choose a past search to re-run.
@@ -925,6 +931,7 @@ Global and Emacs."
     (special-mode)
     (use-local-map ggtags-global-rerun-search-map)
     (setq-local ggtags-navigation-mode nil)
+    (setq-local bookmark-make-record-function #'ggtags-make-bookmark-record)
     (setq truncate-lines t)
     (cl-labels ((prop (s) (propertize s 'face 'minibuffer-prompt))
                 (pp (data)
@@ -962,6 +969,18 @@ Use \\[jump-to-register] to restore the search session."
                      :jump-func #'ggtags-global-rerun-search-1
                      :print-func #'prn))))
 
+(defun ggtags-make-bookmark-record ()
+  `(,(and ggtags-current-tag-name (format "*ggtags %s*" 
ggtags-current-tag-name))
+    (ggtags-search . ,(if ggtags-global-search-ewoc
+                          (cdr (ewoc-data (ewoc-locate 
ggtags-global-search-ewoc)))
+                        (ggtags-global-current-search)))
+    (handler . ggtags-bookmark-jump)))
+
+(declare-function bookmark-prop-get "bookmark")
+
+(defun ggtags-bookmark-jump (bmk)
+  (ggtags-global-rerun-search-1 (bookmark-prop-get bmk 'ggtags-search)))
+
 (defun ggtags-delete-tag-files ()
   "Delete the tag files generated by gtags."
   (interactive (ignore (ggtags-check-project)))
@@ -1293,6 +1312,7 @@ Use \\[jump-to-register] to restore the search session."
   (jit-lock-register #'ggtags-abbreviate-files)
   (add-hook 'compilation-filter-hook 'ggtags-global-filter nil 'local)
   (add-hook 'compilation-finish-functions 'ggtags-handle-single-match nil t)
+  (setq-local bookmark-make-record-function #'ggtags-make-bookmark-record)
   (add-hook 'kill-buffer-hook (lambda () (ggtags-navigation-mode -1)) nil t))
 
 ;; NOTE: Need this to avoid putting menu items in
@@ -1465,7 +1485,8 @@ Use \\[jump-to-register] to restore the search session."
         (setq ggtags-global-search-history
               (cl-remove id ggtags-global-search-history :test #'equal :key 
#'car))
         (add-to-history 'ggtags-global-search-history
-                        (cons id (ggtags-global-current-search))))))
+                        (cons id (ggtags-global-current-search))
+                        ggtags-global-history-length))))
   (run-hooks 'ggtags-find-tag-hook))
 
 (define-minor-mode ggtags-navigation-mode nil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]