branch: externals/hyperbole commit 044d46603ac232a9d1d5435b94e65bc50b69d505 Author: Bob Weiner <r...@gnu.org> Commit: Bob Weiner <r...@gnu.org>
Allow Hyperbole minibuffer menu item by first capital letter --- ChangeLog | 17 +++++++++++++++++ DEMO | 14 +++++++------- hargs.el | 8 ++++++-- hsettings.el | 6 +++--- hui-mini.el | 45 +++++++++++++++++++++++++++++++-------------- 5 files changed, 64 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7525c0..c2e7cb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2021-05-22 Bob Weiner <r...@gnu.org> + +* hsettings.el (hyperbole-web-search-alist): Update 'gitHub' + name. + +* hui-mini.el (hui:menu-item, hui:menu-line): Use simplified, + concatenated car/cdr functions. + (hui:menu-item-keys): Add to modularize menu + item selection and allow selection by first capital letter, + not just first letter. + (hui:menu-select, hui:menu-item): Call hui:menu-item-keys. + (hui:menu-select): Update doc string and {RET} + direct selection handling. + hargs.el (hargs:at-p): When reading a Hyperbole minibuffer menu + item, match to the first capitalized char in each item. + +* kotl/kexport.el (kexport:font-awesome-css-url, 2021-05-19 Bob Weiner <r...@gnu.org> * Makefile (kotl/kotl-autoloads.el): Revert commit that removed diff --git a/DEMO b/DEMO index e915383..7357b45 100644 --- a/DEMO +++ b/DEMO @@ -123,13 +123,13 @@ minibuffer menu you saw at the beginning; one is for use from the keyboard In this demo, we will use the minibuffer menu. To display the top-level Hyperbole menu again use 'C-h h' or click the Action Mouse Key within the blank/inactive minibuffer window. You will see a single line (possibly -wrapped around) with submenus that end with a forward slash (/) and non-menu -items. Type the first letter of any menu item (upper or lower case does not -matter) or click on it with the Action Mouse Key to select and activate it. -You may also move forward an item with 'TAB' or 'M-f' or backward an item -with 'Shift-TAB' or 'M-b' and then use 'RET' to select the item. Also, notice -at the left of this menu is your Hyperbole release version number for easy -reference. +wrapped around) with submenus that end with a forward slash (/) and +non-menu items. Type the first capitalized letter of any menu item (you +can type it as lower or upper case, it does not matter) or click on it with +the Action Mouse Key to select and activate it. You may also move forward +an item with 'TAB' or 'M-f' or backward an item with 'Shift-TAB' or 'M-b' +and then use 'RET' to select the item. Also, notice at the left of this +menu is your Hyperbole release version number for easy reference. A press/click of the Assist Key on a menu item pops up a window displaying help for it while keeping the current menu on screen. 'C-t' or diff --git a/hargs.el b/hargs.el index 65a2499..2a85f12 100644 --- a/hargs.el +++ b/hargs.el @@ -316,9 +316,13 @@ Handles all of the interactive argument types that `hargs:iform-read' does." ;; In menu prefix 1) ((search-backward " " nil t) - ;; On a menu item + ;; On a menu item, return the first capitalized + ;; char or if none, the first character (skip-chars-forward " ") - (following-char)) + (let (case-fold-search) + (if (looking-at "[^ \t\nA-Z]*[A-Z]") + (char-before (match-end 0)) + (following-char)))) ;; At the end of the menu (t 0))))) ((hargs:completion t)) diff --git a/hsettings.el b/hsettings.el index 5b775c6..9371337 100644 --- a/hsettings.el +++ b/hsettings.el @@ -232,7 +232,7 @@ Hyperbole, and then restart Emacs." ("Facebook" . "https://www.facebook.com/hashtag/%s";) ;; To search for a Facebook user, use "https://www.facebook.com/%s";. ("Google" . "http://www.google.com/search?q=%s";) - ("Hub(git)" . "https://github.com/search?ref=simplesearch&q=%s";) + ("gitHub" . "https://github.com/search?ref=simplesearch&q=%s";) ("Images" . "http://www.google.com/images?hl=en&q=%s";) ("Maps" . "http://maps.google.com/maps?q=%s";) ("RFCs" . "https://tools.ietf.org/html/rfc%s";) @@ -241,13 +241,13 @@ Hyperbole, and then restart Emacs." ("Wikipedia" . "https://en.wikipedia.org/wiki/%s";) ("Youtube" . "https://www.youtube.com/results?search_query=%s";)) "*Alist of (web-service-name . url-with-%s-parameter) elements. -The first character of each web-service-name must be unique. +The first capitalized character of each web-service-name must be unique. This custom option is used in the Hyperbole Find/Web menu where the %s in the url-with-%s-parameter is replaced with an interactively obtained search string." :initialize #'custom-initialize-default :set (lambda (_option value) - (setq hyperbole-web-search-alist value) + (set _option value) (hyperbole-update-menus)) :type '(alist :key-type string :value-type string) :group 'hyperbole-commands) diff --git a/hui-mini.el b/hui-mini.el index 0f8d3c5..8d1ef15 100644 --- a/hui-mini.el +++ b/hui-mini.el @@ -285,13 +285,27 @@ With optional HELP-STRING-FLAG, instead returns the one line help string for the (if (eq owind (minibuffer-window)) (select-window owind))))) +(defun hui:menu-item-keys (menu-alist) + "Return the list of ordered keys used to activate items in Hyperbole minibuffer MENU-ALIST. +For each item, the key is either the first capital letter in item +or if there are none, then its first character." + (mapcar (lambda (item) + ;; Return either the first capital letter in item or if + ;; none, then its first character. + (or (catch 'capital + (mapc (lambda (c) (and (<= ?A c) (>= ?Z c) + (throw 'capital c))) + item)) + (aref item 0))) + (mapcar 'car (cdr menu-alist)))) + (defun hui:menu-select (menu-alist &optional doc-flag help-string-flag) - "Prompts user to choose the first character of any item from MENU-ALIST. -Case is not significant. If chosen by direct selection with the Assist Key, -returns any help string for item, else returns the action form for the item. + "Prompts user to choose the first capitalized character of any item from MENU-ALIST. +The character may be entered in lowercase. If chosen by direct selection with the Assist Key, +return any help string for item, else return the action form for the item. Two additional optional arguments may be given when documentation for -a menu item should be shown rather than display of a menu. DOC-FLAG +a menu item should be shown rather than menu display. DOC-FLAG non-nil means show documentation for any item that is selected by the user. HELP-STRING-FLAG non-nil means show only the first line of the documentation, not the full text." @@ -302,8 +316,7 @@ documentation, not the full text." (quit-char (string-to-char hui:menu-quit)) (abort-char (string-to-char hui:menu-abort)) (top-char (string-to-char hui:menu-top)) - (item-keys (mapcar (lambda (item) (aref item 0)) - (mapcar 'car (cdr menu-alist)))) + (item-keys (hui:menu-item-keys menu-alist)) ;; 0 matches an empty string return, no selection (keys (apply 'list 0 1 select-char exit-char quit-char abort-char top-char item-keys)) @@ -319,7 +332,7 @@ documentation, not the full text." (setq hargs:reading-p 'hmenu) (discard-input)) ;; Here, the minibuffer has been exited, and `key' has been set to either: - ;; a menu item initial character code; + ;; a menu item first capitalized character code; ;; a menu command character code; ;; 1 for in the menu prefix area; ;; 0 for at the end of the menu. @@ -330,7 +343,12 @@ documentation, not the full text." (save-excursion (if (search-backward " " nil t) (progn (skip-chars-forward " ") - (setq key (following-char)) + ;; Get the next following capital letter + (let (case-fold-search) + (setq key + (if (looking-at "[^ \t\nA-Z]*[A-Z]") + (char-before (match-end 0)) + (following-char)))) nil) ;; Drop through. t)))) (t (hui:menu-item key doc-flag help-string-flag nil menu-alist))))) @@ -374,21 +392,20 @@ constructs. If not given, the top level Hyperbole menu is used." hui:menus)) (hypb:error "(hui:menu-item): Invalid menu symbol arg: `%s'" menu)))) - (let ((item-keys (mapcar (lambda (item) (aref item 0)) - (mapcar 'car (cdr menu-alist)))) + (let ((item-keys (hui:menu-item-keys menu-alist)) sublist) (when (setq sublist (memq key item-keys)) (setq hui:menu-keys (concat hui:menu-keys (downcase (char-to-string key)))) (let* ((label-act-help-list (nth (- (1+ (length item-keys)) (length sublist)) menu-alist)) - (act-form (car (cdr label-act-help-list)))) + (act-form (cadr label-act-help-list))) (if (or (eq hargs:reading-p 'hmenu-help) (and doc-flag ;; Not another menu to display (not (and (listp act-form) (atom (car act-form)) (atom (cdr act-form)))))) - (let* ((help-str (car (cdr (cdr label-act-help-list)))) - (cmd (if help-str nil (car (cdr label-act-help-list)))) + (let* ((help-str (caddr label-act-help-list)) + (cmd (if help-str nil (cadr label-act-help-list))) (doc-str (if help-str nil (and (functionp cmd) (documentation cmd))))) (and doc-str (string-match "\n" doc-str) (setq doc-str (substring doc-str 0 (match-beginning 0)))) @@ -402,7 +419,7 @@ constructs. If not given, the top level Hyperbole menu is used." (defun hui:menu-line (menu-alist) "Return a menu line string built from MENU-ALIST." - (let ((menu-prompt (concat (car (car menu-alist)) " ")) + (let ((menu-prompt (concat (caar menu-alist) " ")) (menu-items (mapconcat 'car (cdr menu-alist) " ")) menu-line) (setq menu-line (concat menu-prompt menu-items))