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

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

[elpa] externals/hyperbole 2073097fc2 6/8: Merge pull request #587 from


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 2073097fc2 6/8: Merge pull request #587 from rswgnu/rsw
Date: Tue, 10 Sep 2024 06:58:20 -0400 (EDT)

branch: externals/hyperbole
commit 2073097fc28395b81da90d8f8f99557b30e6d7d4
Merge: 25ad337b6b cede541e53
Author: Robert Weiner <rsw@gnu.org>
Commit: GitHub <noreply@github.com>

    Merge pull request #587 from rswgnu/rsw
    
    Fix Action Key not highlighting matching HTML tag pairs
---
 ChangeLog          | 25 ++++++++++++++++++++++++
 hui-mini.el        | 52 ++++++++++++++++++++++++++++++++++++++++++++++++-
 hui-select.el      | 57 +++++++++++++++++++++++++++++-------------------------
 man/hyperbole.texi |  6 +++---
 4 files changed, 110 insertions(+), 30 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 10f437052d..e0b6371a9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-09-09  Bob Weiner  <rsw@gnu.org>
+
+* hui-select.el (hui-select-syntax-table): Fix that # was registering as
+    an opening quote to an sexp rather than punctuation.
+
+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.
@@ -7,6 +22,16 @@
 * Makefile (docker, docker-run): Use "--rm" option so the short lived
     container and its volumes are removed on exit.
 
+2024-09-02  Bob Weiner  <rsw@gnu.org>
+
+* man/hyperbole.texi (Action Button Link Types): Change PYTHONLIBPATH to
+    PYTHONPATH to match the example definition of 'pylib' in the 'defal'
+    macro documentation.
+
+* hui-select.el (hui-select-delimited-thing-call): FIX: Add setting of
+    missing 'hui-select-syntax-table' that was preventing the Action
+    Key from selecting markup pairs in HTML/Web modes.
+
 2024-09-01  Bob Weiner  <rsw@gnu.org>
 
 * man/dir (File): Narrow width to better fit with out Info entries.
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
diff --git a/hui-select.el b/hui-select.el
index 1ea2017594..99793460ad 100644
--- a/hui-select.el
+++ b/hui-select.el
@@ -3,7 +3,7 @@
 ;; Author:       Bob Weiner
 ;;
 ;; Orig-Date:    19-Oct-96 at 02:25:27
-;; Last-Mod:     18-Aug-24 at 09:44:46 by Mats Lidell
+;; Last-Mod:      9-Sep-24 at 22:25:55 by Bob Weiner
 ;;
 ;; SPDX-License-Identifier: GPL-3.0-or-later
 ;;
@@ -347,6 +347,9 @@ Used to include a final line when marking indented code.")
     (modify-syntax-entry ?\} "){" st)
     (modify-syntax-entry ?< "(>" st)
     (modify-syntax-entry ?> ")<" st)
+    ;; Next entry, e.g. for markdown mode, so does not register as a
+    ;; quote starting an sexp, as it does in emacs-lisp-mode
+    (modify-syntax-entry ?# "." st)
     st)
   "Syntax table to use when selecting delimited things.")
 
@@ -409,7 +412,6 @@ region (start . end) defining the boundaries of the thing 
at that position."
   :type '(repeat (cons (character :tag "Syntax-Char") function))
   :group 'hyperbole-commands)
 
-
 ;;; ************************************************************************
 ;;; Public functions
 ;;; ************************************************************************
