branch: elpa/helm
commit 36a6b50f325be94f30c6cf699ede042fa907c6b1
Author: Thierry Volpiatto <thie...@posteo.net>
Commit: Thierry Volpiatto <thie...@posteo.net>

    Generalize popup-info to helm-source
---
 helm-id-utils.el |  1 +
 helm-man.el      | 10 ++++------
 helm-source.el   | 10 +++++++++-
 helm-utils.el    |  4 ++--
 4 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/helm-id-utils.el b/helm-id-utils.el
index 215092b608..315ef22c8e 100644
--- a/helm-id-utils.el
+++ b/helm-id-utils.el
@@ -87,6 +87,7 @@ MacPorts to install id-utils, it should be `gid32'."
    (candidates-process :initform #'helm-gid-candidates-process)
    (filtered-candidate-transformer
     :initform #'helm-gid-filtered-candidate-transformer)
+   (popup-info :initform #'helm-grep-popup-info-fn)
    (candidate-number-limit :initform 99999)
    (action :initform (helm-make-actions
                       "Find File" 'helm-grep-action
diff --git a/helm-man.el b/helm-man.el
index 07fc1024e5..6d20314d18 100644
--- a/helm-man.el
+++ b/helm-man.el
@@ -92,16 +92,14 @@ source.")
     (setq helm-man--pages (mapcar 'car woman-topic-all-completions)))
   (helm-init-candidates-in-buffer 'global helm-man--pages))
 
-(defun helm-man-popup-info (name)
-  (let ((output (shell-command-to-string (format "man -f '%s'" name))))
-    (when (string-match (format "\\(%s ?([^(]+)\\) *- ?\\(.*\\)\n" name)
+(defun helm-man-popup-info (candidate)
+  (let ((output (shell-command-to-string (format "man -f '%s'" candidate))))
+    (when (string-match (format "\\(%s ?([^(]+)\\) *- ?\\(.*\\)\n" candidate)
                         output)
       (match-string 2 output))))
 
 (defclass helm-man-pages-class (helm-source-in-buffer)
-  ((helm-popup-info
-    :initarg :helm-popup-info
-    :initform #'helm-man-popup-info)))
+  ((popup-info :initform #'helm-man-popup-info)))
 
 ;;;###autoload
 (defun helm-man-woman (arg)
diff --git a/helm-source.el b/helm-source.el
index d5586dc46e..ca0072f68d 100644
--- a/helm-source.el
+++ b/helm-source.el
@@ -718,7 +718,15 @@
     :initform 'helm
     :custom symbol
     :documentation
-    "  The current source group, default to `helm' when not specified."))
+    "  The current source group, default to `helm' when not specified.")
+   (popup-info
+    :initarg :popup-info
+    :initform nil
+    :custom function
+    :documentation
+    "  A function that show infos in a popup on the selected candidate.
+  This happen when `helm-popup-tip-mode' is enabled.
+  The function is called on candidate."))
 
   "Main interface to define helm sources."
   :abstract t)
diff --git a/helm-utils.el b/helm-utils.el
index 936a81db37..923ce8885d 100644
--- a/helm-utils.el
+++ b/helm-utils.el
@@ -1039,7 +1039,7 @@ Assume regexp is a pcre based regexp."
   (when helm--maybe-show-help-echo-overlay
     (delete-overlay helm--maybe-show-help-echo-overlay))
   (let* ((src (helm-get-current-source))
-         (popup-info-fn (assoc-default 'helm-popup-info src)))
+         (popup-info-fn (assoc-default 'popup-info src)))
     (when (and helm-alive-p
                helm-popup-tip-mode
                (or (member (assoc-default 'name src)
@@ -1068,7 +1068,7 @@ Assume regexp is a pcre based regexp."
     "Show additional informations in a popup tip at end of line.
 
 When the mode is enabled, popup showup either when the source is one of
-`helm-sources-using-help-echo-popup' or the source has a `helm-popup-info'
+`helm-sources-using-help-echo-popup' or the source has a `popup-info'
 attribute which define a specific function for this source to fetch infos on
 candidate."
   :global t

Reply via email to