[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ergoemacs-mode 0d2d1c6 308/325: Change how sending emac
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ergoemacs-mode 0d2d1c6 308/325: Change how sending emacs keys works |
Date: |
Sat, 23 Oct 2021 18:49:17 -0400 (EDT) |
branch: externals/ergoemacs-mode
commit 0d2d1c6b0916a18b0f9e1942a7c11d6bd2b47656
Author: Matthew Fidler <514778+mattfidler@users.noreply.github.com>
Commit: Matthew Fidler <514778+mattfidler@users.noreply.github.com>
Change how sending emacs keys works
---
ergoemacs-calculate-bindings.el | 2 +-
ergoemacs-cua.el | 17 +++++++++++------
ergoemacs-functions.el | 36 +++++++++++++++++-------------------
ergoemacs-mode.el | 22 ++++++++++++++++++----
ergoemacs-themes.el | 2 +-
5 files changed, 48 insertions(+), 31 deletions(-)
diff --git a/ergoemacs-calculate-bindings.el b/ergoemacs-calculate-bindings.el
index 3cd6c18..4202453 100644
--- a/ergoemacs-calculate-bindings.el
+++ b/ergoemacs-calculate-bindings.el
@@ -95,7 +95,7 @@
("C-x b" switch-to-buffer)
("C-x C-b" ibuffer)
("C-x C-b" execute-extended-command)
- ("C-k" ergoemacs-kill-line)
+ ("C-k" kill-line)
("M-TAB" ergoemacs-call-keyword-completion))
"Ergoemacs short command names."
:group 'ergoemacs-themes
diff --git a/ergoemacs-cua.el b/ergoemacs-cua.el
index cf53284..c73bb61 100644
--- a/ergoemacs-cua.el
+++ b/ergoemacs-cua.el
@@ -120,21 +120,25 @@ This override is enabled for active regions before the
copy and paste are enable
(defvar ergeoemacs-mode-term-raw-mode)
(defvar ergoemacs-mode)
(defvar ergoemacs--temporary-disable)
-
+(defvar ergoemacs-mode-regular)
+(defvar ergoemacs-mode-send-emacs-keys)
(defun ergoemacs--select-keymaps ()
"Setup conditions for selecting the proper keymaps in
`ergoemacs--keymap-alist'."
(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
+ (if ergoemacs-mode-regular
(progn
(setq ergoemacs--ena-region-keymap nil
ergoemacs--ena-prefix-override-keymap nil
ergoemacs--ena-prefix-repeat-keymap nil
- ergoemacs-mode nil))
+ ergoemacs-mode-regular nil
+ ergoemacs-mode-send-emacs-keys nil))
(setq ergoemacs--temporary-disable nil
- ergoemacs-mode t)))
+ ergoemacs-mode-regular t
+ ;; This assumes that `ergoemacs--tempoary-disable' is only called
on the remap keys layer
+ ergoemacs-mode-send-emacs-keys t)))
(when ergoemacs-mode
;; The prefix override (when mark-active) operates in three substates:
;; [1] Before using a prefix key
@@ -263,9 +267,10 @@ Pass prefix ARG to the respective copy functions."
(defun ergoemacs--cua-post-command-handler ()
"Post command hook for `ergoemacs-mode' based cua keys."
- (condition-case nil
+ (when ergoemacs-mode
+ (condition-case nil
(ergoemacs--cua-post-command-handler-1)
- (error nil)))
+ (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 5066c60..d67ff56 100644
--- a/ergoemacs-functions.el
+++ b/ergoemacs-functions.el
@@ -102,22 +102,32 @@
:type 'boolean
:group 'ergoemacs-mode)
-(defun ergoemacs--send-emacs-key (key)
+(defun ergoemacs--send-emacs-key (key &optional key2 key3)
"This replays the events from the intial key press.
-REPEAT is the flag that tells it if is repeated environmennt."
+KEY is the first key in the sequence.
+KEY2 is the optional second key in the sequence.
+KEY3 is the optional third key in the sequence."
;; 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))))
-
-
-
+ (when key3
+ (setq unread-command-events (cons (cons 'no-record key3)
+ unread-command-events)))
+ (when key2
+ (setq unread-command-events (cons (cons 'no-record key2)
+ unread-command-events)))
+ (setq unread-command-events (cons (cons 'no-record key)
+ unread-command-events)))
+
+(defun ergoemacs-kill-line ()
+ "Ergoemacs replacement for `kill-line' using `ergoemacs--send-emacs-key'."
+ (interactive)
+ (ergoemacs--send-emacs-key ?\C-k))
-
(defvar ergoemacs-delete-functions
'(delete-backward-char delete-char kill-word backward-kill-word)
"Defines deletion functions that ergoemacs is aware of.")
@@ -1122,18 +1132,6 @@ Subsequent calls expands the selection to larger
semantic unit."
(mark-sexp -1))))
;;; TEXT TRANSFORMATION RELATED
-
-(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))
-
(defun ergoemacs-kill-line-backward (&optional number)
"Kill text between the beginning of the line to the cursor position.
If there's no text, delete the previous line ending."
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index 7b0c219..a127e78 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -126,6 +126,16 @@ Added beginning-of-buffer Alt+n (QWERTY notation) and
end-of-buffer Alt+Shift+n"
(const :tag "Never Show Mode Line" nil))
:group 'ergoemacs-mode)
+(defcustom ergoemacs-mode-send-emacs-keys t
+ "When t, send corresponding Emacs keys for `ergoemacs-mode' commands."
+ :type 'boolean
+ :group 'ergoemacs-mode)
+
+(defvar ergoemacs--send-emacs-keys-map (let ((map (make-sparse-keymap)))
+ (define-key map [remap kill-line]
'ergoemacs-kill-line)
+ map)
+ "This defines the remaps for the `ergoemacs-mode-send-emacs-keys' commands.")
+
(defun ergoemacs-mode-line (&optional text)
"Set ergoemacs-mode-line.
@@ -182,6 +192,7 @@ The TEXT will be what the mode-line is set to be."
(defvar ergoemacs-post-command-hook nil)
(defvar ergeoemacs-mode-term-raw-mode nil)
+(defvar ergoemacs-mode-regular nil)
(defun ergoemacs-post-command-hook ()
"Run `ergoemacs-mode' post command hooks."
(when ergoemacs-mode
@@ -253,6 +264,7 @@ IS-ERGOEMACS is true when the `ergoemacs-mode' keybindings
are installed."
(dolist (k ergoemacs-mode--save-keymaps-list)
(set k (ergoemacs-mode--get-map k is-ergoemacs))))
+
;; ErgoEmacs minor mode
;;;###autoload
(define-minor-mode ergoemacs-mode
@@ -279,7 +291,7 @@ The `execute-extended-command' is now
\\[execute-extended-command].
(add-hook 'pre-command-hook #'ergoemacs-pre-command-hook)
(add-hook 'post-command-hook #'ergoemacs-post-command-hook)
(add-hook 'after-load-functions #'ergoemacs-after-load-functions)
-
+ (setq ergoemacs-mode-regular t)
(setq ergoemacs-mode--default-frame-alist nil)
(dolist (elt (reverse default-frame-alist))
(push elt ergoemacs-mode--default-frame-alist))
@@ -317,6 +329,7 @@ The `execute-extended-command' is now
\\[execute-extended-command].
(remove-hook 'after-load-functions #'ergoemacs-after-load-functions)
(ergoemacs-mode--restore-maps)
(define-key global-map [menu-bar] ergoemacs-old-menu)
+ (setq ergoemacs-mode-regular nil)
(message "Ergoemacs-mode turned OFF.")))
(defvar ergoemacs-translate--event-hash (make-hash-table)
@@ -430,9 +443,10 @@ after initializing ergoemacs-mode.
(ergoemacs--ena-prefix-override-keymap .
,ergoemacs--prefix-override-keymap)
(ergoemacs--ena-prefix-repeat-keymap .
,ergoemacs--prefix-repeat-keymap)
(ergoemacs--ena-region-keymap .
,ergoemacs-mark-active-keymap)
- (ergoemacs-mode . ,ergoemacs-user-keymap)
- (ergoemacs-mode .
,ergoemacs-override-keymap)
- (ergoemacs-mode . ,ergoemacs-keymap)))
+ (ergoemacs-mode-regular .
,ergoemacs-user-keymap)
+ (ergoemacs-mode-regular .
,ergoemacs-override-keymap)
+ (ergoemacs-mode-regular . ,ergoemacs-keymap)
+ (ergoemacs-mode-send-emacs-keys .
,ergoemacs--send-emacs-keys-map)))
(add-hook 'emulation-mode-map-alists ergoemacs-override-alist)
(advice-add 'undefined :around #'ergoemacs-advice-undefined)
(advice-add 'read-key :before #'ergoemacs-advice-read-key))
diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index 52431e4..04231fc 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") 'ergoemacs-kill-line)
+ (ergoemacs-define-key keymap (kbd "M-g") 'kill-line)
(ergoemacs-define-key keymap (kbd "M-G") 'ergoemacs-kill-line-backward))
(defun ergoemacs-set-text-transform (keymap)
- [elpa] externals/ergoemacs-mode 59c8ab0 285/325: Remove ergoemacs substitute command keys, (continued)
- [elpa] externals/ergoemacs-mode 59c8ab0 285/325: Remove ergoemacs substitute command keys, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 1ef93b5 277/325: Add major modes menu again, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 821a910 287/325: Fix undo-fu, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode d2d29aa 289/325: Another fix for mark-active indent region, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 97623ad 286/325: Remove cua-mode again, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 87fe6ff 292/325: Remove shift C-c and C-x for now, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 2ae2ebf 294/325: Remove command loop, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 5689999 299/325: Fix CUA interference, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 9b72665 304/325: Use passthrough for kill-line, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 577997b 310/325: Pull in many more remaps for using Emacs keys, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 0d2d1c6 308/325: Change how sending emacs keys works,
Stefan Monnier <=
- [elpa] externals/ergoemacs-mode dc2e1a6 321/325: Bind ergoemacs-M-O for more generic fix, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode ea5a7f5 322/325: Remove compilation mode map (emulation overrides); Fix isearch M-O, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 5692fc1 325/325: Add replacement for `C-h k`, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode e718715 309/325: Add `mark-whole-buffer`, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 465d265 312/325: Merge branch 'passthrough', Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 500a2eb 314/325: Possibly Fix #505 search, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 8ea6d54 320/325: Some fixes for shift-select mode, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 6b1b60e 039/325: Cleanup, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode fdafbdf 049/325: Cleanup, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 2c3dbbf 098/325: Remove f1 binding and unused swiper(), Stefan Monnier, 2021/10/23