branch: externals/mct
commit 8ac051b52d1d98ec7a3ef31e58a62069abac9040
Author: Protesilaos Stavrou <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>
Reorganise mct-tcm.el; read shifted keys
For a discussion, see issue 25:
<https://gitlab.com/protesilaos/mct/-/issues/25>.
---
mct-tcm.el | 37 ++++++++++++++++++++-----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/mct-tcm.el b/mct-tcm.el
index 5160aac1a4..123427d448 100644
--- a/mct-tcm.el
+++ b/mct-tcm.el
@@ -31,7 +31,20 @@
;;;; General utilities
-;; NOTE 2022-02-22: This is highly experimental!
+;; FIXME 2022-02-22: Silence message when key binding is undefined.
+;;;###autoload
+(define-minor-mode mct-tcm-mode
+ "MCT extension to narrow through the Completions.
+It intercepts any single character input (without modifiers) in
+the Completions' buffer and passes it to the minibuffer as input.
+This practically means that the user can switch to the
+Completions and then type something to bring focus to the
+minibuffer while narrowing to the given input."
+ :global t
+ :group 'mct
+ (if mct-tcm-mode
+ (add-hook 'completion-list-mode-hook
#'mct-tcm--setup-redirect-self-insert)
+ (remove-hook 'completion-list-mode-hook
#'mct-tcm--setup-redirect-self-insert)))
(defun mct-tcm--redirect-self-insert (&rest _args)
"Redirect single character keys as input to the minibuffer."
@@ -40,27 +53,17 @@
(char (aref keys 0))
(mini (active-minibuffer-window)))
(when (and (char-or-string-p char)
- (not (event-modifiers char)))
+ (or (memq 'shift (event-modifiers char))
+ (not (event-modifiers char))))
(select-window mini)
(insert char))))
+(declare-function mct--minibuffer-p "mct")
+
(defun mct-tcm--setup-redirect-self-insert ()
"Set up `mct-tcm--redirect-self-insert'."
(when (mct--minibuffer-p)
(add-hook 'pre-command-hook #'mct-tcm--redirect-self-insert nil t)))
-;; FIXME 2022-02-22: Silence message when key binding is undefined.
-(define-minor-mode mct-tcm-mode
- "MCT extension to narrow through the Completions.
-It intercepts any single character input (without modifiers) in
-the Completions' buffer and passes it to the minibuffer as input.
-This practically means that the user can switch to the
-Completions and then type something to bring focus to the
-minibuffer while narrowing to the given input."
- :global t
- (if mct-tcm-mode
- (add-hook 'completion-list-mode-hook
#'mct-tcm--setup-redirect-self-insert)
- (remove-hook 'completion-list-mode-hook
#'mct-tcm--setup-redirect-self-insert)))
-
-(provide 'mct)
-;;; mct.el ends here
+(provide 'mct-tcm)
+;;; mct-tcm.el ends here