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

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

[elpa] externals/orderless 94d52640d4 145/204: Change docstring interfac


From: ELPA Syncer
Subject: [elpa] externals/orderless 94d52640d4 145/204: Change docstring interface for orderless-define-completion-style
Date: Tue, 11 Jan 2022 12:58:25 -0500 (EST)

branch: externals/orderless
commit 94d52640d4d8eed1a412907a4e4b6d4dea990b7f
Author: Omar Antolín <omar.antolin@gmail.com>
Commit: Omar Antolín <omar.antolin@gmail.com>

    Change docstring interface for orderless-define-completion-style
---
 orderless.el | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/orderless.el b/orderless.el
index b4ec2fc838..ab6b0ed1de 100644
--- a/orderless.el
+++ b/orderless.el
@@ -515,7 +515,7 @@ This function is part of the `orderless' completion style."
                "Completion of multiple components, in any order."))
 
 (defmacro orderless-define-completion-style
-    (name docstrings &rest configuration)
+    (name &optional docstring &rest configuration)
   "Define an orderless completion style with given CONFIGURATION.
 The CONFIGURATION should be a list of bindings that you could use
 with `let' to configure orderless.  You can include bindings for
@@ -527,28 +527,30 @@ defines for you, NAME-try-completion and 
NAME-all-completions.
 This macro registers those in `completion-styles-alist' as
 forming the completion style NAME.
 
-The DOCSTRINGS argument should be a list of between 0 to 3
-strings.  The strings present are used as the documentation
-string for the completion style, NAME-try-completion, and
-NAME-all-completions, respectively."
-  (declare (indent defun))
+The optional DOCSTRING argument is used as the documentation
+string for the completion style."
+  (declare (doc-string 2) (indent 1))
+  (unless (stringp docstring)
+    (push docstring configuration)
+    (setq docstring nil))
   (let* ((fn-name (lambda (string) (intern (concat (symbol-name name) 
string))))
          (try-completion  (funcall fn-name "-try-completion"))
-         (all-completions (funcall fn-name "-all-completions")))
+         (all-completions (funcall fn-name "-all-completions"))
+         (doc-fmt "`%s' function for the %s completion style.
+This configures orderless according to the %s completion style and 
+delegates to `orderless-%s'.")
+         (fn-doc (lambda (fn) (format doc-fmt fn name name fn))))
   `(progn
      (defun ,try-completion (string table pred point)
-       ,(cadr docstrings)
+       ,(funcall fn-doc "try-completion")
        (let ,configuration
          (orderless-all-completions string table pred point)))
-
      (defun ,all-completions (string table pred point)
-       ,(caddr docstrings)
+       ,(funcall fn-doc "all-completions")
        (let ,configuration
          (orderless-all-completions string table pred point)))
-
      (add-to-list 'completion-styles-alist
-                  '(,name ,try-completion ,all-completions
-                          ,(car docstrings))))))
+                  '(,name ,try-completion ,all-completions ,docstring)))))
 
 ;;; Ivy integration
 



reply via email to

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