emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] scratch/isearch-show-toggles 37d169d 2/2: * lisp/isearch.e


From: Artur Malabarba
Subject: [Emacs-diffs] scratch/isearch-show-toggles 37d169d 2/2: * lisp/isearch.el: Display toggles and their keys
Date: Thu, 29 Oct 2015 00:08:20 +0000

branch: scratch/isearch-show-toggles
commit 37d169df4433be1869eac9c916e548b9bd66ff04
Author: Artur Malabarba <address@hidden>
Commit: Artur Malabarba <address@hidden>

    * lisp/isearch.el: Display toggles and their keys
    
    (isearch--describe-toggles): New function.
    (isearch-show-toggles): New user option.
    (isearch-message-prefix): Use them.
---
 lisp/isearch.el |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/lisp/isearch.el b/lisp/isearch.el
index 6ec5c7f..6327068 100644
--- a/lisp/isearch.el
+++ b/lisp/isearch.el
@@ -1583,6 +1583,30 @@ nil and a non-nil value of the option `search-invisible'
        "match invisible text"
      "match visible text")))
 
+(defcustom isearch-show-toggles t
+  "Non-nil means to list options above input prompt."
+  :type 'boolean
+  :version "25.1")
+
+(defun isearch--describe-toggles ()
+  "Return a propertized description of isearch toggles."
+  (let ((toggles
+         (concat
+          #("Toggles [M-s]:  " 0 9 (face minibuffer-prompt) 12 16 (face 
minibuffer-prompt))
+          (mapconcat (lambda (x) (format (propertize "[%s] %s %s" 'face 
'minibuffer-prompt)
+                                    (propertize (elt x 1) 'face 'default)
+                                    (capitalize (symbol-name (car x)))
+                                    (if (funcall (elt x 2))
+                                        (propertize "ON " 'face 'default) 
"OFF")))
+                     (reverse isearch--toggles)
+                     "  ")
+          "\n"))
+        (width (window-width (minibuffer-window))))
+    (if (> width (string-width toggles))
+        toggles
+      (replace-regexp-in-string "\\[[^[]*\\'" "\n"
+                                (substring toggles 0 width)))))
+
 
 ;; Word search
 
@@ -2592,8 +2616,9 @@ the word mode."
                        (concat " [" current-input-method-title "]: "))
                     ": ")
                   )))
-    (propertize (concat (upcase (substring m 0 1)) (substring m 1))
-               'face 'minibuffer-prompt)))
+    (concat (when isearch-show-toggles (isearch--describe-toggles))
+            (propertize (concat (upcase (substring m 0 1)) (substring m 1))
+                        'face 'minibuffer-prompt))))
 
 (defun isearch-message-suffix (&optional c-q-hack)
   (concat (if c-q-hack "^Q" "")



reply via email to

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