[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 37/287: Added ergoemacs-keymap-collapse and ergoemacs-keymap-empt
From: |
Matthew Fidler |
Subject: |
[elpa] 37/287: Added ergoemacs-keymap-collapse and ergoemacs-keymap-empty-p |
Date: |
Wed, 02 Jul 2014 14:44:24 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit d91378e78f1293a87915ec920689a4f326cc13ef
Author: Matthew L. Fidler <address@hidden>
Date: Tue Jun 3 09:02:07 2014 -0500
Added ergoemacs-keymap-collapse and ergoemacs-keymap-empty-p
---
ergoemacs-theme-engine.el | 117 +++++++++++++++++++++++++++------------------
1 files changed, 70 insertions(+), 47 deletions(-)
diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el
index 2469f47..7c6e216 100644
--- a/ergoemacs-theme-engine.el
+++ b/ergoemacs-theme-engine.el
@@ -1205,12 +1205,12 @@ Formatted for use with `ergoemacs-theme-component-hash'
it will return ::version
ret)
"")))
-(defun ergoemacs-theme-get-component (component &optional version)
+(defun ergoemacs-theme-get-component (component &optional version name)
"Gets the VERSION of COMPONENT from `ergoemacs-theme-comp-hash'.
COMPONENT can be defined as component::version"
(if (listp component)
- (ergoemacs-theme-component-map-list "list"
- :map-list (mapcar (lambda(comp) (ergoemacs-theme-get-component comp
version)) component))
+ (ergoemacs-theme-component-map-list
+ (or name "list") :map-list (mapcar (lambda(comp)
(ergoemacs-theme-get-component comp version)) component))
(let* ((comp-name (or (and (symbolp component) (symbol-name component))
component))
(version (or (and (symbolp version) (symbol-name version))
@@ -1239,7 +1239,34 @@ COMPONENT can be defined as component::version"
(defun ergoemacs-theme-get-obj (&optional theme version)
"Get the VERSION of THEME from `ergoemacs-theme-get-component' and
`ergoemacs-theme-components'"
- (ergoemacs-theme-get-component (ergoemacs-theme-components theme) version))
+ (ergoemacs-theme-get-component (ergoemacs-theme-components theme) version
(or theme ergoemacs-theme)))
+
+(defun ergoemacs-keymap-empty-p (keymap &optional dont-collapse)
+ "Determines if the KEYMAP is an empty keymap.
+DONT-COLLAPSE doesn't collapse empty keymaps"
+ (let ((keymap (or (and dont-collapse keymap)
+ (ergoemacs-keymap-collapse keymap))))
+ (or (equal keymap nil)
+ (equal keymap '(keymap))
+ (and (keymapp keymap) (stringp (nth 1 keymap)) (= 2 (length
keymap))))))
+
+(defun ergoemacs-keymap-collapse (keymap)
+ "Takes out all empty keymaps from a composed keymap"
+ ;;(ergoemacs-keymap-collapse '(keymap (keymap 27 (keymap)) (keymap) (keymap
"me")))
+ (let ((ret '()) tmp)
+ (dolist (item keymap)
+ (cond
+ ((eq item 'keymap) (push item ret))
+ ((ignore-errors (keymapp item))
+ (unless (ergoemacs-keymap-empty-p item t)
+ (setq tmp (ergoemacs-keymap-collapse item))
+ (when tmp
+ (push tmp ret))))
+ (t (push item ret))))
+ (setq ret (reverse ret))
+ (if (ergoemacs-keymap-empty-p ret t)
+ nil
+ ret)))
(defun ergoemacs-theme-i (&optional theme version)
"Gets the keymaps for THEME for VERSION."
@@ -1250,7 +1277,9 @@ COMPONENT can be defined as component::version"
(with-slots (read-map
shortcut-map
map
- shortcut-list) fixed-obj
+ shortcut-list
+ unbind-map
+ rm-keys) fixed-obj
;; Add menu.
(define-key menu-keymap [menu-bar ergoemacs-mode]
`("ErgoEmacs" . ,(ergoemacs-keymap-menu theme)))
@@ -1258,24 +1287,25 @@ COMPONENT can be defined as component::version"
(pop new-map)
(push menu-keymap new-map)
(push 'keymap new-map)
- ;; (setq ergoemacs-read-input-keymap read-map
- ;; ergoemacs-shortcut-keymap shortcut-map
- ;; ergoemacs-keymap new-map
- ;; ergoemacs-theme-shortcut-reset-list shortcut-list
- ;; ergoemacs-unbind-keymap unbind-map
- ;; ergoemacs-theme (or (and (stringp theme) theme)
- ;; (symbol-name theme)))
- ;; (dolist (remap (ergoemacs-get-hooks theme-obj "-mode\\'"))
- ;; (message "%s" remap)
- ;; (setq ergoemacs-emulation-mode-map-alist
- ;; (append ergoemacs-emulation-mode-map-alist
- ;; (list (cons remap
- ;; (oref (ergoemacs-get-fixed-map
- ;; theme-obj remap) map))))))
- (message "%s" ergoemacs-emulation-mode-map-alist))))
-
-;; (message "%s"
-;; (macroexpand `))
+
+ (setq ergoemacs-read-input-keymap read-map
+ ergoemacs-shortcut-keymap shortcut-map
+ ergoemacs-keymap new-map
+ ergoemacs-theme-shortcut-reset-list shortcut-list
+ ergoemacs-unbind-keymap unbind-map
+ ergoemacs-theme (or (and (stringp theme) theme)
+ (and (not (eq nil theme))(symbolp theme)
(symbol-name theme))
+ (and (stringp ergoemacs-theme) ergoemacs-theme)
+ (and (not (eq nil ergoemacs-theme)) (symbolp
ergoemacs-theme) (symbol-name ergoemacs-theme))))
+
+ (setq ergoemacs-emulation-mode-map-alist
+ `(,(cons 'ergoemacs-read-input-keys read-map)
+ ,(cons 'ergoemacs-shortcut-keys shortcut-map)
+ ,@(mapcar
+ (lambda(remap)
+ (cons remap (oref (ergoemacs-get-fixed-map theme-obj remap)
map)))
+ (ergoemacs-get-hooks theme-obj "-mode\\'")))))))
+
@@ -3273,35 +3303,28 @@ This also:
- Sets up read-key maps by running `ergoemacs-theme-hook'.
"
- (mapc
- (lambda(key)
- ;; Read input keymap shouldn't interfere with global map needs.
- (setq ergoemacs-read-input-keymap (ergoemacs-rm-key
ergoemacs-read-input-keymap key))
- ;;
- (let ((vector-key (or (and (vectorp key) key)
- (read-kbd-macro (key-description key) t))))
- ;; ergoemacs-shortcut-keymap should always have `ergoemacs-ctl-c'
- ;; and `ergoemacs-ctl-x' for C-c and C-x, don't unbind here.
- (unless (and (memq (elt vector-key 0) '(3 24))
- (memq (lookup-key ergoemacs-shortcut-keymap (vector (elt
vector-key 0)))
- '(ergoemacs-ctl-x ergoemacs-ctl-c)))
- (setq ergoemacs-shortcut-keymap (ergoemacs-rm-key
ergoemacs-shortcut-keymap key))))
- (setq ergoemacs-keymap (ergoemacs-rm-key ergoemacs-keymap key))
- (setq ergoemacs-unbind-keymap (ergoemacs-rm-key ergoemacs-unbind-keymap
key)))
- list)
+ (dolist (key list)
+ ;; Read input keymap shouldn't interfere with global map needs.
+ (setq ergoemacs-read-input-keymap (ergoemacs-rm-key
ergoemacs-read-input-keymap key))
+ (let ((vector-key (or (and (vectorp key) key)
+ (read-kbd-macro (key-description key) t))))
+ ;; ergoemacs-shortcut-keymap should always have `ergoemacs-ctl-c'
+ ;; and `ergoemacs-ctl-x' for C-c and C-x, don't unbind here.
+ (unless (and (memq (elt vector-key 0) '(3 24))
+ (memq (lookup-key ergoemacs-shortcut-keymap (vector (elt
vector-key 0)))
+ '(ergoemacs-ctl-x ergoemacs-ctl-c)))
+ (setq ergoemacs-shortcut-keymap (ergoemacs-rm-key
ergoemacs-shortcut-keymap key))))
+ (setq ergoemacs-keymap (ergoemacs-rm-key ergoemacs-keymap key))
+ (setq ergoemacs-unbind-keymap (ergoemacs-rm-key ergoemacs-unbind-keymap
key)))
(unless dont-install
(ergoemacs-theme-remove no-message)
;; Reset Shortcut hash.
- (mapc
- (lambda(c)
- (puthash (nth 0 c) (nth 1 c) ergoemacs-command-shortcuts-hash))
- ergoemacs-theme-shortcut-reset-list)
+ (dolist (c ergoemacs-theme-shortcut-reset-list)
+ (puthash (nth 0 c) (nth 1 c) ergoemacs-command-shortcuts-hash))
(setq ergoemacs-emulation-mode-map-alist '())
;; Install persistent mode-based remaps.
- (mapc
- (lambda(mode)
- (ergoemacs-theme-hook mode))
- ergoemacs-theme-mode-based-remaps)
+ (dolist (mode ergoemacs-theme-mode-based-remaps)
+ (ergoemacs-theme-hook mode))
;; `ergoemacs-keymap' top in `minor-mode-map-alist'
(let ((x (assq 'ergoemacs-mode minor-mode-map-alist)))
(when x
- [elpa] 32/287: Fix Issue #226, (continued)
- [elpa] 32/287: Fix Issue #226, Matthew Fidler, 2014/07/02
- [elpa] 33/287: Merge branch 'master' into eieio, Matthew Fidler, 2014/07/02
- [elpa] 04/287: Revert "Stefan Monnier's Patch", Matthew Fidler, 2014/07/02
- [elpa] 35/287: Remove debug-on-error, Matthew Fidler, 2014/07/02
- [elpa] 41/287: Take out hook to change bindings., Matthew Fidler, 2014/07/02
- [elpa] 38/287: Remove global-override, Matthew Fidler, 2014/07/02
- [elpa] 23/287: Basic classes written, Matthew Fidler, 2014/07/02
- [elpa] 29/287: Started parsing., Matthew Fidler, 2014/07/02
- [elpa] 34/287: Now can get the fixed maps for a list of components., Matthew Fidler, 2014/07/02
- [elpa] 36/287: Use pushnew for get-hooks., Matthew Fidler, 2014/07/02
- [elpa] 37/287: Added ergoemacs-keymap-collapse and ergoemacs-keymap-empty-p,
Matthew Fidler <=
- [elpa] 40/287: Remove shortcut override mode., Matthew Fidler, 2014/07/02
- [elpa] 44/287: Suppress shortcuts, Matthew Fidler, 2014/07/02
- [elpa] 39/287: Starting applying keymaps to ergoemacs-emulation-mode-map-alist, Matthew Fidler, 2014/07/02
- [elpa] 45/287: Fix ergoemacs-describe-key, Matthew Fidler, 2014/07/02
- [elpa] 31/287: Created composite map list, Matthew Fidler, 2014/07/02
- [elpa] 42/287: Push shortcuts to the bottom. Should allow overrides., Matthew Fidler, 2014/07/02
- [elpa] 49/287: Bug fix for substitute-command-keys, Matthew Fidler, 2014/07/02
- [elpa] 43/287: Be more conservative with substituting key commands., Matthew Fidler, 2014/07/02
- [elpa] 46/287: Fix Issue #7, Matthew Fidler, 2014/07/02
- [elpa] 50/287: Another bug-fix for substitute-command-keys, Matthew Fidler, 2014/07/02