emacs-helm / helm

Emacs incremental completion and selection narrowing framework
https://emacs-helm.github.io/helm/
GNU General Public License v3.0
3.36k stars 390 forks source link

Hint path in helm-gid when multiple files have the same name #1072

Closed metaturso closed 8 years ago

metaturso commented 9 years ago

When using certain libraries or conventions it's possible that multiple files end up having the same name as they are all defined in different directories, making it impossible to identify a good candidate. See the image below for an example of this scenario.

It would be nice if helm-gid hinted to the path name, or allowed the base name to be toggled with C-] similarly to how the same key behaves in other helm buffers.

Thanks.

thierryvolpiatto commented 9 years ago

Andrea Turso notifications@github.com writes:

When using certain libraries or conventions it's possible that multiple files end up having the same name as they are all defined in different directories.

You can move your mouse cursor above the name of the file.

Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997

metaturso commented 9 years ago

Yes @thierryvolpiatto, you're right, I get a tooltip with the full path to the file when I hover its name.

This might do for the time being, but I would really prefer to discern the candidates directly in the buffer?

thierryvolpiatto commented 8 years ago

This is not possible actually for async sources because we don't have a redisplay function actually (i.e using C-] would call again the whole grep, ag, or gid process). We need a redisplay function for this that redisplay the helm buffer with the actual results without recomputing them (we have it for all source types but async). However if you use the popup package, an alternative is possible, showing in a popup the path of candidate at end of line:

(defvar helm--show-help-echo-timer nil)
(defun helm--show-help-echo ()
  (when helm--show-help-echo-timer
    (cancel-timer helm--show-help-echo-timer)
    (setq helm--show-help-echo-timer nil))
  (setq helm--show-help-echo-timer
        (run-with-idle-timer
         1 nil
         (lambda ()
           (with-helm-window
             (helm-aif (get-text-property (point-at-bol) 'help-echo)
                 (popup-tip (concat " " it) :around nil :point (point-at-eol))))))))
(add-hook 'helm-move-selection-after-hook 'helm--show-help-echo)
thierryvolpiatto commented 8 years ago

Here the code slightly improved:

(defvar helm/show-help-echo-timer nil)
(defvar helm/sources-using-help-echo-popup '("Moccur" "Imenu in all buffers"
                                             "Ack-grep" "AG" "Gid" "Git-Grep"))
(defun helm/show-help-echo ()
  (when helm/show-help-echo-timer
    (cancel-timer helm/show-help-echo-timer)
    (setq helm/show-help-echo-timer nil))
  (when (and helm-alive-p
             (member (assoc-default 'name (helm-get-current-source))
                     helm/sources-using-help-echo-popup))
    (setq helm/show-help-echo-timer
          (run-with-idle-timer
           1 nil
           (lambda ()
             (with-helm-window
               (helm-aif (get-text-property (point-at-bol) 'help-echo)
                   (popup-tip (concat " " (abbreviate-file-name it))
                              :around nil
                              :point (save-excursion
                                       (end-of-visual-line) (point))))))))))
(add-hook 'helm-move-selection-after-hook 'helm/show-help-echo)
(add-hook 'helm-cleanup-hook (lambda ()
                               (when helm/show-help-echo-timer
                                 (cancel-timer helm/show-help-echo-timer)
                                 (setq helm/show-help-echo-timer nil))))
metaturso commented 8 years ago

Hi Thierry, thanks for your patches. I'll test your latest after work and let you know how it goes.

thierryvolpiatto commented 8 years ago

Typo: Read "Ack-Grep" and not "Ack-grep" to have the popup tip in ack-grep.

thierryvolpiatto commented 8 years ago

Will probably provide this as a mode soon.

thierryvolpiatto commented 8 years ago

This can now be enabled with (helm-popup-tip-mode 1). popup library as dependency is now required by helm.