emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master a20c196 336/399: counsel.el (counsel-set-variable): Better


From: Oleh Krehel
Subject: [elpa] master a20c196 336/399: counsel.el (counsel-set-variable): Better annotations for options
Date: Sat, 20 Jul 2019 14:57:52 -0400 (EDT)

branch: master
commit a20c1961d7c2c57eac17c3e9cea544737a395399
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    counsel.el (counsel-set-variable): Better annotations for options
    
    * counsel.el (counsel--setq-doconst): If the option is e.g.
    
        (const :tag "Dotfiles and Lockfiles" "\\(?:\\`\\|[/\\]\\)\\(?:[#.]\\)")
    
    Then display:
    
        Dotfiles and Lockfiles: \(?:\`\|[/\]\)\(?:[#.]\)
    
    Instead of previous:
    
        \\(?:\\`\\|[/\\]\\)\\(?:[#.]\\)
    
    Also, if the option's value is nil, but a :tag is present, display the
    option.
---
 counsel.el | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/counsel.el b/counsel.el
index 34f3fc1..fb36933 100644
--- a/counsel.el
+++ b/counsel.el
@@ -628,15 +628,19 @@ to `ivy-highlight-face'."
 (defun counsel--setq-doconst (x)
   "Return a cons of description and value for X.
 X is an item of a radio- or choice-type defcustom."
-  (let (y)
-    (when (and (listp x)
-               (consp (setq y (last x))))
-      (unless (equal y '(function))
-        (setq x (car y))
-        (cons (prin1-to-string x)
-              (if (symbolp x)
-                  (list 'quote x)
-                x))))))
+  (when (listp x)
+    (let ((v (car-safe (last x)))
+          (tag (and (eq (car x) 'const)
+                    (setq tag (plist-get (cdr x) :tag)))))
+      (when (and (or v tag) (not (eq v 'function)))
+        (cons
+         (concat
+          (when tag
+            (concat tag ": "))
+          (if (stringp v) v (prin1-to-string v)))
+         (if (symbolp v)
+             (list 'quote v)
+           v))))))
 
 (declare-function lv-message "ext:lv")
 (declare-function lv-delete-window "ext:lv")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]