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

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

[elpa] externals/ergoemacs-mode 9b72665 304/325: Use passthrough for kil


From: Stefan Monnier
Subject: [elpa] externals/ergoemacs-mode 9b72665 304/325: Use passthrough for kill-line
Date: Sat, 23 Oct 2021 18:49:16 -0400 (EDT)

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

    Use passthrough for kill-line
---
 ergoemacs-advice.el    |  2 +-
 ergoemacs-cua.el       | 41 ++++++++++++++++++++++++++---------------
 ergoemacs-functions.el | 25 +++++++++++++++++++++++++
 ergoemacs-mode.el      |  4 +++-
 ergoemacs-themes.el    |  2 +-
 5 files changed, 56 insertions(+), 18 deletions(-)

diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el
index 38af9d6..39da47e 100644
--- a/ergoemacs-advice.el
+++ b/ergoemacs-advice.el
@@ -96,7 +96,7 @@ TYPE is the type of translation installed."
 
 (defun ergoemacs-advice-undefined (orig-fun)
   "Allow `ergoemacs-mode' to display keys, and intercept ending <apps> keys."
-  (if ergoemacs-mode
+  (if (and ergoemacs-mode (not ergoemacs--temporary-disable))
       (ergoemacs-mode--undefined-advice)
     (call-interactively orig-fun)))
  
diff --git a/ergoemacs-cua.el b/ergoemacs-cua.el
index 7a276ba..6584e63 100644
--- a/ergoemacs-cua.el
+++ b/ergoemacs-cua.el
@@ -113,21 +113,36 @@ This is also used to select the region keymaps.")
 
 This override is enabled for active regions before the copy and paste are 
enabled.")
 
-
-
 (defvar ergoemacs-inhibit-cua-keys nil
   "Buffer-local variable that may disable the CUA keymappings.")
 (make-variable-buffer-local 'ergoemacs-inhibit-cua-keys)
 
 (defvar ergeoemacs-mode-term-raw-mode)
+(defvar ergoemacs-mode)
+(defvar ergoemacs--temporary-disable)
 
 (defun ergoemacs--select-keymaps ()
   "Setup conditions for selecting the proper keymaps in 
`ergoemacs--keymap-alist'."
-  ;; The prefix override (when mark-active) operates in three substates:
-  ;; [1] Before using a prefix key
-  ;; [2] Immediately after using a prefix key
-  ;; [3] A fraction of a second later
-  (setq ergoemacs--ena-region-keymap ; Determines if the ergion is active
+  (when ergoemacs--temporary-disable
+    ;; The temporary disable commands set `ergoemacs--temporary-disable' to t
+    ;; The first time when the keys are put on the `unread-command-events', 
`ergoemacs-mode' is disabled
+    ;; The second command is executed, and `ergoemacs-mode' is turned back on 
and `ergoemacs--temporary-disable' is to nil
+    (if ergoemacs-mode
+        (progn
+          (setq ergoemacs--ena-region-keymap nil
+              ergoemacs--ena-prefix-override-keymap nil
+              ergoemacs--ena-prefix-repeat-keymap nil
+              ergoemacs-mode nil)
+          (message "disable ergoemacs again"))
+      (setq ergoemacs--temporary-disable nil
+            ergoemacs-mode t))
+    (message "enable ergoemacs again"))
+  (when ergoemacs-mode
+    ;; The prefix override (when mark-active) operates in three substates:
+    ;; [1] Before using a prefix key
+    ;; [2] Immediately after using a prefix key
+    ;; [3] A fraction of a second later
+    (setq ergoemacs--ena-region-keymap ; Determines if the ergion is active
         (and (not ergeoemacs-mode-term-raw-mode) (region-active-p) (not 
deactivate-mark))
         ;; Enable Override -- This is the first state where the keys are 
intercepted; cua state [1]
         ergoemacs--ena-prefix-override-keymap
@@ -144,10 +159,7 @@ This override is enabled for active regions before the 
copy and paste are enable
         (and ergoemacs--ena-region-keymap
              (not ergeoemacs-mode-term-raw-mode)
                 (or (timerp ergoemacs--prefix-override-timer)
-                        (eq ergoemacs--prefix-override-timer 'shift))))
-  ;; In ergoemacs-mode the corresponding `cua--ena-cua-keys-keymap' and 
`cua--ena-global-mark-keymap' are not needed or used
-  (message "r: %s po: %s pr: %s")
-  )
+                        (eq ergoemacs--prefix-override-timer 'shift))))))
 
 (defun ergoemacs--prefix-override-timeout ()
   "This is whap happens on the `ergoemacs-mode' timeout for C-c and C-v are 
supplied."
@@ -253,10 +265,9 @@ Pass prefix ARG to the respective copy functions."
 
 (defun ergoemacs--cua-post-command-handler ()
   "Post command hook for `ergoemacs-mode' based cua keys."
-  (when ergoemacs-mode
-    (condition-case nil
-        (ergoemacs--cua-post-command-handler-1)
-      (error nil))))
+  (condition-case nil
+      (ergoemacs--cua-post-command-handler-1)
+    (error nil)))
 
 (add-hook 'post-command-hook #'ergoemacs--cua-post-command-handler)
 (add-hook 'pre-command-hook  #'ergoemacs--cua-pre-command-handler)
diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el
index e1773f3..14f6ffa 100644
--- a/ergoemacs-functions.el
+++ b/ergoemacs-functions.el
@@ -95,12 +95,37 @@
 (declare-function w32-long-file-name "compat")
 (declare-function term-paste "term")
 (declare-function calc-yank "calc-yank")
+(defvar ergoemacs-temporary-disable)
 
 (defcustom ergoemacs-isearch-backward-char-to-edit nil
   "Backward char will edit isearch."
   :type 'boolean
   :group 'ergoemacs-mode)
 
+(defun ergoemacs--send-emacs-key (key)
+  "This replays the events from the intial key press.
+
+REPEAT is the flag that tells it if is repeated environmennt."
+  ;; Don't record this command
+  (setq ergoemacs--temporary-disable t
+        this-command last-command)
+  ;; Restore the prefix arg
+  (prefix-command-preserve-state)
+  ;; Push the key back on the event queue
+  (setq unread-command-events (list (cons 'no-record key))))
+
+(defun ergoemacs-kill-line (&optional arg)
+  "Kill the rest of the (visual) line.
+
+This is often `kill-visual-line' or `kill-line'. 
+
+The ARG was is used in the above functions, and is called by 
+temporarily turning off `ergoemacs-mode' and then sending the 
+emacs defualt kill line control k key to the `unread-command-events'"
+  (interactive "P")
+  (ergoemacs--send-emacs-key ?\C-k))
+
+    
 
 (defvar ergoemacs-delete-functions
   '(delete-backward-char delete-char kill-word backward-kill-word)
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index f407da6..7b0c219 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -118,7 +118,6 @@ Added beginning-of-buffer Alt+n (QWERTY notation) and 
end-of-buffer Alt+Shift+n"
   :initialize #'custom-initialize-default
   :group 'ergoemacs-mode)
 
-
 (defcustom ergoemacs-mode-line t
   "Determines when the ergoemacs-mode modeline indicator is shown."
   :type '(choice
@@ -155,6 +154,9 @@ The TEXT will be what the mode-line is set to be."
 
 (font-lock-add-keywords 'emacs-lisp-mode ergoemacs-font-lock-keywords)
 
+(defvar ergoemacs--temporary-disable nil
+  "Variable for temporarily disabling `ergoemacs-mode'")
+
 
 
 (defvar ergoemacs-mode-startup-hook nil
diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index 04231fc..52431e4 100644
--- a/ergoemacs-themes.el
+++ b/ergoemacs-themes.el
@@ -544,7 +544,7 @@ These keys do not depend on the layout."
 
 (defun ergoemacs-set-kill-line (keymap)
   "Kill Line for KEYMAP."
-  (ergoemacs-define-key keymap (kbd "M-g") 'kill-line)
+  (ergoemacs-define-key keymap (kbd "M-g") 'ergoemacs-kill-line)
   (ergoemacs-define-key keymap (kbd "M-G") 'ergoemacs-kill-line-backward))
 
 (defun ergoemacs-set-text-transform (keymap)



reply via email to

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