branch: elpa/helm commit 0c8cec57b64e31661df75676d1e96dc7c28d6938 Author: Thierry Volpiatto <thie...@posteo.net> Commit: Thierry Volpiatto <thie...@posteo.net>
New function to get longest cand and use it --- helm-command.el | 3 +-- helm-core.el | 8 ++++++++ helm-elisp.el | 3 +-- helm-mode.el | 16 +++------------- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/helm-command.el b/helm-command.el index f0e922f379..c5bb1bf34e 100644 --- a/helm-command.el +++ b/helm-command.el @@ -135,8 +135,7 @@ fuzzy matching is running its own sort function with a different algorithm." (with-helm-current-buffer (cl-loop with max-len = (when helm-M-x-show-short-doc - (buffer-local-value 'helm-candidate-buffer-longest-len - (get-buffer (helm-candidate-buffer)))) + (helm-in-buffer-get-longest-candidate)) with local-map = (helm-M-x-current-mode-map-alist) for cand in candidates for local-key = (car (rassq cand local-map)) diff --git a/helm-core.el b/helm-core.el index 0e1d858cc8..a701102588 100644 --- a/helm-core.el +++ b/helm-core.el @@ -6848,6 +6848,14 @@ It is a local variable set from `helm-init-candidates-in-buffer' in Allow getting the longest length of initial candidates in transformers without looping again through the whole list.") +(defsubst helm-in-buffer-get-longest-candidate () + "Return the longest candidate recorded in `helm-candidate-buffer'." + (helm-aif (helm-candidate-buffer) + (buffer-local-value + 'helm-candidate-buffer-longest-len + (get-buffer it)) + 0)) + (defun helm-init-candidates-in-buffer (buffer-spec data) "Register BUFFER-SPEC with DATA for a helm candidates-in-buffer session. diff --git a/helm-elisp.el b/helm-elisp.el index 9285f82658..3350e5fbd4 100644 --- a/helm-elisp.el +++ b/helm-elisp.el @@ -540,8 +540,7 @@ is only used to test DEFAULT." (defun helm-apropos-short-doc-transformer (candidates _source) (if helm-apropos-show-short-doc - (cl-loop with max-len = (buffer-local-value 'helm-candidate-buffer-longest-len - (get-buffer (helm-candidate-buffer))) + (cl-loop with max-len = (helm-in-buffer-get-longest-candidate) for cand in candidates for doc = (helm-get-first-line-documentation (intern-soft cand)) collect (cons (format "%s%s%s" diff --git a/helm-mode.el b/helm-mode.el index 84c796447f..db4a671fbb 100644 --- a/helm-mode.el +++ b/helm-mode.el @@ -1021,9 +1021,7 @@ command. The command should be specified as a string and the category as a symb (propertize (symbol-name major-mode) 'face 'font-lock-warning-face))) (size (helm-buffer-size buf)) - (len (buffer-local-value - 'helm-candidate-buffer-longest-len - (helm-candidate-buffer))) + (len (helm-in-buffer-get-longest-candidate)) (suffix (format "%s%s%s%s%s(in %s)" (make-string (1+ (- len (length comp))) ? ) (propertize size @@ -1070,13 +1068,7 @@ is used." ;; style and a candidate buffer remains (with its local vars ;; still available). (max-len (and (memq helm-completion-style '(helm helm-fuzzy)) - (buffer-local-value - 'helm-candidate-buffer-longest-len - (get-buffer (or (helm-candidate-buffer) - ;; Return 0 in this case and don't - ;; fail with a nil arg with - ;; get-buffer. - helm-buffer))))) + (helm-in-buffer-get-longest-candidate))) (sep (if (or (null max-len) (zerop max-len)) " --" ; Default separator. (make-string (- max-len (length comp)) ? ))) @@ -1114,9 +1106,7 @@ is used." (let* ((sym (intern-soft comp)) (desc (helm-aand (package-get-descriptor sym) (package-desc-summary it))) - (sep (make-string (1+ (- (buffer-local-value - 'helm-candidate-buffer-longest-len - (get-buffer (helm-candidate-buffer))) + (sep (make-string (1+ (- (helm-in-buffer-get-longest-candidate) (length comp))) ? ))) (list comp