[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/ergoemacs-mode a5febc9 291/325: Remove shift selection
From: |
Stefan Monnier |
Subject: |
[elpa] externals/ergoemacs-mode a5febc9 291/325: Remove shift selection and try to fix C-S-x C-S-c |
Date: |
Sat, 23 Oct 2021 18:49:13 -0400 (EDT) |
branch: externals/ergoemacs-mode
commit a5febc9591de5953528547e020f44fe1cfccfebd
Author: Matthew Fidler <514778+mattfidler@users.noreply.github.com>
Commit: Matthew Fidler <514778+mattfidler@users.noreply.github.com>
Remove shift selection and try to fix C-S-x C-S-c
---
ergoemacs-advice.el | 7 +------
ergoemacs-command-loop.el | 41 ++++++++++++++++++++++++++++++++++++-----
ergoemacs-mode.el | 6 +++---
3 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el
index 9338ce6..38af9d6 100644
--- a/ergoemacs-advice.el
+++ b/ergoemacs-advice.el
@@ -99,12 +99,7 @@ TYPE is the type of translation installed."
(if ergoemacs-mode
(ergoemacs-mode--undefined-advice)
(call-interactively orig-fun)))
-
- (defun ergoemacs-advice-handle-shift-selection ()
- "Allow `ergoemacs-mode' to do shift selection on keys like Alt+# to Alt+3."
- (when (eq 'ergoemacs-command-loop--shift-translate (key-binding
(this-single-command-keys)))
- (setq this-command-keys-shift-translated t)))
-
+
(defun ergoemacs-advice-read-key ()
"Drop single command keys for read-key." ; For compataiblity with emacs 25.5
(setq ergoemacs-command-loop--single-command-keys nil))
diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el
index dd340c6..95da1af 100644
--- a/ergoemacs-command-loop.el
+++ b/ergoemacs-command-loop.el
@@ -862,7 +862,7 @@ KEYS is the keys information"
(defun ergoemacs-command--dispach-cua ()
"Dispatches the CUA C-x and C-c."
- (when ergoemacs-mode-cua-mode
+ (when (and (not this-command-keys-shift-translated) ergoemacs-mode-cua-mode)
(let ((keys (this-single-command-keys)))
(when (and (= 1 (length keys))
(memq (aref keys 0) ergoemacs-command--cua-key-codes)
@@ -881,15 +881,46 @@ KEYS is the keys information"
(defun ergoemacs-command--cua-timer-on ()
"Turn on the cua timer."
- (when (and mark-active ergoemacs-mode-cua-mode)
- (setq erogemacs-command--cua-timer
- (run-at-time t ergoemacs-command-loop-blink-rate
#'ergoemacs-command--dispach-cua))))
+ (if (and mark-active ergoemacs-mode-cua-mode
+ (not (eq erogemacs-command--cua-timer 'shift)))
+ (setq erogemacs-command--cua-timer
+ (run-at-time t ergoemacs-command-loop-blink-rate
#'ergoemacs-command--dispach-cua))
+ (unless mark-active
+ (ergoemacs-command--cua-timer-off)
+ (setq erogemacs-command--cua-timer nil))))
(defun ergoemacs-command--cua-timer-off ()
"Turn off the cua timer."
- (when erogemacs-command--cua-timer
+ (when (timerp erogemacs-command--cua-timer)
(cancel-timer erogemacs-command--cua-timer)))
+
+;;;;;;;;;;;;
+;; Taken and modified from cua-base
+(defun ergoemacs-cua--shift-control-prefix (prefix)
+ ;; handle S-C-x and S-C-c by emulating the fast double prefix function.
+ ;; Don't record this command
+ (setq this-command last-command)
+ ;; Restore the prefix arg
+ ;; This should make it so that exchange-point-and-mark gets the prefix when
+ ;; you do C-u S-C-x C-x work (where the C-u is properly passed to the C-x
+ ;; C-x binding after the first S-C-x was rewritten to just C-x).
+ (prefix-command-preserve-state)
+ ;; Activate the cua--prefix-repeat-keymap
+ (setq erogemacs-command--cua-timer 'shift)
+ (ergoemacs-command--cua-timer-off)
+ ;; Repalce key
+ (setq unread-command-events (list prefix)))
+
+(defun ergoemacs-cua--shift-control-c-prefix ()
+ (interactive)
+ (ergoemacs-cua--shift-control-prefix ?\C-c))
+
+(defun ergoemacs-cua--shift-control-x-prefix ()
+ (interactive)
+ (ergoemacs-cua--shift-control-prefix ?\C-x))
+;;;;
+
(add-hook 'ergoemacs-post-command-hook #'ergoemacs-command--cua-timer-on)
(add-hook 'ergoemacs-shutdown-hook #'ergoemacs-command--cua-timer-off)
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index 5d0536c..07b4502 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -412,7 +412,9 @@ after initializing ergoemacs-mode.
(defvar ergoemacs-mark-active-cua-keymap (let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c
<ergoemacs-timeout>") 'ergoemacs-copy-line-or-region)
- (define-key map (kbd "C-v
<ergoemacs-timeout>") 'ergoemacs-paste)
+ (define-key map (kbd "C-x
<ergoemacs-timeout>") 'ergoemacs-cut-line-or-region)
+ (define-key map [(shift control c)]
'ergoemacs-cua--shift-control-c-prefix)
+ (define-key map [(shift control x)]
'ergoemacs-cua--shift-control-x-prefix)
map)
"The keybinding that is active when the mark is active.")
@@ -440,7 +442,6 @@ after initializing ergoemacs-mode.
(when ergoemacs-mode-cua-mode
(add-hook 'minor-mode-map-alist ergoemacs-minor-cua-alist))
(advice-add 'undefined :around #'ergoemacs-advice-undefined)
- (advice-add 'handle-shift-selection :before
#'ergoemacs-advice-handle-shift-selection)
(advice-add 'read-key :before #'ergoemacs-advice-read-key))
(defun ergoemacs-remove-override-keymap ()
@@ -450,7 +451,6 @@ after initializing ergoemacs-mode.
(when ergoemacs-mode-cua-mode
(remove-hook 'minor-mode-map-alist ergoemacs-minor-cua-alist))
(advice-remove 'undefined #'ergoemacs-advice-undefined)
- (advice-remove 'handle-shift-selection
#'ergoemacs-advice-handle-shift-selection)
(advice-remove 'read-key #'ergoemacs-advice-read-key))
- [elpa] externals/ergoemacs-mode 465d265 312/325: Merge branch 'passthrough', (continued)
- [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
- [elpa] externals/ergoemacs-mode 12a1552 259/325: Remove ergoemacs-timing, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 97ac03f 081/325: Resolve all of the :emacs keybindings in ergoemacs-themes, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 74ad06f 228/325: Remove deftheme, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode ba79935 258/325: Remove lookup and information about global map, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode a5febc9 291/325: Remove shift selection and try to fix C-S-x C-S-c,
Stefan Monnier <=
- [elpa] externals/ergoemacs-mode a9cea74 303/325: Make ergoemacs-describe-current-theme and "C-h '" work., Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode e778e82 307/325: Take out debug echo AND fix backward delete, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 187b07d 315/325: Describe keys for the current buffer, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode de3c5e7 262/325: Restore isearch-mode-map, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 42833ac 264/325: Code cleanup, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode ac33443 265/325: Add back the M-n commands for the reduction keymap, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 29ebf6e 271/325: Add compilation mode map to catch some of greps keys, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 81466b3 284/325: Unwind protect the timer #505, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode a38e4f3 275/325: Add option for keeping emacs keys that are not overwritten by ergoemacs, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 48c6d90 274/325: Merge branch 'mattfidler-master', Stefan Monnier, 2021/10/23