emacsorphanage / helm-gtags

GNU GLOBAL helm interface
204 stars 31 forks source link

Is it currently possible to start looking for tags directly in helm windows? #123

Closed jacekmigacz closed 8 years ago

jacekmigacz commented 8 years ago

Let's say I'm calling helm-gtags-find-files (C-c P).

  1. I'm getting Find File: prompt in minibuffer.
  2. When I hit RETURN; helm lookup window shows up.
  3. When I find item I hit RETURN-RETURN to get there.

Is it possible to skip 1.) and 3.) ?

Thanks.

syohex commented 8 years ago

No. I suppose helm-mode is available for this purpose. However I think it is better to use helm completion for helm-gtags-find-file as default.

Do you want this feature for all commands, helm-gtags-find-tag, helm-gtags-find-rtag etc ?

jacekmigacz commented 8 years ago

What does it mean that helm-mode is available for this purpose? Is there any switch to make helm-gtags more helm`ish?

I'll try to present my point of view in slides below. helm-gtags

syohex commented 8 years ago

What does it mean that helm-mode is available for this purpose? Is there any switch to make helm-gtags more helm`ish?

TAB key

syohex commented 8 years ago

We can enable helm style completion only for helm-gtags-find-file with following patch.

diff --git a/helm-gtags.el b/helm-gtags.el
index f9d2c7b..40f254e 100644
--- a/helm-gtags.el
+++ b/helm-gtags.el
@@ -285,8 +285,14 @@ Always update if value of this variable is nil."
         (setq prompt (format "%s(default \"%s\") " prompt tagname)))
       (let ((completion-ignore-case helm-gtags-ignore-case)
             (completing-read-function 'completing-read-default))
-        (completing-read prompt comp-func nil nil nil
-                         'helm-gtags--completing-history tagname)))))
+        (if (eq type 'find-file)
+            (helm-comp-read prompt comp-func
+                            :history 'helm-gtags--completing-history
+                            :initial-input tagname
+                            :exec-when-only-one t
+                            :default tagname)
+          (completing-read prompt comp-func nil nil nil
+                           'helm-gtags--completing-history tagname))))))

 (defun helm-gtags--path-libpath-p (tagroot)
   (helm-aif (getenv "GTAGSLIBPATH")
jacekmigacz commented 8 years ago

Looking for files is much faster with patch applied.

Only issue I see is that, when you jump to one file and decide to jump to another, another try has input filled with value of first line of previous found file. I mean if previously found file (.c source) has include directive in the first line of cursor is on some include directive, then I have to clear input before performing another search. (with value of helm-gtags-use-input-at-cursor set to nil).

What I want to say is guessing input for helm-gtags-find-file is not necessary, because when I want to jump to file which name is under cursor I'd use helm-gtags-dwim.

Anyway thanks for help and what code snipped you pasted. I have some motivation and point when I can start to work on it on my own.