[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/helm 8d208ac923 2/2: Use new function helm-in-buffer-make-
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/helm 8d208ac923 2/2: Use new function helm-in-buffer-make-separator to avoid repetitions |
Date: |
Tue, 26 Sep 2023 16:00:40 -0400 (EDT) |
branch: elpa/helm
commit 8d208ac923bcba79c7c45e83b53c90ddf257e5d0
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Use new function helm-in-buffer-make-separator to avoid repetitions
---
helm-core.el | 11 +++++++++++
helm-elisp.el | 2 +-
helm-mode.el | 22 ++++++----------------
3 files changed, 18 insertions(+), 17 deletions(-)
diff --git a/helm-core.el b/helm-core.el
index 452dc0579a..af785fb0cd 100644
--- a/helm-core.el
+++ b/helm-core.el
@@ -6885,6 +6885,17 @@ It is useful to align extra informations after
candidates in `helm-buffer'.")
(get-buffer it))
0))
+(defun helm-in-buffer-make-separator (cand &optional longest)
+ "Create a separator to align candidates in `helm-source-in-buffer'.
+Longest candidate should have been modified at initialization of
+source, otherwise LONGEST can be used to specify longest candidate."
+ (let ((lgst (or longest (helm-in-buffer-get-longest-candidate)))
+ (len (length cand)))
+ (make-string (1+ (if (> lgst len)
+ (- lgst (length cand))
+ 0))
+ ? )))
+
(defun helm-init-candidates-in-buffer (buffer-spec data &optional
force-longest)
"Register BUFFER-SPEC with DATA for a helm candidates-in-buffer session.
diff --git a/helm-elisp.el b/helm-elisp.el
index 92d67d0c06..ce0fb5f1c5 100644
--- a/helm-elisp.el
+++ b/helm-elisp.el
@@ -943,7 +943,7 @@ description change you can reset the caches with a prefix
arg."
for c in candidates
for count from 0
for bn = (helm-basename c 2)
- for sep = (make-string (1+ (- lgst (length bn))) ? )
+ for sep = (helm-in-buffer-make-separator bn lgst)
for path = (or (assoc-default bn
helm--locate-library-cache)
(let ((p (find-library-name bn)))
(push (cons bn p)
helm--locate-library-cache)
diff --git a/helm-mode.el b/helm-mode.el
index aa3b88e928..a4eee8e7f7 100644
--- a/helm-mode.el
+++ b/helm-mode.el
@@ -1145,7 +1145,7 @@ is used."
(helm-in-buffer-get-longest-candidate)))
(sep (if (or (null max-len) (zerop max-len))
" --" ; Default separator.
- (make-string (1+ (- max-len (length comp))) ? )))
+ (helm-in-buffer-make-separator comp max-len)))
(doc (ignore-errors
(helm-get-first-line-documentation sym)))
(symbol-class (help--symbol-class sym))
@@ -1193,9 +1193,7 @@ is used."
(desc (if built-in
(aref (assoc-default sym package--builtins) 2)
(and id (package-desc-summary id))))
- (sep (make-string (1+ (- (helm-in-buffer-get-longest-candidate)
- (length comp)))
- ? )))
+ (sep (helm-in-buffer-make-separator comp)))
(list comp
(propertize
(if status
@@ -1210,9 +1208,7 @@ is used."
(defun helm-completion-theme-affixation (_completions)
(lambda (comp)
(let* ((sym (intern-soft comp))
- (sep (make-string (1+ (- (helm-in-buffer-get-longest-candidate)
- (length comp)))
- ? ))
+ (sep (helm-in-buffer-make-separator comp))
(doc (if (custom-theme-p sym)
(helm-get-first-line-documentation sym)
(helm--get-theme-doc-1 sym))))
@@ -1257,9 +1253,7 @@ is used."
(let ((doc (with-output-to-string
(with-current-buffer standard-output
(print-coding-system-briefly (intern comp) 'tightly))))
- (sep (make-string (1+ (- (helm-in-buffer-get-longest-candidate)
- (length comp)))
- ? )))
+ (sep (helm-in-buffer-make-separator comp)))
(list comp "" (helm-aand (replace-regexp-in-string "^ *" "" doc)
(replace-regexp-in-string "[\n]" "" it)
(propertize it 'face 'helm-completions-detailed)
@@ -1267,9 +1261,7 @@ is used."
(defun helm-completion-color-affixation (_comps)
(lambda (comp)
- (let ((sep (make-string (1+ (- (helm-in-buffer-get-longest-candidate)
- (length comp)))
- ? ))
+ (let ((sep (helm-in-buffer-make-separator comp))
(rgb (condition-case nil
(helm-acase comp
("foreground at point" (with-helm-current-buffer
@@ -1293,9 +1285,7 @@ is used."
;; behavior of find-library-include-other-files remove them for the benefit
;; of everybody.
(unless (string-match "\\(\\.elc\\|/\\)\\'" comp)
- (let* ((sep (make-string (1+ (- (helm-in-buffer-get-longest-candidate)
- (length comp)))
- ? ))
+ (let* ((sep (helm-in-buffer-make-separator comp))
(path (or (assoc-default comp helm--locate-library-cache)
(let ((p (find-library-name comp)))
(push (cons comp p) helm--locate-library-cache)