branch: master
commit 2b8d33f3284c4af2011a9d30799cdb6be8fcf4f5
Author: Leo Liu <[email protected]>
Commit: Leo Liu <[email protected]>
Handle invalid history match in ggtags-global-filter
by jumping to first error instead.
For example when a history match is set on the second match of all
matches and the search later turns up only single match, ggtags will
fail to jump to match. To make things worse ggtags-global-handle-exit
will kill the *ggtags-global* buffer leaving users with no opportunity
to move to a valid match.
---
ggtags.el | 26 +++++++++++++++-----------
1 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/ggtags.el b/ggtags.el
index 09e3e63..7d53b86 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -3,7 +3,7 @@
;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
;; Author: Leo Liu <[email protected]>
-;; Version: 0.8.10
+;; Version: 0.8.11
;; Keywords: tools, convenience
;; Created: 2013-01-29
;; URL: https://github.com/leoliu/ggtags
@@ -1623,19 +1623,23 @@ commands `next-error' and `previous-error'.
ggtags-auto-jump-to-match-target))
(ggtags-forward-to-line ggtags-auto-jump-to-match-target)
(setq-local ggtags-auto-jump-to-match-target nil)
- ;;
- ;; Can't call `compile-goto-error' here becuase
+ (ggtags-delay-finish-functions
+ (with-display-buffer-no-window
+ (condition-case nil
+ (let ((compilation-auto-jump-to-first-error t))
+ (compilation-auto-jump (current-buffer) (point)))
+ (error (message "\
+ggtags: history match invalid, jump to first error instead")
+ (first-error)))))
;; `compilation-filter' restores point and as a result commands
;; dependent on point such as `ggtags-navigation-next-file' and
;; `ggtags-navigation-previous-file' fail to work.
- (run-with-idle-timer 0 nil (lambda (buf pt)
- (and (buffer-live-p buf)
- (with-current-buffer buf
- (ggtags-delay-finish-functions
- (let
((compilation-auto-jump-to-first-error t))
- (with-display-buffer-no-window
- (compilation-auto-jump buf
pt)))))))
- (current-buffer) (point)))
+ (run-with-idle-timer
+ 0 nil
+ (lambda (buf pt)
+ (and (buffer-live-p buf)
+ (with-current-buffer buf (goto-char pt))))
+ (current-buffer) (point)))
(make-local-variable 'ggtags-global-large-output)
(when (> ggtags-global-output-lines ggtags-global-large-output)
(cl-incf ggtags-global-large-output 500)