@@ -789,14 +791,13 @@ The character at POS is selected if no other thing is 
matched."
                              (- (cdr region) (car region)))
                        (< region-size min-region))
               (setq min-region region-size
-                    result
-                    (list
-                     ;; The actual selection type is
-                     ;; sometimes different than the one we
-                     ;; originally tried, so recompute it here.
-                     (car (assq hui-select-previous
-                                hui-select-bigger-alist))
-                     (car region) (cdr region)))))
+                    result (list
+                            ;; The actual selection type is
+                            ;; sometimes different than the one we
+                            ;; originally tried, so recompute it here.
+                            (car (assq hui-select-previous
+                                       hui-select-bigger-alist))
+                            (car region) (cdr region)))))
           hui-select-bigger-alist)
          (if result
              ;; Returns hui-select-region
@@ -841,7 +842,7 @@ Typically:
  If `hui-select-char-p' is set non-nil, then as a fallback, the
  character at POS will be selected.
 
-If an error occurs during syntax scanning, it returns nil."
+If an error occurs during syntax scanning, return nil."
   (interactive "d")
   (setq hui-select-previous 'char)
   (if (save-excursion (goto-char pos) (eolp))
@@ -858,11 +859,11 @@ If an error occurs during syntax scanning, it returns 
nil."
 
 (defun hui-select-at-delimited-thing-p ()
   "Return non-nil if point is at a delimited thing, else nil.
-A delimited tings is a markup pair, list, array/vector, set,
+A delimited thing is a markup pair, list, array/vector, set,
 comment or string.  The non-nil value returned is the function to
 call to select that syntactic unit.
 
-Ignores any match if on an Emacs button and instead returns nil."
+Ignore any match if on an Emacs button and instead return nil."
   (unless (button-at (point))
     (setq hkey-value (hui-select-delimited-thing-call #'hui-select-at-p))
     (cond ((eq hkey-value 'hui-select-punctuation)
@@ -975,19 +976,23 @@ call to select that syntactic unit."
   (unless (and (memq major-mode hui-select-ignore-quoted-sexp-modes)
               ;; Ignore quoted identifier sexpressions, like #'function
               (char-after) (memq (char-after) '(?# ?\')))
-    (let ((hui-select-char-p)
-         (hui-select-whitespace)
-         (hui-select-syntax-alist '((?\" . hui-select-string)
-                                    (?\( . hui-select-sexp-start)
-                                    (?\$ . hui-select-sexp-start)
-                                    (?\' . hui-select-sexp-start)
-                                    (?\) . hui-select-sexp-end)
-                                    (?\< . hui-select-comment)
-                                    ;; Punctuation needed to match
-                                    ;; multi-char comment delimiters
-                                    (?\. . hui-select-punctuation))))
-      (hui-select-reset)
-      (funcall func))))
+    (with-syntax-table
+       (if (memq major-mode hui-select-ignore-quoted-sexp-modes)
+           (syntax-table)
+         hui-select-syntax-table)
+      (let ((hui-select-char-p)
+           (hui-select-whitespace)
+           (hui-select-syntax-alist '((?\" . hui-select-string)
+                                      (?\( . hui-select-sexp-start)
+                                      (?\$ . hui-select-sexp-start)
+                                      (?\' . hui-select-sexp-start)
+                                      (?\) . hui-select-sexp-end)
+                                      (?\< . hui-select-comment)
+                                      ;; Punctuation needed to match
+                                      ;; multi-char comment delimiters
+                                      (?\. . hui-select-punctuation))))
+       (hui-select-reset)
+       (funcall func)))))
 
 (defun hui-select-region-bigger-p (old-region new-region)
   "Non-nil means the new region is bigger than the old region.
diff --git a/man/hyperbole.texi b/man/hyperbole.texi
index 2813ce4e22..e40ee134a5 100644
--- a/man/hyperbole.texi
+++ b/man/hyperbole.texi
@@ -7,7 +7,7 @@
 @c Author:       Bob Weiner
 @c
 @c Orig-Date:     6-Nov-91 at 11:18:03
-@c Last-Mod:      1-Sep-24 at 20:28:29 by Bob Weiner
+@c Last-Mod:      2-Sep-24 at 19:50:16 by Bob Weiner
 
 @c %**start of header (This is for running Texinfo on a region.)
 @setfilename hyperbole.info
@@ -7468,11 +7468,11 @@ button is activated and does one of four things with 
LINK-EXPR:
 @item invokes a function or action type of one argument, the button text sans 
the function name, to display it.
 @end enumerate
 
-For example, if you use Python and have a @samp{PYTHONLIBPATH} environment
+For example, if you use Python and have a @samp{PYTHONPATH} environment
 variable, then pressing @bkbd{C-x C-e} @code{eval-last-sexp} after
 this expression:
 
-@code{(defal pylib "$@{PYTHONLIBPATH@}/%s")}
+@code{(defal pylib "$@{PYTHONPATH@}/%s")}
 
 @noindent
 defines a new action button link type called ’pylib’ whose buttons



reply via email to

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