[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole 3239a77990 4/8: Cust/Highlight-Menu-Keys-Togg
From: |
ELPA Syncer |
Subject: |
[elpa] externals/hyperbole 3239a77990 4/8: Cust/Highlight-Menu-Keys-Toggle - add this menu item |
Date: |
Tue, 10 Sep 2024 06:58:19 -0400 (EDT) |
branch: externals/hyperbole
commit 3239a779901bd7e10d2330654947e2d428ecefa9
Author: bw <rsw@gnu.org>
Commit: bw <rsw@gnu.org>
Cust/Highlight-Menu-Keys-Toggle - add this menu item
New customizationo, hui:menu-highlight-flag determines whether menu
item keys to press are fontified (typically bolded and with
underline).
---
ChangeLog | 10 ++++++++++
hui-mini.el | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 61 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 03e8471ce0..6e5c7169f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-09-08 Bob Weiner <rsw@gnu.org>
+
+* hui-mini.el (hui:menu-highlight-flag): Add this new customization.
+ (hui:menu-item-highlight-key): Add to highlight with
+ 'read-multiple-choice-face' the key to press for each menu item
+ if `hui:menu-highlight-flag' is non-nil.
+ (hui:menu-read-from-minibuffer): Call above function.
+ (hui:menu-item-toggle-highlight): Add and use in Cust/
+ menu.
+
2024-09-08 Mats Lidell <matsl@gnu.org>
* test/hibtypes-tests.el (ibtypes::hyp-manual-test): Add test.
diff --git a/hui-mini.el b/hui-mini.el
index 452519ff59..544a316bba 100644
--- a/hui-mini.el
+++ b/hui-mini.el
@@ -3,7 +3,7 @@
;; Author: Bob Weiner
;;
;; Orig-Date: 15-Oct-91 at 20:13:17
-;; Last-Mod: 1-Sep-24 at 19:46:18 by Bob Weiner
+;; Last-Mod: 9-Sep-24 at 01:27:12 by Bob Weiner
;;
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
@@ -396,6 +396,18 @@ or if there are none, then its first character."
(mapcar (lambda (item) (hui:menu-item-key item))
(mapcar 'car (cdr menu-alist))))
+(defun hui:menu-item-toggle-highlight (&optional arg)
+ "Toggle highlighting Hyperbole minibuffer menu item keys.
+With optional ARG, enable iff ARG is positive."
+ (interactive "P")
+ (if (or (and arg (<= (prefix-numeric-value arg) 0))
+ (and (not (and arg (> (prefix-numeric-value arg) 0)))
+ hui:menu-highlight-flag))
+ (progn (customize-set-variable 'hui:menu-highlight-flag nil)
+ (message "Menu key highlighting is off."))
+ (customize-set-variable 'hui:menu-highlight-flag t)
+ (message "Menu key highlighting is on")))
+
(defun hui:menu-read-from-minibuffer (prompt &optional initial-contents keymap
read
hist default-value inherit-input-method)
"Hyperbole minibuffer menu replacement for `read-from-minibuffer'.
@@ -412,6 +424,7 @@ Allows custom handling of menu lines before selecting an
item."
(setq initial-contents (string-replace current-name
(concat "==" current-name "==")
initial-contents)))))
+ (setq initial-contents (hui:menu-maybe-highlight-item-keys initial-contents))
(read-from-minibuffer prompt initial-contents keymap read
hist default-value inherit-input-method))
@@ -563,6 +576,34 @@ constructs. If not given, the top level Hyperbole menu is
used."
(list #'hui:menu-to-personal-section label)
act-form))))))
+(defun hui:menu-maybe-highlight-item-keys (menu-str)
+ "Maybe highlight the first capital letter of each MENU-STR item.
+Highlight if customization variable `hui:menu-highlight-flag' is
+non-nil and the display supports underlined faces. Return the
+potentially modified MENU-STR."
+ (if (and hui:menu-highlight-flag
+ (display-supports-face-attributes-p
+ '(:underline t) (window-frame)))
+ (let ((after-menu-name-flag)
+ (after-word-capital-letter-flag)
+ (pos 0))
+ (mapc (lambda (c)
+ (cond ((= c ?>)
+ (setq after-menu-name-flag t))
+ ((= c ?\ )
+ (setq after-word-capital-letter-flag nil))
+ ((and after-menu-name-flag
+ (not after-word-capital-letter-flag)
+ (<= ?A c) (>= ?Z c))
+ (put-text-property pos (1+ pos)
+ 'face 'read-multiple-choice-face
+ menu-str)
+ (setq after-word-capital-letter-flag t)))
+ (setq pos (1+ pos)))
+ menu-str)
+ menu-str)
+ menu-str))
+
(defun hui:menu-line (menu-alist)
"Return a menu line string built from MENU-ALIST."
(let ((menu-prompt (concat (caar menu-alist) " "))
@@ -736,6 +777,8 @@ command instead. Typically prevents clashes over {\\`C-c'
/}."
"Toggle display of Smart Key context after each press, for
debugging.")
("Find-File-URLs" hpath:find-file-urls-mode
"Toggle find-file support for ftp and www URLs.")
+ ("Highlight-Menu-Keys-Toggle" hui:menu-item-toggle-highlight
+ "Toggle highlighting of minibuffer menu keys.")
("Isearch-Invisible" hypb:toggle-isearch-invisible
"Toggle whether isearch searches invisible text or not.")
("KeyBindings/" (menu . cust-keys) "Rebinds global Hyperbole
keys.")
@@ -969,6 +1012,13 @@ command instead. Typically prevents clashes over
{\\`C-c' /}."
;;; Public Customizations - must come after menus are defined
;;; ************************************************************************
+(defcustom hui:menu-highlight-flag t
+ "*If non-nil, highlight the first capitalized character of each menu item.
+Highlight with `read-multiple-choice-face'. The display must
+support underlined faces as well."
+ :type 'boolean
+ :group 'hyperbole-buttons)
+
(unless hui:menu-hywiki
(makunbound 'hui:menu-hywiki))
(defcustom hui:menu-hywiki
- [elpa] externals/hyperbole updated (25ad337b6b -> 246ab46e65), ELPA Syncer, 2024/09/10
- [elpa] externals/hyperbole f68bf1bab5 3/8: Merge branch 'master' of hyperbole into rsw, ELPA Syncer, 2024/09/10
- [elpa] externals/hyperbole 577c3c1b13 1/8: Fix Action Key not highlighting matching HTML tag pairs, ELPA Syncer, 2024/09/10
- [elpa] externals/hyperbole d4fd2ad38b 2/8: Merge branch 'rsw' hyperbole into rsw, ELPA Syncer, 2024/09/10
- [elpa] externals/hyperbole 2073097fc2 6/8: Merge pull request #587 from rswgnu/rsw, ELPA Syncer, 2024/09/10
- [elpa] externals/hyperbole bf64a07549 7/8: hywiki.el - When exporting a HyWiki mark all broken links, ELPA Syncer, 2024/09/10
- [elpa] externals/hyperbole 3239a77990 4/8: Cust/Highlight-Menu-Keys-Toggle - add this menu item,
ELPA Syncer <=
- [elpa] externals/hyperbole 246ab46e65 8/8: Merge pull request #588 from rswgnu/rsw, ELPA Syncer, 2024/09/10
- [elpa] externals/hyperbole cede541e53 5/8: hui-select.el - Fix # in syntax-table to be punctuation, ELPA Syncer, 2024/09/10