[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/helm cd3107ea57 04/11: Allow using a function for help in
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/helm cd3107ea57 04/11: Allow using a function for help in *-read-answer |
Date: |
Thu, 6 Jun 2024 10:00:14 -0400 (EDT) |
branch: elpa/helm
commit cd3107ea578da4fb8ad98fb0dd783b60b7c47bf7
Author: Thierry Volpiatto <thievol@posteo.net>
Commit: Thierry Volpiatto <thievol@posteo.net>
Allow using a function for help in *-read-answer
---
helm-lib.el | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/helm-lib.el b/helm-lib.el
index 096fe7002c..c8fbe9d21c 100644
--- a/helm-lib.el
+++ b/helm-lib.el
@@ -1280,8 +1280,9 @@ If user enters an answer which is one of ANSWER-LIST
return this
answer, otherwise keep prompting for a valid answer.
Note that answer should be a single char, only short answer are
accepted.
-When HELP is provided, it is a string which will be displayed in a buffer when
-\"h\" is pressed (don't forget to add \"h\" in prompt).
+When HELP is provided, it is a string or a function that returns a string
+which will be displayed in a buffer when \"h\"
+is pressed (don't forget to add \"h\" in prompt).
Example:
@@ -1310,15 +1311,35 @@ Example:
(quit-window t it)
(with-current-buffer-window "*choices help*"
'(display-buffer-at-bottom
- (window-height . fit-window-to-buffer)
- (preserve-size . (nil . t)))
- nil (insert help))))
+ (window-height . fit-window-to-buffer)
+ (preserve-size . (nil . t)))
+ nil (progn
+ (insert (if (functionp help)
+ (funcall help) help))
+ (setq-local cursor-type nil)))))
(t (message "Please answer by %s"
(mapconcat 'identity choices ", "))
(sit-for 1)))))
(helm-aand help (get-buffer-window "*choices help*") (quit-window t it))))
-(defun helm-read-answer-dolist-with-action (prompt list action &optional
prompt-formater)
+(defun helm-read-answer-default-help-fn ()
+ "Return a string suitable for `helm-read-answer' help."
+ (with-temp-buffer
+ (save-excursion
+ (insert "y: yes\n"
+ "n: no\n"
+ "!: yes for all\n"
+ "q: quit\n"
+ "h: toggle this help"))
+ (while (re-search-forward "^\\(.\\):" nil t)
+ (helm-add-face-text-properties (match-beginning 1) (match-end 1)
+ 'font-lock-variable-name-face))
+ (buffer-string)))
+
+(defun helm-read-answer-dolist-with-action (prompt list action
+ &optional
+ prompt-formater
+ help-function)
"Read answer with PROMPT and execute ACTION on each element of LIST.
Argument PROMPT is a format spec string e.g. \"Do this on %s?\"
@@ -1346,7 +1367,7 @@ used to modify each element of LIST to be displayed in
PROMPT."
(funcall prompt-formater elm)
elm))
'("y" "n" "!" "q")
- "y: yes\nn: no\n!: yes for all\nq: quit\nh: toggle this
help")
+ (or help-function #'helm-read-answer-default-help-fn))
("y" (funcall action elm))
("n" (ignore))
("!" (prog1
- [nongnu] elpa/helm updated (aa51c1a8d6 -> 8ef8bc4ee8), ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm cd3107ea57 04/11: Allow using a function for help in *-read-answer,
ELPA Syncer <=
- [nongnu] elpa/helm 0d76b45321 03/11: Provide help for helm-read-answer-dolist-with-action, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm a2f5185d61 08/11: Fix source name in helm-fd, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm e31a81506d 10/11: Do not update when doing C-k on an empty minibuffer, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm 73b1641e51 02/11: Provide a HELP argument to helm-read-answer, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm ddd9365725 01/11: Disable helm for read-multiple-choice--long-answers, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm e1442071ae 05/11: Provide help in several read-answer's, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm ba204d3b81 07/11: Add Fd and Etags to helm-files-save-history-extra-sources, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm 76023fbe80 06/11: Expand file name in helm-files-save-file-name-history, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm 7e926402cd 09/11: Enhance helm-delete-minibuffer-contents prefix arg behavior, ELPA Syncer, 2024/06/06
- [nongnu] elpa/helm 8ef8bc4ee8 11/11: Update NEWS, ELPA Syncer, 2024/06/06