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

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

[elpa] externals/hyperbole 2376bb1: Simplify prefix key bindings, removi


From: ELPA Syncer
Subject: [elpa] externals/hyperbole 2376bb1: Simplify prefix key bindings, removing global parent keymaps
Date: Fri, 30 Apr 2021 01:57:07 -0400 (EDT)

branch: externals/hyperbole
commit 2376bb1fa2fc7d8daf82b10bb24525822f783dfb
Author: Bob Weiner <rsw@gnu.org>
Commit: Bob Weiner <rsw@gnu.org>

    Simplify prefix key bindings, removing global parent keymaps
    
    This fixes an issue with the prior commit where Hyperbole bindings
    could bleed into the global maps.
---
 Changes      | 18 ++++++++++++-
 hibtypes.el  |  6 ++++-
 hpath.el     | 20 +++++++++-----
 hyperbole.el | 86 +++++++++++++++++++++++++++++-------------------------------
 4 files changed, 77 insertions(+), 53 deletions(-)

diff --git a/Changes b/Changes
index 0266a5f..240956d 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,19 @@
+2021-04-30  Bob Weiner  <rsw@gnu.org>
+
+* hpath.el (hpath:at-p):
+  hibtypes.el (pathname): Prevent from matching to a shell
+    command within a semicolon separated sequence of commands.
+
+2021-04-29  Bob Weiner  <rsw@gnu.org>
+
+* hyperbole.el (hyperb:init): Remove enhanced priority Hyperbole
+    minor-mode from emulation-mode-map-alists.
+               (hkey-initialize): Remove Hyperbole-specific C-h
+    and C-c prefix maps and use of the corresponding global prefix
+    maps as parent keymaps for hyperbole-mode.  define-key does
+    the right thing for minor modes without any of this.
+               (hkey-help-set-key): Remove, not needed.
+
 2021-04-28  Mats Lidell  <matsl@gnu.org>
 
 * Makefile (EL_COMPILE) (ELC_COMPILE): Add hui-dired-sidebar and
@@ -16,7 +32,7 @@
   man/hyperbole.texi (HyRolo Keys): Document new {r} binding.
 
 * hyperbole.el (hyperbole-mode): Add hyperbole-mode-hook.
-               (enable-hyperbole-mode, disable-hyperbole-mode):
+               (hyperbole--enable-mode, hyperbole--disable-mode):
     Add to separate from hyperb:init.
                (hyperbole-mode): Update to use above functions.
 
