[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ergoemacs-mode e6edcbe 15/87: Remove prefix switching t
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ergoemacs-mode e6edcbe 15/87: Remove prefix switching to command loop. |
Date: |
Wed, 14 Apr 2021 18:46:59 -0400 (EDT) |
branch: externals/ergoemacs-mode
commit e6edcbeb2d97ed705da3e074c0be40a06b87ebbd
Author: Fidler <matthew.fidler@gmail.com>
Commit: Fidler <matthew.fidler@gmail.com>
Remove prefix switching to command loop.
---
ergoemacs-advice.el | 31 ++++++--
ergoemacs-command-loop.el | 194 +++++++++++++++++++++-------------------------
ergoemacs-mode.el | 5 +-
3 files changed, 114 insertions(+), 116 deletions(-)
diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el
index d935fef..91d34da 100644
--- a/ergoemacs-advice.el
+++ b/ergoemacs-advice.el
@@ -320,15 +320,30 @@ command selected, instead of rerunning `smex' and
:type :before
(setq ergoemacs-command-loop--single-command-keys nil))
-(defun ergoemacs-mode--undefined-advice ()
- "Advice for undefined."
- (let ((keys (this-single-command-keys)))
- (if (member (substring keys -1) '([apps] [menu]))
- (progn
- (setq ergoemacs-command-loop--eat nil)
- (ergoemacs-command-loop keys))
+(defun ergoemacs-mode--undefined-advice (&optional type)
+ "Advice for undefined.
+
+TYPE is the type of translation installed."
+ (let* ((keys (this-single-command-keys))
+ (type (or type :normal))
+ (translation (ergoemacs-translate--get type))
+ (local-keymap (ergoemacs-translate--keymap translation))
+ (local-key (substring keys -1))
+ modal-p
+ found)
+ (when (setq modal-p (ergoemacs :modal-p))
+ (setq local-keymap (ergoemacs-translation-struct-keymap-modal modal-p)))
+ (if (setq found (lookup-key local-keymap local-key))
+ (let ((i 1)) ;; Setup history
+ (setq ergoemacs-command-loop--history nil)
+ (while (<= i (- (length keys) 1))
+ (push (list (substring keys 0 i) :normal nil
+ current-prefix-arg (aref (substring keys (- i 1) i) 0))
+ ergoemacs-command-loop--history)
+ (setq i (+ 1 i)))
+ (ergoemacs-command-loop keys nil nil nil
ergoemacs-command-loop--history))
(ding)
- (ergoemacs-command-loop--temp-message "%s is undefined!"
+ (ergoemacs-command-loop--temp-message "%s does not do anything!"
(ergoemacs-key-description
(this-single-command-keys)))
(setq defining-kbd-macro nil)
(force-mode-line-update)
diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el
index 43aa902..f9c66a2 100644
--- a/ergoemacs-command-loop.el
+++ b/ergoemacs-command-loop.el
@@ -745,9 +745,77 @@ return nil."
(setq last-input input
input (ergoemacs-command-loop--decode-event input
key-translation-map current-key))
(unless (eq last-input input)
- (setq binding (key-binding (ergoemacs :combine current-key input)
t))))
+ (setq binding (key-binding (ergoemacs :combine current-key input) t))))
input))
+(defun ergoemacs-command-loop--key-msg (blink-on universal text current-key
unchorded trans keys)
+ "Key message.
+
+BLINK-ON is the flag for if the blink is on
+
+UNIVERSAL is if the prompt is in the universal argument.
+
+TEXT for prompting.
+
+CURRENT-KEY Current key.
+
+UNCHORDED is this a unchorded key?
+
+TRANS translation information.
+
+KEYS is the keys information"
+ (format
+ "%s" (concat
+ ergoemacs-command-loop--read-key-prompt
+ (ergoemacs-command-loop--read-key-help-text-prefix-argument blink-on
universal)
+ text
+ (ergoemacs-key-description current-key)
+ unchorded
+ ;; Cursor
+ (or (and (string= ergoemacs-command-loop--read-key-prompt "") "") " ")
+ (or (and universal "")
+ (and ergoemacs-command-loop-blink-character
+ (or (and blink-on (ergoemacs :unicode-or-alt
ergoemacs-command-loop-blink-character "-"))
+ " "))
+ " ")
+ trans
+ keys)))
+
+(defvar erogemacs-command--echo-timer nil)
+(defvar ergoemacs-command--blink-on nil)
+(defvar ergoemacs-orig-echo-keystrokes nil)
+
+(defun ergoemacs-command--echo-prefix ()
+ "Echos prefix keys in the ergoemacs-mode way."
+ (let ((keys (this-single-command-keys)))
+ (unless (or (equal [] keys)
+ (ergoemacs-command-loop-p))
+ (ergoemacs-command-loop--message
+ "%s" (ergoemacs-command-loop--key-msg
+ (setq ergoemacs-command--blink-on (not
ergoemacs-command--blink-on))
+ nil nil
+ (this-single-command-keys)
+ nil nil nil)))))
+
+(defun ergoemacs-command--echo-timer ()
+ "Echo the keystrokes in the `ergoemacs-mode' way."
+ (when (and (not ergoemacs-command-loop-type)
+ (not erogemacs-command--echo-timer))
+ (unless ergoemacs-orig-echo-keystrokes
+ (setq ergoemacs-orig-echo-keystrokes echo-keystrokes))
+ (setq echo-keystrokes 0)
+ (setq erogemacs-command--echo-timer
+ (run-at-time t ergoemacs-command-loop-blink-rate
#'ergoemacs-command--echo-prefix))))
+
+(defun ergoemacs-command--echo-timer-off ()
+ "Turn off the timer."
+ (setq echo-keystrokes ergoemacs-orig-echo-keystrokes)
+ (when erogemacs-command--echo-timer
+ (cancel-timer erogemacs-command--echo-timer)))
+
+(add-hook 'ergoemacs-post-command-hook #'ergoemacs-command--echo-timer)
+(add-hook 'ergoemacs-shutdown-hook #'ergoemacs-command--echo-timer-off)
+
(defun ergoemacs-command-loop--read-key (&optional current-key type universal)
"Read a key for the `ergoemacs-mode' command loop.
@@ -809,10 +877,10 @@ read."
(or (and double
(mapconcat
(lambda(elt)
- ;; (and (setq tmp (elt current-key 0))
- ;; (or (and (consp tmp) (symbolp (setq tmp (car tmp)))))
- ;; (stringp tmp)
- ;; (string-match-p "\\<mouse\\>" tmp))
+ ;; (and (setq tmp (elt current-key
0))
+ ;; (or (and (consp tmp)
(symbolp (setq tmp (car tmp)))))
+ ;; (stringp tmp)
+ ;; (string-match-p
"\\<mouse\\>" tmp))
(format "%s%s%s"
(ergoemacs :modifier-desc
(nth 0 elt))
(ergoemacs
:unicode-or-alt "↔" "<->")
@@ -850,22 +918,7 @@ read."
(while (not input)
(setq blink-on (not blink-on)
input (ergoemacs-command-loop--read-event
- (format
- "%s" (concat
- ergoemacs-command-loop--read-key-prompt
-
(ergoemacs-command-loop--read-key-help-text-prefix-argument blink-on universal)
- text
- (ergoemacs-key-description current-key)
- unchorded
- ;; Cursor
- (or (and (string=
ergoemacs-command-loop--read-key-prompt "") "") " ")
- (or (and universal "")
- (and ergoemacs-command-loop-blink-character
- (or (and blink-on (ergoemacs
:unicode-or-alt ergoemacs-command-loop-blink-character "-"))
- " "))
- " ")
- trans
- keys))
+ (ergoemacs-command-loop--key-msg blink-on universal text
current-key unchorded trans keys)
current-key)))
(cond
((and (setq trans (or (and (memq input mod-keys)
@@ -881,22 +934,7 @@ read."
(while (not input)
(setq blink-on (not blink-on)
input (ergoemacs-command-loop--read-event
- (format
- "%s" (concat
- ergoemacs-command-loop--read-key-prompt
-
(ergoemacs-command-loop--read-key-help-text-prefix-argument blink-on universal)
- text
- (or (and reset-key-p "")
(ergoemacs-key-description current-key))
- unchorded
- ;; Cursor
- (or (and (string=
ergoemacs-command-loop--read-key-prompt "") "") " ")
- (or (and universal "")
- (and ergoemacs-command-loop-blink-character
- (or (and blink-on (ergoemacs
:unicode-or-alt ergoemacs-command-loop-blink-character "-"))
- " "))
- " ")
- "\n"
- "\n"))
+ (ergoemacs-command-loop--key-msg blink-on universal text
current-key unchorded trans keys)
current-key)))
(setq raw-input input
input (ergoemacs-translate--event-mods input trans)
@@ -1044,7 +1082,7 @@ sure that `ergoemacs-command-loop--internal' hasn't been
called."
(eq (symbol-function 'this-command-keys)
#'ergoemacs-command-loop--this-command-keys))
(defvar ergoemacs-command-loop-start nil)
-(defun ergoemacs-command-loop (&optional key type initial-key-type universal)
+(defun ergoemacs-command-loop (&optional key type initial-key-type universal
initial-history)
"Process `ergoemacs-command-loop'.
KEY is the key being read, or sequence being read.
@@ -1057,12 +1095,14 @@ translation.
UNIVERSAL is if the function will be calling a universal
argument.
+INITIAL-HISTORY is the initial history list.
+
The true work is done in `ergoemacs-command-loop--internal'."
(interactive)
(cond
((and (or ergoemacs-command-loop-start key) (not
(ergoemacs-command-loop-p)))
;; (ergoemacs-command-loop--message "Start ergoemacs-mode command loop." )
- (ergoemacs-command-loop--internal key type initial-key-type universal))
+ (ergoemacs-command-loop--internal key type initial-key-type universal
initial-history))
(t
(setq ergoemacs-command-loop--exit :ignore-post-command-hook
prefix-arg current-prefix-arg
@@ -1072,7 +1112,8 @@ The true work is done in
`ergoemacs-command-loop--internal'."
unread-command-events)
ergoemacs-command-loop--universal (if (and
ergoemacs-command-loop--universal (not universal)) nil
universal)
- ergoemacs-command-loop--current-type (or type
ergoemacs-command-loop--current-type)))))
+ ergoemacs-command-loop--current-type (or type
ergoemacs-command-loop--current-type)
+ ergoemacs-command-loop--history (or initial-history
ergoemacs-command-loop--history)))))
(defvar ergoemacs-command-loop--running-pre-command-hook-p nil
"Variable to tell if ergoemacs-command loop is running the
`pre-command-hook'.")
@@ -1103,7 +1144,7 @@ appropriate value based on the COMMAND."
(set (make-local-variable
'ergoemacs-command-loop--minibuffer-unsupported-p) t))
(ergoemacs-command-loop--minibuffer-supported-p)))
-(defun ergoemacs-command-loop-full-p (&optional type )
+(defun ergoemacs-command-loop-full-p (&optional type)
"Determines if the full command loop should be run.
TYPE is the type of command loop to check for. By default this
@@ -1118,63 +1159,6 @@ is the :full command loop."
t)
(not (memq major-mode ergoemacs-command-loop--excluded-major-modes))))
-(defun ergoemacs-command-loop-prefix-timer-p ()
- "Determines if the command loop is run for a prefix timer."
- (ergoemacs-command-loop-full-p :prefix-timer))
-
-(defvar ergoemacs-command-loop--prefix-timer-polling-time 0.1
- "Timer for polling of prefix keys.")
-
-(defvar ergoemacs-command-loop--prefix-timer nil)
-
-(defun ergoemacs-command-loop--prefix-timer ()
- "Start prefix timer for ergoemacs-mode command loop."
- (when (and (null ergoemacs-command-loop--prefix-timer)
- (eq ergoemacs-command-loop-type :prefix-timer))
- (setq ergoemacs-command-loop--prefix-timer
- (run-with-idle-timer
ergoemacs-command-loop--prefix-timer-polling-time t
#'ergoemacs-command-loop--start-for-prefix))))
-
-(defun ergoemacs-command-loop--stop-prefix-timer ()
- "Stop prefix timer for ergoemacs-mode command loop."
- (when ergoemacs-command-loop--prefix-timer
- (cancel-timer ergoemacs-command-loop--prefix-timer)
- (setq ergoemacs-command-loop--prefix-timer nil)))
-
-(defvar ergoemacs-command-loop--eat nil)
-(defvar ergoemacs-command-loop--eat-unread nil)
-(defun ergoemacs-command-loop--start-for-prefix ()
- "Start the ergoemacs command loop for the currently running prefix key."
- (when (and (not (ergoemacs :modal-p))
- (ergoemacs-command-loop-prefix-timer-p)
- (ergoemacs-keymapp (key-binding (this-single-command-keys)))
- (not (ergoemacs-command-loop-p)))
- (setq ergoemacs-command-loop-start t
- ergoemacs-command-loop--single-command-keys (this-single-command-keys)
- ergoemacs-command-loop--eat
ergoemacs-command-loop--single-command-keys
- ergoemacs-command-loop--eat-unread nil)
- (ergoemacs-command-loop--stop-prefix-timer)
- (ergoemacs-command-loop ergoemacs-command-loop--single-command-keys)))
-
-(defun ergoemacs-command-loop--eat ()
- "Eat the key sequence calling the prefix start."
- (when ergoemacs-command-loop--eat
- (let ((map (make-keymap))
- (fn '(lambda ()
- (interactive)
- (setq overriding-terminal-local-map nil
- unread-command-events ergoemacs-command-loop--eat-unread
- ergoemacs-command-loop--eat-unread nil)
- (ergoemacs-command-loop--prefix-timer))))
- (define-key map [eroemacs-eat] fn)
- (define-key map (vconcat ergoemacs-command-loop--eat [eroemacs-eat]) fn)
- (setq overriding-terminal-local-map map
- ergoemacs-command-loop--eat nil
- unread-command-events (list 'ergoemacs-eat)))))
-
-(add-hook 'ergoemacs-mode-startup-hook #'ergoemacs-command-loop--prefix-timer)
-(add-hook 'ergoemacs-mode-shutdown-hook
#'ergoemacs-command-loop--stop-prefix-timer)
-(add-hook 'post-command-hook #'ergoemacs-command-loop--eat)
-
(defun ergoemacs-command-loop--start-with-pre-command-hook ()
"Start ergoemacs command loop.
@@ -1630,7 +1614,8 @@ instead of `format'."
(setq ergoemacs-command-loop--spinner-list (nth 1 (assoc
ergoemacs-command-loop-spinner ergoemacs-command-loop-spinners))
ergoemacs-command-loop--spinner-i 0))
(ergoemacs-command-loop--message "%s%s" (nth (mod (setq
ergoemacs-command-loop--spinner-i (+ 1 ergoemacs-command-loop--spinner-i))
- (length
ergoemacs-command-loop--spinner-list)) ergoemacs-command-loop--spinner-list)
+ (length
ergoemacs-command-loop--spinner-list))
+
ergoemacs-command-loop--spinner-list)
rest))))))
(defun ergoemacs-command-loop--spinner-end ()
@@ -1653,7 +1638,7 @@ Used to replace:
Currently these are all vectors and all ingore prefix arguments.
They don't exactly behave like their Emacs equivalents."
- (or (and ergoemacs-mode `ergoemacs-command-loop--single-command-keys)
+ (or (and ergoemacs-mode ergoemacs-command-loop--single-command-keys)
(funcall ergoemacs-command-loop--this-command-keys)))
(defvar ergoemacs-command-loop--timer nil
@@ -1706,7 +1691,7 @@ Ignore all the other options."
ergoemacs-command-loop--read-key-prompt old-prompt))
ret))
-(defun ergoemacs-command-loop--internal (&optional key type initial-key-type
universal)
+(defun ergoemacs-command-loop--internal (&optional key type initial-key-type
universal initial-history)
"Read keyboard input and execute command.
The KEY is the keyboard input where the reading begins. If nil,
read the whole keymap.
@@ -1719,6 +1704,8 @@ INITIAL-KEY-TYPE represents the translation type for the
initial KEY.
UNIVERSAL allows ergoemacs-read-key to start with universal
argument prompt.
+INITIAL-HISTORY is the initial history list to use.
+
While in the loop, every command resets the keys typed every time
a command is completed (by `clear-this-command-keys')
@@ -1764,7 +1751,7 @@ Emacs versions)."
(setq tmp (ergoemacs-command-loop--listify-key-sequence key
initial-key-type)
unread-command-events (or (and unread-command-events tmp
(append tmp unread-command-events)) tmp)
ergoemacs-command-loop--first-type first-type
- ergoemacs-command-loop--history nil
+ ergoemacs-command-loop--history initial-history
ergoemacs-command-loop-start nil)
(while continue-read
(setq ergoemacs-last-command-was-ergoemacs-ignore-p nil)
@@ -1824,9 +1811,6 @@ Emacs versions)."
(ergoemacs-command-loop--call-interactively this-command)
(setq command this-command
this-command tmp))
- (when (and ergoemacs-command-loop--eat
unread-command-events)
- (setq ergoemacs-command-loop--eat-unread
unread-command-events
- unread-command-events nil))
;; If the command changed anything, fix it here.
(unless (equal type ergoemacs-command-loop--current-type)
(setq type ergoemacs-command-loop--current-type
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index 618c6b9..4a42086 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -596,7 +596,7 @@ When STORE-P is non-nil, save the tables."
(ergoemacs-timing (intern (format "load-%s" pkg))
(load (symbol-name pkg)))))
-(defcustom ergoemacs-use-unicode-symbols t
+(defcustom ergoemacs-use-unicode-symbols nil
"Use unicode symbols in display."
:type 'boolean
:group 'ergoemacs-mode)
@@ -972,11 +972,10 @@ Valid values are:
(define-obsolete-variable-alias 'ergoemacs-read-swaps
'ergoemacs-command-loop-swap-translation)
-(defcustom ergoemacs-command-loop-type :prefix-timer
+(defcustom ergoemacs-command-loop-type nil
"Type of `ergoemacs-mode' command loop."
:type '(choice
(const :tag "Replace emacs command loop (full)" :full)
- (const :tag "Use command loop on prefix keys by timer" :prefix-timer)
;; (const :tag "Test mode; Don't actually run command " :test)
(const :tag "No command loop support" nil))
:group 'ergoemacs-comamnd-loop)
- [elpa] externals/ergoemacs-mode b61ece8 74/87: Merge remote-tracking branch 'elpa/externals/ergoemacs-mode', (continued)
- [elpa] externals/ergoemacs-mode b61ece8 74/87: Merge remote-tracking branch 'elpa/externals/ergoemacs-mode', Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 543bc98 78/87: Silence ergoemacs-functions byte compile warnings, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode f9d6e3f 87/87: Bring over some more emacs mainatiner fixes, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode cac7b56 51/87: Fix (string-match-p error), Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode f3f4bf0 75/87: Revert "Merge remote-tracking branch 'elpa/externals/ergoemacs-mode'", Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode dde41b4 81/87: Fix some more warnings and test icy stuff only when icy is there, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode dc9c567 83/87: Add back the highlighting of the end key, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 7df155e 40/87: Don't refresh the package contents. See #452, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode dfb5a43 48/87: Add key to fix Issue #470, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 78e8d55 85/87: Fix regression with #503, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode e6edcbe 15/87: Remove prefix switching to command loop.,
Stefan Monnier <=
- [elpa] externals/ergoemacs-mode 6ec72c0 86/87: Go back to ergoemacs-display-key-use-face (suggestion from emacs devs), Stefan Monnier, 2021/04/14