emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ergoemacs-mode 6c4b457 280/325: Add emacs type of comma


From: Stefan Monnier
Subject: [elpa] externals/ergoemacs-mode 6c4b457 280/325: Add emacs type of command loop support.
Date: Sat, 23 Oct 2021 18:49:11 -0400 (EDT)

branch: externals/ergoemacs-mode
commit 6c4b4573e527343969b3228a2481bdeadb37c17c
Author: Matthew Fidler <514778+mattfidler@users.noreply.github.com>
Commit: Matthew Fidler <514778+mattfidler@users.noreply.github.com>

    Add emacs type of command loop support.
---
 ergoemacs-advice.el       |  2 +-
 ergoemacs-command-loop.el | 39 ++++++++++++++++++++++++++++++++++++---
 ergoemacs-themes.el       | 15 +++------------
 3 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el
index feb7724..9338ce6 100644
--- a/ergoemacs-advice.el
+++ b/ergoemacs-advice.el
@@ -74,7 +74,7 @@ TYPE is the type of translation installed."
     (when (setq modal-p (ergoemacs :modal-p))
       (setq local-keymap (ergoemacs-translation-struct-keymap-modal modal-p)))
     ;; This starts the command loop when DEL or MENU is replaced in the proper 
place.
-    (if (lookup-key local-keymap local-key)
+    (if (and (not (eq ergoemacs-command-loop-type :emacs)) (lookup-key 
local-keymap local-key))
            (let ((i 1)) ;; Setup history
              (setq ergoemacs-command-loop--history nil)
              (while (<= i (- (length keys) 1))
diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el
index 3f1540b..290e09a 100644
--- a/ergoemacs-command-loop.el
+++ b/ergoemacs-command-loop.el
@@ -217,7 +217,8 @@ ignore the post-command hooks.")
   :type '(choice
           (const :tag "Replace emacs command loop (full)" :full)
           ;; (const :tag "Test mode; Don't actually run command " :test)
-          (const :tag "No command loop support" nil))
+          (const :tag "Command Loop when called directly" nil)
+          (const :tag "Emacs" :emacs))
   :group 'ergoemacs-comamnd-loop)
 
 (defcustom ergoemacs-command-loop-hide-shift-translations t
@@ -252,7 +253,6 @@ ignore the post-command hooks.")
 (defvar ergoemacs-mode)
 (defvar ergoemacs-command-loop-type)
 (defvar ergoemacs-keymap)
-(defvar ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)
 (defvar ergoemacs-ctl-c-or-ctl-x-delay)
 
 
@@ -953,7 +953,6 @@ read."
             modal tmp
             tmp nil))
     
-    ;; (ergoemacs-command-loop--read-key (read-kbd-macro "C-x" t) 
:unchorded-ctl)
     (when (functionp text)
       (setq text (funcall text)))
 
@@ -2359,6 +2358,40 @@ For instance in QWERTY M-> is shift translated to M-."
     (setq ergoemacs-this-command-keys-shift-translated t
          this-command-keys-shift-translated t)
     (ergoemacs-command-loop--call-interactively (key-binding shift-trans))))
+
+
+(defun ergoemacs-command-loop-C-c-unchorded ()
+  "Unchorded C-c."
+  (interactive)
+  (when (eq ergoemacs-command-loop-type :emacs)
+    (error "Unchorded C-c requires ergoemacs command loop"))
+  (let ((i 1)
+        (keys (this-single-command-keys)))
+       (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 "C-c" :unchorded-ctl nil nil 
ergoemacs-command-loop--history)))
+
+
+(defun ergoemacs-command-loop-C-x-ctl-to-alt ()
+  "Unchorded C-x."
+  (interactive)
+  (when (eq ergoemacs-command-loop-type :emacs)
+    (error "Unchorded C-x requires ergoemacs command loop"))
+  (let ((i 1)
+        (keys (this-single-command-keys)))
+       (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 "C-x" :ctl-to-alt nil nil 
ergoemacs-command-loop--history)))
+
+
 (provide 'ergoemacs-command-loop)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; ergoemacs-command-loop.el ends here
diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index a35a946..8ac744d 100644
--- a/ergoemacs-themes.el
+++ b/ergoemacs-themes.el
@@ -618,17 +618,8 @@ These keys do not depend on the layout."
   (ergoemacs-define-key keymap (kbd "<apps> SPC") 'set-mark-command)
   (ergoemacs-define-key keymap (kbd "<apps> a") 'mark-whole-buffer)
 
-  (ergoemacs-define-key ergoemacs-override-keymap
-                       (kbd "<apps> f")
-                       (lambda ()
-                          (interactive)
-                          (ergoemacs-command-loop "C-x" :ctl-to-alt)))
-
-  (ergoemacs-define-key ergoemacs-override-keymap
-                       (kbd "<apps> d")
-                       (lambda ()
-                          (interactive)
-                          (ergoemacs-command-loop "C-c" :unchorded-ctl)))
+  (ergoemacs-define-key ergoemacs-override-keymap (kbd "<apps> f") 
'ergoemacs-command-loop-C-x-ctl-to-alt)
+  (ergoemacs-define-key ergoemacs-override-keymap (kbd "<apps> d") 
'ergoemacs-command-loop-C-c-unchorded)
 
   (ergoemacs-define-key        ergoemacs-override-keymap (kbd "<menu> n") 
'org-agenda (kbd "a"))
   (ergoemacs-define-key        ergoemacs-override-keymap (kbd "<menu> n") 
'org-capture (kbd "A"))
@@ -646,7 +637,7 @@ These keys do not depend on the layout."
   (ergoemacs-define-key        ergoemacs-override-keymap (kbd "<menu> n") 
'org-capture (kbd "t"))
   (ergoemacs-define-key        ergoemacs-override-keymap (kbd "<menu> n") 
'org-agenda (kbd "C-t"))
   (ergoemacs-define-key        ergoemacs-override-keymap (kbd "<menu> n") 
'org-agenda (kbd "T"))
-
+  
   (define-key ergoemacs-translate--parent-map [f2] 
'ergoemacs-command-loop--force-universal-argument)
   (define-key ergoemacs-translate--parent-map (kbd "DEL") 
'ergoemacs-command-loop--force-undo-last)
   (define-key ergoemacs-translate--parent-map  (if (eq system-type 
'windows-nt) [apps] [menu])



reply via email to

[Prev in Thread] Current Thread [Next in Thread]