diff --git a/hibtypes.el b/hibtypes.el
index cf96618..9b856dd 100644
--- a/hibtypes.el
+++ b/hibtypes.el
@@ -224,7 +224,11 @@ display options."
                 (setq path (if (or assist-flag (hyperb:stack-frame 
'(hkey-help)))
                                path
                              (hpath:choose-from-path-variable path "Display")))
-                (unless (or (null path) (string-empty-p path))
+                (unless (or (null path) (string-blank-p path)
+                            ;; Could be a shell command from a semicolon
+                            ;; separated list; ignore if so.
+                            (and (string-match "\\`\\s-*\\([^;         ]+\\)" 
path)
+                                 (executable-find (match-string 1 path))))
                   (hact 'link-to-file path)))
                ((string-match "\\`[^\\\\/~]+\\.el[cn]?\\(\\.gz\\)?\\'" path)
                  (apply #'ibut:label-set path (hpath:start-end path))
diff --git a/hpath.el b/hpath.el
index 643ad4f..5a3f2e9 100644
--- a/hpath.el
+++ b/hpath.el
@@ -817,13 +817,19 @@ paths are allowed.  Absolute pathnames must begin with a 
`/' or `~'."
                ;; Don't allow more than one set of grouping chars
                (not (string-match "\)\\s-*\(\\|\\]\\s-*\\[\\|\}\\s-*\{" path)))
           ;; With point inside a path variable, return the path that point is 
on or to the right of.
-          (or (and (setq subpath (hargs:delimited "[:\"\']" "[:\"\']" t t nil 
"[\t\n\r\f]\\|[;:] \\| [;:]"))
-                   (not (string-match "[:;\t\n\r\f]" subpath))
-                   subpath)
-              (and (setq subpath (hargs:delimited "[;\"\']" "[;\"\']"  t t nil 
"[\t\n\r\f]\\|[;:] \\| [;:]"))
-                   (not (string-match "[;\t\n\r\f]\\|:[^:]*:" subpath))
-                   subpath)
-              "."))
+          (setq subpath (or (and (setq subpath (hargs:delimited "[:\"\']" 
"[:\"\']" t t nil "[\t\n\r\f]\\|[;:] \\| [;:]"))
+                                 (not (string-match "[:;\t\n\r\f]" subpath))
+                                 subpath)
+                            (and (setq subpath (hargs:delimited "[;\"\']" 
"[;\"\']"  t t nil "[\t\n\r\f]\\|[;:] \\| [;:]"))
+                                 (not (string-match "[;\t\n\r\f]\\|:[^:]*:" 
subpath))
+                                 subpath)))
+          (if subpath
+              ;; Could be a shell command from a semicolon separated
+              ;; list; ignore if so
+              (unless (and (string-match "\\`\\s-*\\([^;       ]+\\)" subpath)
+                           (executable-find (match-string 1 subpath)))
+                subpath)
+            "."))
          ((hpath:is-p path type non-exist))
          ;; Local file URLs
          ;; ((hpath:is-p (hargs:delimited "file://" "[ \t\n\r\"\'\}]" nil t)))
diff --git a/hyperbole.el b/hyperbole.el
index 48c7d42..9feaf16 100644
--- a/hyperbole.el
+++ b/hyperbole.el
@@ -204,10 +204,10 @@ which prevents automatic removal of any local bindings to 
the same key."
 (defvar hmouse-middle-flag)
 (defvar hmouse-bindings-flag)
 (defvar hyperb:user-email)
-(defvar hyperbole-help-map (make-sparse-keymap)
-  "Help prefix keymap available only when Hyperbole minor mode is enabled.")
-(defvar hyperbole-mode-specific-map (make-sparse-keymap)
-  "C-c prefix keymap available only when Hyperbole minor mode is enabled.")
+;; (defvar hyperbole-help-map (make-sparse-keymap)
+;;  "Help prefix keymap available only when Hyperbole minor mode is enabled.")
+;; (defvar hyperbole-mode-specific-map (make-sparse-keymap)
+;;   "C-c prefix keymap available only when Hyperbole minor mode is enabled.")
 
 (defun hkey-initialize ()
   "If `hkey-init' is non-nil, initialize Hyperbole key bindings.
@@ -225,12 +225,12 @@ of the commands."
        (global-set-key (vector help-char ?h) #'hyperbole))
     ;;
     ;; Define help prefix key in this keymap.
-    (set-keymap-parent hyperbole-help-map help-map)
-    (hkey-set-key (vector help-char) hyperbole-help-map)
+    ;; (set-keymap-parent hyperbole-help-map help-map)
+    ;; (hkey-set-key (vector help-char) hyperbole-help-map)
     ;;
     ;; Define C-c prefix key in this keymap.
-    (set-keymap-parent hyperbole-mode-specific-map mode-specific-map)
-    (hkey-set-key "\C-c" hyperbole-mode-specific-map)
+    ;; (set-keymap-parent hyperbole-mode-specific-map mode-specific-map)
+    ;; (hkey-set-key "\C-c" hyperbole-mode-specific-map)
     ;;
     ;; Binds the Action Key to {M-RET} and the Assist Key to {C-u M-RET}
     ;; and loads the Hyperbole mouse key bindings.
@@ -243,7 +243,7 @@ of the commands."
     ;; Typically bind the key, {C-h A}, for Action Key help and {C-u C-h A} 
for Assist key
     ;; help.
     (or (where-is-internal #'hkey-help)
-       (hkey-help-set-key "A" #'hkey-help))
+       (hkey-set-key (vector help-char ?A) #'hkey-help))
     ;;
     ;; Provides a site standard way of emulating most Hyperbole mouse drag
     ;; commands from the keyboard.  This is most useful for rapidly creating
@@ -617,8 +617,9 @@ If FLAG is nil then text is shown, while if FLAG is t the 
text is hidden."
   (hkey-initialize)
   ;;
   ;; The keymaps in `emulation-mode-map-alists' take precedence over
-  ;; `minor-mode-map-alist'
-  (add-to-list 'emulation-mode-map-alists `((hyperbole-mode . 
,hyperbole-mode-map)))
+  ;; `minor-mode-map-alist'; add this only if other minor modes are
+  ;; overriding Hyperbole keys.
+  ;; (add-to-list 'emulation-mode-map-alists `((hyperbole-mode . 
,hyperbole-mode-map)))
   ;;
   ;; Hyperbole initialization is complete.
   (message "Initializing Hyperbole...done"))
@@ -659,13 +660,8 @@ This is used only when running from git source and not a 
package release."
       (where-is-internal command)
       (hkey-set-key key command)))
 
-(defun hkey-help-set-key (key command)
-  "Define a Hyperbole minor mode help-map KEY bound to COMMAND."
-  (define-key hyperbole-help-map key command))
-
-(defun enable-hyperbole-mode ()
+(defun hyperbole--enable-mode ()
   "Enable Hyperbole global minor mode."
-  (interactive)
   ;;
   ;; Abbreviate MSWindows /cygdrive mount point paths.
   (when (file-exists-p "/cygdrive")
@@ -681,29 +677,26 @@ This is used only when running from git source and not a 
package release."
              'write-file-hooks)
            #'hattr:save t)
   ;;
-  (hyperb:init-menubar)
-  ;; Activate hyperbole-mode
-  (run-hooks 'hyperbole-mode-hook))
+  (hyperb:init-menubar))
 
-(defun disable-hyperbole-mode ()
+(defun hyperbole--disable-mode ()
   "Disable Hyperbole keys, menus and hooks."
-  (interactive)
-    ;; Deactivate hyperbole-mode
-    ;; Delete Hyperbole menu from all menubars.
-    (hui-menu-remove Hyperbole)
-    ;;
-    ;; Remove Hyperbole button comment from future outgoing mail.
-    (when (boundp 'smail:comment) (setq smail:comment nil))
-    (remove-hook 'after-init-hook #'hyperb:init)
-    ;;
-    (setq directory-abbrev-alist (remq hyperb:cygdrive
-                                      directory-abbrev-alist)
-         hpath:posix-mount-point-to-mswindows-alist nil)
-    ;;
-    (remove-hook (if (boundp 'write-file-functions)
-                    'write-file-functions
-                  'write-file-hooks)
-                #'hattr:save))
+  ;; Deactivate hyperbole-mode
+  ;; Delete Hyperbole menu from all menubars.
+  (hui-menu-remove Hyperbole)
+  ;;
+  ;; Remove Hyperbole button comment from future outgoing mail.
+  (when (boundp 'smail:comment) (setq smail:comment nil))
+  (remove-hook 'after-init-hook #'hyperb:init)
+  ;;
+  (setq directory-abbrev-alist (remq hyperb:cygdrive
+                                    directory-abbrev-alist)
+       hpath:posix-mount-point-to-mswindows-alist nil)
+  ;;
+  (remove-hook (if (boundp 'write-file-functions)
+                  'write-file-functions
+                'write-file-hooks)
+              #'hattr:save))
 
 (defvar hyperbole-mode-map (make-sparse-keymap)
   "Keymap for the GNU Hyperbole global minor mode.
@@ -726,21 +719,26 @@ documentation at \"(hyperbole)Top\".
 
 \\{hyperbole-mode-map}"
   :global t
-  :keymap hyperbole-mode-map
   :lighter hyperbole-mode-lighter
   (if hyperbole-mode
-      (enable-hyperbole-mode)
-    (disable-hyperbole-mode)))
+      (hyperbole--enable-mode)
+    (hyperbole--disable-mode)))
 
+;; This next expression initializes the Hyperbole keymap but does not
+;; activate Hyperbole.  The only user-visible change it should make is
+;; to globally bind {C-h h} to 'hyperbole' which when invoked will both
+;; activate Hyperbole and show its minibuffer menu.
 (if after-init-time
     ;; Initialize Hyperbole key bindings and hooks.
     (hyperb:init)
   ;; Initialize after other key bindings are loaded at startup.
   (add-hook 'after-init-hook #'hyperb:init t))
 
-;; !! FIXME: Loading a file should not change Emacs's behavior but we
-;; need this here for awhile until can ensure Hyperbole users know to
-;; add this to their Emacs init files.
+;; !! FIXME: This next expression activates Hyperbole for compatibility
+;; with prior releases where (require 'hyperbole) was enough to
+;; activate its key bindings.  However, loading a file should not
+;; change Emacs's behavior, so after educating users to add this
+;; next line to their Emacs initializations, it should be removed.
 (hyperbole-mode 1)
 
 (makunbound 'hyperbole-loading)



reply via email to

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