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

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

[elpa] externals/ergoemacs-mode 12d5e8e 176/325: Handle conflict between


From: Stefan Monnier
Subject: [elpa] externals/ergoemacs-mode 12d5e8e 176/325: Handle conflict between M-O and arrow keys in the terminal
Date: Sat, 23 Oct 2021 18:48:47 -0400 (EDT)

branch: externals/ergoemacs-mode
commit 12d5e8e76864c74a442f79b97bbdff89eb190cb9
Author: Walter Landry <wlandry@caltech.edu>
Commit: Walter Landry <wlandry@caltech.edu>

    Handle conflict between M-O and arrow keys in the terminal
---
 ergoemacs-themes.el | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index e724c90..827ee91 100644
--- a/ergoemacs-themes.el
+++ b/ergoemacs-themes.el
@@ -1150,6 +1150,49 @@ calling any other ergoemacs-set-* function"
                                    describe-copying)
                           ,(if (eq system-type 'darwin) "Help" "?")))))
 
+
+(defun ergoemacs-handle-M-O ()
+  "Handle M-O input.  In a terminal, this can be either arrow
+keys (e.g. M-O A == <up>) or regular M-O keybinding."
+  (interactive)
+  (if (input-pending-p)
+      (let ((second-char (read-char)))
+        (cond
+         ((eq second-char 65) ;; A
+          (execute-kbd-macro (kbd "<up>"))
+          )
+         ((eq second-char 66) ;; B
+          (execute-kbd-macro (kbd "<down>"))
+          )
+         ((eq second-char 67) ;; C
+          (execute-kbd-macro (kbd "<right>"))
+          )
+         ((eq second-char 68) ;; D
+          (execute-kbd-macro (kbd "<left>"))
+          )
+         ((eq second-char 72) ;; H
+          (execute-kbd-macro (kbd "<home>"))
+          )
+         ((eq second-char 70) ;; F
+          (execute-kbd-macro (kbd "<end>"))
+          )
+         (t
+          (beep)
+          )
+         )
+        )
+    (call-interactively ergoemacs-M-O-binding)
+    )
+  )
+
+(defvar ergoemacs-M-O-binding () nil)
+(defun ergoemacs-fix-arrow-keys (keymap)
+  (setq ergoemacs-M-O-binding (lookup-key keymap (kbd "M-O")))
+  (if ergoemacs-M-O-binding
+      (define-key keymap (kbd "M-O") 'ergoemacs-handle-M-O)
+    )
+  )
+
 (ergoemacs-theme standard ()
   "Standard Ergoemacs Theme"
   )
@@ -1180,6 +1223,7 @@ calling any other ergoemacs-set-* function"
   (ergoemacs-set-kill-line ergoemacs-override-keymap)
   (ergoemacs-set-text-transform ergoemacs-override-keymap)
   (ergoemacs-set-select-items ergoemacs-override-keymap)
+  (ergoemacs-fix-arrow-keys ergoemacs-override-keymap)
 
   (ergoemacs-set-remaps)
   (ergoemacs-set-quit)



reply via email to

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