branch: externals/srht commit 0e0d56a77b2fe2fe40993f920c36c0ff64bcbd68 Author: Aleksandr Vityazev <avitya...@posteo.org> Commit: Aleksandr Vityazev <avitya...@posteo.org>
srth: srht-read-with-annotaion: Fix. * lisp/srht: Fix srht-read-with-annotaion, update doc strings. * lisp/srht-paste: Update srht-paste--sha according to the fix. --- lisp/srht-git.el | 2 +- lisp/srht-paste.el | 6 ++++-- lisp/srht.el | 31 +++++++++++++++++-------------- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/lisp/srht-git.el b/lisp/srht-git.el index 905e3fe375..990474c183 100644 --- a/lisp/srht-git.el +++ b/lisp/srht-git.el @@ -163,7 +163,7 @@ is assumed." (seq-map (pcase-lambda ((map (:created c) (:visibility v) (:name n))) - (list n c v n)) + (list n c v)) (plist-get (or srht-git-repos (setq srht-git-repos (srht-retrive (srht-git-repos)))) diff --git a/lisp/srht-paste.el b/lisp/srht-paste.el index b3ef3f7354..1ee4bff9f6 100644 --- a/lisp/srht-paste.el +++ b/lisp/srht-paste.el @@ -71,8 +71,10 @@ CONTENTS must be a UTF-8 encoded string; binary files are not allowed." (defun srht-paste--sha () "Read a FILENAME in the minibuffer, with completion and return SHA." - (srht-read-with-annotaion "Select paste: " - (srht-paste--candidates) #'srht-paste--annot)) + (let ((cand (srht-paste--candidates))) + (car (last (assoc (srht-read-with-annotaion + "Select paste: " cand #'srht-paste--annot) + 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 775bcb02a6..0737f4527d 100644 --- a/lisp/srht.el +++ b/lisp/srht.el @@ -160,19 +160,22 @@ contain the body at all. FORM is optional." "Create an API request with ARGS using the DELETE method." (srht--make-crud-request 'delete args)) -(defun srht-read-with-annotaion (prompt candidates annot-function) - "TODO: doc" +(defun srht-read-with-annotaion (prompt collection annot-function) + "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." (declare (indent 1)) - (let* ((p candidates) - (table - (lambda (string pred action) - (if (eq action 'metadata) - `(metadata - (annotation-function . ,annot-function) - (cycle-sort-function . identity) - (display-sort-function . identity)) - (complete-with-action action p string pred))))) - (car (last (assoc (completing-read prompt table) p))))) + (let ((table + (lambda (string pred action) + (if (eq action 'metadata) + `(metadata + (annotation-function . ,annot-function) + (cycle-sort-function . identity) + (display-sort-function . identity)) + (complete-with-action action collection string pred))))) + (completing-read prompt table))) (defalias 'srht-file-name-concat (if (fboundp 'file-name-concat) @@ -191,8 +194,8 @@ contain the body at all. FORM is optional." (cdr components))))))) (defun srht-kill-link (service name resource) - "TODO: update. -Make URL constructed from NAME and SHA the latest kill in the kill ring." + "Make URL the latest kill in the kill ring. +Constructed from SERVICE, NAME and RESOURCE." (kill-new (srht-file-name-concat (srht--make-uri service nil nil) name resource)) (message "URL in kill-ring"))