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

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

[elpa] externals/ergoemacs-mode b4b5241 30/87: Add back ergoemacs-style


From: Stefan Monnier
Subject: [elpa] externals/ergoemacs-mode b4b5241 30/87: Add back ergoemacs-style shift-translation
Date: Wed, 14 Apr 2021 18:47:02 -0400 (EDT)

branch: externals/ergoemacs-mode
commit b4b5241e679cc1a7bd7b1f3703f1a7ce602cd1f6
Author: Fidler <matthew.fidler@gmail.com>
Commit: Fidler <matthew.fidler@gmail.com>

    Add back ergoemacs-style shift-translation
    
    M-> translates to M-. in colemak to allow reduction to have
    shift-selection style on ergoemacs-keys
---
 ergoemacs-advice.el       |  6 ++++++
 ergoemacs-command-loop.el | 13 ++++++++++++-
 ergoemacs-translate.el    | 21 ++++++++++++++++++++-
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el
index 31ef9c0..0ba3770 100644
--- a/ergoemacs-advice.el
+++ b/ergoemacs-advice.el
@@ -360,6 +360,12 @@ TYPE is the type of translation installed."
       ad-do-it
     (ergoemacs-mode--undefined-advice)))
 
+(ergoemacs-advice handle-shift-selection ()
+  "Allow `ergoemacs-mode' to do shift selection on keys like Alt+# to Alt+3."
+  :type :before
+  (when (eq 'ergoemacs-command-loop--shift-translate (key-binding 
(this-single-command-keys)))
+    (setq this-command-keys-shift-translated t)))
+
 (provide 'ergoemacs-advice)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; ergoemacs-advice.el ends here
diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el
index 1f858e1..7cc5197 100644
--- a/ergoemacs-command-loop.el
+++ b/ergoemacs-command-loop.el
@@ -1556,7 +1556,8 @@ needed (and resotre them to the original values)."
   "Call the COMMAND interactively.  Also handle mouse events (if possible.)
 The RECORD-FLAG and KEYS are sent to 
`ergoemacs-command-loop--grow-interactive'."
   (ergoemacs-command-loop--sync-point)
-  (setq ergoemacs-last-command-was-ergoemacs-ignore-p nil)
+  (setq ergoemacs-last-command-was-ergoemacs-ignore-p nil
+       this-command-keys-shift-translated (or 
ergoemacs-this-command-keys-shift-translated 
this-command-keys-shift-translated))
   (cond
    ((and (eventp last-command-event)
          (consp last-command-event)
@@ -2319,6 +2320,16 @@ For instance in QWERTY M-> is shift translated to M-."
        (setq unread-command-events (append (ergoemacs-translate--emacs-shift 
shift-trans) '(ergoemacs-timeout)))
       (setq ergoemacs-this-command-keys-shift-translated t)
       (ergoemacs-command-loop--internal shift-trans))))
+
+(defun ergoemacs-command-loop--shift-translate ()
+  "Shift translation."
+  (interactive)
+  (let ((shift-trans (ergoemacs-translate--emacs-shift 
(this-single-command-keys) 'ergoemacs-shift)))
+    (message "%s->%s" (key-description (this-single-command-keys))
+            (key-description shift-trans))
+    (setq ergoemacs-this-command-keys-shift-translated t
+         this-command-keys-shift-translated t)
+    (ergoemacs-command-loop--call-interactively (key-binding shift-trans))))
 (provide 'ergoemacs-command-loop)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; ergoemacs-command-loop.el ends here
diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el
index 6931f8c..7d66cd8 100644
--- a/ergoemacs-translate.el
+++ b/ergoemacs-translate.el
@@ -232,6 +232,24 @@ If no changes are performed, return nil."
         (setq ret new-key))
       ret)))
 
+(defun ergoemacs-translate--ergoemacs-shift-select (key)
+  "Translate KEY to allow `ergoemacs-mode' shift translation.
+
+This will shift translate Alt+# to Alt+3."
+  (let (modifiers basic)
+    (when (and (vectorp key)
+               ;; only makes sense for single key combinations.
+               (= (length key) 1)
+               ;; Doesn't make sense if shifted...
+               (not (or (memq 'shift (setq modifiers 
(ergoemacs-translate--event-modifiers (aref key 0))))
+                        (memq 'ergoemacs-shift modifiers)))
+              ;; Only define if emacs doesn't handle shift selection.
+              (not (eq (event-convert-list (list 'shift (setq basic 
(event-basic-type (aref key 0)))))
+                       (ergoemacs-translate--event-convert-list (list 
'ergoemacs-shift basic)))))
+      (setq ergoemacs-translate--define-key-if-defined-p nil
+            ergoemacs-translate--define-key-replacement-function 
'ergoemacs-command-loop--shift-translate)
+      (vector (ergoemacs-translate--event-convert-list (append modifiers (list 
'ergoemacs-shift basic)))))))
+
 (defun ergoemacs-translate--ergoemacs-timeout (key)
   "Translates KEY to allow Shift translation to default to key sequence.
 
@@ -270,7 +288,8 @@ If no chanegs are performed, return nil."
     ergoemacs-translate--swap-menu
     ergoemacs-translate--to-string
     ergoemacs-translate--to-vector
-    ergoemacs-translate--ergoemacs-timeout)
+    ergoemacs-translate--ergoemacs-timeout
+    ergoemacs-translate--ergoemacs-shift-select)
   "Functions to apply to key.
 
 These functions take a key as an argument and translate it in



reply via email to

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