[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 21/38: Add new command ggtags-save-to-register for #37
From: |
Leo Liu |
Subject: |
[elpa] 21/38: Add new command ggtags-save-to-register for #37 |
Date: |
Mon, 24 Mar 2014 09:31:36 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 339ec1069bd42d029bfd8d922beff3ca47443158
Author: Leo Liu <address@hidden>
Date: Tue Mar 18 10:12:20 2014 +0800
Add new command ggtags-save-to-register for #37
---
ggtags.el | 51 ++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 48 insertions(+), 3 deletions(-)
diff --git a/ggtags.el b/ggtags.el
index 3f437b6..e44a592 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -74,10 +74,12 @@
(list 'make-variable-buffer-local (list 'quote var))))))
(eval-and-compile
- (or (fboundp 'user-error)
+ (or (fboundp 'user-error) ;24.3
(defalias 'user-error 'error))
- (or (fboundp 'read-only-mode)
- (defalias 'read-only-mode 'toggle-read-only)))
+ (or (fboundp 'read-only-mode) ;24.3
+ (defalias 'read-only-mode 'toggle-read-only))
+ (or (fboundp 'register-read-with-preview) ;24.4
+ (defalias 'register-read-with-preview 'read-char)))
(defgroup ggtags nil
"GNU Global source code tagging system."
@@ -825,6 +827,46 @@ Global and Emacs."
(nreverse files))))
(tags-query-replace from to delimited file-form)))
+(defun ggtags-save-to-register (r)
+ "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))))))
+ (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)
+ (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)))))
+
(defun ggtags-delete-tag-files ()
"Delete the tag files generated by gtags."
(interactive (ignore (ggtags-check-project)))
@@ -1445,6 +1487,7 @@ When finished invoke CALLBACK in BUFFER with process exit
status."
(define-key m "\M-k" 'ggtags-kill-file-buffers)
(define-key m "\M-h" 'ggtags-view-tag-history)
(define-key m "\M-j" 'ggtags-visit-project-root)
+ (define-key m (kbd "M-SPC") 'ggtags-save-to-register)
(define-key m (kbd "M-%") 'ggtags-query-replace)
(define-key m "\M-?" 'ggtags-show-definition)
m))
@@ -1495,6 +1538,8 @@ When finished invoke CALLBACK in BUFFER with process exit
status."
(define-key menu [prev-mark]
'(menu-item "Previous mark" ggtags-prev-mark))
(define-key menu [sep1] menu-bar-separator)
+ (define-key menu [save-to-register]
+ '(menu-item "Save search session" ggtags-save-to-register))
(define-key menu [previous-error]
'(menu-item "Previous match" previous-error))
(define-key menu [next-error]
- [elpa] 11/38: Make last change acutally work, (continued)
- [elpa] 11/38: Make last change acutally work, Leo Liu, 2014/03/24
- [elpa] 12/38: Fix compatibility for locate-dominating-file, Leo Liu, 2014/03/24
- [elpa] 14/38: Display project root directory name on mode-line, Leo Liu, 2014/03/24
- [elpa] 22/38: New command ggtags-navigation-isearch-forward, Leo Liu, 2014/03/24
- [elpa] 17/38: Fix ggtags-with-current-project to include GTAGSCONF, Leo Liu, 2014/03/24
- [elpa] 19/38: Use read-only-mode in ggtags-toggle-project-read-only, Leo Liu, 2014/03/24
- [elpa] 18/38: Fix #36: Allow customising path to global's exectuables, Leo Liu, 2014/03/24
- [elpa] 20/38: Teach ggtags-find-tag-dwim to detect #include files, Leo Liu, 2014/03/24
- [elpa] 25/38: Fix ggtags-find-project to check on the GTAGS file, Leo Liu, 2014/03/24
- [elpa] 23/38: Simplify ggtags-save-to-register by always re-do the search, Leo Liu, 2014/03/24
- [elpa] 21/38: Add new command ggtags-save-to-register for #37,
Leo Liu <=
- [elpa] 16/38: Fix ggtags-show-definition to run in current project, Leo Liu, 2014/03/24
- [elpa] 24/38: Fix thinko in "Don't display buffer if ggtags-navigation-mode is exited", Leo Liu, 2014/03/24
- [elpa] 26/38: New macro ignore-errors-unless-debug and use it, Leo Liu, 2014/03/24
- [elpa] 15/38: Small fixes to last change, Leo Liu, 2014/03/24
- [elpa] 32/38: Bind ggtags-save-to-register in ggtags-global-rerun-search-map, Leo Liu, 2014/03/24
- [elpa] 28/38: New helper ggtags-forward-to-line and use it, Leo Liu, 2014/03/24
- [elpa] 27/38: Cosmetic change: Fix indentation, Leo Liu, 2014/03/24
- [elpa] 29/38: New feature ggtags-global-restore-search for #37, Leo Liu, 2014/03/24
- [elpa] 33/38: Disable ggtags-navigation-mode in ggtags-global-rerun-search, Leo Liu, 2014/03/24
- [elpa] 31/38: Also record ggtags-process-environment in search history, Leo Liu, 2014/03/24