summaryrefslogtreecommitdiff
path: root/helm-tags.el
diff options
context:
space:
mode:
authorThierry Volpiatto <thierry.volpiatto@gmail.com>2015-09-13 09:46:17 +0200
committerThierry Volpiatto <thierry.volpiatto@gmail.com>2015-09-13 09:46:17 +0200
commit64072f0facec9027144f636102582b76054d7fd6 (patch)
tree962a21ed52a51f20f037a70bba48d1002806b626 /helm-tags.el
parent6eb312b4ad96cc634b65813ec1fd24af072b6462 (diff)
Fix jumping to candidates in etags (#1164).
* helm-tags.el (helm-etags-create-buffer): Now calculate line number and include it. (helm-etags-split-line): Same as helm-grep-split-line (should use it instead). (helm-etags-build-source): Fix match-part according to new split. (helm-etags-action-goto): Jump to candidate according to line number.
Diffstat (limited to 'helm-tags.el')
-rw-r--r--helm-tags.el27
1 files changed, 15 insertions, 12 deletions
diff --git a/helm-tags.el b/helm-tags.el
index aa17a5d1..7ee76978 100644
--- a/helm-tags.el
+++ b/helm-tags.el
@@ -170,17 +170,19 @@ If not found in CURRENT-DIR search in upper directory."
with fname
with cand
for i in split for count from 0
- for elm = (unless (string-match "^\x0c" i)
- (helm-aif (string-match "\177" i)
+ for elm = (unless (string-match "^\x0c" i) ;; "^L"
+ (helm-aif (string-match "\177" i) ;; "^?"
(substring i 0 it)
i))
+ for linum = (when (string-match "[0-9]+,?[0-9]*$" i)
+ (car (split-string (match-string 0 i) ",")))
do (cond ((and elm (string-match "^\\([^,]+\\),[0-9]+$" elm))
(setq fname (propertize (match-string 1 elm)
'face 'helm-etags-file)))
- (elm (setq cand (concat fname ": " elm)))
+ (elm (setq cand (format "%s:%s:%s" fname linum elm)))
(t (setq cand nil)))
when cand do (progn
- (insert (concat cand "\n"))
+ (insert (propertize (concat cand "\n") 'linum linum))
(progress-reporter-update progress-reporter count)))))
(defun helm-etags-init ()
@@ -206,9 +208,9 @@ If no entry in cache, create one."
(cons f (helm-etags-mtime f))))))))))
(defun helm-etags-split-line (line)
- (let ((regexp "\\`\\([[:lower:][:upper:]]?:?.*?\\): \\(.*\\)"))
+ (let ((regexp "^\\([[:lower:][:upper:]]?:?.*?\\):\\([0-9]+\\):\\(.*\\)"))
(when (string-match regexp line)
- (cl-loop for n from 1 to 2 collect (match-string n line)))))
+ (cl-loop for n from 1 to 3 collect (match-string n line)))))
(defvar helm-source-etags-select nil
"Helm source for Etags.")
@@ -223,8 +225,8 @@ If no entry in cache, create one."
;; and not the filename.
(cl-ecase helm-etags-match-part-only
(endtag (cadr (split-string
- (cadr (helm-etags-split-line candidate)))))
- (tag (cadr (helm-etags-split-line candidate)))
+ (cl-caddr (helm-etags-split-line candidate)))))
+ (tag (cl-caddr (helm-etags-split-line candidate)))
(all candidate)))
:help-message 'helm-etags-help-message
:keymap helm-etags-map
@@ -255,14 +257,15 @@ If no entry in cache, create one."
(car split) (file-name-directory tagf))
when (file-exists-p f)
return f))
- (elm (cadr split)))
+ (elm (cl-caddr split))
+ (linum (string-to-number (cadr split))))
(if (null fname)
(error "file %s not found" fname)
(ring-insert find-tag-marker-ring (point-marker))
(funcall switcher fname)
- (goto-char (point-min))
- (search-forward elm nil t)
- (goto-char (match-beginning 0)))))
+ (helm-goto-line linum t)
+ (when (search-forward elm nil t)
+ (goto-char (match-beginning 0))))))
(defun helm-etags-mtime (file)
"Last modification time of etags tag FILE."