[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 07/18: Refactor out ggtags-include-file from ggtags-find-tag-dwim
From: |
Leo Liu |
Subject: |
[elpa] 07/18: Refactor out ggtags-include-file from ggtags-find-tag-dwim |
Date: |
Sat, 05 Apr 2014 01:25:15 +0000 |
leoliu pushed a commit to branch master
in repository elpa.
commit 828546825bac86b1ea29875f5e31c5d51f0db7ca
Author: Leo Liu <address@hidden>
Date: Wed Apr 2 08:44:44 2014 +0800
Refactor out ggtags-include-file from ggtags-find-tag-dwim
Do not move point to the beginning of line if ggtags-include-pattern
is a function otherwise it cannot access the value of point.
---
ggtags.el | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/ggtags.el b/ggtags.el
index 4acf610..dfe7a6e 100644
--- a/ggtags.el
+++ b/ggtags.el
@@ -129,7 +129,8 @@ automatically switches to 'global --single-update'."
(defcustom ggtags-include-pattern
'("^\\s-*#\\(?:include\\|import\\)\\s-*[\"<]\\(?:[./]*\\)?\\(.*?\\)[\">]" .
1)
"Pattern used to detect #include files.
-Value can be (REGEXP . SUB) or a function with no arguments."
+Value can be (REGEXP . SUB) or a function with no arguments.
+REGEXP should match from the beginning of line."
:type '(choice (const :tag "Disable" nil)
(cons regexp integer)
function)
@@ -761,6 +762,20 @@ Do nothing if GTAGS exceeds the oversize limit unless
FORCE."
(ggtags-check-project)
(ggtags-global-start (apply #'ggtags-global-build-command cmd args)))
+(defun ggtags-include-file ()
+ "Calculate the include file based on `ggtags-include-pattern'."
+ (pcase ggtags-include-pattern
+ (`nil nil)
+ ((pred functionp)
+ (funcall ggtags-include-pattern))
+ (`(,re . ,sub)
+ (save-excursion
+ (beginning-of-line)
+ (and (looking-at re) (match-string sub))))
+ (_ (warn "Invalid value for `ggtags-include-pattern':%s"
+ ggtags-include-pattern)
+ nil)))
+
;;;###autoload
(defun ggtags-find-tag-dwim (name &optional what)
"Find NAME by context.
@@ -771,14 +786,7 @@ the include file instead.
When called interactively with a prefix arg, always find
definition tags."
(interactive
- (let ((include (and (not current-prefix-arg)
- ggtags-include-pattern
- (save-excursion
- (beginning-of-line)
- (if (functionp ggtags-include-pattern)
- (funcall ggtags-include-pattern)
- (and (looking-at (car ggtags-include-pattern))
- (match-string (cdr
ggtags-include-pattern))))))))
+ (let ((include (and (not current-prefix-arg) (ggtags-include-file))))
(if include (list include 'include)
(list (ggtags-read-tag 'definition current-prefix-arg)
(and current-prefix-arg 'definition)))))
- [elpa] branch master updated (c5636ba -> 769f2f2), Leo Liu, 2014/04/04
- [elpa] 04/18: Add NEWS to README.rst for 0.8.0 and 0.8.1, Leo Liu, 2014/04/04
- [elpa] 02/18: New function ggtags-echo and use it, Leo Liu, 2014/04/04
- [elpa] 01/18: For #45: Fix popping up/down window for search with single match, Leo Liu, 2014/04/04
- [elpa] 03/18: Fix #45: Change default value of ggtags-auto-jump-to-match, Leo Liu, 2014/04/04
- [elpa] 06/18: Fix error in approximation to (line-number-at-pos (point-max)), Leo Liu, 2014/04/04
- [elpa] 05/18: New function ggtags-eldoc-function for eldoc support, Leo Liu, 2014/04/04
- [elpa] 08/18: Don't activate eldoc support by default, Leo Liu, 2014/04/04
- [elpa] 09/18: Fix multiple calls of ggtags-show-definition, Leo Liu, 2014/04/04
- [elpa] 10/18: Make ggtags-eldoc-function work better when no project root, Leo Liu, 2014/04/04
- [elpa] 07/18: Refactor out ggtags-include-file from ggtags-find-tag-dwim,
Leo Liu <=
- [elpa] 12/18: Make ggtags-use-project-gtagsconf work on remote projects, Leo Liu, 2014/04/04
- [elpa] 11/18: Revert "Fix ggtags-with-current-project to include GTAGSCONF", Leo Liu, 2014/04/04
- [elpa] 13/18: New macro ggtags-with-temp-message that reports execution time, Leo Liu, 2014/04/04
- [elpa] 14/18: Don't reply on excution order of filter and sentinel functions, Leo Liu, 2014/04/04
- [elpa] 15/18: Revert "Don't reply on excution order of filter and sentinel functions", Leo Liu, 2014/04/04
- [elpa] 16/18: Properly fix the bug by delaying compilation finish functions, Leo Liu, 2014/04/04
- [elpa] 17/18: Doc fixes and add NEWS for 0.8.2, Leo Liu, 2014/04/04
- [elpa] 18/18: Merge branch 'master' of github.com:leoliu/ggtags, Leo Liu, 2014/04/04