summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2016-11-29 08:21:02 +0100
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2016-11-29 08:21:02 +0100
commite7d045dcce22d4fbda233c3b4d51ee6f486d4480 (patch)
treee3965d371b7c65efeb76200b285384c8315a5230
parenta0ddb65ce88b6220e6d771b5b6f6645d137d7d15 (diff)
Improve loop in helm-etags-action-goto.
* helm-tags.el (helm-etags--file-from-tag): New. (helm-etags-action-goto): Use it.
-rw-r--r--helm-tags.el27
1 files changed, 12 insertions, 15 deletions
diff --git a/helm-tags.el b/helm-tags.el
index 0afe5669..b81eb18c 100644
--- a/helm-tags.el
+++ b/helm-tags.el
@@ -250,27 +250,24 @@ If no entry in cache, create one."
(defvar find-tag-marker-ring)
+(defsubst helm-etags--file-from-tag (fname)
+ (cl-loop for ext in
+ (cons "" (remove "" tags-compression-info-list))
+ for file = (concat fname ext)
+ when (file-exists-p file)
+ return file))
+
(defun helm-etags-action-goto (switcher candidate)
"Helm default action to jump to an etags entry in other window."
(require 'etags)
(helm-log-run-hook 'helm-goto-line-before-hook)
- ;; If interested in compressed-files, search files with extensions.
(let* ((split (helm-grep-split-line candidate))
- (file-search-extensions (if auto-compression-mode
- tags-compression-info-list
- '("")))
(fname (cl-loop for tagf being the hash-keys of helm-etags-cache
- for f = (expand-file-name
- (car split) (file-name-directory tagf))
-
- ;; search the file with each possible extension
- do (while (and (not (file-exists-p f)) file-search-extensions)
- (if (not (file-exists-p (concat f (car file-search-extensions))))
- (setq file-search-extensions (cdr file-search-extensions))
- (setq f (concat f (car file-search-extensions)))))
-
- when (file-exists-p f)
- return f))
+ for f = (expand-file-name
+ (car split) (file-name-directory tagf))
+ ;; Try to find an existing file, possibly compressed.
+ when (helm-etags--file-from-tag f)
+ return it))
(elm (cl-caddr split))
(linum (string-to-number (cadr split))))
(if (null fname)