[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 57/287: Added basic variable/mode initialization routines.
From: |
Matthew Fidler |
Subject: |
[elpa] 57/287: Added basic variable/mode initialization routines. |
Date: |
Wed, 02 Jul 2014 14:44:35 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit 81419cc4983176e84c143fafbdc01ef43244cd87
Author: Matthew L. Fidler <address@hidden>
Date: Fri Jun 6 08:55:19 2014 -0500
Added basic variable/mode initialization routines.
---
ergoemacs-theme-engine.el | 62 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 52 insertions(+), 10 deletions(-)
diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el
index 5c41c01..580bf80 100644
--- a/ergoemacs-theme-engine.el
+++ b/ergoemacs-theme-engine.el
@@ -742,18 +742,12 @@ Assumes maps are orthogonal."
(init :initarg :init
:initform ()
:type list)
- (applied-init :initarg :applied-init
- :initform ()
- :type list)
(version :initarg :version ;; "" is default version
:initform ""
:type string)
(versions :initarg :versions
:initform ()
- :type list)
- (deferred-init :initarg :deferred-init
- :initform ()
- :type list))
+ :type list))
"`ergoemacs-mode' theme-component maps")
(defmethod ergoemacs-theme-component-maps--ini ((obj
ergoemacs-theme-component-maps))
@@ -889,12 +883,60 @@ ergoemacs-get-keymaps-for-hook OBJ HOOK")
(defmethod ergoemacs-get-keymaps-for-hook ((obj
ergoemacs-theme-component-map-list) hook &optional ret)
(ergoemacs-get-hooks obj (concat "\\`" (regexp-quote (symbol-name hook))
"\\'") ret t))
+(defmethod ergoemacs-get-inits ((obj ergoemacs-theme-component-map-list))
+ (let (ret '())
+ (with-slots (map-list) obj
+ (dolist (map map-list)
+ (setq ret (append ret (oref map init)))))
+ ret))
+
+(defvar ergoemacs-applied-inits '())
+(defmethod ergoemacs-apply-inits ((obj ergoemacs-theme-component-map-list))
+ (dolist (init (ergoemacs-apply-inits obj))
+ (let ((var (nth 0 init))
+ (fun (nth 1 init))
+ ret)
+ (cond
+ ((not (boundp var)) ;; Do nothing, not bound yet.
+ )
+ ((assq var ergoemacs-applied-inits)
+ ;; Already applied, Do nothing for now.
+ )
+ ((and (string-match-p "-mode$" (symbol-name var))
+ (ignore-errors (commandp var t)))
+ (push (list var (if (symbol-value var) 1 -1))
+ ergoemacs-applied-inits)
+ ;; Minor mode toggle...
+ (funcall var (funcall fun)) ;; (minor-mode deferred-arg))
+ (t
+ ;; Variable state change
+ (push (list var (symbol-value var))
+ ergoemacs-applied-inits)
+ (set var (funcall fun))))))))
+
+(defun ergoemacs-remove-inits ()
+ "Remove the applied initilizations of modes and variables.
+This assumes the variables are stored in `ergoemacs-applied-inits'"
+ (dolist (init ergoemacs-applied-inits)
+ (let ((var (nth 0 init))
+ (val (nth 1 init)))
+ (cond
+ ((and (string-match-p "-mode$" (symbol-name var))
+ (ignore-errors (commandp var t)))
+ (funcall var val))
+ (t
+ (set var val)))))
+ (setq ergoemacs-applied-inits '()))
+
(defmethod ergoemacs-debug-obj ((obj ergoemacs-theme-component-map-list))
(ergoemacs-debug-clear)
(let (tmp)
(with-slots (map-list object-name) obj
(ergoemacs-debug "* %s" object-name)
+ (ergoemacs-debug "** Variables and Modes")
+ (dolist (init (ergoemacs-get-inits obj))
+ (ergoemacs-debug "%s = %s" (nth 0 init) (nth 1 init)))
(ergoemacs-debug-obj (ergoemacs-get-fixed-map obj))
(ergoemacs-debug "*** Hooks")
(dolist (hook (ergoemacs-get-hooks obj))
@@ -1229,17 +1271,17 @@ When REMOVE-P is non-nil, remove hooks
`(ergoemacs-define-key 'global-map ,(nth 1 elt) nil))
((ignore-errors (eq (nth 0 elt) 'set))
;; Currently doesn't support (setq a b c d ), but it should.
- `(ergoemacs-set ,(nth 1 elt) ,(nth 2 elt)))
+ `(ergoemacs-set ,(nth 1 elt) '(lambda() ,(nth 2 elt))))
((ignore-errors (eq (nth 0 elt) 'setq))
(let ((tmp-elt elt)
(ret '()))
(pop tmp-elt)
(while (and (= 0 (mod (length tmp-elt) 2)) (< 0 (length
tmp-elt)))
- (push `(ergoemacs-set (quote ,(pop tmp-elt)) ,(pop
tmp-elt)) ret))
+ (push `(ergoemacs-set (quote ,(pop tmp-elt)) '(lambda()
,(pop tmp-elt))) ret))
(push 'progn ret)
ret))
((ignore-errors (string-match "-mode$" (symbol-name (nth 0
elt))))
- `(ergoemacs-set (quote ,(nth 0 elt)) ,(nth 1 elt)))
+ `(ergoemacs-set (quote ,(nth 0 elt)) '(lambda() ,(nth 1 elt))))
((ignore-errors (eq (nth 0 elt) 'global-set-key))
(if (ignore-errors (keymapp (symbol-value (nth 2 elt))))
`(ergoemacs-define-key 'global-map ,(nth 1 elt) (quote
,(nth 2 elt)))
- [elpa] 45/287: Fix ergoemacs-describe-key, (continued)
- [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
- [elpa] 52/287: Debugging ergoemacs-theme obect, Matthew Fidler, 2014/07/02
- [elpa] 51/287: more substitute-command-keys fixes, Matthew Fidler, 2014/07/02
- [elpa] 58/287: Fix misplaced paren, Matthew Fidler, 2014/07/02
- [elpa] 57/287: Added basic variable/mode initialization routines.,
Matthew Fidler <=
- [elpa] 54/287: Maps seem correct now, Matthew Fidler, 2014/07/02
- [elpa] 48/287: Unstage the incompatible, Matthew Fidler, 2014/07/02
- [elpa] 55/287: Nicer theme debugging display, Matthew Fidler, 2014/07/02
- [elpa] 56/287: Better key replacements., Matthew Fidler, 2014/07/02
- [elpa] 64/287: Replace either M-x or <execute> with M-x code., Matthew Fidler, 2014/07/02
- [elpa] 63/287: Fixed mapvar issues., Matthew Fidler, 2014/07/02
- [elpa] 47/287: Stage some components, Matthew Fidler, 2014/07/02
- [elpa] 62/287: Playing with object more., Matthew Fidler, 2014/07/02
- [elpa] 53/287: Better debug and modify keymaps fix bugs, Matthew Fidler, 2014/07/02
- [elpa] 59/287: Fix typo, Matthew Fidler, 2014/07/02