[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/hyperbole af73116 07/25: hib-kbd.el: Recognize helm-M-x
From: |
Stefan Monnier |
Subject: |
[elpa] externals/hyperbole af73116 07/25: hib-kbd.el: Recognize helm-M-x or counsel-M-x bound to M-x |
Date: |
Tue, 22 Sep 2020 10:29:26 -0400 (EDT) |
branch: externals/hyperbole
commit af731168cf7d7057da8e4e9716c45571b49d2bad
Author: Bob Weiner <Bob.Weiner@DuffandPhelps.com>
Commit: Bob Weiner <Bob.Weiner@DuffandPhelps.com>
hib-kbd.el: Recognize helm-M-x or counsel-M-x bound to M-x
---
Changes | 5 +++++
HY-NEWS | 7 +++++++
hib-kbd.el | 50 ++++++++++++++++++++++++++++++++++++++------------
3 files changed, 50 insertions(+), 12 deletions(-)
diff --git a/Changes b/Changes
index d4d97a5..2aef647 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,8 @@
+2020-07-25 Bob Weiner <rsw@gnu.org>
+
+* hib-kbd.el (kbd-key:execute-special-series): Added and used in kbd-key:act
+ to make key series work properly when helm-mode or counsel-mode are
enabled.
+
2020-07-23 Bob Weiner <rsw@gnu.org>
* hui.el (hui:ibut-label-create): Fixed to skip back past opening delimiter
diff --git a/HY-NEWS b/HY-NEWS
index c3df751..d980eb7 100644
--- a/HY-NEWS
+++ b/HY-NEWS
@@ -15,6 +15,13 @@
associated with Agenda items such as TODOs in another window. The
Assist Key shows help.
+ BUTTON TYPES
+
+ - {Key Series} Button Support for Helm and Counsel: Key series buttons
+ with M-x commands now work properly when counsel-mode or helm-mode are
+ enabled and M-x is rebound.
+
+
===========================================================================
* V7.1.2
===========================================================================
diff --git a/hib-kbd.el b/hib-kbd.el
index b3736cc..074d5f8 100644
--- a/hib-kbd.el
+++ b/hib-kbd.el
@@ -29,6 +29,7 @@
;;; ************************************************************************
(require 'hactypes)
+(require 'seq)
(defvar kbd-key:named-key-list
'("add" "backspace" "begin" "bs" "clear" "decimal" "delete" "del"
@@ -117,10 +118,8 @@ Returns t if KEY-SERIES has a binding, else nil."
(setq current-prefix-arg nil) ;; Execution of the key-series may set it.
(let ((binding (kbd-key:binding key-series)))
(cond ((null binding)
- ;; If this is a special key seqence, execute it by adding
- ;; its keys to the stream of unread command events.
(when (kbd-key:special-sequence-p key-series)
- (kbd-key:key-series-to-events key-series)
+ (kbd-key:execute-special-series key-series)
t))
((memq binding '(action-key action-mouse-key hkey-either))
(beep)
@@ -128,9 +127,32 @@ Returns t if KEY-SERIES has a binding, else nil."
t)
(t (call-interactively binding) t))))
+(defun kbd-key:execute-special-series (key-series)
+ "Execute key series."
+ (if (eq (key-binding [?\M-x]) #'execute-extended-command)
+ (kbd-key:key-series-to-events key-series)
+ ;; Disable helm or counsel while processing M-x commands; helm at
+ ;; least gobbles final RET key,
+ (let ((orig-binding (global-key-binding [?\M-x]))
+ (counsel-flag (and (boundp 'counsel-mode) counsel-mode))
+ (helm-flag (and (boundp 'helm-mode) helm-mode)))
+ (unwind-protect
+ (progn
+ (when counsel-flag (counsel-mode -1))
+ (when helm-flag (helm-mode -1))
+ (global-set-key [?\M-x] 'execute-extended-command)
+ (kbd-key:key-series-to-events key-series)
+ (sit-for 0.001))
+ (when counsel-flag (counsel-mode 1))
+ (when helm-flag (helm-mode 1))
+ (global-set-key [?\M-x] orig-binding)))))
+
(defun kbd-key:key-series-to-events (key-series)
"Insert the key-series as a series of keyboard events into Emacs' unread
input stream."
- (setq unread-command-events (nconc unread-command-events
(listify-key-sequence (kbd-key:kbd key-series)))))
+ (setq unread-command-events (nconc unread-command-events
+ (listify-key-sequence
+ (kbd-key:kbd
+ key-series)))))
(defun kbd-key:doc (key-series &optional full)
"Show first line of doc for binding of keyboard KEY-SERIES in minibuffer.
@@ -263,12 +285,13 @@ For an approximate inverse of this, see
`key-description'."
(setq times (string-to-number (substring word 0 (match-end 1))))
(setq word (substring word (1+ (match-end 1)))))
(cond ((string-match "^<<.+>>$" word)
- (setq key (vconcat (if (eq (key-binding [?\M-x])
- 'execute-extended-command)
- [?\M-x]
- (or (car (where-is-internal
- 'execute-extended-command))
- [?\M-x]))
+ (setq key (vconcat (cond ((memq (key-binding [?\M-x])
+
kbd-key:extended-command-binding-list)
+ [?\M-x])
+ ((seq-filter
+ (lambda (elt) (car (where-is-internal
elt)))
+ kbd-key:extended-command-binding-list)
+ [?\M-x]))
(substring word 2 -2) "\r")))
((and (string-match "^\\(\\([ACHMsS]-\\)*\\)<\\(.+\\)>$" word)
(progn
@@ -409,8 +432,11 @@ a M-x extended command,
;;; ************************************************************************
(defconst kbd-key:extended-command-prefix
- (kbd-key:normalize (key-description (where-is-internal
'execute-extended-command (current-global-map) t)))
- "Normalized prefix string that invokes an extended command; typically ESC
x.")
+ (format "\\_<%s\\_>" (kbd-key:normalize "M-x"))
+ "Normalized prefix regular expression that invokes an extended command; by
default, M-x.")
+
+(defconst kbd-key:extended-command-binding-list '(execute-extended-command
helm-M-x counsel-M-x)
+ "List of commands that may be bound to M-x to invoke extended/named
commands.")
(defvar kbd-key:mini-menu-key nil
"The key sequence that invokes the Hyperbole minibuffer menu.")
- [elpa] externals/hyperbole updated (7184b30 -> d65920b), Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole e26ab90 04/25: (hyperb:init): Remove WSL abbrev of /mnt/c as /c since may not exist, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole a4f880c 01/25: hbdata.el (hbdata:write): Make first ebut in dir work immediately, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole f55f332 03/25: Smart Key activation of global Org links and Agenda items, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole af73116 07/25: hib-kbd.el: Recognize helm-M-x or counsel-M-x bound to M-x,
Stefan Monnier <=
- [elpa] externals/hyperbole 82653d5 06/25: hib-kbd.el: Recognize helm-M-x or counsel-M-x bound to M-x, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 09032d9 13/25: Disable minibuffer-completion-confirm while processing key series, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 74922d1 14/25: Merge Mats dired-sidebar support and rsw mods, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 7eae539 05/25: (hui:ibut-label-create): Skip back past opening delimiter, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 1cf5f3d 16/25: Allow Action Key to expand a tree when point is on the ellipsis, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 9e13b43 02/25: hui-select.el and hyperbole.el reformatting; no logic changes, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 42487cb 09/25: Temporarily disable helm-mode when executing a key series, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole f633365 17/25: Normalize committer email addresses, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 8ef773d 18/25: Add Action/Assist key support for magit modes, Stefan Monnier, 2020/09/22
- [elpa] externals/hyperbole 520ecae 19/25: Fix improper registering of a drag outside of Emacs when none, Stefan Monnier, 2020/09/22