[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 67/287: Completely use the object
From: |
Matthew Fidler |
Subject: |
[elpa] 67/287: Completely use the object |
Date: |
Wed, 02 Jul 2014 14:44:41 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit a8b0d3e6fa1be312ef441775fa8fcd9c11ebb81b
Author: Matthew L. Fidler <address@hidden>
Date: Wed Jun 11 08:50:50 2014 -0500
Completely use the object
---
ergoemacs-theme-engine.el | 1945 ++++-----------------------------------------
1 files changed, 173 insertions(+), 1772 deletions(-)
diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el
index 8b9b688..b537a2b 100644
--- a/ergoemacs-theme-engine.el
+++ b/ergoemacs-theme-engine.el
@@ -418,7 +418,8 @@ DEF is anything that can be a key's definition:
or an extended menu item definition.
")
-(defmethod ergoemacs-define-map ((obj ergoemacs-fixed-map) key def &optional
no-unbind)
+(defmethod ergoemacs-define-map ((obj ergoemacs-fixed-map) key def &optional
+ no-unbind)
(with-slots (shortcut-map
no-shortcut-map
map
@@ -449,10 +450,14 @@ DEF is anything that can be a key's definition:
(ergoemacs-theme-component--ignore-globally-defined-key key-vect)
(ergoemacs-define-map--read-map obj key-vect)
(cond
- ((and global-map-p (eq def nil))
+ ((and global-map-p (eq def nil) (not no-unbind))
;; Unbound keymap
(define-key unbind-map key-vect 'ergoemacs-undefined)
(oset obj unbind-map unbind-map))
+ ((and global-map-p (eq def nil) no-unbind)
+ ;; Remove from all keymaps
+ (push key-vect rm-keys)
+ (oset obj rm-keys rm-keys))
((and global-map-p (commandp def t)
(not (string-match "\\(mouse\\|wheel\\)" (key-description key)))
(ergoemacs-shortcut-function-binding def))
@@ -500,7 +505,7 @@ DEF is anything that can be a key's definition:
(dolist (command def)
(if (not (commandp command t))
(push command tmp)
- (define-key map key-vect def)
+ (define-key map key-vect command)
(ergoemacs-define-map--cmd-list obj key-desc def)
(oset obj map map)
(throw 'found-command t))))
@@ -509,10 +514,7 @@ DEF is anything that can be a key's definition:
(ergoemacs-define-map--deferred-list obj key-vect tmp)))
((symbolp def)
;; Unbound symbol, add to deferred key list
- (ergoemacs-define-map--deferred-list obj key-vect (list def)))
- ((eq def nil)
- (push key-vect rm-keys)
- (oset obj rm-keys rm-keys))))))
+ (ergoemacs-define-map--deferred-list obj key-vect (list def)))))))
(defclass ergoemacs-variable-map (ergoemacs-named)
@@ -818,7 +820,8 @@ Assumes maps are orthogonal."
:global-map-p t
:variable-reg variable-reg
:just-first just-first
- :layout layout)))))
+ :layout layout))
+ )))
(defvar ergoemacs-theme-component-maps--always nil)
(defvar ergoemacs-theme-component-maps--full-map nil)
@@ -1018,7 +1021,14 @@ FULL-SHORTCUT-MAP-P "
(defvar ergoemacs-deferred-keys '()
"List of keys that have deferred bindings.")
-(defmethod ergoemacs-emulation-alists ((obj
ergoemacs-theme-component-map-list) &optional remove-p)
+(defvar ergoemacs-original-keys-to-shortcut-keys-regexp ""
+ "Regular expression of original keys that have shortcuts.")
+
+(defvar ergoemacs-original-keys-to-shortcut-keys (make-hash-table :test 'equal)
+ "Hash table of the original maps that `ergoemacs-mode' saves.")
+
+
+(defmethod ergoemacs-theme-obj-install ((obj
ergoemacs-theme-component-map-list) &optional remove-p)
;; First call 8 sec; Second call 2 sec.. Need to speed up?
(with-slots (read-map
map
@@ -1028,11 +1038,16 @@ FULL-SHORTCUT-MAP-P "
shortcut-list
rm-keys) (ergoemacs-get-fixed-map obj)
(let ((hook-map-list '())
- (i 0)
- ergoemacs-emulation-mode-map-alist
- ergoemacs-read-emulation-mode-map-alist)
- (setq ergoemacs-read-emulation-mode-map-alist
- `((ergoemacs-read-input-keys ,@(or read-map
(make-sparse-keymap)))))
+ ;; (read-map (or read-map (make-spase-keymap)))
+ ;; (shortcut-map (or shortcut-map (make-sparse-keymap)))
+ ;; (map (or map (make-sparse-keymap)))
+ (menu-keymap (make-sparse-keymap))
+ final-map final-shortcut-map final-read-map
+ (i 0))
+
+ ;; Get all the major-mode hooks that will be called or modified
+ (setq ergoemacs-deferred-maps '()
+ ergoemacs-deferred-keys '())
(dolist (hook (ergoemacs-get-hooks obj))
(let ((emulation-var (intern (concat "ergoemacs--for-" (symbol-name
hook))))
(tmp '()) o-map n-map
@@ -1050,36 +1065,35 @@ FULL-SHORTCUT-MAP-P "
(fset fn-name
`(lambda() ,(format "Turn on `ergoemacs-mode' for `%s'
during the hook `%s'."
(symbol-name map-name) (symbol-name
hook))
- (let ((new-map (copy-keymap (quote ,map))))
+ (let ((new-map ',map))
(set ',map-name
- (copy-keymap
- (make-composed-keymap
- (ergoemacs-theme--install-shortcuts-list
- ,shortcut-list new-map ,map-name ,full-map)
,map-name))))))
+ (copy-keymap
+ (make-composed-keymap
+ (ergoemacs-theme--install-shortcuts-list
+ ',shortcut-list new-map ,map-name
,full-map) ,map-name))))))
(funcall (if remove-p #'remove-hook #'add-hook) hook
- emulation-var)))
+ fn-name)))
((and modify-map (not (boundp map-name)))
(pushnew (list map-name full-map map deferred-keys)
ergoemacs-deferred-maps))
((and modify-map (boundp map-name))
;; Maps that are modified once (modify NOW if bound);
;; no need for hooks?
- ;; (setq defer (append defer (cons map-name deferred-keys)))
- ;; (setq o-map (gethash map-name ergoemacs-original-map-hash))
- ;; (if remove-p
- ;; (when o-map
- ;; (message "Restore %s" map-name)
- ;; (set map-name (copy-keymap o-map)))
- ;; (message "Modify %s" map-name)
- ;; (unless o-map
- ;; (setq o-map (copy-keymap (symbol-value map-name)))
- ;; (puthash map-name o-map ergoemacs-original-map-hash))
- ;; (setq n-map (copy-keymap map))
- ;; (set map-name (copy-keymap
- ;; (make-composed-keymap
- ;; (ergoemacs-theme--install-shortcuts-list
- ;; shortcut-list n-map o-map full-map)
- ;; o-map))))
- )
+ (setq defer (append defer (cons map-name deferred-keys)))
+ (setq o-map (gethash map-name ergoemacs-original-map-hash))
+ (if remove-p
+ (when o-map
+ (message "Restore %s" map-name)
+ (set map-name (copy-keymap o-map)))
+ (message "Modify %s" map-name)
+ (unless o-map
+ (setq o-map (copy-keymap (symbol-value map-name)))
+ (puthash map-name o-map ergoemacs-original-map-hash))
+ (setq n-map (copy-keymap map))
+ (set map-name (copy-keymap
+ (make-composed-keymap
+ (ergoemacs-theme--install-shortcuts-list
+ shortcut-list n-map o-map full-map)
+ o-map)))))
(t ;; Maps that are not modified.
(unless remove-p
(message "Setup %s" hook)
@@ -1099,11 +1113,69 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
(setq i (+ i 1))
(push (cons emulation-var (ergoemacs-get-fixed-map--composite tmp))
hook-map-list))))
- (setq ergoemacs-emulation-mode-map-alist
+
+ ;; Reset shortcut hash
+ (setq ergoemacs-command-shortcuts-hash (make-hash-table :test 'equal)
+ ergoemacs-original-keys-to-shortcut-keys-regexp ""
+ ergoemacs-original-keys-to-shortcut-keys (make-hash-table :test
'equal))
+ (unless remove-p
+ ;; Remove keys that should not be in the keymap.
+ ;; This includes globally set keys that `ergoemacs-mode' will
+ ;; respect.
+ ;; The removing of keys doesn't really work right now.
+ (setq final-shortcut-map (copy-keymap shortcut-map)
+ final-unbind-map (copy-keymap unbind-map)
+ final-read-map (copy-keymap read-map)
+ final-map (copy-keymap map))
+ (dolist (key (append rm-keys ergoemacs-global-override-rm-keys))
+ (let ((vector-key (or (and (vectorp key) key)
+ (read-kbd-macro (key-description key) t))))
+ (setq final-read-map (or (and (memq (elt vector-key 0) '(3 24)) ;;
Keep `C-c' and `C-x'.
+ (memq (lookup-key final-read-map
(vector (elt vector-key 0))) '(ergoemacs-ctl-x ergoemacs-ctl-c))
+ final-read-map)
+ (ergoemacs-rm-key final-read-map key))
+ final-shortcut-map (ergoemacs-rm-key final-shortcut-map key)
+ final-map (ergoemacs-rm-key final-map key)
+ final-unbind-map (ergoemacs-rm-key final-unbind-map key))))
+ ;; Add `ergoemacs-mode' menu.
+ (define-key menu-keymap [menu-bar ergoemacs-mode]
+ `("ErgoEmacs" . ,(ergoemacs-keymap-menu ergoemacs-theme)))
+ ;; Coaleasing the keymaps needs to be done after removing the
+ ;; keys, otherwise the keys are not removed... Probably
+ ;; playing with pointers in C.
+ ;; (setq final-map (ergoemacs-get-fixed-map--combine-maps menu-keymap
final-map))
+ ;; Use a combined keymap instead
+ (setq final-map (make-composed-keymap (list menu-keymap final-map)))
+ ;; Rebuild Shortcut hash
+ (let (tmp)
+ (dolist (c shortcut-list)
+ (puthash (nth 0 c) (nth 1 c) ergoemacs-command-shortcuts-hash)
+ (when (eq (nth 1 (nth 1 c)) 'global)
+ (dolist (global-key (ergoemacs-shortcut-function-binding (nth 0
(nth 1 c))))
+ (if (not (gethash global-key
ergoemacs-original-keys-to-shortcut-keys))
+ (puthash global-key (append (gethash global-key
ergoemacs-original-keys-to-shortcut-keys) (list (nth 0 c)))
ergoemacs-original-keys-to-shortcut-keys)
+ (push (key-description global-key) tmp)
+ (puthash global-key (list (nth 0 c))
ergoemacs-original-keys-to-shortcut-keys)))))
+ (setq ergoemacs-original-keys-to-shortcut-keys-regexp
+ (regexp-opt tmp t))))
+ ;; Turn on/off ergoemacs-mode
+ (set-default 'ergoemacs-mode (not remove-p))
+ (set-default 'ergoemacs-shortcut-keys (not remove-p))
+ (set-default 'ergoemacs-read-input-keys (not remove-p))
+ (set-default 'ergoemacs-unbind-keys (not remove-p))
+ (setq ergoemacs-mode (not remove-p)
+ ergoemacs-keymap final-map
+ ergoemacs-shortcut-keys (not remove-p)
+ ergoemacs-read-input-keys (not remove-p)
+ ergoemacs-unbind-keys (not remove-p)
+ ergoemacs-read-input-keymap final-read-map
+ ergoemacs-read-emulation-mode-map-alist
`((ergoemacs-read-input-keys ,@final-read-map))
+ ergoemacs-shortcut-keymap final-shortcut-map
+ ergoemacs-emulation-mode-map-alist
`(,@(reverse
(append
hook-map-list
- (mapcar
+ (mapcar ;; Get the minor-mode maps that will be added.
(lambda(remap)
(with-slots (map
deferred-keys) (ergoemacs-get-fixed-map obj
remap)
@@ -1112,8 +1184,24 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
(setq i (+ i 1))
(cons remap map)))
(ergoemacs-get-hooks obj "-mode\\'"))))
- (ergoemacs-shortcut-keys ,@(or shortcut-map
(make-sparse-keymap)))))
- ergoemacs-emulation-mode-map-alist)))
+ (ergoemacs-shortcut-keys ,@final-shortcut-map)))
+ ;; Apply variables and mode changes.
+ (if remove-p
+ (progn
+ (dolist (item '(ergoemacs-mode ergoemacs-unbind-keys))
+ (let ((x (assq item minor-mode-map-alist)))
+ (when x
+ (setq minor-mode-map-alist (delq x minor-mode-map-alist)))))
+ (ergoemacs-remove-inits))
+ ;; Setup `ergoemacs-mode' and `ergoemacs-unbind-keys'
+ (setq minor-mode-map-alist
+ `((ergoemacs-mode ,@final-map)
+ ,@minor-mode-map-alist
+ (ergoemacs-unbind-keys ,@final-unbind-map)))
+ (ergoemacs-apply-inits obj)
+ (unwind-protect
+ (run-hooks 'ergoemacs-theme-hook)))
+ t)))
(defmethod ergoemacs-debug-obj ((obj ergoemacs-theme-component-map-list))
(ergoemacs-debug-clear)
@@ -1149,77 +1237,6 @@ The actual keymap changes are included in
`ergoemacs-emulation-mode-map-alist'."
-(defvar ergoemacs-original-keys-to-shortcut-keys-regexp ""
- "Regular expression of original keys that have shortcuts.")
-
-(defvar ergoemacs-original-keys-to-shortcut-keys (make-hash-table :test 'equal)
- "Hash table of the original maps that `ergoemacs-mode' saves.")
-
-;; (defvar ergoemacs-theme-hook-installed '()
-;; "Installed hooks")
-
-;; (defgeneric ergoemacs-apply-keymaps-for-hook (obj hook)
-;; "Installs keymaps for a specific hook")
-
-;; (defmethod ergoemacs-apply-keymaps-for-hook ((obj
ergoemacs-theme-component-map-list) hook)
-;; (with-slots (shortcut-list) (ergoemacs-get-fixed-map obj)
-;; (dolist (map-name (ergoemacs-get-keymaps-for-hook obj hook))
-;; (with-slots (map
-;; full-map
-;; always
-;; modify-map) (ergoemacs-get-fixed-map obj map-name)
-;; (cond
-;; (modify-map
-;; (if (not (keymapp (symbol-value map-name)))
-;; (warn "Keymap %s not found. Ergoemacs-mode cannot correct."
keymap-name)
-;; (unless (member (list hook map-name)
ergoemacs-theme-hook-installed)
-;; (let ((orig-map (gethash map-name
ergoemacs-original-map-hash))
-;; (fix-map (copy-keymap fix))
-;; (shortcut-map (make-sparse-keymap)))
-;; (unless orig-map
-;; ;; Save original map.
-;; (puthash map-name (copy-keymap (symbol-value map-name))
ergoemacs-original-map-hash)
-;; (setq orig-map (copy-keymap (symbol-value map-name))))
-;; ;; Now apply map changes.
-;; (set map-name
-;; (make-composed-keymap
-;; (list (ergoemacs-theme--install-shortcuts-list
-;; shortcut-list fix-map orig-map full-map)
-;; orig-map)))
-;; (unless always
-;; (push (list hook map-name)
ergoemacs-theme-hook-installed))))))
-;; (t
-;; ;; Shortcuts are handled by the shortcut layer.
-;; (let ((emulation-var (intern (concat "ergoemacs--for-"
(symbol-name hook) "-with-" (symbol-name map-name))))
-;; x)
-;; (unless (boundp emulation-var)
-;; (set-default emulation-var nil))
-;; (set (make-local-variable emulation-var) t)
-;; (setq x (assq emulation-var ergoemacs-emulation-mode-map-alist))
-;; (when (or (not x) always)
-;; (ergoemacs-add-emulation
-;; emulation-var (oref (ergoemacs-get-fixed-map obj map-name)
map))))))))))
-
-;; (defgeneric ergoemacs-create-hooks ()
-;; "Create and add/remove hooks for `ergoemacs-theme-component-map-list'
object.
-
-;; Call:
-;; ergoemacs-create-hooks OBJ REMOVE-P
-
-;; When REMOVE-P is non-nil, remove hooks
-
-;; ")
-
-;; (defmethod ergoemacs-create-hooks ((obj ergoemacs-theme-component-map-list)
remove-p)
-;; (dolist (hook (ergoemacs-get-hooks obj))
-;; (fset (intern (concat "ergoemacs-for-" (symbol-name hook)))
-;; `(lambda ()
-;; ,(format "Run `ergoemacs-theme-hook' for `%s'"
-;; (symbol-name hook))
-;; (ergoemacs-theme-hook ',hook)))
-;; (funcall (if remove-p #'remove-hook #'add-hook) hook
-;; (intern (concat "ergoemacs-for-" (symbol-name hook))))))
-
(defun ergoemacs-get-fixed-map--composite (map-list)
(or (and map-list
(or (and (= 1 (length map-list)) (nth 0 map-list))
@@ -1476,7 +1493,7 @@ Uses `ergoemacs-theme-component--parse-keys-and-body' and
'ergoemacs-theme-component--parse-remaining
skip-first))
-(defun ergoemacs-theme-component--parse-keys-and-body (keys-and-body
parse-function &optional skip-first)
+(defun ergoemacs-theme-component--parse-keys-and-body (keys-and-body &optional
parse-function skip-first)
"Split KEYS-AND-BODY into keyword-and-value pairs and the remaining body.
KEYS-AND-BODY should have the form of a property list, with the
@@ -1567,7 +1584,7 @@ additional parsing routines defined by PARSE-FUNCTION."
(defvar ergoemacs-theme-comp-hash (make-hash-table :test 'equal)
"Hash of ergoemacs theme components")
-(defmacro ergoemacs-theme-comp (&rest body-and-plist)
+(defmacro ergoemacs-theme-component (&rest body-and-plist)
"A component of an ergoemacs-theme."
(declare (doc-string 2)
(indent 2))
@@ -1578,7 +1595,7 @@ additional parsing routines defined by PARSE-FUNCTION."
',(nth 0 kb)
'(lambda () ,@(nth 1 kb))))
ergoemacs-theme-comp-hash)))
-(defmacro ergoemacs-t (&rest body-and-plist)
+(defmacro ergoemacs-theme (&rest body-and-plist)
"Define an ergoemacs-theme.
:components -- list of components that this theme uses. These can't be seen or
toggled
:optional-on -- list of components that are optional and are on by default
@@ -1698,7 +1715,7 @@ 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
(or theme ergoemacs-theme)))
+ (ergoemacs-theme-get-component (ergoemacs-theme-components (or theme
ergoemacs-theme)) version (or theme ergoemacs-theme)))
(defun ergoemacs-keymap-empty-p (keymap &optional dont-collapse)
"Determines if the KEYMAP is an empty keymap.
@@ -1729,493 +1746,19 @@ DONT-COLLAPSE doesn't collapse empty keymaps"
(defun ergoemacs-theme-debug (&optional theme version)
"Prints debugging information about the theme object."
(interactive)
- (let* ((theme-obj (ergoemacs-theme-get-obj theme version)))
+ (let* ((theme-obj (ergoemacs-theme-get-obj (or theme ergoemacs-theme)
version)))
(ergoemacs-debug-obj theme-obj)))
-(defun ergoemacs-theme-i (&optional theme version)
- "Gets the keymaps for THEME for VERSION."
- (let* ((theme-obj (ergoemacs-theme-get-obj theme version))
- (fixed-obj (ergoemacs-get-fixed-map theme-obj))
- (menu-keymap (make-sparse-keymap))
- (ergoemacs-emulation-mode-map-alist '()))
- (with-slots (read-map
- shortcut-map
- map
- shortcut-list
- unbind-map
- rm-keys) fixed-obj
- ;; Add menu.
- (define-key menu-keymap [menu-bar ergoemacs-mode]
- `("ErgoEmacs" . ,(ergoemacs-keymap-menu theme)))
- (setq new-map (copy-keymap map))
- (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)
- (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))))
- (ergoemacs-add-emulation
- nil nil
- (mapcar
- (lambda(remap)
- (cons remap (oref (ergoemacs-get-fixed-map theme-obj remap) map)))
- (ergoemacs-get-hooks theme-obj "-mode\\'"))))))
-
-
-
-
-;; (setq ergoemacs-theme-component-maps--curr-component
-;; (ergoemacs-theme-component-maps "test" :layout "colemak"))
-
-;; (ergoemacs-define-key 'global-map (kbd "M-u") 'previous-line)
-;; (ergoemacs-define-key 'global-map (kbd "C-o") 'find-file)
-
-;; Dummy variables
-(setq ergoemacs-component-version-curr nil
- ergoemacs-component-version-list nil
- ergoemacs-component-version-fixed-layout nil
- ergoemacs-component-version-fixed-layout-rm nil
- ergoemacs-component-version-redundant-keys nil
- ergoemacs-component-version-minor-mode-layout nil
- ergoemacs-component-version-variable-layout-rm nil
- ergoemacs-component-version-variable-layout nil
- ergoemacs-theme-save-variable '())
-
-
-(defun ergoemacs--parse-keys-and-body (keys-and-body &optional is-theme)
- "Split KEYS-AND-BODY into keyword-and-value pairs and the remaining body.
-
-KEYS-AND-BODY should have the form of a property list, with the
-exception that only keywords are permitted as keys and that the
-tail -- the body -- is a list of forms that does not start with a
-keyword.
-
-Returns a two-element list containing the keys-and-values plist
-and the body.
-
-This has been stolen directly from ert by Christian Ohler <address@hidden>
-
-Afterward it was modified for use with `ergoemacs-mode'. In
-particular it:
-- `define-key' is converted to `ergoemacs-theme-component--define-key' and
keymaps are quoted
-- `global-set-key' is converted to `ergoemacs-theme-component--global-set-key'
-- `global-unset-key' is converted to
`ergoemacs-theme-component--global-set-key'
-- `global-reset-key' is converted `ergoemacs-theme-component--global-reset-key'
-- `setq' and `set' is converted to `ergoemacs-theme-component--set'
-- Mode initialization like (delete-selection-mode 1)
- or (delete-selection) is converted to
- `ergoemacs-theme-component--mode'
-- Allows :version statement expansion
-- Adds with-hook syntax or (when -hook) or (when -mode)
-"
- (let ((extracted-key-accu '())
- last-was-version
- plist
- (remaining keys-and-body))
- ;; Allow
- ;; (component name)
- (unless (or (keywordp (first remaining)) (boundp 'skip-first))
- (if (condition-case nil
- (stringp (first remaining))
- (error nil))
- (push `(:name . ,(pop remaining)) extracted-key-accu)
- (push `(:name . ,(symbol-name (pop remaining))) extracted-key-accu))
- (when (memq (type-of (first remaining)) '(symbol cons))
- (pop remaining))
- (when (stringp (first remaining))
- (push `(:description . ,(pop remaining)) extracted-key-accu)))
- (while (and (consp remaining) (keywordp (first remaining)))
- (let ((keyword (pop remaining)))
- (unless (consp remaining)
- (error "Value expected after keyword %S in %S"
- keyword keys-and-body))
- (when (assoc keyword extracted-key-accu)
- (warn "Keyword %S appears more than once in %S" keyword
- keys-and-body))
- (push (cons keyword (pop remaining)) extracted-key-accu)))
- (setq extracted-key-accu (nreverse extracted-key-accu))
- ;; Now change remaining (define-key keymap key def) to
- ;; (define-key 'keymap key def)
- ;; Also change (with-hook hook-name ) to (let ((ergoemacs-hook
'hook-name)))
- (unless is-theme
- (setq remaining
- (mapcar
- (lambda(elt)
- (cond
- (last-was-version
- (setq last-was-version nil)
- (if (stringp elt)
- `(when (boundp 'component-version) (setq
component-version ,elt))
- `(when (boundp 'component-version) (setq component-version
,(symbol-name elt)))))
- ((condition-case nil
- (eq elt ':version)
- (error nil))
- (setq last-was-version t)
- nil)
- ((condition-case err
- (eq (nth 0 elt) 'global-reset-key)
- (error nil))
- `(ergoemacs-theme-component--global-reset-key ,(nth 1 elt)))
- ((condition-case err
- (eq (nth 0 elt) 'global-unset-key)
- (error nil))
- `(ergoemacs-theme-component--global-set-key ,(nth 1 elt) nil))
- ((condition-case err
- (eq (nth 0 elt) 'setq)
- (error nil))
- ;; Currently doesn't support (setq a b c d ), but it should.
- `(ergoemacs-theme-component--set (quote ,(nth 1 elt)) ,(nth 2
elt)))
- ((condition-case err
- (eq (nth 0 elt) 'set)
- (error nil))
- `(ergoemacs-theme-component--set (nth 1 elt) ,(nth 2 elt)))
- ((condition-case err
- (string-match "-mode$" (symbol-name (nth 0 elt)))
- (error nil))
- `(ergoemacs-theme-component--mode (quote ,(nth 0 elt)) ,(nth
1 elt)))
- ((condition-case err
- (eq (nth 0 elt) 'global-set-key)
- (error nil))
- (if (condition-case nil
- (keymapp (symbol-value (nth 2 elt)))
- (error nil))
- (progn
- `(ergoemacs-theme-component--global-set-key ,(nth 1
elt) (quote ,(nth 2 elt))))
- `(ergoemacs-theme-component--global-set-key ,(nth 1 elt)
,(nth 2 elt))))
- ((condition-case err
- (eq (nth 0 elt) 'define-key)
- (error nil))
- (if (equal (nth 1 elt) '(current-global-map))
- (if (condition-case nil
- (keymapp (symbol-value (nth 3 elt)))
- (error nil))
- `(ergoemacs-theme-component--global-set-key ,(nth 2
elt) (quote ,(nth 3 elt)))
- `(ergoemacs-theme-component--global-set-key ,(nth 2
elt) ,(nth 3 elt)))
- (if (condition-case nil
- (keymapp (symbol-value (nth 3 elt)))
- (error nil))
- `(ergoemacs-theme-component--define-key (quote ,(nth 1
elt)) ,(nth 2 elt) (quote ,(nth 3 elt)))
- `(ergoemacs-theme-component--define-key (quote ,(nth 1
elt)) ,(nth 2 elt) ,(nth 3 elt)))))
- ((or (condition-case err
- (eq (nth 0 elt) 'with-hook)
- (error nil))
- (and (condition-case err
- (eq (nth 0 elt) 'when)
- (error nil))
- (condition-case err
- (string-match "-\\(hook\\|mode\\)$" (symbol-name
(nth 1 elt)))
- (error nil))))
- (let (tmp skip-first)
- (setq tmp (ergoemacs--parse-keys-and-body (cdr (cdr elt))))
- `(let ((ergoemacs-hook (quote ,(nth 1 elt)))
- (ergoemacs-hook-modify-keymap
- ,(or (plist-get (nth 0 tmp)
- ':modify-keymap)
- (plist-get (nth 0 tmp)
- ':modify-map)))
- (ergoemacs-hook-full-shortcut-map
- ,(or (plist-get (nth 0 tmp)
- ':full-shortcut-keymap)
- (plist-get (nth 0 tmp)
- ':full-shortcut-map)
- (plist-get (nth 0 tmp)
- ':full-map)
- (plist-get (nth 0 tmp)
- ':full-keymap)))
- (ergoemacs-hook-always ,(plist-get (nth 0 tmp)
- ':always)))
- ,@(nth 1 tmp))))
- (t elt)))
- remaining)))
- (setq plist (loop for (key . value) in extracted-key-accu
- collect key
- collect value))
- (list plist remaining)))
-(defvar ergoemacs-theme-component-hash (make-hash-table :test 'equal))
-(defvar ergoemacs-theme-component-cache (make-hash-table :test 'equal))
-(defun ergoemacs-theme-component--version-bump ()
- (when (and (boundp 'component-version)
- component-version
- (boundp 'ergoemacs-component-version-minor-mode-layout)
- (boundp 'ergoemacs-component-version-curr)
- (boundp 'fixed-layout) (boundp 'variable-layout)
- (boundp 'fixed-layout-rm) (boundp 'variable-layout-rm)
- (boundp 'redundant-keys) (boundp 'defined-keys)
- (boundp 'versions)
- (boundp 'ergoemacs-just-first-reg)
- (not (equal ergoemacs-component-version-curr component-version)))
- ;; Create/Update component-version fixed or variable layouts.
- (when ergoemacs-component-version-curr
- (push (list ergoemacs-component-version-curr
- ergoemacs-component-version-fixed-layout
- ergoemacs-component-version-variable-layout
- ergoemacs-component-version-redundant-keys
- ergoemacs-component-version-minor-mode-layout
- ergoemacs-component-version-fixed-layout-rm
- ergoemacs-component-version-variable-layout-rm)
- ergoemacs-component-version-list))
- (setq ergoemacs-component-version-curr component-version)
- (push ergoemacs-component-version-curr versions)
- (unless ergoemacs-component-version-minor-mode-layout
- (setq ergoemacs-component-version-minor-mode-layout
ergoemacs-component-version-minor-mode-layout))
- (unless ergoemacs-component-version-fixed-layout
- (setq ergoemacs-component-version-fixed-layout fixed-layout))
- (unless ergoemacs-component-version-fixed-layout-rm
- (setq ergoemacs-component-version-fixed-layout-rm fixed-layout-rm))
- (unless ergoemacs-component-version-fixed-layout
- (setq ergoemacs-component-version-variable-layout variable-layout))
- (unless ergoemacs-component-version-fixed-layout-rm
- (setq ergoemacs-component-version-variable-layout-rm variable-layout-rm))
- (unless ergoemacs-component-version-redundant-keys
- (setq ergoemacs-component-version-redundant-keys redundant-keys))))
-
-(defun ergoemacs-theme-component--rm-key (key)
- "Remove KEY from `ergoemacs-mode' keymaps"
- (let* ((kd (key-description key)) jf
- (variable-p (if (boundp 'ergoemacs-force-variable-reg)
ergoemacs-force-variable-reg
- (and (boundp 'ergoemacs-variable-reg)
- ergoemacs-variable-reg
- (condition-case nil
- (string-match ergoemacs-variable-reg kd)
- (error nil))))))
- (when variable-p
- (setq jf (if (boundp 'ergoemacs-force-variable-reg)
ergoemacs-force-variable-reg
- (and (boundp 'ergoemacs-just-first-reg)
ergoemacs-just-first-reg
- (condition-case nil
- (string-match ergoemacs-just-first-reg kd)
- (error nil))))))
- (cond
- ((and variable-p (boundp 'variable-layout-rm))
- (setq kd (ergoemacs-kbd kd t jf))
- (push (list kd jf) variable-layout-rm))
- ((boundp 'fixed-layout-rm)
- (push key fixed-layout-rm)))))
-
-(defun ergoemacs-theme-component--global-reset-key (key)
- "Reset KEY.
-will take out KEY from `ergoemacs-component-version-redundant-keys'"
- (when (and (boundp 'component-version)
- component-version
- (boundp 'ergoemacs-component-version-curr)
- (boundp 'fixed-layout) (boundp 'variable-layout)
- (boundp 'redundant-keys) (boundp 'defined-keys)
- (boundp 'versions)
- (boundp 'ergoemacs-component-version-redundant-keys)
- (boundp 'ergoemacs-just-first-reg))
- (ergoemacs-theme-component--version-bump)
- (let ((kd (key-description key))
- tmp)
- (setq tmp '())
- (mapc
- (lambda(x)
- (unless (string= x kd)
- (push x tmp)))
- ergoemacs-component-version-redundant-keys)
- (setq ergoemacs-component-version-redundant-keys tmp))))
-
-(defun ergoemacs-theme-component--global-set-key (key command)
- "Setup ergoemacs theme component internally.
-When fixed-layout and variable-layout are bound"
- (cond
- ((and (boundp 'ergoemacs-hook)
- (string-match "mode$" (symbol-name ergoemacs-hook)))
- (ergoemacs-theme-component--define-key ergoemacs-hook key command))
- ((and (vectorp key) (eq (elt key 0) 'remap))
- (let ((ergoemacs-hook 'ergoemacs-mode)
- (ergoemacs-hook-modify-keymap nil)
- (ergoemacs-hook-full-shortcut-map nil)
- (ergoemacs-hook-always nil))
- (ergoemacs-theme-component--define-key 'ergoemacs-mode key command)))
- ((and (boundp 'component-version)
- component-version
- (boundp 'ergoemacs-component-version-curr)
- (boundp 'fixed-layout) (boundp 'variable-layout)
- (boundp 'redundant-keys) (boundp 'defined-keys)
- (boundp 'versions)
- (boundp 'ergoemacs-just-first-reg))
- (ergoemacs-theme-component--version-bump)
- (let* ((kd (key-description key)) cd jf removed
- (variable-p (if (boundp 'ergoemacs-force-variable-reg)
- ergoemacs-force-variable-reg
- (and (boundp 'ergoemacs-variable-reg)
- ergoemacs-variable-reg
- (condition-case nil
- (string-match ergoemacs-variable-reg kd)
- (error nil))))))
- (when cd
- (setq cd (car (cdr cd))))
- (if (not command)
- (mapc ;; Remove command from lists.
- (lambda(y)
- (let (tmp '())
- (mapc
- (lambda(x)
- (unless (equal (nth 0 x) kd)
- (push x tmp)))
- (symbol-value y))
- (set y tmp)))
- '(ergoemacs-component-version-fixed-layout
ergoemacs-component-version-variable-layout))
- (if (not variable-p)
- (progn ;; Fixed Layout component
- (setq ergoemacs-component-version-fixed-layout
- (mapcar
- (lambda(x)
- (if (not (equal (nth 0 x) kd))
- x
- (setq removed t)
- (list kd command cd)))
- ergoemacs-component-version-fixed-layout))
- (unless removed
- (push (list kd command cd)
ergoemacs-component-version-fixed-layout)))
- ;; (push (list kd command) defined-keys)
- (setq jf (if (boundp 'ergoemacs-force-variable-reg)
ergoemacs-force-variable-reg
- (and (boundp 'ergoemacs-just-first-reg)
ergoemacs-just-first-reg
- (condition-case nil
- (string-match ergoemacs-just-first-reg kd)
- (error nil)))))
- (setq kd (ergoemacs-kbd kd t jf))
- (setq ergoemacs-component-version-variable-layout
- (mapcar
- (lambda(x)
- (if (not (equal (nth 0 x) kd))
- x
- (setq removed t)
- (list kd command cd jf)))
- ergoemacs-component-version-variable-layout))
- (unless removed
- (push (list kd command cd jf)
ergoemacs-component-version-variable-layout))))))
- ((and (boundp 'fixed-layout) (boundp 'variable-layout)
- (boundp 'component-version)
- (not component-version)
- (boundp 'redundant-keys) (boundp 'defined-keys))
- (let ((kd (key-description key)) cd jf)
- (if (not command) ; redundant key
- (push kd redundant-keys)
- (setq cd (assoc command ergoemacs-function-short-names)) ; Short key
description
- (when cd
- (setq cd (car (cdr cd))))
- (if (not (if (boundp 'ergoemacs-force-variable-reg)
ergoemacs-force-variable-reg
- (condition-case nil
- (string-match ergoemacs-variable-reg kd)
- (error nil))))
- (push (list kd command cd) fixed-layout) ;; Fixed layout component
- (push (list kd command) defined-keys)
- (setq jf (if (boundp 'ergoemacs-force-variable-reg)
ergoemacs-force-variable-reg
- (and ergoemacs-just-first-reg
- (condition-case nil
- (string-match ergoemacs-just-first-reg kd)
- (error nil)))))
- (setq kd (ergoemacs-kbd kd t jf))
- (push (list kd command cd jf) variable-layout)))))))
-
-(defun ergoemacs-theme-component--define-key (keymap key def)
- "Setup mode-specific information."
- (when (and (boundp 'fixed-layout) (boundp 'variable-layout))
- (if (memq keymap '(global-map ergoemacs-keymap))
- (if (and (eq keymap 'ergoemacs-keymap) (not def))
- (ergoemacs-theme-component--rm-key key)
- (ergoemacs-theme-component--global-set-key key def))
- (let* ((hook (or
- (and (boundp 'ergoemacs-hook) ergoemacs-hook)
- (intern (if (string-match "mode" (symbol-name keymap))
- (replace-regexp-in-string "mode.*" "mode-hook"
(symbol-name keymap))
- ;; Assume -keymap or -map defines -mode-hook
- (string-match "(key)?map" "mode-hook"
(symbol-name keymap))))))
- (modify-keymap-p
- (and (boundp 'ergoemacs-hook-modify-keymap)
- ergoemacs-hook-modify-keymap))
- (full-shortcut-p
- (and (boundp 'ergoemacs-hook-full-shortcut-map)
- ergoemacs-hook-full-shortcut-map))
- (always-run-p (and (boundp 'ergoemacs-hook-always)
- ergoemacs-hook-always))
- (kd (key-description key))
- (variable-p (and (boundp 'ergoemacs-variable-reg)
- ergoemacs-variable-reg
- (condition-case nil
- (string-match ergoemacs-variable-reg kd)
- (error nil))))
- a-key
- jf found-1-p found-2-p)
- (when (and (boundp 'emulation-setup) (boundp 'ergoemacs-hook)
- (string-match "mode$" (symbol-name ergoemacs-hook)))
- (add-to-list 'emulation-setup ergoemacs-hook nil 'eq))
- (when (boundp 'minor-mode-hook-list)
- (add-to-list 'minor-mode-hook-list hook nil 'eq))
- (when variable-p
- (setq variable-p t)
- (setq jf (if (boundp 'ergoemacs-force-variable-reg)
ergoemacs-force-variable-reg
- (and ergoemacs-just-first-reg
- (condition-case nil
- (string-match ergoemacs-just-first-reg kd)
- (error nil)))))
- (setq kd (ergoemacs-kbd kd t jf)))
- (cond
- ((and (boundp 'component-version)
- component-version
- (boundp 'ergoemacs-component-version-curr)
- (boundp 'fixed-layout) (boundp 'variable-layout)
- (boundp 'redundant-keys) (boundp 'defined-keys)
- (boundp 'versions)
- (boundp 'ergoemacs-just-first-reg))
- (ergoemacs-theme-component--version-bump) ;; Change version
information
- )
- ((and (boundp 'fixed-layout) (boundp 'variable-layout)
- (boundp 'component-version)
- (not component-version)
- (boundp 'redundant-keys) (boundp 'defined-keys))
- ;; Keymaps modified are stored as (hook (keymaps))
- ;; Keys are stored as ((hook keymap/t variable-p) ((key def)))
- (setq a-key (list hook (if modify-keymap-p keymap
- (or (and (boundp 'ergoemacs-hook)
- (string-match "mode$" (symbol-name
ergoemacs-hook))
- ergoemacs-hook) t)) variable-p))
- (setq minor-mode-layout
- (mapcar
- (lambda(elt)
- (cond
- ((eq (car elt) hook)
- (let ((lst (car (cdr elt))))
- (add-to-list 'lst (if modify-keymap-p keymap
- (or (and (boundp 'ergoemacs-hook)
- (string-match "mode$"
(symbol-name ergoemacs-hook))
- ergoemacs-hook) t)) nil
'eq)
- (setq found-1-p t)
- (list hook lst)))
- ((equal (car elt) a-key)
- (let ((lst (car (cdr elt))) new-lst)
- (mapc
- (lambda(elt-2)
- (cond
- ((equal (car elt-2) kd)
- (setq found-2-p t)
- (push (list kd def jf) new-lst))
- (t
- (push elt-2 new-lst))))
- lst)
- (unless found-2-p
- (push (list kd def) new-lst))
- (setq found-2-p t)
- (list a-key new-lst always-run-p full-shortcut-p)))
- (t
- elt)))
- minor-mode-layout))
- (unless found-1-p
- (push (list hook (list (if modify-keymap-p keymap
- (or (and (boundp 'ergoemacs-hook)
- (string-match "mode$"
(symbol-name ergoemacs-hook))
- ergoemacs-hook) t))))
minor-mode-layout))
- (unless found-2-p
- (push (list a-key (list (list kd def)) always-run-p
full-shortcut-p) minor-mode-layout))))))))
+(defun ergoemacs-theme-install (&optional theme version)
+ "Gets the keymaps for THEME for VERSION."
+ (ergoemacs-theme-obj-install (ergoemacs-theme-get-obj (or theme
ergoemacs-theme) version)))
+(defun ergoemacs-theme-remove ()
+ "Remove the currently installed theme and reset to emacs keys."
+ (ergoemacs-theme-obj-install
+ (ergoemacs-theme-get-obj
+ ergoemacs-theme (ergoemacs-theme-get-version)) 'remove))
(defun ergoemacs-theme-component--ignore-globally-defined-key (key)
"Adds KEY to `ergoemacs-global-override-rm-keys' and
`ergoemacs-global-override-map' if globally redefined."
@@ -2231,865 +1774,8 @@ When fixed-layout and variable-layout are bound"
(throw 'found-global-command t))
(setq key (substring key 0 (- (length key) 1)))))))
-(defun ergoemacs-theme-component--define-key-in-keymaps (keymap
keymap-shortcut key def)
- "Defines KEY in KEYMAP or KEYMAP-SHORTCUT to be DEF.
-Similar to `define-key'.
-
-DEF can be:
-1. A function; If globally defined, this is defined by
- `ergoemacs-shortcut-remap'
-2. A list of functions
-3. A keymap
-4. A kbd-code that this shortcuts to with `ergoemacs-read'
-
-"
- (cond
- ((eq 'cons (type-of def))
- (let (found)
- (if (condition-case err
- (stringp (nth 0 def))
- (error nil))
- (progn
- (when (boundp 'shortcut-list)
- (push (list (read-kbd-macro (key-description key) t)
- `(,(nth 0 def) ,(nth 1 def)))
- shortcut-list))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key 'ergoemacs-shortcut))
- (mapc
- (lambda(new-def)
- (unless found
- (when (condition-case err
- (interactive-form new-def)
- (error nil))
- (setq found
- (ergoemacs-theme-component--define-key-in-keymaps
- keymap keymap-shortcut key new-def)))))
- def))
- found))
- ((condition-case err
- (interactive-form def)
- (error nil))
- (cond
- ;; only setup on `ergoemacs-shortcut-keymap' when setting up
- ;; ergoemacs default keymap.
- ((memq def '(ergoemacs-ctl-c ergoemacs-ctl-x))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key def))
- ((and (not (string-match "\\(mouse\\|wheel\\)" (key-description key)))
- (ergoemacs-shortcut-function-binding def))
- (when (boundp 'shortcut-list)
- (push (list (read-kbd-macro (key-description key) t)
- (list def 'global)) shortcut-list))
- (if (ergoemacs-is-movement-command-p def)
- (if (let (case-fold-search) (string-match "\\(S-\\|[A-Z]$\\)"
(key-description key)))
- (progn
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key
'ergoemacs-shortcut-movement-no-shift-select))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key 'ergoemacs-shortcut-movement))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key 'ergoemacs-shortcut)))
- ((or (commandp def t) (keymapp def))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap key def)))
- t)
- ((condition-case err
- (keymapp (symbol-value def))
- (error nil))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap key (symbol-value def))
- t)
- ((condition-case err
- (or (vectorp def) (stringp def))
- (error nil))
- (progn
- (when (boundp 'shortcut-list)
- (push (list (read-kbd-macro (key-description key) t)
- `(,(if (stringp def) def
- (key-description def)) nil)) shortcut-list))
- (if (ergoemacs-is-movement-command-p def)
- (if (let (case-fold-search) (string-match "\\(S-\\|[A-Z]$\\)"
(key-description key)))
- (progn
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key
'ergoemacs-shortcut-movement-no-shift-select))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key 'ergoemacs-shortcut-movement))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (define-key keymap-shortcut key 'ergoemacs-shortcut)))
- t)
- (t nil)))
-
-(defun ergoemacs-theme-component--set (elt value)
- "Direct `ergoemacs-mode' to set quoted ELT to VALUE when enabling a
theme-component.
-Will attempt to restore the value when turning off the component/theme."
- (push (list elt value) ergoemacs-theme-save-variables))
-
-(defun ergoemacs-theme-component--mode (mode &optional value)
- "Direct `ergoemacs-mode' to turn on/off a minor-mode MODE with the optional
argument VALUE.
-Will attempt to restore the mode state when turning off the component/theme."
- (push (list mode (or value 1)) ergoemacs-theme-save-variables))
-
-(defcustom ergoemacs-prefer-variable-keybindings t
- "Prefer Variable keybindings over fixed keybindings."
- :type 'boolean
- :group 'ergoemacs-mode)
-
-
-(defun ergoemacs-theme-component-keymaps-for-hook (hook component &optional
version)
- "Gets the keymaps for COMPONENT and component VERSION for HOOK.
-If the COMPONENT has the suffix :fixed, just get the fixed component.
-If the COMPONENT has the suffix :variable, just get the variable component.
-If the COMPONENT has the suffix ::version, just get the closest specified
version.
-
-If COMPONENT is a list, return the composite keymaps of all the
-components listed.
-
-The return value is an alist of keymaps needed for this hook. The format is:
- ((map-name always-modify-p keymap-stub full-map))
-
-map-name is the map name that will be modified
-always-modify-p is a flag that will modify the keymap every time the hook is
run.
-keymaps-stub is the keymap overrides that will be installed.
-
-When map-name is t or ends in -mode, it is for a keymap put in
-`ergoemacs-emulation-mode-map-alist'.
-
-This function does not finalize maps by installing them into the original maps.
-"
- (if (eq (type-of component) 'cons)
- (let ((ret nil) ;; List of components.
- already-done-list
- (version version)
- always-modify-p)
- (mapc
- (lambda(comp)
- (let ((new-ret (ergoemacs-theme-component-keymaps-for-hook hook
comp version)))
- (if (not ret)
- (setq ret new-ret)
- (setq already-done-list '())
- (setq ret
- (mapcar
- (lambda(keymap-list)
- (let ((map-name (nth 0 keymap-list))
- old-map new-map
- full-map-p)
- (setq new-map (assoc map-name new-ret))
- (if (not new-map)
- keymap-list
- ;; Try to decompose keymaps as much as
- ;; possible. That way you won't have
- ;; keymaps like:
- ;; (keymap (keymap (keymap (keymap...))))
- ;; For no reason.
- (push map-name already-done-list)
- (setq always-modify-p (or (nth 1 keymap-list) (nth
1 new-map)))
- (setq new-map (nth 2 new-map)
- old-map (nth 2 keymap-list)
- full-map-p (or (nth 3 keymap-list)
- (nth 3 new-map)))
- (cond
- ((and (keymapp (nth 1 new-map)) ; 2 composed.
- (keymapp (nth 1 old-map)))
- (pop new-map)
- (pop old-map)
- (setq new-map (append new-map old-map))
- (push 'keymap new-map))
- ((and (keymapp (nth 1 old-map)) (keymapp new-map))
- (pop old-map)
- (setq new-map (append (list new-map) old-map))
- (push 'keymap new-map))
- ((and (keymapp (nth 1 new-map)) (keymapp
old-map)) ;; New map is composed.
- (pop new-map)
- (setq new-map (append new-map (list old-map)))
- (push 'keymap new-map))
- ((and (keymapp new-map) (keymapp old-map))
- ;; decomposed maps.
- (setq new-map (make-composed-keymap (list
new-map old-map))))
- ((keymapp old-map)
- (setq new-map old-map))
- ((keymapp new-map)))
- (list map-name always-modify-p new-map
full-map-p))))
- ret))
- (mapc
- (lambda(keymap-list)
- (unless (member (nth 0 keymap-list) already-done-list)
- (push keymap-list ret)))
- new-ret))))
- (reverse component))
- ret)
- ;; Single component
- (let ((true-component (replace-regexp-in-string ":\\(fixed\\|variable\\)"
""
- (or (and (stringp
component) component)
- (symbol-name
component))))
- (only-variable (string-match ":variable" (or (and (stringp
component) component)
- (symbol-name
component))))
- (only-fixed (string-match ":fixed" (or (and (stringp component)
component)
- (symbol-name component))))
- fixed-maps variable-maps
- (true-version version)
- (version (or version (ergoemacs-theme-get-version)))
- minor-alist keymap-list shortcut-list
- always-p full-shortcut-map-p ret already-done-list)
- (when (string-match "::\\([0-9.]+\\)$" true-component)
- (setq version (match-string 1 true-component)
- true-component (replace-match "" nil nil true-component)))
- (if (not version)
- (setq version "")
- (setq version (ergoemacs-theme-component-get-closest-version
- version
- (gethash (concat true-component ":version")
- ergoemacs-theme-component-hash))))
- (unless only-variable
- (setq fixed-maps (gethash (concat true-component version ":"
(symbol-name hook) ":maps")
- ergoemacs-theme-component-cache))
- (unless fixed-maps
- ;; Setup fixed fixed-keymap for this component.
- (setq minor-alist
- (gethash (concat true-component version ":minor")
- ergoemacs-theme-component-hash))
- (when minor-alist
- (setq keymap-list (assoc hook minor-alist))
- (when keymap-list
- (setq keymap-list (car (cdr keymap-list))
- fixed-maps '())
- (mapc
- (lambda(map-name)
- (let ((keys (assoc (list hook map-name nil) minor-alist))
- (map (make-sparse-keymap))
- always-p)
- (when keys
- (setq always-p (nth 2 keys)
- full-shortcut-map-p (nth 3 keys)
- keys (nth 1 keys))
- (mapc
- (lambda(key-list)
- (cond
- ((stringp (nth 1 key-list))
-
(ergoemacs-theme-component--ignore-globally-defined-key (read-kbd-macro (nth 0
key-list) t))
- (define-key map (read-kbd-macro (nth 0 key-list) t)
- `(lambda() (interactive) (ergoemacs-read-key ,(nth
1 key-list)))))
- ((or (commandp (nth 1 key-list) t)
- (keymapp (nth 1 key-list)))
-
(ergoemacs-theme-component--ignore-globally-defined-key (read-kbd-macro (nth 0
key-list) t))
- (define-key map (read-kbd-macro (nth 0 key-list) t)
- (nth 1 key-list)))))
- (reverse keys))
- (unless (equal map '(keymap))
- (push `(,map-name ,always-p ,map
- ,full-shortcut-map-p) fixed-maps)))))
- keymap-list)
- (unless (equal fixed-maps '())
- (puthash (concat true-component version ":" (symbol-name hook)
":maps") fixed-maps
- ergoemacs-theme-component-cache))))))
-
- (unless only-fixed
- (setq variable-maps (gethash (concat true-component version ":"
ergoemacs-keyboard-layout ":" (symbol-name hook) ":maps")
ergoemacs-theme-component-cache))
- (unless variable-maps
- ;; Setup variable keymaps for this component.
- (setq minor-alist
- (gethash (concat true-component version ":minor")
ergoemacs-theme-component-hash))
- (when minor-alist
- (setq keymap-list (assoc hook minor-alist))
- (when keymap-list
- (setq keymap-list (car (cdr keymap-list))
- variable-maps '())
- (mapc
- (lambda(map-name)
- (let ((keys (assoc (list hook map-name t) minor-alist))
- (map (make-sparse-keymap))
- full-map
- always-p)
- (when keys
- (setq always-p (nth 2 keys))
- (setq full-shortcut-map-p (nth 3 keys))
- (setq keys (nth 1 keys))
- (mapc
- (lambda(key-list)
- (cond
- ((stringp (nth 1 key-list))
-
(ergoemacs-theme-component--ignore-globally-defined-key (ergoemacs-kbd (nth 0
key-list) nil (nth 3 key-list)))
- (define-key map (ergoemacs-kbd (nth 0 key-list) nil
(nth 3 key-list))
- `(lambda() (interactive) (ergoemacs-read-key ,(nth
1 key-list)))))
- (t
-
(ergoemacs-theme-component--ignore-globally-defined-key (ergoemacs-kbd (nth 0
key-list) nil (nth 3 key-list)))
- (define-key map (ergoemacs-kbd (nth 0 key-list) nil
(nth 3 key-list))
- (nth 1 key-list)))))
- (reverse keys))
- (unless (equal map '(keymap))
- (push `(,map-name ,always-p ,map ,full-shortcut-map-p)
variable-maps)))))
- keymap-list)
- (unless (equal variable-maps '())
- (puthash (concat true-component version ":"
ergoemacs-keyboard-layout ":" (symbol-name hook) ":maps")
- variable-maps ergoemacs-theme-component-cache))))))
- ;; Now variable maps
- (setq already-done-list '())
- (setq ret
- (mapcar
- (lambda(keymap-list)
- (let ((map-name (nth 0 keymap-list))
- fixed-map composed-map tmp full-shortcut-map-p)
- (setq fixed-map (assoc map-name fixed-maps))
- (if (not fixed-map)
- keymap-list
- (push map-name already-done-list)
- (setq full-shortcut-map-p (or (nth 3 keymap-list) (nth 2
fixed-map)))
- ;; Need to decompose if needed...
- (cond
- ((and (keymapp (nth 1 (nth 2 keymap-list)))
- (keymapp (nth 1 (nth 2 fixed-map))))
- (setq composed-map (nth 2 keymap-list))
- (pop composed-map)
- (setq tmp (nth 2 fixed-map))
- (pop tmp))
- ((keymapp (nth 1 (nth 2 keymap-list)))
- (setq composed-map (nth 2 keymap-list))
- (pop composed-map)
- (setq tmp (list (nth 2 fixed-map))))
- ((keymapp (nth 1 (nth 2 fixed-map)))
- (setq composed-map (list (nth 2 keymap-list)))
- (setq tmp (nth 2 fixed-map))
- (pop tmp))
- (t
- (setq composed-map (list (nth 2 keymap-list)))
- (setq tmp (list (nth 2 fixed-map)))))
- (setq composed-map
- (if ergoemacs-prefer-variable-keybindings
- (append composed-map tmp)
- (append tmp composed-map)))
- (push 'keymap composed-map)
- (setq tmp `(,map-name ,(or (nth 1 keymap-list) (nth 1
fixed-map))
- ,composed-map ,full-shortcut-map-p))
- tmp)))
- variable-maps))
- (mapc
- (lambda(keymap-list)
- (unless (member (nth 0 keymap-list) already-done-list)
- (push keymap-list ret)))
- fixed-maps)
- ret)))
-
-(defun ergoemacs-theme-component-keymaps (component &optional version)
- "Gets the keymaps for COMPONENT for component VERSION.
-If the COMPONENT has the suffix :fixed, just get the fixed component.
-If the COMPONENT has the suffix :variable, just get the variable component.
-If the COMPONENT has the suffix ::version, just get the closest specified
version.
-
-If COMPONENT is a list, return the composite keymaps of all the
-components listed.
-
-Returns list of: read-keymap shortcut-keymap keymap shortcut-list
unbind-keymap rm-keys emulation-setup vars.
-"
- (if (eq (type-of component) 'cons)
- (let ((ret nil)
- k-l
- (l0 '())
- (l1 '())
- (l2 '())
- (l3 '())
- (l4 '())
- (l5 '())
- (l6 '())
- (l7 '())) ;; List of components.
- (mapc
- (lambda(comp)
- (let ((new-ret (ergoemacs-theme-component-keymaps comp version)))
- (when (and (nth 0 new-ret) (not (equal (nth 0 new-ret)
'(keymap))))
- (if (not (keymapp (nth 1 (nth 0 new-ret))))
- (push (nth 0 new-ret) l0) ;; Not a composed keymap.
- (setq k-l (nth 0 new-ret)) ;; Composed keymap.
- ;; Decompose keymaps.
- (pop k-l)
- (setq l0 (append k-l l0))))
- (when (and (nth 1 new-ret) (not (equal (nth 1 new-ret)
'(keymap))))
- (if (not (keymapp (nth 1 (nth 1 new-ret))))
- (push (nth 1 new-ret) l1) ;; Not a composed keymap.
- (setq k-l (nth 1 new-ret)) ;; Composed keymap.
- ;; Decompose keymaps.
- (pop k-l)
- (setq l1 (append k-l l1))))
- (when (and (nth 2 new-ret) (not (equal (nth 2 new-ret)
'(keymap))))
- (if (not (keymapp (nth 1 (nth 2 new-ret))))
- (push (nth 2 new-ret) l2) ;; Not a composed keymap.
- (setq k-l (nth 2 new-ret)) ;; Composed keymap.
- ;; Decompose keymaps.
- (pop k-l)
- (setq l2 (append k-l l2))))
- (when (nth 3 new-ret)
- (setq l3 (append l3 (nth 3 new-ret))))
- (when (and (nth 4 new-ret) (not (equal (nth 4 new-ret)
'(keymap))))
- (if (not (keymapp (nth 1 (nth 4 new-ret))))
- (push (nth 4 new-ret) l4) ;; Not a composed keymap.
- (setq k-l (nth 4 new-ret)) ;; Composed keymap.
- ;; Decompose keymaps.
- (pop k-l)
- (setq l4 (append k-l l4))))
- (when (nth 5 new-ret)
- (setq l5 (append l5 (nth 5 new-ret))))
- (when (nth 6 new-ret)
- (setq l6 (append l6 (nth 6 new-ret))))
- (when (nth 7 new-ret)
- (setq l7 (append l7 (nth 7 new-ret))))))
- (reverse component))
- (setq ret
- (list
- (make-composed-keymap l0)
- (make-composed-keymap l1)
- (make-composed-keymap l2)
- l3
- (make-composed-keymap l4)
- l5 l6 l7)))
- (let (fixed-shortcut
- fixed-read
- fixed-shortcut-list
- unbind
- variable-shortcut
- variable-read
- fixed variable
- fixed-rm variable-rm
- rm-lst
- key-list
- (ergoemacs-ignore-advice t)
- (case-fold-search t)
- key
- trans-key input-keys
- cmd cmd-tmp
- emulation-setup
- vars
- (version (or version (ergoemacs-theme-get-version)))
- (shortcut-list '())
- (true-component (replace-regexp-in-string ":\\(fixed\\|variable\\)"
""
- (or (and (stringp
component) component)
- (symbol-name
component))))
- (only-variable (string-match ":variable" (or (and (stringp
component) component)
- (symbol-name
component))))
- (only-fixed (string-match ":fixed" (or (and (stringp component)
component)
- (symbol-name component)))))
- (when (string-match "::\\([0-9.]+\\)$" true-component)
- (setq version (match-string 1 true-component))
- (setq true-component (replace-match "" nil nil true-component)))
- (if (not version)
- (setq version "")
- (setq version (ergoemacs-theme-component-get-closest-version
- version
- (gethash (concat true-component ":version")
- ergoemacs-theme-component-hash))))
-
- (setq unbind (gethash (concat true-component version ":unbind")
ergoemacs-theme-component-cache))
- (setq emulation-setup (gethash (concat true-component ":emulation")
ergoemacs-theme-component-hash))
- (setq vars (gethash (concat true-component ":vars")
ergoemacs-theme-component-hash))
- (unless unbind
- (setq unbind (make-sparse-keymap))
- (mapc
- (lambda(x)
- (ergoemacs-theme-component--ignore-globally-defined-key
(read-kbd-macro x))
- (define-key unbind (read-kbd-macro x) 'ergoemacs-undefined))
- (gethash (concat true-component version ":redundant")
ergoemacs-theme-component-hash))
- (puthash (concat true-component version ":unbind") unbind
ergoemacs-theme-component-cache))
- (unless only-variable
- (setq fixed-shortcut (gethash (concat true-component version
":fixed:shortcut") ergoemacs-theme-component-cache)
- fixed-read (gethash (concat true-component version
":fixed:read") ergoemacs-theme-component-cache)
- fixed (gethash (concat true-component version ":fixed:map")
ergoemacs-theme-component-cache)
- fixed-rm (gethash (concat true-component version ":fixed-rm")
ergoemacs-theme-component-cache)
- fixed-shortcut-list (gethash (concat true-component version
- ":fixed:shortcut:list")
- ergoemacs-theme-component-cache))
- (unless (or fixed fixed-shortcut fixed-read fixed-shortcut-list)
- ;; Setup fixed fixed-keymap for this component.
- (setq key-list (gethash (concat true-component version ":fixed")
ergoemacs-theme-component-hash))
- (when key-list
- (setq fixed-shortcut (make-sparse-keymap))
- (setq fixed (make-sparse-keymap))
- (setq fixed-read (make-sparse-keymap))
- (mapc
- (lambda(x)
- (when (and (eq 'string (type-of (nth 0 x))))
- (setq trans-key (ergoemacs-get-kbd-translation (nth 0 x)))
- (setq key (read-kbd-macro trans-key))
- (when (string-match "^\\([^ ]+\\) " (nth 0 x))
- (add-to-list 'input-keys (match-string 1 (nth 0 x))))
- (ergoemacs-theme-component--ignore-globally-defined-key key)
- (setq cmd (nth 1 x))
- (ergoemacs-theme-component--define-key-in-keymaps fixed
fixed-shortcut key cmd)))
- (reverse key-list))
- (when input-keys
- (mapc
- (lambda(key)
- (unless (member key ergoemacs-ignored-prefixes)
- (ergoemacs-theme-component--ignore-globally-defined-key
(read-kbd-macro key))
- (define-key fixed-read (read-kbd-macro key)
- `(lambda()
- (interactive)
- (ergoemacs-read-key ,key 'normal)))))
- (reverse input-keys)))
- (setq fixed-shortcut-list shortcut-list)
- (setq input-keys '())
- (setq shortcut-list '())
- (puthash (concat true-component version ":fixed:shortcut")
fixed-shortcut
- ergoemacs-theme-component-cache)
- (puthash (concat true-component version ":fixed:read") fixed-read
- ergoemacs-theme-component-cache)
- (puthash (concat true-component version ":fixed:map") fixed
- ergoemacs-theme-component-cache)
- (puthash (concat true-component version ":fixed:shortcut:list")
- fixed-shortcut-list ergoemacs-theme-component-cache))))
-
- (unless only-fixed
- (setq variable-shortcut (gethash (concat true-component ":"
ergoemacs-keyboard-layout version ":variable:shortcut")
ergoemacs-theme-component-cache)
- variable-read (gethash (concat true-component ":"
ergoemacs-keyboard-layout version ":variable:read")
ergoemacs-theme-component-cache)
- variable (gethash (concat true-component ":"
ergoemacs-keyboard-layout version ":variable:map")
ergoemacs-theme-component-cache)
- variable-rm (gethash (concat true-component ":"
ergoemacs-keyboard-layout version ":variable-rm")
ergoemacs-theme-component-cache)
- variable-shortcut-list (gethash (concat true-component ":"
ergoemacs-keyboard-layout version ":variable:shortcut:list")
ergoemacs-theme-component-cache))
- (unless (or variable variable-shortcut variable-read
variable-shortcut-list)
- (setq variable-rm
- (mapcar
- (lambda(x)
- (ergoemacs-kbd (nth 0 x) nil (nth 1 x)))
- (gethash (concat true-component version ":variable-rm")
ergoemacs-theme-component-hash)))
- ;; Setup variable variable-keymap for this component.
- (setq key-list (gethash (concat true-component version ":variable")
ergoemacs-theme-component-hash))
- (when key-list
- (setq variable-shortcut (make-sparse-keymap))
- (setq variable (make-sparse-keymap))
- (setq variable-read (make-sparse-keymap))
- (mapc
- (lambda(x)
- (when (and (eq 'string (type-of (nth 0 x))))
- (setq key (ergoemacs-kbd (nth 0 x) nil (nth 3 x)))
- (when (string-match "^\\([^ ]+\\) " (nth 0 x))
- (add-to-list 'input-keys (match-string 1 (nth 0 x))))
- (setq cmd (nth 1 x))
- (ergoemacs-theme-component--define-key-in-keymaps variable
variable-shortcut key cmd)))
- (reverse key-list))
- (when input-keys
- (mapc
- (lambda(key)
- (unless (member key ergoemacs-ignored-prefixes)
- (define-key variable-read (read-kbd-macro key)
- `(lambda()
- (interactive)
- (ergoemacs-read-key ,key 'normal)))))
- (reverse input-keys)))
- (setq variable-shortcut-list shortcut-list
- input-keys '())
- (setq shortcut-list '())
- (puthash (concat true-component ":" ergoemacs-keyboard-layout
version ":variable:shortcut") variable-shortcut
- ergoemacs-theme-component-cache)
- (puthash (concat true-component ":" ergoemacs-keyboard-layout
version ":variable:read") variable-read
- ergoemacs-theme-component-cache)
- (puthash (concat true-component ":" ergoemacs-keyboard-layout
version ":variable:map") variable
- ergoemacs-theme-component-cache)
- (puthash (concat true-component ":" ergoemacs-keyboard-layout
version ":variable-rm") variable-rm ergoemacs-theme-component-cache)
- (puthash (concat true-component ":" ergoemacs-keyboard-layout
version ":variable:shortcut:list") variable-shortcut-list
- ergoemacs-theme-component-cache))))
- (mapc
- (lambda(var)
- (when (equal (symbol-value var) '(keymap))
- (set var nil)))
- '(fixed-read
- fixed-shortcut
- fixed
- variable-read
- variable-shortcut
- variable
- unbind))
- (cond
- ((and variable-rm fixed-rm)
- (setq rm-lst (append variable-rm fixed-rm)))
- (variable-rm
- (setq rm-lst variable-rm))
- (fixed-rm
- (setq rm-lst fixed-rm)))
- (cond
- (only-fixed
- (list fixed-read fixed-shortcut fixed fixed-shortcut-list nil rm-lst
emulation-setup vars))
- (only-variable
- (list variable-read variable-shortcut variable variable-shortcut-list
nil rm-lst emulation-setup vars))
- (t
- (list (or (and variable-read fixed-read
- (make-composed-keymap (if
ergoemacs-prefer-variable-keybindings
- (list variable-read
fixed-read)
- (list fixed-read
variable-read))))
- variable-read fixed-read)
- (or (and variable-shortcut fixed-shortcut
- (make-composed-keymap (if
ergoemacs-prefer-variable-keybindings
- (list variable-shortcut
fixed-shortcut)
- (list fixed-shortcut
variable-shortcut))))
- variable-shortcut fixed-shortcut)
- (or (and variable fixed
- (make-composed-keymap (if
ergoemacs-prefer-variable-keybindings
- (list variable fixed)
- (list fixed variable))))
- variable fixed)
- (if ergoemacs-prefer-variable-keybindings
- (append variable-shortcut-list fixed-shortcut-list)
- (append fixed-shortcut-list variable-shortcut-list))
- unbind rm-lst emulation-setup vars))))))
-
-
-(defvar ergoemacs-theme-hook-installed '()
- "Installed hooks")
-(defun ergoemacs-theme-hook (hook)
- "Run `ergoemacs-mode' HOOK."
- (let (deactivate-mark
- ;; Emulation variable for map.
- (emulation-var (if (not (string-match "mode$" (symbol-name hook)))
- (intern (concat "ergoemacs--emulation-for-"
(symbol-name hook)))
- hook))
- (all-always-p t)
- x)
- (unless (string-match "mode$" (symbol-name hook))
- (unless (boundp hook)
- (set-default hook nil)
- (set hook nil))
- (when (boundp emulation-var)
- (set (make-local-variable emulation-var) t)))
- (unless (member hook ergoemacs-theme-hook-installed)
- (mapc
- (lambda(x)
- (let ((map-name (nth 0 x))
- (always-modify-p (nth 1 x))
- (replace (nth 2 x)))
- (cond
- ((or (and (eq hook map-name)
- (string-match "mode$" (symbol-name map-name))
- (not (member (list hook map-name)
- ergoemacs-theme-hook-installed)))
- (and (eq map-name 't)
- (not (member (list hook t)
ergoemacs-theme-hook-installed))))
- (unless (boundp emulation-var)
- (set-default emulation-var nil)
- (set (make-local-variable emulation-var) t))
- (ergoemacs-add-emulation emulation-var replace)
- (if always-modify-p
- (setq all-always-p nil)
- (push (list hook map-name) ergoemacs-theme-hook-installed)))
- ((not (member (list hook map-name) ergoemacs-theme-hook-installed))
- (unless (string-match "mode$" (symbol-name map-name))
- (set map-name (copy-keymap replace)))
- (if always-modify-p
- (setq all-always-p nil)
- (push (list hook map-name) ergoemacs-theme-hook-installed))))))
- (ergoemacs-theme-keymaps-for-hook hook ergoemacs-theme))
- (unless all-always-p
- (push hook ergoemacs-theme-hook-installed)))))
-
-(defun ergoemacs-theme-component-make-hooks (component &optional remove-p)
- "Make ergoemacs-mode hooks for COMPONENT.
-COMPONENT may also be a list of components.
-
-When REMOVE-P, remove the created ergoemacs-mode hook functions
-from the appropriate startup hooks. Otherwise the hooks are
-added to the appropriate startup hooks.
-"
- (if (eq (type-of component) 'cons)
- (mapc
- (lambda(c)
- (ergoemacs-theme-component-make-hooks c remove-p))
- component)
- (let ((true-component (replace-regexp-in-string
":\\(fixed\\|variable\\|:[0-9.]+\\)" ""
- (or (and (stringp
component) component)
- (symbol-name
component)))))
- (mapc
- (lambda(hook)
- (when (string-match "hook\\'" (symbol-name hook))
- (fset (intern (concat "ergoemacs-for-" (symbol-name hook)))
- `(lambda ()
- ,(format "Run `ergoemacs-theme-hook' for `%s'"
- (symbol-name hook))
- (ergoemacs-theme-hook ',hook)))
- (funcall (if remove-p #'remove-hook #'add-hook) hook
- (intern (concat "ergoemacs-for-" (symbol-name hook))))))
- (gethash (concat true-component ":minor-list")
- ergoemacs-theme-component-hash)))))
-
-(defun ergoemacs--theme-component (plist body)
- (let ((name (plist-get plist ':name))
- (desc (or (plist-get plist ':description) ""))
- (layout (or (plist-get plist ':layout) "us"))
- (ergoemacs-variable-reg (or (plist-get plist ':variable-reg)
- (concat "\\(?:^\\|<\\)" (regexp-opt '("M-"
"<apps>" "<menu>")))))
- (ergoemacs-just-first-reg (or (plist-get plist ':first-is-variable-reg)
- nil))
- (versions '())
- (component-version nil)
- (ergoemacs-component-version-variable-layout nil)
- (ergoemacs-component-version-variable-layout-rm nil)
- (ergoemacs-component-version-fixed-layout nil)
- (ergoemacs-component-version-fixed-layout-rm nil)
- (ergoemacs-component-version-redundant-keys nil)
- (ergoemacs-component-version-minor-mode-layout nil)
- (ergoemacs-component-version-curr nil)
- (ergoemacs-component-version-list '())
- (defined-keys '())
- (variable-layout '())
- (variable-layout-rm '())
- (fixed-layout '())
- (fixed-layout-rm '())
- (defined-commands '())
- (minor-mode-layout '())
- (minor-mode-hook-list '())
- (emulation-setup '())
- (redundant-keys '())
- (ergoemacs-translation-from ergoemacs-translation-from)
- (ergoemacs-translation-to ergoemacs-translation-to)
- (ergoemacs-shifted-assoc ergoemacs-shifted-assoc)
- (ergoemacs-needs-translation ergoemacs-needs-translation)
- (ergoemacs-translation-assoc ergoemacs-translation-assoc)
- (ergoemacs-translation-regexp ergoemacs-translation-regexp)
- (case-fold-search nil)
- (ergoemacs-theme-save-variables '()))
- (when (ad-is-advised 'define-key)
- ;; FIXME:
- ;; - AFAICT, this advice is never re-enabled.
- ;; - ad-disable-advice only marks the advice as disabled, but doesn't
- ;; actually disable it yet (we'd need to deactivate+reactivate the
- ;; advice for that).
- (ad-disable-advice 'define-key 'around 'ergoemacs-define-key-advice))
- (ergoemacs-setup-translation "us" layout) ; Make sure keys are
- ; stored in QWERTY
- ; notation.
- (funcall body)
- ;; Finalize version setup
- (when ergoemacs-component-version-curr
- (push (list ergoemacs-component-version-curr
- ergoemacs-component-version-fixed-layout
- ergoemacs-component-version-variable-layout
- ergoemacs-component-version-redundant-keys
- ergoemacs-component-version-minor-mode-layout
- ergoemacs-component-version-fixed-layout-rm
- ergoemacs-component-version-variable-layout-rm)
- ergoemacs-component-version-list))
- (puthash (concat name ":plist") plist ergoemacs-theme-component-hash)
- (puthash (concat name ":fixed") fixed-layout
ergoemacs-theme-component-hash)
- (puthash (concat name ":fixed-rm") fixed-layout-rm
ergoemacs-theme-component-hash)
- (puthash (concat name ":variable") variable-layout
ergoemacs-theme-component-hash)
- (puthash (concat name ":variable-rm") variable-layout-rm
ergoemacs-theme-component-hash)
- (puthash (concat name ":version") versions ergoemacs-theme-component-hash)
- (puthash (concat name ":redundant") redundant-keys
ergoemacs-theme-component-hash)
- (puthash (concat name ":minor") minor-mode-layout
ergoemacs-theme-component-hash)
- (puthash (concat name ":minor-list") minor-mode-hook-list
ergoemacs-theme-component-hash)
- (puthash (concat name ":emulation") emulation-setup
ergoemacs-theme-component-hash)
- (puthash (concat name ":vars") ergoemacs-theme-save-variables
ergoemacs-theme-component-hash)
- (mapc
- (lambda(x)
- (let ((ver (nth 0 x))
- (fixed (nth 1 x))
- (var (nth 2 x))
- (red (nth 3 x))
- (fixed-rm (nth 4 x))
- (var-rm (nth 5 x)))
- (puthash (concat name "::" ver ":fixed") fixed
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":variable") var
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":redundant") var
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":fixed-rm") fixed-rm
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":variable-rm") var-rm
ergoemacs-theme-component-hash)))
- ergoemacs-component-version-list)))
-
-(defmacro ergoemacs-theme-component (&rest body-and-plist)
- "A component of an ergoemacs-theme."
- (declare (doc-string 2)
- (indent 2))
- (let ((kb (make-symbol "body-and-plist")))
- (setq kb (ergoemacs--parse-keys-and-body body-and-plist))
- `(let ((name ,(plist-get (nth 0 kb) ':name))
- (desc ,(or (plist-get (nth 0 kb) ':description) ""))
- (layout ,(or (plist-get (nth 0 kb) ':layout) "us"))
- (ergoemacs-variable-reg ,(or (plist-get (nth 0 kb) ':variable-reg)
- (concat "\\(?:^\\|<\\)" (regexp-opt
'("M-" "<apps>" "<menu>")))))
- (ergoemacs-just-first-reg ,(or (plist-get (nth 0 kb)
':first-is-variable-reg)
- nil))
- (versions '())
- (component-version nil)
- (ergoemacs-component-version-variable-layout nil)
- (ergoemacs-component-version-variable-layout-rm nil)
- (ergoemacs-component-version-fixed-layout nil)
- (ergoemacs-component-version-fixed-layout-rm nil)
- (ergoemacs-component-version-redundant-keys nil)
- (ergoemacs-component-version-minor-mode-layout nil)
- (ergoemacs-component-version-curr nil)
- (ergoemacs-component-version-list '())
- (defined-keys '())
- (variable-layout '())
- (variable-layout-rm '())
- (fixed-layout '())
- (fixed-layout-rm '())
- (defined-commands '())
- (minor-mode-layout '())
- (minor-mode-hook-list '())
- (emulation-setup '())
- (redundant-keys '())
- (ergoemacs-translation-from ergoemacs-translation-from)
- (ergoemacs-translation-to ergoemacs-translation-to)
- (ergoemacs-shifted-assoc ergoemacs-shifted-assoc)
- (ergoemacs-needs-translation ergoemacs-needs-translation)
- (ergoemacs-translation-assoc ergoemacs-translation-assoc)
- (ergoemacs-translation-regexp ergoemacs-translation-regexp)
- (case-fold-search nil)
- (ergoemacs-theme-save-variables '()))
- (when (ad-is-advised 'define-key)
- (ad-disable-advice 'define-key 'around 'ergoemacs-define-key-advice))
- (ergoemacs-setup-translation "us" layout) ; Make sure keys are
- ; stored in QWERTY
- ; notation.
- ,@(nth 1 kb)
- ;; Finalize version setup
- (when ergoemacs-component-version-curr
- (push (list ergoemacs-component-version-curr
- ergoemacs-component-version-fixed-layout
- ergoemacs-component-version-variable-layout
- ergoemacs-component-version-redundant-keys
- ergoemacs-component-version-minor-mode-layout
- ergoemacs-component-version-fixed-layout-rm
- ergoemacs-component-version-variable-layout-rm)
- ergoemacs-component-version-list))
- (puthash (concat name ":plist") ',(nth 0 kb)
ergoemacs-theme-component-hash)
- (puthash (concat name ":fixed") fixed-layout
ergoemacs-theme-component-hash)
- (puthash (concat name ":fixed-rm") fixed-layout-rm
ergoemacs-theme-component-hash)
- (puthash (concat name ":variable") variable-layout
ergoemacs-theme-component-hash)
- (puthash (concat name ":variable-rm") variable-layout-rm
ergoemacs-theme-component-hash)
- (puthash (concat name ":version") versions
ergoemacs-theme-component-hash)
- (puthash (concat name ":redundant") redundant-keys
ergoemacs-theme-component-hash)
- (puthash (concat name ":minor") minor-mode-layout
ergoemacs-theme-component-hash)
- (puthash (concat name ":minor-list") minor-mode-hook-list
ergoemacs-theme-component-hash)
- (puthash (concat name ":emulation") emulation-setup
ergoemacs-theme-component-hash)
- (puthash (concat name ":vars") ergoemacs-theme-save-variables
ergoemacs-theme-component-hash)
- (mapc
- (lambda(x)
- (let ((ver (nth 0 x))
- (fixed (nth 1 x))
- (var (nth 2 x))
- (red (nth 3 x))
- (fixed-rm (nth 4 x))
- (var-rm (nth 5 x)))
- (puthash (concat name "::" ver ":fixed") fixed
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":variable") var
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":redundant") var
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":fixed-rm") fixed-rm
ergoemacs-theme-component-hash)
- (puthash (concat name "::" ver ":variable-rm") var-rm
ergoemacs-theme-component-hash)))
- ergoemacs-component-version-list))))
-;;; Theme functions
-
-(defun ergoemacs-theme-set-version (version)
- "Sets the current themes default VERSION"
- (let (found)
- (setq ergoemacs-theme-version
- (mapcar
- (lambda(elt)
- (if (not (equal ergoemacs-theme (nth 0 elt)))
- elt
- (setq found t)
- (list ergoemacs-theme version)))
- ergoemacs-theme-version))
- (unless found
- (push (list ergoemacs-theme version) ergoemacs-theme-version))))
-
-(defun ergoemacs-theme-get-version ()
- "Gets the current version for the current theme"
- (let ((theme-ver (assoc ergoemacs-theme ergoemacs-theme-version)))
- (if (not theme-ver) nil
- (car (cdr theme-ver)))))
-
+
+;; FIXME
(defun ergoemacs-theme-versions (theme)
"Get a list of versions for the current theme."
(let ((theme-plist (gethash (if (stringp theme) theme
@@ -3117,6 +1803,26 @@ added to the appropriate startup hooks.
(setq versions (sort versions 'string<))
versions))
+(defun ergoemacs-theme-set-version (version)
+ "Sets the current themes default VERSION"
+ (let (found)
+ (setq ergoemacs-theme-version
+ (mapcar
+ (lambda(elt)
+ (if (not (equal ergoemacs-theme (nth 0 elt)))
+ elt
+ (setq found t)
+ (list ergoemacs-theme version)))
+ ergoemacs-theme-version))
+ (unless found
+ (push (list ergoemacs-theme version) ergoemacs-theme-version))))
+
+(defun ergoemacs-theme-get-version ()
+ "Gets the current version for the current theme"
+ (let ((theme-ver (assoc ergoemacs-theme ergoemacs-theme-version)))
+ (if (not theme-ver) nil
+ (car (cdr theme-ver)))))
+
(defun ergoemacs-theme-components (&optional theme)
"Get a list of components used for the current theme.
This respects `ergoemacs-theme-options'."
@@ -3146,100 +1852,6 @@ This respects `ergoemacs-theme-options'."
(setq components (reverse components))
components))
-(defun ergoemacs-theme-make-hooks (theme &optional remove-p)
- "Creates hooks for THEME.
-
-When REMOVE-P, remove the created ergoemacs-mode hook functions
-from the appropriate startup hooks. Otherwise the hooks are
-added to the appropriate startup hooks.
-"
- (ergoemacs-theme-component-make-hooks (ergoemacs-theme-components theme)
remove-p))
-
-(defun ergoemacs-theme-keymaps-for-hook (hook theme &optional version)
- "Gets the keymaps for the HOOK specific to the THEME and VERSION specified.
-
-The return value is an alist of keymaps needed for this hook.
-The format is:
-
- ((map-name always-modify-p keymap-replacement))
-
-map-name is the map name that will be modified
-always-modify-p is a flag that will modify the keymap every time the hook is
run.
-keymaps-stub is the keymap overrides that will be installed.
-
-When map-name is t, it is for a keymap put in
-`ergoemacs-emulation-mode-map-alist'
-
-Uses `ergoemacs-theme-component-keymaps-for-hook' and
-`ergoemacs-theme-components'"
- ;;
- (let ((theme-components (ergoemacs-theme-components theme))
- overall-keymaps)
- (setq overall-keymaps (ergoemacs-theme-keymaps theme version))
- ;; 0:read-keymap 1:shortcut-keymap 2:keymap 3:shortcut-list
4:unbind-keymap.
-
- (mapcar
- (lambda(c)
- (if (or (eq (nth 0 c) 't)
- (and (string-match "mode$" (symbol-name (nth 0 c)))
- (eq (nth 0 c) hook)))
- (progn
- (list (nth 0 c) (nth 1 c) (nth 2 c)))
- (let ((map-name (nth 0 c))
- (always-modify-p (nth 1 c))
- (base-keymap (nth 2 c))
- (full-keymap-p (nth 3 c))
- (shortcut-map (make-sparse-keymap)) tmp
- orig-map
- final-map)
- (setq orig-map (gethash (concat (symbol-name map-name) (symbol-name
hook) ":original-map") ergoemacs-theme-component-cache))
- (unless orig-map
- (when (boundp map-name)
- (unwind-protect
- (setq orig-map (copy-keymap (symbol-value map-name)))))
- (when orig-map
- (puthash (concat (symbol-name map-name) (symbol-name hook)
":original-map") orig-map ergoemacs-theme-component-cache)))
- (if (not orig-map)
- (setq orig-map (make-sparse-keymap))
- (setq orig-map (copy-keymap orig-map))
- (ergoemacs-theme--install-shortcuts-list
- (nth 3 overall-keymaps) shortcut-map
- orig-map full-keymap-p))
-
- (if (and (keymapp (nth 1 base-keymap))
- (eq 'keymap (nth 0 base-keymap)))
- (pop base-keymap)
- (setq base-keymap (list base-keymap)))
- (if (not full-keymap-p)
- (setq final-map (make-composed-keymap
- (if (not (and (eq 'keymap (nth 0 shortcut-map))
- (keymapp (nth 1 shortcut-map))))
- (append base-keymap (list shortcut-map))
- (pop shortcut-map)
- (append base-keymap shortcut-map)) orig-map))
- (setq base-keymap
- (if (not (and (eq 'keymap (nth 0 shortcut-map))
- (keymapp (nth 1 shortcut-map))))
- (append base-keymap (list shortcut-map))
- (pop shortcut-map)
- (append base-keymap shortcut-map)))
- (when (nth 0 overall-keymaps)
- (setq base-keymap (append (nth 0 overall-keymaps) base-keymap)))
- ;; Set parent to original keymap and compose read-keymap.
- (when (= (length base-keymap) 1)
- ;; ((keymap)) to (keymap)
- (setq base-keymap (nth 0 base-keymap)))
- (setq final-map (make-composed-keymap base-keymap orig-map)))
- (when (and (= 2 (length final-map))
- (eq (nth 0 final-map) 'keymap)
- (keymapp (nth 1 final-map)))
- ;; Take care of (keymap (keymap ...))
- (setq final-map (nth 1 final-map)))
- (when full-keymap-p ; Don't install shortcuts up.
- (define-key final-map '[ergoemacs] 'ignore))
- (list map-name always-modify-p final-map))))
- (ergoemacs-theme-component-keymaps-for-hook hook theme-components
version))))
-
;;;###autoload
(defun ergoemacs-theme-option-off (option)
"Turns OPTION off.
@@ -3368,8 +1980,9 @@ If OFF is non-nil, turn off the options instead."
(mapc
(lambda(option)
(when (memq option (append options-on options-off))
- (setq plist2 (gethash (concat (symbol-name option) ":plist")
ergoemacs-theme-component-hash))
- (setq desc (plist-get plist2 ':description))
+ ;; (setq plist2 (gethash (concat (symbol-name option)
":plist") ergoemacs-theme-component-hash))
+ ;; (setq desc (plist-get plist2 ':description))
+ (setq desc (oref (ergoemacs-theme-get-component (symbol-name
option)) description))
(push option menu-options)
(push
`(,option
@@ -3393,9 +2006,8 @@ If OFF is non-nil, turn off the options instead."
(mapc
(lambda(option)
(unless (member option menu-options)
- (let ((plist2 (gethash (concat (symbol-name option) ":plist")
ergoemacs-theme-component-hash))
- desc)
- (setq desc (plist-get plist2 ':description))
+ (let (;; (plist2 (gethash (concat (symbol-name option) ":plist")
ergoemacs-theme-component-hash))
+ (desc (oref (ergoemacs-theme-get-component (symbol-name
option)) description)))
(push desc options-list)
(push (list desc option) options-alist))))
(append options-on options-off))
@@ -3457,7 +2069,7 @@ If OFF is non-nil, turn off the options instead."
:button (:radio . (string= ergoemacs-theme ,theme))))
(sort (ergoemacs-get-themes) 'string<))))
,(ergoemacs-keymap-menu-theme-options theme)
- ,(ergoemacs-keymap-menu-theme-version theme)
+ ;; ,(ergoemacs-keymap-menu-theme-version theme)
(ergoemacs-c-x-sep "--")
(ergoemacs-c-x-c-c
menu-item "Ctrl+C and Ctrl+X behavior"
@@ -3556,6 +2168,7 @@ If OFF is non-nil, turn off the options instead."
(lambda() (interactive) (ergoemacs-mode -1)))))
(defvar ergoemacs-get-variable-layout nil)
+;; FIXME:
(defun ergoemacs-get-variable-layout ()
"Get the old-style variable layout list for `ergoemacs-extras'."
(let ((ret '()))
@@ -3582,6 +2195,7 @@ If OFF is non-nil, turn off the options instead."
(setq ergoemacs-get-variable-layout ret)
'ergoemacs-get-variable-layout))
+;; FIXME:
(defvar ergoemacs-get-fixed-layout nil)
(defun ergoemacs-get-fixed-layout ()
"Get the old-style fixed layout list for `ergoemacs-extras'."
@@ -3609,73 +2223,6 @@ If OFF is non-nil, turn off the options instead."
(setq ergoemacs-get-fixed-layout ret)
'ergoemacs-get-fixed-layout))
-(defun ergoemacs-theme-keymaps (theme &optional version)
- "Gets the keymaps for THEME for VERSION.
-Returns list of: read-keymap shortcut-keymap keymap shortcut-list
unbind-keymap rm-keys emulation-setup vars.
-Uses `ergoemacs-theme-component-keymaps' and `ergoemacs-theme-components'"
- (let* ((ret (ergoemacs-theme-component-keymaps (ergoemacs-theme-components
theme) version))
- (menu-keymap (make-sparse-keymap))
- (ergoemacs-ignore-advice t)
- prior keys)
- (push (pop ret) prior)
- (push (pop ret) prior)
- (setq prior (reverse prior))
- (setq keys (pop ret))
- (define-key menu-keymap [menu-bar ergoemacs-mode]
- `("ErgoEmacs" . ,(ergoemacs-keymap-menu theme)))
- (pop keys)
- (push menu-keymap keys)
- (push 'keymap keys)
- (setq ret`(,@prior ,keys ,@ret))
- ret))
-
-(defun ergoemacs-theme-restore-maps (&optional no-message)
- "Restore original keymaps.
-When NO-MESSAGE is true, don't tell the user."
- (mapc
- (lambda(x)
- (when (eq 'cons (type-of x))
- (let ((hook (nth 0 x))
- (map-name (nth 1 x))
- orig-map)
- (unless (string-match "-mode$" (symbol-name map-name))
- (unless (eq map-name 't)
- (setq orig-map
- (gethash (concat (symbol-name map-name) (symbol-name hook)
":original-map") ergoemacs-theme-component-cache))
- (when orig-map
- (unless no-message
- (message "Restoring %s" map-name))
- (set map-name (copy-keymap orig-map))))))))
- ergoemacs-theme-hook-installed))
-
-
-
-(defun ergoemacs-theme-remove (&optional no-message)
- "Remove the currently installed theme and reset to emacs keys.
-When NO-MESSAGE is true, don't tell the user."
- (ergoemacs-theme-make-hooks ergoemacs-theme 'remove-hooks)
- (ergoemacs-emulations 'remove)
- ;;; Restore maps
- (ergoemacs-theme-restore-maps no-message)
- (setq ergoemacs-command-shortcuts-hash (make-hash-table :test 'equal)
- ergoemacs-original-keys-to-shortcut-keys-regexp ""
- ergoemacs-original-keys-to-shortcut-keys (make-hash-table :test 'equal)
- ergoemacs-extract-map-hash (make-hash-table :test 'equal)
- ;; ergoemacs-shortcut-function-binding-hash (make-hash-table :test
'equal)
- ergoemacs-emulation-mode-map-alist '()
- ergoemacs-shortcut-keys nil
- ergoemacs-modal nil
- ergoemacs-repeat-keys nil
- ergoemacs-read-input-keys nil
- ergoemacs-theme-hook-installed '())
- (let ((x (assq 'ergoemacs-mode minor-mode-map-alist)))
- ;; Remove keymap
- (when x
- (setq minor-mode-map-alist (delq x minor-mode-map-alist)))
- (setq x (assq 'ergoemacs-unbind-keys minor-mode-map-alist))
- (when x
- (setq minor-mode-map-alist (delq x minor-mode-map-alist)))))
-
(defun ergoemacs-rm-key (keymap key)
"Removes KEY from KEYMAP even if it is an ergoemacs composed keymap.
Also add global overrides from the current global map, if necessary.
@@ -3705,153 +2252,7 @@ Returns new keymap."
(define-key new-keymap key nil)
new-keymap)))))
-(defvar ergoemacs-theme-hook nil)
-(defun ergoemacs-theme-remove-key-list (list &optional no-message dont-install)
- "Removes shortcuts keys in LIST from:
-- `ergoemacs-read-input-keymap'
-- `ergoemacs-shortcut-keymap'
-- `ergoemacs-keymap'
-- `ergoemacs-unbind-keymap'
-
-This also:
-- Restores all changed keymaps with `ergoemacs-theme-restore-maps'
-- Blanks out ergoemacs-mode changes by resetting
`ergoemacs-emulation-mode-map-alist'
-- Reapplies maps to either `minor-mode-map-alist' or
`ergoemacs-emulation-mode-map-alist'
-- Set-up persistent remaps defined in `ergoemacs-theme-mode-based-remaps'
-- Sets up read-key maps by running `ergoemacs-theme-hook'.
-
-"
- (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.
- (let (tmp)
- (dolist (c ergoemacs-theme-shortcut-reset-list)
- (puthash (nth 0 c) (nth 1 c) ergoemacs-command-shortcuts-hash)
- (when (eq (nth 1 (nth 1 c)) 'global)
- (dolist (global-key (ergoemacs-shortcut-function-binding (nth 0 (nth
1 c))))
- (if (not (gethash global-key
ergoemacs-original-keys-to-shortcut-keys))
- (puthash global-key (append (gethash global-key
ergoemacs-original-keys-to-shortcut-keys) (list (nth 0 c)))
ergoemacs-original-keys-to-shortcut-keys)
- (push (key-description global-key) tmp)
- (puthash global-key (list (nth 0 c))
ergoemacs-original-keys-to-shortcut-keys)))))
- (setq ergoemacs-original-keys-to-shortcut-keys-regexp
- (regexp-opt tmp t)))
- (setq ergoemacs-emulation-mode-map-alist '())
- ;; Install persistent 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
- (setq minor-mode-map-alist (delq x minor-mode-map-alist)))
- (push (cons 'ergoemacs-mode ergoemacs-keymap) minor-mode-map-alist))
-
- ;; `ergoemacs-unbind-keys' at the bottom in `minor-mode-map-alist'
- (let ((x (assq 'ergoemacs-unbind-keys minor-mode-map-alist)))
- (when x
- (setq minor-mode-map-alist (delq x minor-mode-map-alist)))
- ;; Put at the END of the list.
- (setq minor-mode-map-alist
- (append minor-mode-map-alist
- (list (cons 'ergoemacs-unbind-keys
ergoemacs-unbind-keymap)))))
-
- ;; `ergoemacs-read-input-keymap', then `ergoemacs-shortcut-keymap'
- ;; in `ergoemacs-emulation-mode-map-alist'
- (ergoemacs-add-emulation)
- (add-hook 'emulation-mode-map-alists
'ergoemacs-modal-emulation-mode-map-alist)
- (add-hook 'emulation-mode-map-alists
'ergoemacs-repeat-emulation-mode-map-alist)
- (add-hook 'emulation-mode-map-alists
'ergoemacs-read-emulation-mode-map-alist)
- (add-hook 'emulation-mode-map-alists 'ergoemacs-emulation-mode-map-alist)
- (ergoemacs-theme-make-hooks ergoemacs-theme)
- (set-default 'ergoemacs-mode t)
- (set-default 'ergoemacs-shortcut-keys t)
- (set-default 'ergoemacs-read-input-keys t)
- (set-default 'ergoemacs-unbind-keys t)
- (setq ergoemacs-mode t
- ergoemacs-shortcut-keys t
- ergoemacs-read-input-keys t
- ergoemacs-unbind-keys t)
- (unwind-protect
- (run-hooks 'ergoemacs-theme-hook))))
-
-(defvar ergoemacs-theme-mode-based-remaps nil)
-(defvar ergoemacs-theme-shortcut-reset-list nil)
-(defvar ergoemacs-theme-save-variables-actual nil)
-(defvar ergoemacs-theme-save-variables-state nil)
-(defun ergoemacs-theme-apply-variables (var-list)
- "Apply the themes' modes and variables, defined in VAR-LIST"
- (unless ergoemacs-theme-save-variables-state
- (setq ergoemacs-theme-save-variables-actual var-list)
- (setq ergoemacs-theme-save-variables-actual
- (mapcar
- (lambda(x)
- (let (val val2)
- (if (condition-case err (or (= 1 (nth 1 x)) (= -1 (nth 1 x)))
(error nil))
- (progn
- (funcall (nth 0 x) (nth 1 x))
- (setq val (if (= (nth 1 x) 1) -1 1)))
- (set (nth 0 x) (nth 1 x))
- (set-default (nth 0 x) (nth 1 x))
- (if (not (nth 2 x))
- (setq val (not (nth 1 x)))
- (setq val (nth 2 x))
- (setq val2 (nth 1 x))))
- `(,(nth 0 x) ,val ,val2)))
- ergoemacs-theme-save-variables-actual))
- (setq ergoemacs-theme-save-variables-state t)))
-
-(defun ergoemacs-theme-revert-variables ()
- "Revert the theme's variables/modes"
- (when ergoemacs-theme-save-variables-state
- (setq ergoemacs-theme-save-variables-actual
- (mapcar
- (lambda(x)
- (let (val val2)
- (if (condition-case err (or (= 1 (nth 1 x)) (= -1 (nth 1 x)))
(error nil))
- (progn
- (funcall (nth 0 x) (nth 1 x))
- (setq val (if (= 1 (nth 1 x)) -1 1)))
- (set (nth 0 x) (nth 1 x))
- (if (not (nth 2 x))
- (setq val (not (nth 1 x)))
- (setq val (nth 2 x))
- (setq val2 (nth 1 x)))
- (set-default (nth 0 x) (nth 1 x)))
- `(,(nth 0 x) ,val ,val2)))
- ergoemacs-theme-save-variables-actual))
- (setq ergoemacs-theme-save-variables-actual nil
- ergoemacs-theme-save-variables-state nil)))
(defvar ergoemacs-M-x "M-x ")
-(defun ergoemacs-theme-install (theme &optional version)
- "Installs `ergoemacs-theme' THEME into appropriate keymaps."
- (let ((tc (ergoemacs-theme-keymaps theme version)))
- (setq ergoemacs-read-input-keymap (nth 0 tc)
- ergoemacs-shortcut-keymap (nth 1 tc)
- ergoemacs-keymap (nth 2 tc)
- ergoemacs-theme-shortcut-reset-list (nth 3 tc)
- ergoemacs-unbind-keymap (nth 4 tc)
- ergoemacs-theme-mode-based-remaps (nth 6 tc)
- ergoemacs-theme (or (and (stringp theme) theme)
- (symbol-name theme)))
- (ergoemacs-theme-revert-variables)
- (ergoemacs-theme-apply-variables (nth 7 tc))
- ;; Remove unneeded shortcuts & setup `ergoemacs-mode'
- (ergoemacs-theme-remove-key-list
- (if (nth 5 tc)
- (append (nth 5 tc) ergoemacs-global-override-rm-keys)
- ergoemacs-global-override-rm-keys))))
(defvar ergoemacs-theme-hash (make-hash-table :test 'equal))
@@ -3886,7 +2287,7 @@ The rest of the body is an `ergoemacs-theme-component'
named THEME-NAME-theme
(indent 2))
(let ((kb (make-symbol "body-and-plist"))
(tmp (make-symbol "tmp")))
- (setq kb (ergoemacs--parse-keys-and-body body-and-plist))
+ (setq kb (ergoemacs-theme-component--parse-keys-and-body body-and-plist))
(setq tmp (eval (plist-get (nth 0 kb) ':components)))
(push (intern (concat (plist-get (nth 0 kb) ':name) "-theme")) tmp)
(setq tmp (plist-put (nth 0 kb) ':components tmp))
- [elpa] 97/287: First attempt for Cask without Cask (I'm on windows), (continued)
- [elpa] 97/287: First attempt for Cask without Cask (I'm on windows), Matthew Fidler, 2014/07/02
- [elpa] 116/287: Take out compiler warnings from ergoemacs-shortcuts.el, Matthew Fidler, 2014/07/02
- [elpa] 89/287: Fix most keybinding issues, Matthew Fidler, 2014/07/02
- [elpa] 113/287: No more warnings for ergoemacs-modal.el; mapc->dolist, Matthew Fidler, 2014/07/02
- [elpa] 132/287: Be more careful when redefining maps., Matthew Fidler, 2014/07/02
- [elpa] 129/287: Fix compiler warnings for ergoemacs-unbind.el, Matthew Fidler, 2014/07/02
- [elpa] 140/287: Fix Byte Compile Warnings, Matthew Fidler, 2014/07/02
- [elpa] 117/287: Take out compiler errors from ergoemacs-test, Matthew Fidler, 2014/07/02
- [elpa] 93/287: Add ergoemacs-shortcut-emulation-mode-map-alist, Matthew Fidler, 2014/07/02
- [elpa] 119/287: Fix byte-compile warnings for ergoemacs-macros.el, Matthew Fidler, 2014/07/02
- [elpa] 67/287: Completely use the object,
Matthew Fidler <=
- [elpa] 134/287: Finalize tests; Passes on windows, Matthew Fidler, 2014/07/02
- [elpa] 101/287: Fix Cask setup?, Matthew Fidler, 2014/07/02
- [elpa] 133/287: Remove byte compiled load warning, Matthew Fidler, 2014/07/02
- [elpa] 202/287: Allow hooks in themes; save settings on exit (Issue #234), Matthew Fidler, 2014/07/02