[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ergoemacs-mode 1421a65 06/87: Change how key prefixes a
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ergoemacs-mode 1421a65 06/87: Change how key prefixes are handled. |
Date: |
Wed, 14 Apr 2021 18:46:57 -0400 (EDT) |
branch: externals/ergoemacs-mode
commit 1421a65c51ff548bb53b8fad9ce2b7ae9fb98d62
Author: Fidler <matthew.fidler@gmail.com>
Commit: Fidler <matthew.fidler@gmail.com>
Change how key prefixes are handled.
May fix issues #441 and #439
---
ergoemacs-command-loop.el | 56 +++++++++++++++++++++++++++++++++++++++--------
ergoemacs-mapkeymap.el | 12 +++++-----
ergoemacs-mode.el | 3 ++-
3 files changed, 55 insertions(+), 16 deletions(-)
diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el
index caa886a..5aa9301 100644
--- a/ergoemacs-command-loop.el
+++ b/ergoemacs-command-loop.el
@@ -308,10 +308,11 @@ with this function."
This is called through `ergoemacs-command-loop'"
(interactive)
(cond
- ;; ((not (ergoemacs :command-loop-p))
- ;; ;; Command loop hasn't started.
- ;; (setq current-prefix-arg '(4))
- ;; (ergoemacs-command-loop nil type nil t))
+ ((not (ergoemacs-command-loop-p))
+ ;; Command loop hasn't started.
+ (setq current-prefix-arg '(4))
+ (setq ergoemacs-command-loop-start t)
+ (ergoemacs-command-loop nil (ergoemacs-command-loop--modal-p) nil t))
((not current-prefix-arg)
(setq current-prefix-arg '(4)
ergoemacs-command-loop--universal t
@@ -1040,7 +1041,7 @@ This sequence is compatible with `listify-key-sequence'."
"Determine if `ergoemacs-mode' is running its command loop.
This is done by looking at the current `backtrace' and making
sure that `ergoemacs-command-loop--internal' hasn't been called."
- (eq ergoemacs-last-command-event last-command-event))
+ (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)
@@ -1059,7 +1060,7 @@ argument.
The true work is done in `ergoemacs-command-loop--internal'."
(interactive)
(cond
- ((and ergoemacs-command-loop-start (not (ergoemacs-command-loop-p)))
+ ((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))
(t
@@ -1102,10 +1103,13 @@ 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 ()
- "Determines if the full command loop should be run."
+(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
+is the :full command loop."
(and
- (eq ergoemacs-command-loop-type :full)
+ (or (eq ergoemacs-command-loop-type (or type :full)) (ergoemacs :modal-p))
(ergoemacs-command-loop--minibuffer-supported-p)
(catch 'excluded-variables
(dolist (var ergoemacs-command-loop--excluded-variables)
@@ -1114,6 +1118,40 @@ appropriate value based on the COMMAND."
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-at-time t ergoemacs-command-loop--prefix-timer-polling-time
#'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)))
+
+(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 ergoemacs-command-loop--single-command-keys)))
+
+(add-hook 'ergoemacs-mode-startup-hook
#'ergoemacs-command-loop--start-for-prefix)
+
(defun ergoemacs-command-loop--start-with-pre-command-hook ()
"Start ergoemacs command loop.
diff --git a/ergoemacs-mapkeymap.el b/ergoemacs-mapkeymap.el
index f7c52cc..cb08017 100644
--- a/ergoemacs-mapkeymap.el
+++ b/ergoemacs-mapkeymap.el
@@ -84,8 +84,7 @@ If `ergoemacs-mode' cant determine the value, return nil."
(and (fboundp keymap) (setq tmp (symbol-function
keymap))
(ergoemacs-keymapp tmp) tmp))))))))
-(defvar ergoemacs-map-keymap--submap-stack nil)
-
+(defvar ergoemacs-map-keymap--map-submap-last-map nil)
(defun ergoemacs-map-keymap--map-submap (sub-keymap function &optional
original prefix flat-keymap nil-keys)
"Expose SUB-KEYMAP, then apply `ergoemacs-map-keymap'.
@@ -97,8 +96,8 @@ FLAT-KEYMAP and NIL-KEYS arguments. It is missing the keymap
argument, since it is calculated from the exposed sub-keymap."
(let ((tmp (ergoemacs-map-keymap--expose-keymap sub-keymap)))
(when tmp
- (unless (memq tmp ergoemacs-map-keymap--submap-stack)
- (push tmp ergoemacs-map-keymap--submap-stack)
+ (unless (eq ergoemacs-map-keymap--map-submap-last-map tmp)
+ (setq ergoemacs-map-keymap--map-submap-last-map tmp)
(ergoemacs-map-keymap function
(cond
((eq original :setcdr)
@@ -107,8 +106,7 @@ argument, since it is calculated from the exposed
sub-keymap."
(original
(ergoemacs :original tmp))
(t tmp))
- original prefix flat-keymap nil-keys)
- (pop ergoemacs-map-keymap--submap-stack)))))
+ original prefix flat-keymap nil-keys)))))
(defun ergoemacs-map-keymap (function keymap &optional original prefix
flat-keymap nil-keys)
"Call FUNCTION for all keys in hash table KEYMAP.
@@ -141,6 +139,8 @@ them to be masked when mapping over the keymap."
calc-parent-p
prefix-map
tmp)
+ (when (not prefix)
+ (setq ergoemacs-map-keymap--map-submap-last-map nil))
(when (ergoemacs-keymapp keymap)
(map-keymap
(lambda(event item)
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index c18fd42..618c6b9 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -972,10 +972,11 @@ Valid values are:
(define-obsolete-variable-alias 'ergoemacs-read-swaps
'ergoemacs-command-loop-swap-translation)
-(defcustom ergoemacs-command-loop-type :full
+(defcustom ergoemacs-command-loop-type :prefix-timer
"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 07ef724 22/87: Change ergoemacs-override-keymap key bindings., (continued)
- [elpa] externals/ergoemacs-mode 07ef724 22/87: Change ergoemacs-override-keymap key bindings., Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode a75a338 07/87: Add ergoemacs start prefix correctly, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode f3dd332 23/87: Revert set-map-list, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 98703c4 27/87: Add Swiper keys. Issue #445, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 01197b3 13/87: Add undefined handling, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 4a8de51 19/87: The image is created for the current theme., Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 176af55 10/87: Take out message, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 6051ab5 25/87: Remove unicode fonts setup. Refix Issue #408, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 87fe85a 36/87: No longer try to ensure undo-tree and persistent-soft are installed, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode b4b5241 30/87: Add back ergoemacs-style shift-translation, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 1421a65 06/87: Change how key prefixes are handled.,
Stefan Monnier <=
- [elpa] externals/ergoemacs-mode 59235bb 12/87: Allow ergoemacs-mode to handle ending <apps> keys, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 27c6245 05/87: Remove helm-do-grep. Its no longer found in helm, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode b70d9fe 43/87: Fix back quote., Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode d5d2ba4 39/87: Create extras directory. See Issue #452, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode f5aa0f7 63/87: Merge pull request #496 from wlandry/command_loop, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 10007d2 64/87: Preserve the behavior of 'space' when rebinding inside a minibuffer, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode ad3ec45 73/87: Fix describe-ergoemacs-theme and consolidate menu items, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode eaf2812 79/87: Suppress more warnings, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 347070d 76/87: Some changes, Stefan Monnier, 2021/04/14
- [elpa] externals/ergoemacs-mode 19fea7e 77/87: Fix byte compile of ergoemacs-command-loop, Stefan Monnier, 2021/04/14