[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 01/14: Enhance ggtags-view-tag-history to use next-/previous-erro
From: |
Leo Liu |
Subject: |
[elpa] 01/14: Enhance ggtags-view-tag-history to use next-/previous-error |
Date: |
Sun, 30 Mar 2014 07:02:37 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit e1323319c670167adf4c6e14c815e6d8847e6759
Author: Leo Liu <address@hidden>
Date: Tue Mar 25 16:52:22 2014 +0800
Enhance ggtags-view-tag-history to use next-/previous-error
- New major mode ggtags-view-tag-history-mode derived from
tabulated-list-mode with custom key bindings.
- Update README.rst.
---
README.rst | 13 +++++++----
ggtags.el | 62 +++++++++++++++++++++++++++++++++++++++++------------------
2 files changed, 51 insertions(+), 24 deletions(-)
diff --git a/README.rst b/README.rst
index 6296c54..5517daf 100644
--- a/README.rst
+++ b/README.rst
@@ -187,8 +187,8 @@ turned on to facilitate locating the right match.
``RET``
- Found the right match so exit the navigation mode. Resumable by
- ``M-,`` (``tags-loop-continue``).
+ Found the right match so exit navigation mode. Resumable by ``M-,``
+ (``tags-loop-continue``).
``M-*``
@@ -197,7 +197,7 @@ turned on to facilitate locating the right match.
Miscellaneous commands
++++++++++++++++++++++
-Commands are made avaiable via the ``Ggtags`` menu in ``ggtags-mode``.
+Commands are avaiable from the ``Ggtags`` menu in ``ggtags-mode``.
ggtags-prev-mark
@@ -211,8 +211,11 @@ ggtags-next-mark
ggtags-view-tag-history
Pop to a buffer listing all visited locations from newest to
- oldest. Use ``TAB`` and ``S-TAB`` to move to next/prev entry and
- ``RET`` to visit it.
+ oldest. The buffer is a next error buffer and works with standard
+ commands ``next-error`` and ``previous-error``. In addition ``TAB``
+ and ``S-TAB`` move to next/prev entry, and ``RET`` visits the
+ location. ``M-n`` and ``M-p`` move to and display the next/previous
+ entry.
ggtags-global-rerun-search
diff --git a/ggtags.el b/ggtags.el
index 541025a..8435ccb 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
;; Author: Leo Liu <address@hidden>
-;; Version: 0.8.0
+;; Version: 0.8.1
;; Keywords: tools, convenience
;; Created: 2013-01-29
;; URL: https://github.com/leoliu/ggtags
@@ -1058,7 +1058,22 @@ Use \\[jump-to-register] to restore the search session."
(interactive)
(ggtags-next-mark 'previous))
+(defvar ggtags-view-tag-history-mode-map
+ (let ((m (make-sparse-keymap)))
+ (define-key m "\M-n" 'next-error-no-select)
+ (define-key m "\M-p" 'previous-error-no-select)
+ (define-key m "q" (lambda () (interactive) (quit-window t)))
+ m))
+
+(define-derived-mode ggtags-view-tag-history-mode tabulated-list-mode "TagHist"
+ :abbrev-table nil :group 'ggtags)
+
(defun ggtags-view-tag-history ()
+ "Pop to a buffer listing visited locations from newest to oldest.
+The buffer is a next error buffer and works with standard
+commands `next-error' and `previous-error'.
+
+\\{ggtags-view-tag-history-mode-map}"
(interactive)
(and (ring-empty-p find-tag-marker-ring)
(user-error "Tag ring empty"))
@@ -1066,31 +1081,25 @@ Use \\[jump-to-register] to restore the search session."
(inhibit-read-only t))
(pop-to-buffer "*Tag Ring*")
(erase-buffer)
- (tabulated-list-mode)
+ (ggtags-view-tag-history-mode)
+ (setq next-error-function #'ggtags-view-tag-history-next-error
+ next-error-last-buffer (current-buffer))
(setq tabulated-list-entries
;; Use a function so that revert can work properly.
(lambda ()
(let ((counter (ring-length find-tag-marker-ring))
(elements (or (ring-elements find-tag-marker-ring)
(user-error "Tag ring empty")))
- (action
- (lambda (button) (interactive)
- (let ((m (button-get button 'marker)))
- (or (markerp m) (user-error "Marker dead"))
- (setq ggtags-tag-ring-index
- (ring-member find-tag-marker-ring m))
- (pop-to-buffer (marker-buffer m))
- (goto-char (marker-position m)))))
- (get-line
- (lambda (m)
- (with-current-buffer (marker-buffer m)
- (save-excursion
- (goto-char m)
- (buffer-substring (line-beginning-position)
- (line-end-position)))))))
+ (action (lambda (_button) (next-error 0)))
+ (get-line (lambda (m)
+ (with-current-buffer (marker-buffer m)
+ (save-excursion
+ (goto-char m)
+ (buffer-substring (line-beginning-position)
+ (line-end-position)))))))
(setq tabulated-list-format
`[("ID" ,(max (1+ (floor (log counter 10))) 2)
- (lambda (x y) (< (car x) (car y))))
+ car-less-than-car)
("Buffer" ,(max (cl-loop for m in elements
for b = (marker-buffer m)
maximize
@@ -1125,7 +1134,22 @@ Use \\[jump-to-register] to restore the search session."
elements))))
(setq tabulated-list-sort-key '("ID" . t))
(tabulated-list-print)
- (fit-window-to-buffer)))
+ (fit-window-to-buffer nil (floor (frame-height) 2))))
+
+(defun ggtags-view-tag-history-next-error (&optional arg reset)
+ (if (not reset)
+ (forward-button arg)
+ (goto-char (point-min))
+ (forward-button (if (button-at (point)) 0 1)))
+ (when (get-buffer-window)
+ (set-window-point (get-buffer-window) (point)))
+ (pcase (button-get (button-at (point)) 'marker)
+ ((and (pred markerp) m)
+ (if (eq (get-buffer-window) (selected-window))
+ (pop-to-buffer (marker-buffer m))
+ (switch-to-buffer (marker-buffer m)))
+ (goto-char (marker-position m)))
+ (_ (error "Dead marker"))))
(defun ggtags-global-exit-message-function (_process-status exit-status msg)
(setq ggtags-global-exit-status exit-status)
- [elpa] branch master updated (b8924f8 -> 3dc7169), Leo Liu, 2014/03/30
- [elpa] 03/14: Change ggtags-read-tag to completing-read when no default, Leo Liu, 2014/03/30
- [elpa] 02/14: Fix #12: Remove ggtags-completing-read-function, Leo Liu, 2014/03/30
- [elpa] 04/14: Fix ggtags-try-complete-tag to use ggtags-bounds-of-tag-function, Leo Liu, 2014/03/30
- [elpa] 05/14: Fix #42: Clear ggtags-project-root in non-file buffers, Leo Liu, 2014/03/30
- [elpa] 01/14: Enhance ggtags-view-tag-history to use next-/previous-error,
Leo Liu <=
- [elpa] 06/14: New user variable ggtags-global-use-color, Leo Liu, 2014/03/30
- [elpa] 08/14: Fix warning: Making variable buffer-local while let-bound!, Leo Liu, 2014/03/30
- [elpa] 10/14: Disable ggtags-navigation-mode at the right time, Leo Liu, 2014/03/30
- [elpa] 13/14: Fix #44: New variable ggtags-enable-navigation-keys, Leo Liu, 2014/03/30
- [elpa] 09/14: Use compilation-auto-jump in ggtags-global-filter, Leo Liu, 2014/03/30
- [elpa] 11/14: Rename ggtags-handle-single-match to ggtags-global-handle-exit, Leo Liu, 2014/03/30
- [elpa] 12/14: Fix ggtags-navigation-mode-abort when pop-tag-mark errs, Leo Liu, 2014/03/30
- [elpa] 14/14: Merge branch 'master' of github.com:leoliu/ggtags, Leo Liu, 2014/03/30
- [elpa] 07/14: Implement feature #43: Jump to match from search history, Leo Liu, 2014/03/30