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

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

[elpa] 43/117: Setup local overrides outside of minibuffers and overridi


From: Matthew Fidler
Subject: [elpa] 43/117: Setup local overrides outside of minibuffers and overriding keymaps
Date: Fri, 25 Jul 2014 13:24:07 +0000

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

commit ccf88b6536c9276e88876891873389d5db91824c
Author: Matthew L. Fidler <address@hidden>
Date:   Wed Jul 16 17:44:42 2014 -0500

    Setup local overrides outside of minibuffers and overriding keymaps
---
 ergoemacs-shortcuts.el |   44 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/ergoemacs-shortcuts.el b/ergoemacs-shortcuts.el
index ec714c0..6afc798 100644
--- a/ergoemacs-shortcuts.el
+++ b/ergoemacs-shortcuts.el
@@ -214,6 +214,7 @@ Used to help with translation keymaps like 
`input-decode-map'"
 (defvar ergoemacs-modal)
 (defvar ergoemacs-universal-fns)
 (defvar ergoemacs-read-input-keys)
+(defvar ergoemacs-read-local-emulation-mode-map-alist)
 (declare-function ergoemacs-unicode-char "ergoemacs-translate.el")
 (declare-function ergoemacs-translate "ergoemacs-translate.el")
 (declare-function ergoemacs-local-map "ergoemacs-translate.el")
@@ -1853,7 +1854,7 @@ Setup C-c and C-x keys to be described properly.")
 The keymaps are:
 - `overriding-terminal-local-map'
 - `overriding-local-map'
-- overlays with :keymap property
+- Overlays with :keymap property
 - text property with :keymap property."
   (let ((inhibit-read-only t)
         deactivate-mark
@@ -1909,6 +1910,47 @@ The keymaps are:
         ;; (ergoemacs-debug-keymap 'override-text-map)
         )))))
 
+(defvar ergoemacs-debug-keymap--temp-map)
+(declare-function ergoemacs-real-substitute-command-keys "ergoemacs-advice.el")
+(defun ergoemacs-extract-prefixes (keymap)
+  "Extract prefix commands for KEYMAP.
+Ignores command sequences starting with `ergoemacs-ignored-prefixes'."
+  (save-match-data
+    (let ((string (or (ignore-errors
+                        (ergoemacs-real-substitute-command-keys (format 
"\\{%s}" (symbol-name keymap))))
+                      (progn
+                        (setq ergoemacs-debug-keymap--temp-map keymap)
+                        (ergoemacs-real-substitute-command-keys 
"\\{ergoemacs-debug-keymap--temp-map}"))))
+          (pt 0)
+          (ret '()))
+      (while (string-match "^\\([^ \n][^ \n\t]*?\\) [^.].+*" string pt)
+        (unless (or (string-match-p "\\(--\\|key\\)" (match-string 1 string))
+                    (member (match-string 1 string) ergoemacs-ignored-prefixes)
+                    (member (match-string 1 string) ret))
+          (push (match-string 1 string) ret))
+        (setq pt (match-end 0)))
+      ret)))
+
+(defvar ergoemacs-ignore-advice)
+(defun ergoemacs-setup-local-prefixes ()
+  "Setup local prefixes to use `ergoemacs-read-key'.
+Do not do anything if you are:
+- In the minibuffer (determined by `minibufferp')
+- If overriding text maps are active, like `overriding-terminal-local-map' and 
`overriding-local-map'"
+  (unless (or (minibufferp) overriding-terminal-local-map overriding-local-map)
+    (let* ((map (current-local-map))
+           (ergoemacs-ignore-advice t)
+           key-vector
+           (prefixes (ergoemacs-extract-prefixes map))
+           (read-map (make-sparse-keymap)))
+      (when prefixes
+        (dolist (prefix prefixes)
+          (setq key-vector (read-kbd-macro prefix prefix))
+          (ignore-errors 
+            (define-key read-map key-vector 'ergoemacs-read-key-default)))
+        (set (make-local-variable 
'ergoemacs-read-local-emulation-mode-map-alist)
+             (list (cons 'ergoemacs-read-input-keys read-map)))))))
+
 (provide 'ergoemacs-shortcuts)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; ergoemacs-shortcuts.el ends here



reply via email to

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