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

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

[elpa] 89/287: Fix most keybinding issues


From: Matthew Fidler
Subject: [elpa] 89/287: Fix most keybinding issues
Date: Wed, 02 Jul 2014 14:44:53 +0000

mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.

commit b5bfd7f9aab8c3faee95ff2f97f62d78533e5520
Author: Matthew L. Fidler <address@hidden>
Date:   Fri Jun 13 09:32:23 2014 -0500

    Fix most keybinding issues
---
 ergoemacs-advices.el      |   31 ++++++++++---------------------
 ergoemacs-theme-engine.el |   36 ++++++++++++++++++++++++++++++++----
 2 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/ergoemacs-advices.el b/ergoemacs-advices.el
index 798382f..9b1cba6 100644
--- a/ergoemacs-advices.el
+++ b/ergoemacs-advices.el
@@ -95,27 +95,16 @@ Also adds keymap-flag for user-defined keys run with 
`run-mode-hooks'."
 (defvar ergoemacs-ignore-advice nil)
 (defun ergoemacs-global-set-key-after (key)
   (if ergoemacs-ignore-advice nil
-    (unless (or (and (vectorp key)
-                     (memq (elt key 0) '(menu-bar 27 remap)))
-                (and (not (vectorp key))
-                     (string= "ESC" (key-description key))))
-      (let ((ergoemacs-ignore-advice t))
-        (add-to-list 'ergoemacs-global-changed-cache (key-description key))
-        (when ergoemacs-global-not-changed-cache
-          (delete (key-description key) ergoemacs-global-not-changed-cache))
-        (add-to-list 'ergoemacs-global-override-rm-keys (or (and (vectorp key) 
key)
-                                                            (read-kbd-macro 
(key-description key) t)))
-        (setq ergoemacs-shortcut-keymap (ergoemacs-rm-key 
ergoemacs-shortcut-keymap key)
-              ergoemacs-read-input-keymap (ergoemacs-rm-key 
ergoemacs-read-input-keymap key)
-              ergoemacs-keymap (ergoemacs-rm-key ergoemacs-keymap key)
-              ergoemacs-unbind-keymap (ergoemacs-rm-key ergoemacs-keymap key))
-        (remhash key ergoemacs-command-shortcuts-hash)
-        (setq ergoemacs-read-emulation-mode-map-alist
-              (list (cons 'ergoemacs-read-input-keys 
ergoemacs-read-input-keymap))
-              ergoemacs-emulation-mode-map-alist
-              (append (nbutlast ergoemacs-emulation-mode-map-alist 1)
-                      (list (cons 'ergoemacs-shortcut-keys 
ergoemacs-shortcut-keymap))))
-        (ergoemacs-shuffle-keys t)))))
+    (let ((kd (key-description key)))
+      (unless (or (and (vectorp key)
+                       (memq (elt key 0) '(menu-bar 27 remap)))
+                  (and (not (vectorp key))
+                       (string= "ESC" kd)))
+        ;; Let `ergoemacs-mode' know these keys have changed.
+        (pushnew kd ergoemacs-global-changed-cache :test 'equal)
+        (setq ergoemacs-global-not-changed-cache (delete kd 
ergoemacs-global-not-changed-cache))
+        ;; Remove the key from `ergoemacs-mode' bindings
+        (ergoemacs-theme-component--ignore-globally-defined-key key t)))))
 
 (defadvice local-set-key (around ergoemacs-local-set-key-advice (key command) 
activate)
   "This let you use `local-set-key' as usual when `ergoemacs-mode' is enabled."
diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el
index dda5cb8..fc5feef 100644
--- a/ergoemacs-theme-engine.el
+++ b/ergoemacs-theme-engine.el
@@ -1903,19 +1903,47 @@ DONT-COLLAPSE doesn't collapse empty keymaps"
     (ergoemacs-theme-obj-install ergoemacs-theme--object 'remove)
     (setq ergoemacs-theme-object nil)))
 
-(defun ergoemacs-theme-component--ignore-globally-defined-key (key)
+(defun ergoemacs-theme-component--ignore-globally-defined-key (key &optional 
reset)
   "Adds KEY to `ergoemacs-global-override-rm-keys' and 
`ergoemacs-global-override-map' if globally redefined."
   (let ((ergoemacs-ignore-advice t)
         (key (or (and (vectorp key) key) (read-kbd-macro (key-description key) 
t)))
-        lk)
+        test-key lk)
     (catch 'found-global-command
       (while (>= (length key) 1)
         (setq lk (lookup-key (current-global-map) key))
         (when (and (ergoemacs-global-changed-p key)
                    (or (commandp lk t)
                        (keymapp lk)))
-          ;; Remove from shortcuts, if present
-          (remhash key ergoemacs-command-shortcuts-hash)
+          (when reset ;; Reset keymaps
+            ;; Reset keymaps.
+            (dolist (map '(ergoemacs-shortcut-keymap 
ergoemacs-read-input-keymap ergoemacs-keymap ergoemacs-unbind-keymap))
+              (set map (ergoemacs-rm-key (symbol-value map) key))
+              (setq lk (lookup-key (symbol-value map) key))
+              (if (not (integerp lk))
+                  (setq test-key key)
+                (setq test-key (substring key 0 lk))
+                (setq lk (lookup-key (symbol-value map) test-key)))
+              (when (commandp lk t)
+                (set map (ergoemacs-rm-key (symbol-value map) test-key))))
+            ;; Remove from shortcuts, if present
+            (remhash key ergoemacs-command-shortcuts-hash)
+            ;; Reset `ergoemacs-shortcut-prefix-keys'
+            (setq ergoemacs-shortcut-prefix-keys '())
+            (maphash
+             (lambda(key ignore)
+               (when (< 1 (length key))
+                 (pushnew (substring key 0 -1)
+                          ergoemacs-shortcut-prefix-keys
+                          :test 'equal)))
+            ergoemacs-command-shortcuts-hash)
+            ;; Setup emulation maps.
+            (setq ergoemacs-read-emulation-mode-map-alist
+                  (list (cons 'ergoemacs-read-input-keys 
ergoemacs-read-input-keymap))
+                  ergoemacs-emulation-mode-map-alist
+                  (append (nbutlast ergoemacs-emulation-mode-map-alist 1)
+                          (list (cons 'ergoemacs-shortcut-keys 
ergoemacs-shortcut-keymap))))
+            ;;Put maps in `minor-mode-map-alist'
+            (ergoemacs-shuffle-keys t))
           (push key ergoemacs-global-override-rm-keys)
           (throw 'found-global-command t))
         (setq key (substring key 0 (- (length key) 1)))))))



reply via email to

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