emacs-diffs
[Top][All Lists]
Advanced

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

feature/completions-customs e28309ce05: Add two new options for completi


From: Jimmy Aguilar Mena
Subject: feature/completions-customs e28309ce05: Add two new options for completions.
Date: Fri, 11 Mar 2022 18:57:59 -0500 (EST)

branch: feature/completions-customs
commit e28309ce053be8736176109755cb492fea338b20
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>

    Add two new options for completions.
    
    * doc/emacs/mini.texi (completion-lazy-count):
    (completion-header-text-property-list) : New customs
    
    Updated NEWS and manual.
---
 doc/emacs/mini.texi | 12 ++++++++++++
 etc/NEWS            | 10 ++++++++++
 lisp/minibuffer.el  | 30 ++++++++++++++++++++++++++----
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 7224c48613..769acbcdd5 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -667,6 +667,18 @@ control of the Completion window display properties you 
can use
 Alists,,Action Alists for Buffer Display, elisp, The Emacs Lisp
 Reference Manual}).
 
+@vindex completion-lazy-count
+@vindex completion-header-text-property-list
+  When the boolean variable @code{completion-lazy-count} is
+non-@code{nil} the completions header line shows the total number of
+completion candidates.  With the text property list
+@code{completion-header-text-property-list} (@pxref{Property
+Lists,,Property Lists, elisp, The Emacs Lisp Reference Manual}) the
+user can specify some text properties to the completions header line.
+Some useful values may be @code{face}, @code{cursor-intangible} or
+@code{invisible} (@pxref{Special Properties,,Properties with Special
+Meanings, elisp, The Emacs Lisp Reference Manual}).
+
 @vindex completions-highlight-mode
 When the mode @code{completions-highlight-mode} is active the candidate
 under the cursor is highlighted when the completion window is
diff --git a/etc/NEWS b/etc/NEWS
index 9ea6512dca..041d3c9d19 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -567,11 +567,21 @@ some completion is made.
 *** New user option 'completions-max-height'.
 This option limits the height of the "*Completions*" buffer.
 
++++
+*** New option 'completion-header-text-property-list'
+List of text properties to add to the header line of completions.
+
++++
+*** New option 'completion-lazy-count'
+When non-nil the completions header line shows the total number of
+completion candidates.
+
 +++
 *** New mode 'completions-highlight-mode'.
 This mode highlights the current candidate in the *Completions* buffer
 with the 'completions-highlight' face.
 
+
 ** Isearch and Replace
 
 +++
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 9ac18f8df9..1768673bcb 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1873,6 +1873,20 @@ completions."
   :type 'boolean
   :version "28.1")
 
+(defcustom completion-header-text-property-list nil
+  "List of text properties to add to the header line of completions.
+For example you can change the header color to red setting this
+to: `(face (:foreground ``red'')).  Some useful properties may be
+`cursor-intangible' or `invisible'.  See Info node `(elisp) Special
+Properties'."
+  :type 'plist
+  :version "29.1")
+
+(defcustom completion-lazy-count nil
+  "When non-nil, display the total number of candidates in the completions 
header."
+  :type 'boolean
+  :version "29.1")
+
 (defun completion--insert-strings (strings &optional group-fun)
   "Insert a list of STRINGS into the current buffer.
 The candidate strings are inserted into the buffer depending on the
@@ -2135,10 +2149,18 @@ candidates."
 
     (with-current-buffer standard-output
       (goto-char (point-max))
-      (if (null completions)
-          (insert "There are no possible completions of what you have typed.")
-        (insert "Possible completions are:\n")
-        (completion--insert-strings completions group-fun))))
+      (if completions
+          (let ((start (point))
+                (text (concat
+                       "Possible completions are"
+                       (if completion-lazy-count
+                           (format " (%s)" (length completions)))
+                       ":\n")))
+            (insert text)
+            (when completion-header-text-property-list
+              (add-text-properties start (point) 
completion-header-text-property-list))
+            (completion--insert-strings completions group-fun))
+        (insert "There are no possible completions of what you have typed."))))
 
   (run-hooks 'completion-setup-hook)
   nil)



reply via email to

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