aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJohan Claesson <[email protected]>2016-05-22 17:01:40 +0200
committerDan Gudmundsson <[email protected]>2016-05-23 12:02:56 +0200
commitd24d7c921cc7a93fa0e80982ab8d2c00bac6b8b0 (patch)
tree5d57814525811c2553a884b831a19abf4006d0ab /lib
parent6aeb091fd69ad2fcb7cb087822cf51ff4acb1a1a (diff)
downloadotp-d24d7c921cc7a93fa0e80982ab8d2c00bac6b8b0.tar.gz
otp-d24d7c921cc7a93fa0e80982ab8d2c00bac6b8b0.tar.bz2
otp-d24d7c921cc7a93fa0e80982ab8d2c00bac6b8b0.zip
Let find-tag visit definitions in right order
The right order is defined by find-tag-tag-order which is a list of predicate functions. Tags matched by the first function shall be visited first. After that tags matched by the seconds function shall be visited and so on. Previous behavior was to visit tags that match any of the functions in the order they appear in the TAGS file. Reported by Dan Gudmundsson.
Diffstat (limited to 'lib')
-rw-r--r--lib/tools/emacs/erlang.el51
1 files changed, 18 insertions, 33 deletions
diff --git a/lib/tools/emacs/erlang.el b/lib/tools/emacs/erlang.el
index aff2c4b2c9..b808987e6e 100644
--- a/lib/tools/emacs/erlang.el
+++ b/lib/tools/emacs/erlang.el
@@ -4661,9 +4661,25 @@ Tags can be given on the forms `tag', `module:', `module:tag'."
(set (make-local-variable 'find-tag-regexp-search-function)
'erlang-tags-regexp-search-forward)
(set (make-local-variable 'find-tag-tag-order)
- '(erlang-tag-match-module-p))
+ (mapcar #'erlang-make-order-function-aware-of-modules
+ erlang-tags-orig-tag-order))
(set (make-local-variable 'find-tag-regexp-tag-order)
- '(erlang-tag-match-module-regexp-p))))
+ (mapcar #'erlang-make-order-function-aware-of-modules
+ erlang-tags-orig-regexp-tag-order))))
+
+(defun erlang-make-order-function-aware-of-modules (f)
+ `(lambda (tag)
+ (let (mod)
+ (when (string-match ":" tag)
+ (setq mod (substring tag 0 (match-beginning 0)))
+ (setq tag (substring tag (match-end 0) nil)))
+ (and (funcall ',f tag)
+ (or (null mod)
+ (erlang-tag-at-point-match-module-p mod))))))
+
+(defun erlang-tag-at-point-match-module-p (mod)
+ (string-equal mod (erlang-get-module-from-file-name
+ (funcall (symbol-function 'file-of-tag)))))
(defun erlang-tags-remove-module-check ()
@@ -4740,37 +4756,6 @@ for a tag on the form `module:tag'."
(funcall erlang-tags-orig-regexp-search-function
tag bound noerror count)))
-
-;; t if point is at a tag line that matches TAG, containing
-;; module information. Assumes that all other order functions
-;; are stored in `erlang-tags-orig-[regex]-tag-order'.
-
-(defun erlang-tag-match-module-p (tag)
- (erlang-tag-match-module-common-p tag erlang-tags-orig-tag-order))
-
-(defun erlang-tag-match-module-regexp-p (tag)
- (erlang-tag-match-module-common-p tag erlang-tags-orig-regexp-tag-order))
-
-(defun erlang-tag-match-module-common-p (tag order)
- (let ((mod nil)
- (found nil))
- (if (string-match ":" tag)
- (progn
- (setq mod (substring tag 0 (match-beginning 0)))
- (setq tag (substring tag (match-end 0) nil))))
- (while (and order (not found))
- (setq found
- (and (not (memq (car order)
- '(erlang-tag-match-module-p
- erlang-tag-match-module-regexp-p)))
- (funcall (car order) tag)))
- (setq order (cdr order)))
- (and found
- (or (null mod)
- (string= mod (erlang-get-module-from-file-name
- (funcall (symbol-function 'file-of-tag))))))))
-
-
;;; Tags completion, Emacs 19 `etags' specific.
;;;
;;; The basic idea is to create a second completion table `erlang-tags-