[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/mct 7ebf1826b5 02/23: Put "continuous input" code in it
From: |
ELPA Syncer |
Subject: |
[elpa] externals/mct 7ebf1826b5 02/23: Put "continuous input" code in its own file |
Date: |
Fri, 25 Feb 2022 07:57:37 -0500 (EST) |
branch: externals/mct
commit 7ebf1826b511230babd9e6b661ae273bb0fae25d
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Put "continuous input" code in its own file
For a discussion about the ongoing development, see issue 25:
<https://gitlab.com/protesilaos/mct/-/issues/25>.
---
mct-tcm.el | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
mct.el | 31 -------------------------------
2 files changed, 61 insertions(+), 31 deletions(-)
diff --git a/mct-tcm.el b/mct-tcm.el
new file mode 100644
index 0000000000..be82165a7a
--- /dev/null
+++ b/mct-tcm.el
@@ -0,0 +1,61 @@
+;;; mct-tcm.el --- MCT which Treats the Completions as the Minibuffer -*-
lexical-binding: t -*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Protesilaos Stavrou <info@protesilaos.com>
+;; URL: https://gitlab.com/protesilaos/mct
+;; Version: 0.5.0
+;; Package-Requires: ((emacs "27.1"))
+
+;; This file is NOT part of GNU Emacs.
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or (at
+;; your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; An extension to MCT that intercepts single character keys in the
+;; Completions' buffer and send them as input in the minibuffer.
+
+;;; Code:
+
+;;;; General utilities
+
+;; NOTE 2022-02-22: This is highly experimental!
+
+(defun mct-tcm--redirect-self-insert (&rest _args)
+ "Redirect to the minibuffer per `mct-tcm-continuous-self-insert'."
+ (when-let* ((mct-tcm-mode)
+ (keys (this-single-command-keys))
+ (char (aref keys 0))
+ (mini (active-minibuffer-window)))
+ (when (and (char-or-string-p char)
+ (not (event-modifiers char)))
+ (select-window mini)
+ (insert char))))
+
+(defun mct-tcm--setup-redirect-self-insert ()
+ "Set up `mct-tcm-continuous-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."
+ :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
diff --git a/mct.el b/mct.el
index cec592cc22..ef044cbf0a 100644
--- a/mct.el
+++ b/mct.el
@@ -258,20 +258,6 @@ affairs."
:type 'boolean
:group 'mct)
-;; NOTE 2022-02-22: This is highly experimental!
-(defcustom mct-continuous-self-insert nil
- "Redirect self-insertions from the Completions to the minibuffer.
-When this variable is set to non-nil value, MCT will intercept
-any call to `self-insert-command' or single character key and
-send it to the minibuffer.
-
-This practically means that while typing in the Completions, the
-input is used to narrow the list of candidates (whereas the
-default is to let the Completions use their own keys and not try
-to send the input to the minibuffer)."
- :type 'boolean
- :group 'mct)
-
;;;; Completion metadata
(defun mct--this-command ()
@@ -315,22 +301,6 @@ to send the input to the minibuffer)."
;;;; Basics of intersection between minibuffer and Completions' buffer
-;; FIXME 2022-02-22: Silence message when key binding is undefined.
-(defun mct--redirect-self-insert (&rest _args)
- "Redirect to the minibuffer per `mct-continuous-self-insert'."
- (when-let* ((mct-continuous-self-insert)
- (keys (this-single-command-keys))
- (char (aref keys 0))
- (mini (active-minibuffer-window)))
- (when (and (char-or-string-p char)
- (not (event-modifiers char)))
- (select-window mini)
- (insert char))))
-
-(defun mct--setup-redirect-self-insert ()
- "Set up `mct-continuous-self-insert'."
- (add-hook 'pre-command-hook #'mct--redirect-self-insert nil t))
-
(define-obsolete-variable-alias
'mct-hl-line 'mct-highlight-candidate "0.3.0")
@@ -1200,7 +1170,6 @@ region.")
(mct--setup-appearance)
(mct--setup-completion-list-keymap)
(mct--setup-highlighting)
- (mct--setup-redirect-self-insert)
(mct--setup-line-numbers)
(cursor-sensor-mode)))
- [elpa] externals/mct d55400b6b1 13/23: Improve mct-tcm documentation, (continued)
- [elpa] externals/mct d55400b6b1 13/23: Improve mct-tcm documentation, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 894a6ccc84 19/23: Require seq library in mct-tcm, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 038ff66a54 06/23: Refine mct-tcm interaction model, ELPA Syncer, 2022/02/25
- [elpa] externals/mct a551ab0fdb 05/23: Require mct library, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 9e11607409 14/23: Minor rewording, ELPA Syncer, 2022/02/25
- [elpa] externals/mct dea21e4701 23/23: Warn about mct extensions directory, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 79416f1ca8 08/23: Fix indentation, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 6b6b9c3a9f 18/23: Require subr-x only at compile time, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 35384917af 01/23: Add prototype for continuous input, ELPA Syncer, 2022/02/25
- [elpa] externals/mct f9394ede61 10/23: Add FIXME for weird Emacs 27 bug, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 7ebf1826b5 02/23: Put "continuous input" code in its own file,
ELPA Syncer <=
- [elpa] externals/mct cf9af9118a 12/23: Remove superfluous 'declare-function', ELPA Syncer, 2022/02/25
- [elpa] externals/mct bd105cc7b4 17/23: Handle C-DEL and M-DEL in mct-tcm, ELPA Syncer, 2022/02/25
- [elpa] externals/mct b37bdeb0bf 21/23: Move mct-tcm.el to "extensions" directory, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 3193a95c30 11/23: Simplify &rest in private function, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 1d254a0bb7 16/23: Handle backspace or DEL in mct-tcm, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 973ab321a8 20/23: Add FIXME for Emacs 27, ELPA Syncer, 2022/02/25
- [elpa] externals/mct 8ee4e6d799 09/23: Set mct-live-completion to non-nil, not visible, ELPA Syncer, 2022/02/25
- [elpa] externals/mct e50b222fdf 22/23: Merge branch 'experiment-continuous-input', ELPA Syncer, 2022/02/25