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

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

[elpa] externals/srht 0e53961bbc 27/27: srht-read-with-annotaion: Add ca


From: ELPA Syncer
Subject: [elpa] externals/srht 0e53961bbc 27/27: srht-read-with-annotaion: Add category arg.
Date: Tue, 17 May 2022 22:58:01 -0400 (EDT)

branch: externals/srht
commit 0e53961bbc997ec00317b1fd143e5e1336bd8754
Author: Aleksandr Vityazev <avityazev@posteo.org>
Commit: Aleksandr Vityazev <avityazev@posteo.org>

    srht-read-with-annotaion: Add category arg.
    
    * lisp/srht (srht-read-with-annotaion): Add category argument.
    (srht--api-request): Fix srht-token check.
    * lisp/srht-git (srht-git--repo-name-read): Update according to changes.
    * lisp/srht-paste (srht-paste--sha): -/-/-.
---
 lisp/srht-git.el   |  2 +-
 lisp/srht-paste.el |  7 ++++---
 lisp/srht.el       | 11 +++++++----
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/lisp/srht-git.el b/lisp/srht-git.el
index 8f5adbd8ac..f317cc33ce 100644
--- a/lisp/srht-git.el
+++ b/lisp/srht-git.el
@@ -194,7 +194,7 @@ is assumed."
 (defun srht-git--repo-name-read ()
   "Read a repository name in the minibuffer, with completion."
   (srht-read-with-annotaion "Select repository: "
-    (srht-git--candidates) #'srht-git--annot))
+    (srht-git--candidates) #'srht-git--annot 'sourcehut-git-repository))
 
 (defvar srht-git-repo-name-history nil
   "History variable.")
diff --git a/lisp/srht-paste.el b/lisp/srht-paste.el
index 483842f524..5522529e7f 100644
--- a/lisp/srht-paste.el
+++ b/lisp/srht-paste.el
@@ -76,9 +76,10 @@ QUERY is the query for the URI."
 (defun srht-paste--sha ()
   "Read a FILENAME in the minibuffer, with completion and return SHA."
   (let ((cand (srht-paste--candidates)))
-    (car (last (assoc (srht-read-with-annotaion
-                          "Select paste: " cand #'srht-paste--annot)
-                      cand)))))
+    (car (last (assoc
+                (srht-read-with-annotaion
+                    "Select paste: " cand #'srht-paste--annot 'sourcehut-paste)
+                cand)))))
 
 (defun srht-paste (&optional sha &rest details)
   "Create, retrieve or delete a paste.
diff --git a/lisp/srht.el b/lisp/srht.el
index d35b38464c..9fb12f684d 100644
--- a/lisp/srht.el
+++ b/lisp/srht.el
@@ -126,7 +126,7 @@ THEN (see `plz').
 THEN is a callback function, which is called in the response data.
 ELSE is an optional callback function called when the request
 fails with one argument, a `plz-error' struct."
-  (unless srht-token
+  (when (or (string-empty-p srht-token) (not srht-token))
     (error "Need a token"))
   (let ((uri (srht--make-uri service path query))
         (content-type (or form "application/json")))
@@ -169,17 +169,20 @@ URI."
   "Create an API request with ARGS using the DELETE method."
   (srht--make-crud-request 'delete args))
 
-(defun srht-read-with-annotaion (prompt collection annot-function)
+(defun srht-read-with-annotaion (prompt collection annot-function category)
   "Read a string in the minibuffer, with completion.
 PROMPT is a string to prompt with; normally it ends in a colon and a space.
 COLLECTION can be a list of strings, an alist or a hash table.
-ANNOT-FUNCTION the value should be a function for “annotating” completions.
-The function should take one argument, STRING, which is a possible completion."
+ANNOT-FUNCTION value should be a function for “annotating” completions.
+The function should take one argument, STRING, which is a possible completion.
+CATEGORY value should be a symbol describing what kind of text the
+completion function is trying to complete."
   (declare (indent 1))
   (let ((table
          (lambda (string pred action)
            (if (eq action 'metadata)
                `(metadata
+                 (category . ,category)
                  (annotation-function . ,annot-function)
                  (cycle-sort-function . identity)
                  (display-sort-function . identity))



reply via email to

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