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

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

[elpa] 04/287: Revert "Stefan Monnier's Patch"


From: Matthew Fidler
Subject: [elpa] 04/287: Revert "Stefan Monnier's Patch"
Date: Wed, 02 Jul 2014 14:44:06 +0000

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

commit 4cfb38c22c6e4be3521678bc1b990b5765e9de54
Author: Matthew L. Fidler <address@hidden>
Date:   Fri May 23 17:59:45 2014 +0800

    Revert "Stefan Monnier's Patch"
    
    This reverts commit 8e95ab15132087ce163b3d8834a5d2b0d322140d.
    
    Conflicts:
    
        ergoemacs-advices.el
        ergoemacs-theme-engine.el
        ergoemacs-unbind.el
---
 .gitignore                |    2 -
 ergoemacs-advices.el      |   51 +++---
 ergoemacs-extras.el       |    6 +-
 ergoemacs-functions.el    |    6 +-
 ergoemacs-layouts.el      |    4 +-
 ergoemacs-menus.el        |    6 +-
 ergoemacs-modal.el        |    2 +-
 ergoemacs-mode.el         |   18 +-
 ergoemacs-shortcuts.el    |  183 ++++++++++++------
 ergoemacs-test.el         |    2 +-
 ergoemacs-theme-engine.el |  465 +++++++++++++++++++++++++++------------------
 ergoemacs-themes.el       |    6 -
 ergoemacs-track.el        |    8 +-
 ergoemacs-translate.el    |   33 ++--
 ergoemacs-unbind.el       |  163 +++++++++--------
 15 files changed, 558 insertions(+), 397 deletions(-)

diff --git a/.gitignore b/.gitignore
index a296883..9849c5e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,5 @@
 *~
 out/*
-*-autoloads.el
-*-pkg.el
 *.elc
 \#*\#
 .\#*
diff --git a/ergoemacs-advices.el b/ergoemacs-advices.el
index df0cf30..0db7dae 100644
--- a/ergoemacs-advices.el
+++ b/ergoemacs-advices.el
@@ -35,69 +35,72 @@
   "Ergoemacs directory.")
 (add-to-list 'load-path ergoemacs-dir)
 (require 'ergoemacs-shortcuts)
-(require 'ergoemacs-unbind)
-
-(defvar ergoemacs-advices '()
-  "List of advices to enable and disable when ergoemacs is running.")
-
-(defvar ergoemacs-run-mode-hooks ())
 
 (defmacro ergoemacs-define-overrides (&rest body)
   "Force the define-keys to work"
   `(let ((ergoemacs-run-mode-hooks t))
      ,@body))
 
-(defadvice add-hook (around ergoemacs-add-hook-advice (hook function &optional 
append  local) activate)
+(defadvice add-hook (around ergoemacs-add-hook-advice (hook function &optional 
append  local))
   "Advice to allow `this-command' to be set correctly before running 
`pre-command-hook'
 If `pre-command-hook' is used and `ergoemacs-mode' is enabled add to 
`ergoemacs-pre-command-hook' instead."
   (cond
+<<<<<<< HEAD
    ((and (boundp 'ergoemacs-mode)
          ergoemacs-mode (eq hook 'pre-command-hook)
          (boundp 'ergoemacs-hook-functions)
+=======
+   ((and ergoemacs-mode (eq hook 'pre-command-hook)
+>>>>>>> parent of 8e95ab1... Stefan Monnier's Patch
          (memq hook ergoemacs-hook-functions))
     (add-hook 'ergoemacs-pre-command-hook function append local))
    (t
     ad-do-it)))
+(ad-activate 'add-hook)
 
-(defadvice remove-hook (around ergoemacs-remove-hook-advice (hook function 
&optional local) activate)
+(defadvice remove-hook (around ergoemacs-remove-hook-advice (hook function 
&optional local))
   "Advice to allow `this-command' to be set correctly before running 
`pre-command-hook'.
 If `pre-command-hook' is used and `ergoemacs-mode' is remove from 
`ergoemacs-pre-command-hook' instead."
   (cond
+<<<<<<< HEAD
    ((and (boundp 'ergoemacs-mode)
          ergoemacs-mode (eq hook 'pre-command-hook)
          (boundp 'ergoemacs-hook-functions)
+=======
+   ((and ergoemacs-mode (eq hook 'pre-command-hook)
+>>>>>>> parent of 8e95ab1... Stefan Monnier's Patch
          (memq hook ergoemacs-hook-functions))
     (remove-hook 'ergoemacs-pre-command-hook function local))
    (t
     ad-do-it)))
+(ad-activate 'remove-hook)
 
-(defadvice define-key (around ergoemacs-define-key-advice (keymap key def) 
activate)
+(defadvice define-key (around ergoemacs-define-key-advice (keymap key def))
   "This does the right thing when modifying `ergoemacs-keymap'.
 Also adds keymap-flag for user-defined keys run with `run-mode-hooks'."
-  (let ((is-global-p (eq keymap (current-global-map))))
-    (if (and ergoemacs-run-mode-hooks
-             (not is-global-p)
-             (not (and (boundp 'ergoemacs-keymap)
-                       (eq keymap ergoemacs-keymap))))
+  (let ((is-global-p (equal keymap (current-global-map))))
+    (if (and (boundp 'ergoemacs-run-mode-hooks) ergoemacs-run-mode-hooks
+             (not (equal keymap (current-global-map)))
+             (not (equal keymap ergoemacs-keymap)))
         (let ((ergoemacs-run-mode-hooks nil)
               (new-key (read-kbd-macro
                         (format "<ergoemacs-user> %s"
                                 (key-description key)))))
-          (define-key keymap new-key def)))
+          (unwind-protect
+              (define-key keymap new-key def))))
     ad-do-it
     (when is-global-p
       (let ((vk key))
-        (ergoemacs-global-set-key-after key)
+        (ergoemacs-global-set-key-after key def)
         (unless (vectorp vk) ;; Do vector def too.
           (setq vk (read-kbd-macro (key-description key) t))
-          (ergoemacs-global-set-key-after vk))))))
+          (ergoemacs-global-set-key-after vk def))))))
+(ad-activate 'define-key)
 
 (defvar ergoemacs-global-override-rm-keys '())
-
-(defvar no-ergoemacs-advice nil)
 ;;; Advices enabled or disabled with ergoemacs-mode
-(defun ergoemacs-global-set-key-after (key)
-  (if no-ergoemacs-advice nil
+(defun ergoemacs-global-set-key-after (key command)
+  (if (and (boundp 'no-ergoemacs-advice) no-ergoemacs-advice) nil
     (unless (or (and (vectorp key)
                      (memq (elt key 0) '(menu-bar 27 remap)))
                 (and (not (vectorp key))
@@ -222,16 +225,18 @@ This require `ergoemacs-mode' to be enabled as well as
     (ad-activate 'helm-ff-auto-expand-to-home-or-root)))
 
 
-(defadvice run-mode-hooks (around ergoemacs-run-hooks activate)
+(defadvice run-mode-hooks (around ergoemacs-run-hooks)
   "`ergoemacs-mode' run-hooks advice helps user define keys properly.
 This assumes any key defined while running a hook is a user-defined hook."
   (let ((ergoemacs-run-mode-hooks t))
     ad-do-it))
+(ad-activate 'run-mode-hooks)
 
-(defadvice turn-on-undo-tree-mode (around ergoemacs-undo-tree-mode activate)
+(defadvice turn-on-undo-tree-mode (around ergoemacs-undo-tree-mode)
   "Make `ergoemacs-mode' and undo-tree compatible."
   (ergoemacs-with-global
    ad-do-it))
+(ad-activate 'turn-on-undo-tree-mode)
 
 
 (defcustom ergoemacs-check-new-buffer-auto-mode 't
diff --git a/ergoemacs-extras.el b/ergoemacs-extras.el
index 05d4ccb..3201702 100644
--- a/ergoemacs-extras.el
+++ b/ergoemacs-extras.el
@@ -587,7 +587,7 @@ function change_layout() {
       (while (re-search-forward "\\<C-" nil t)
         (replace-match (if swap-option-and-control "~" "^") nil t))
       (setq ret (buffer-string)))
-    ret))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-gen-mac-osx (layout &optional file-name extra 
swap-opiton-and-control)
   "Generates an Autohotkey Script for Ergoemacs Keybindings.
@@ -1104,7 +1104,7 @@ Files are generated in the dir 〔ergoemacs-extras〕 at 
`user-emacs-directory'.
       (goto-char (point-min))
       (while (re-search-forward ">\\(AA\\)<" nil t)
         (replace-match "><" t)))
-    ret))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-keyfreq-calc-ergo (x list var-layout cmd-n total-n)
   "Calculate keyfreq based on ergoemacs positions."
@@ -1637,7 +1637,7 @@ IS-PREFIX tell ergoemacs if this is a prefix diagram."
       (message "Generated!"))
     (when (called-interactively-p 'interactive)
       (browse-url (concat "file://" file)))
-    file))
+    (symbol-value 'file)))
 
 ;;;###autoload
 (defun ergoemacs-svgs (&optional layouts)
diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el
index e535ff9..bfc63ed 100644
--- a/ergoemacs-functions.el
+++ b/ergoemacs-functions.el
@@ -239,7 +239,7 @@ C-u C=u deletes old byte compilde `ergoemacs-mode' files."
         (emacs-dir (invocation-directory))
         (full-exe (concat "\"" (expand-file-name emacs-exe emacs-dir)
                           "\"")))
-    full-exe))
+    (symbol-value 'full-exe)))
 
 (defun ergoemacs-cheat-sheet-file ()
   "Cheet sheet file for ergoemacs."
@@ -252,7 +252,7 @@ C-u C=u deletes old byte compilde `ergoemacs-mode' files."
     (setq extra-dir (expand-file-name (concat "ergoemacs-layout-" 
ergoemacs-keyboard-layout ".svg")))
     (when (not (file-exists-p extra-dir))
       (ergoemacs-gen-svg ergoemacs-theme "kbd-ergo.svg" (concat var-dir 
"ergo-layouts")))
-    extra-dir))
+    (symbol-value 'extra-dir)))
 
 (defun ergoemacs-open-line ()
   "Inserts an indented newline after the current line and moves the point to 
it."
@@ -1886,7 +1886,7 @@ With a prefix, force regeneration. "
             (browse-url-of-file file)
           (error
            (ergoemacs-open-in-external-app file)))))
-    file))
+    (symbol-value 'file)))
 
 ;;; Unaccent region taken and modified from Drew Adam's unaccent.el
 
diff --git a/ergoemacs-layouts.el b/ergoemacs-layouts.el
index 45d91ce..d4440c4 100644
--- a/ergoemacs-layouts.el
+++ b/ergoemacs-layouts.el
@@ -363,10 +363,10 @@
   "Get the list of all known layouts."
   (if (and ergoemacs-get-layouts-no-aliases
            (not aliases))
-      ergoemacs-get-layouts-no-aliases
+      (symbol-value 'ergoemacs-get-layouts-no-aliases)
     (if (and ergoemacs-get-layouts-aliases
              aliases)
-        ergoemacs-get-layouts-aliases
+        (symbol-value 'ergoemacs-get-layouts-aliases)
       (let (ret)
         (mapatoms
          (lambda(s)
diff --git a/ergoemacs-menus.el b/ergoemacs-menus.el
index 08e3ded..c85c792 100644
--- a/ergoemacs-menus.el
+++ b/ergoemacs-menus.el
@@ -134,7 +134,7 @@ Tries to get the value from `ergoemacs-mode-names'.  If not 
guess the language n
       (setq ret (car (cdr ret))))
     (setq ret (concat (upcase (substring ret 0 1))
                       (substring ret 1)))
-    ret))
+    (symbol-value 'ret)))
 
 ;; `Languages'  
 (defun ergoemacs-get-major-modes ()
@@ -683,9 +683,9 @@ All other modes are assumed to be minor modes or 
unimportant.
                            (:toggle and
                                     (boundp 'speedbar-frame)
                                     (frame-live-p
-                                     speedbar-frame)
+                                     (symbol-value 'speedbar-frame))
                                     (frame-visible-p
-                                     speedbar-frame))
+                                     (symbol-value 'speedbar-frame)))
                            :keys "")
         ;; (datetime-separator)
         ;; (showhide-date-time)
diff --git a/ergoemacs-modal.el b/ergoemacs-modal.el
index 978145a..d39ab50 100644
--- a/ergoemacs-modal.el
+++ b/ergoemacs-modal.el
@@ -246,7 +246,7 @@ If so return the hash of translation values."
              (lookup-key ergoemacs-modal-ignored-keymap
                          (or ergoemacs-single-command-keys 
(this-single-command-keys))))
         (setq ret nil)))
-      ret)))
+      (symbol-value 'ret))))
 
 (defun ergoemacs-modal-default (&optional arg)
   "The default command for `ergoemacs-mode' modal.
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index e6ea3dd..31ec5d2 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -369,6 +369,9 @@ remove the keymap depends on user input and KEEP-PRED:
 
 ;; ErgoEmacs hooks
 
+(defvar ergoemacs-advices '()
+  "List of advices to enable and disable when ergoemacs is running.")
+
 (defun ergoemacs-setup-keys (&optional no-check)
   "Setups keys based on a particular layout. Based on 
`ergoemacs-keyboard-layout'."
   (interactive)
@@ -771,9 +774,7 @@ These hooks are deferred to make sure `this-command' is set 
appropriately.")
 
 (defun ergoemacs-populate-pre-command-hook (&optional depopulate)
   "Populate `ergoemacs-pre-command-hook' with `pre-command-hook' values."
-  (let ((from-hook (if depopulate 'ergoemacs-pre-command-hook
-                     'pre-command-hook))
-        do-append ergoemacs-mode)
+  (let (do-append ergoemacs-mode)
     (mapc
      (lambda(item)
        (if (eq item t)
@@ -783,11 +784,10 @@ These hooks are deferred to make sure `this-command' is 
set appropriately.")
            (remove-hook 'pre-command-hook item nil))
          (when depopulate
            (add-hook 'pre-command-hook item do-append nil)
-           (remove-hook 'ergoemacs-pre-command-hook item nil))))
-     (default-value from-hook))
-    ;; FIXME: This should be done in every buffer!
-    (unless (equal (default-value from-hook)
-                   (symbol-value from-hook))
+           (remove-hook 'ergoemacs-pre-command-hook item do-append))))
+     (default-value (if depopulate 'ergoemacs-pre-command-hook 
'pre-command-hook)))
+    (unless (equal (default-value (if depopulate 'ergoemacs-pre-command-hook 
'pre-command-hook))
+                   (symbol-value (if depopulate 'ergoemacs-pre-command-hook 
'pre-command-hook)))
       (setq do-append nil)
       (mapc
        (lambda(item)
@@ -799,7 +799,7 @@ These hooks are deferred to make sure `this-command' is set 
appropriately.")
            (when depopulate
              (add-hook 'pre-command-hook item do-append t)
              (remove-hook 'ergoemacs-pre-command-hook item t))))
-       (symbol-value from-hook)))))
+       (symbol-value (if depopulate 'ergoemacs-pre-command-hook 
'pre-command-hook))))))
 (defvar ergoemacs-smart-functions
   '(ergoemacs-shortcut
     ergoemacs-shortcut-movement-no-shift-select ergoemacs-shortcut-movement 
ergoemacs-read-key
diff --git a/ergoemacs-shortcuts.el b/ergoemacs-shortcuts.el
index 05b960e..15070da 100644
--- a/ergoemacs-shortcuts.el
+++ b/ergoemacs-shortcuts.el
@@ -50,8 +50,6 @@
 ;; 
 ;;; Code:
 (require 'guide-key nil t)
-(unless (fboundp 'ergoemacs-pretty-key)
-  (require 'ergoemacs-translate))
 
 (defmacro ergoemacs-with-ergoemacs (&rest body)
   "With basic `ergoemacs-mode' mode keys.
@@ -175,13 +173,13 @@ This sequence is compatible with `listify-key-sequence'."
   (let (input)
     (cond
      ((not key)) ;; Not specified.
-     ((vectorp key) ;; Actual key sequence
+     ((eq (type-of key) 'vector) ;; Actual key sequence
       (setq input (listify-key-sequence key)))
-     ((consp key) ;; Listified key sequence
+     ((eq (type-of key) 'cons) ;; Listified key sequence
       (setq input key))
-     ((stringp key) ;; Kbd code
+     ((eq (type-of key) 'string) ;; Kbd code
       (setq input (listify-key-sequence (read-kbd-macro key t)))))
-    input))
+    (symbol-value 'input)))
 
 (defun ergoemacs-universal-argument (&optional type)
   "Ergoemacs universal argument.
@@ -417,7 +415,7 @@ universal argument can be entered.
            ((eq current-prefix-arg '-)
             (setq current-prefix-arg nil)
             (setq ret nil))))))))
-    ret))
+    (symbol-value 'ret)))
 
 (defcustom ergoemacs-read-swaps
   '(((normal normal) unchorded)
@@ -506,7 +504,7 @@ It will replace anything defined by `ergoemacs-translation'"
          (setq next-key (plist-put next-key var-pretty pretty))
          (setq next-key (plist-put next-key var-s-pretty pretty))))
      ergoemacs-translations)
-    next-key))
+    (symbol-value 'next-key)))
 
 (defvar ergoemacs-alt-text
   (replace-regexp-in-string
@@ -533,7 +531,7 @@ It will replace anything defined by `ergoemacs-translation'"
     (setq pretty (plist-get next-key ':alt-pretty))
     (setq kbd (plist-get next-key ':alt))
     (setq next-key (ergoemacs-read-key-install-next-key next-key key pretty 
kbd))
-    next-key))
+    (symbol-value 'next-key)))
 
 (defun ergoemacs-read-key-next-key-is-ctl (&optional type pretty-key)
   "The next key read is an Ctrl+ key. (or C- )"
@@ -548,19 +546,22 @@ It will replace anything defined by 
`ergoemacs-translation'"
     (setq pretty (plist-get next-key ':ctl-pretty))
     (setq kbd (plist-get next-key ':ctl))
     (setq next-key (ergoemacs-read-key-install-next-key next-key key pretty 
kbd))
-    next-key))
+    (symbol-value 'next-key)))
 
 (defun ergoemacs-read-key-next-key-is-alt-ctl (&optional type pretty-key)
   "The next key read is an Alt+Ctrl+ key. (or C-M- )"
   (interactive)
-  (let* ((next-key
-          (ergoemacs-translate
-           (vector
-            (ergoemacs-read-event nil pretty-key ergoemacs-alt-ctl-text))))
-         (key (plist-get next-key ':alt-ctl-key))
-         (pretty (plist-get next-key ':alt-ctl-pretty))
-         (kbd (plist-get next-key ':alt-ctl)))
-    (ergoemacs-read-key-install-next-key next-key key pretty kbd)))
+  (let (next-key
+        key pretty kbd)
+    (setq next-key
+              (ergoemacs-translate
+               (vector
+                (ergoemacs-read-event nil pretty-key ergoemacs-alt-ctl-text))))
+    (setq key (plist-get next-key ':alt-ctl-key))
+    (setq pretty (plist-get next-key ':alt-ctl-pretty))
+    (setq kbd (plist-get next-key ':alt-ctl))
+    (setq next-key (ergoemacs-read-key-install-next-key next-key key pretty 
kbd))
+    (symbol-value'next-key)))
 
 (defun ergoemacs-read-key-next-key-is-quoted (&optional type pretty-key)
   "The next key read is quoted."
@@ -574,7 +575,7 @@ It will replace anything defined by `ergoemacs-translation'"
       (setq pretty (plist-get next-key ':normal-pretty))
       (setq kbd (plist-get next-key ':normal))
       (setq next-key (ergoemacs-read-key-install-next-key next-key key pretty 
kbd))
-      next-key)))
+      (symbol-value 'next-key))))
 
 (defun ergoemacs-read-key-help ()
   "Show help for the current sequence KEY."
@@ -625,15 +626,15 @@ It will replace anything defined by 
`ergoemacs-translation'"
 (defun ergoemacs-defer-post-command-hook ()
   "Defers `post-command-hook'."
   (set-default 'ergoemacs-defer-post-command-hook (default-value 
'post-command-hook))
-  (set (make-local-variable 'ergoemacs-defer-post-command-hook) 
post-command-hook)
+  (set (make-local-variable 'ergoemacs-defer-post-command-hook) (symbol-value 
'post-command-hook))
   (set (make-local-variable 'post-command-hook) nil)
   (set-default 'post-command-hook nil))
 
 (defun ergoemacs-restore-post-command-hook ()
   (when (or (default-value 'ergoemacs-defer-post-command-hook)
-            ergoemacs-defer-post-command-hook)
+            (symbol-value 'ergoemacs-defer-post-command-hook))
     (set-default 'post-command-hook (default-value 
'ergoemacs-defer-post-command-hook))
-    (set (make-local-variable 'post-command-hook) 
ergoemacs-defer-post-command-hook)
+    (set (make-local-variable 'post-command-hook) (symbol-value 
'ergoemacs-defer-post-command-hook))
     (set (make-local-variable 'ergoemacs-defer-post-command-hook) nil)
     (set-default 'ergoemacs-defer-post-command-hook nil)))
 
@@ -731,7 +732,7 @@ In addition, when the function is called:
       (setq tmp (intern (match-string 1 tmp)))
       (setq type tmp
             first-type tmp))
-    ret))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-read-key-lookup-get-ret (fn)
   "Get ret type for FN.
@@ -747,24 +748,7 @@ to the appropriate values for `ergoemacs-read-key'.
       (setq ret 'keymap))
     (when (memq fn ergoemacs-universal-fns)
       (setq ret (ergoemacs-read-key-lookup-get-ret---universal fn)))
-    ret))
-
-(defun ergoemacs--key-message (pretty-key dest)
-  (when (and ergoemacs-echo-function
-             (boundp 'pretty-key-undefined)
-             (not (or this-command-keys-shift-translated
-                      ergoemacs-shift-translated)))
-    (let (message-log-max)
-      (if (string= pretty-key-undefined pretty-key)
-          (when (eq ergoemacs-echo-function t)
-            (message "%s%s%s" pretty-key
-                     (ergoemacs-unicode-char "→" "->")
-                     dest))
-        (message "%s%s%s (from %s)"
-                 pretty-key
-                 (ergoemacs-unicode-char "→" "->")
-                 dest
-                 pretty-key-undefined)))))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-read-key-lookup (prior-key prior-pretty-key key pretty-key 
force-key)
   "Lookup KEY and run if necessary.
@@ -869,7 +853,21 @@ FORCE-KEY forces keys like <escape> to work properly.
                            (error nil))))
                   (setq fn (or (command-remapping fn (point)) fn))
                   (setq ergoemacs-single-command-keys key)
-                  (ergoemacs--key-message pretty-key fn)
+                  (when (and ergoemacs-echo-function
+                             (boundp 'pretty-key-undefined)
+                             (not (or this-command-keys-shift-translated
+                                      ergoemacs-shift-translated)))
+                    (let (message-log-max)
+                      (if (string= pretty-key-undefined pretty-key)
+                          (when (eq ergoemacs-echo-function t)
+                            (message "%s%s%s" pretty-key
+                                     (ergoemacs-unicode-char "→" "->")
+                                     (symbol-name fn)))
+                        (message "%s%s%s (from %s)"
+                                 pretty-key
+                                 (ergoemacs-unicode-char "→" "->")
+                                 (symbol-name fn)
+                                 pretty-key-undefined))))
                   (ergoemacs-read-key-call fn nil key)
                   (setq ergoemacs-single-command-keys nil)
                   (setq ret 'translate-fn))
@@ -882,8 +880,21 @@ FORCE-KEY forces keys like <escape> to work properly.
                   (setq unread-command-events (append (listify-key-sequence 
tmp) unread-command-events))
                   (ergoemacs-defer-post-command-hook)
                   (reset-this-command-lengths)
-                  (ergoemacs--key-message
-                   pretty-key (ergoemacs-pretty-key (key-description tmp)))
+                  (when (and ergoemacs-echo-function
+                             (boundp 'pretty-key-undefined)
+                             (not (or this-command-keys-shift-translated
+                                      ergoemacs-shift-translated)))
+                    (let (message-log-max)
+                      (if (string= pretty-key-undefined pretty-key)
+                          (when (eq ergoemacs-echo-function t)
+                            (message "%s%s%s" pretty-key
+                                     (ergoemacs-unicode-char "→" "->")
+                                     (ergoemacs-pretty-key (key-description 
tmp))))
+                        (message "%s%s%s (from %s)"
+                                 pretty-key
+                                 (ergoemacs-unicode-char "→" "->")
+                                 (ergoemacs-pretty-key (key-description tmp))
+                                 pretty-key-undefined))))
                   (when lookup
                     (define-key lookup [ergoemacs-single-command-keys] 'ignore)
                     (setq ergoemacs-read-key-overriding-terminal-local-save 
overriding-terminal-local-map)
@@ -937,18 +948,45 @@ FORCE-KEY forces keys like <escape> to work properly.
                          (condition-case err
                              (interactive-form (nth 0 hash))
                            (error nil)))
-                    (ergoemacs--key-message pretty-key (nth 0 hash))
+                    (when (and ergoemacs-echo-function
+                               (boundp 'pretty-key-undefined)
+                               (not (or this-command-keys-shift-translated
+                                        ergoemacs-shift-translated)))
+                      (let (message-log-max)
+                        (if (string= pretty-key-undefined pretty-key)
+                            (when (eq ergoemacs-echo-function t)
+                              (message "%s%s%s" pretty-key
+                                       (ergoemacs-unicode-char "→" "->")
+                                       (symbol-name (nth 0 hash))))
+                          (message "%s%s%s (from %s)"
+                                   pretty-key
+                                   (ergoemacs-unicode-char "→" "->")
+                                   (symbol-name (nth 0 hash))
+                                   pretty-key-undefined))))
                     (ergoemacs-shortcut-remap (nth 0 hash))
                     (setq ergoemacs-single-command-keys nil)
                     (setq ret 'function-remap))
                    ((and ergoemacs-shortcut-keys (not ergoemacs-describe-key)
                          (not ergoemacs-single-command-keys))
-                    (ergoemacs--key-message pretty-key
-                                            (or (nth 0 hash)
-                                                (let ((fn (key-binding key)))
-                                                  (or (command-remapping
-                                                       fn (point))
-                                                      fn))))
+                    (when (and ergoemacs-echo-function
+                               (boundp 'pretty-key-undefined)
+                               (not (or this-command-keys-shift-translated
+                                        ergoemacs-shift-translated)))
+                      (let (message-log-max)
+                        (if (nth 0 hash)
+                            (setq fn (nth 0 hash))
+                          (setq fn (key-binding key))
+                          (setq fn (or (command-remapping fn (point)) fn)))
+                        (if (string= pretty-key-undefined pretty-key)
+                            (when (eq ergoemacs-echo-function t)
+                              (message "%s%s%s;" pretty-key
+                                       (ergoemacs-unicode-char "→" "->")
+                                       fn))
+                          (message "%s%s%s (from %s);"
+                                   pretty-key
+                                   (ergoemacs-unicode-char "→" "->")
+                                   fn
+                                   pretty-key-undefined))))
                     ;; There is some issue with these keys.  Read-key
                     ;; thinks it is in a minibuffer, so the recursive 
                     ;; minibuffer error is raised unless these are put
@@ -974,7 +1012,21 @@ FORCE-KEY forces keys like <escape> to work properly.
                       (setq ret (ergoemacs-read-key-lookup-get-ret---universal 
fn)))
                     (unless ret
                       (setq ergoemacs-single-command-keys key)
-                      (ergoemacs--key-message pretty-key fn)
+                      (when (and ergoemacs-echo-function
+                                 (boundp 'pretty-key-undefined)
+                                 (not (or this-command-keys-shift-translated
+                                          ergoemacs-shift-translated)))
+                        (let (message-log-max)
+                          (if (string= pretty-key-undefined pretty-key)
+                              (when (eq ergoemacs-echo-function t)
+                                (message "%s%s%s" pretty-key
+                                         (ergoemacs-unicode-char "→" "->")
+                                         (symbol-name fn)))
+                            (message "%s%s%s (from %s)"
+                                     pretty-key
+                                     (ergoemacs-unicode-char "→" "->")
+                                     (symbol-name fn)
+                                     pretty-key-undefined))))
                       (ergoemacs-read-key-call fn nil key)
                       (setq ergoemacs-single-command-keys nil)
                       (setq ret 'function))))))
@@ -999,14 +1051,23 @@ FORCE-KEY forces keys like <escape> to work properly.
                 (unless ret
                   (setq fn (or (command-remapping fn (point)) fn))
                   (setq ergoemacs-single-command-keys key)
-                  (ergoemacs--key-message pretty-key fn)
+                  (let (message-log-max)
+                    (if (string= pretty-key-undefined pretty-key)
+                        (message "%s%s%s" pretty-key
+                                 (ergoemacs-unicode-char "→" "->")
+                                 fn)
+                      (message "%s%s%s (from %s)"
+                               pretty-key
+                               (ergoemacs-unicode-char "→" "->")
+                               fn
+                               pretty-key-undefined)))
                   (ergoemacs-read-key-call fn nil key)
                   (setq ergoemacs-single-command-keys nil)
                   (setq ret 'function-global-or-override)))))
           ;; Fix tempoary over
           (when (and tmp-overlay (not 
ergoemacs-read-key-overriding-overlay-save))
             (delete-overlay tmp-overlay)))
-        ret)
+        (symbol-value 'ret))
     ;; Turn off read-input-keys for shortcuts
     (when unread-command-events
       (when ergoemacs-modal
@@ -1031,7 +1092,7 @@ Otherwise add new translation to key-plist and return it."
       (setq key-plist (plist-put key-plist (intern new-trans) kd))
       (setq kd (ergoemacs-pretty-key kd))
       (setq key-plist (plist-put key-plist (intern (concat new-trans 
"-pretty")) kd)))
-    key-plist))
+    (symbol-value 'key-plist)))
 
 (defvar ergoemacs-shift-translated nil)
 (defvar ergoemacs-deactivate-mark nil)
@@ -1427,7 +1488,7 @@ DEF can be:
                (setq found
                      (ergoemacs-define-key keymap key new-def)))))
          def))
-      found))
+      (symbol-value 'found)))
    ((condition-case err
         (interactive-form def)
       (error nil))
@@ -1646,7 +1707,7 @@ This also considers archaic emacs bindings by looking at
 in effect)."
   (let ((ret (gethash (list function dont-ignore-menu) 
ergoemacs-shortcut-function-binding-hash)))
     (if ret
-        ret
+        (symbol-value 'ret)
       (setq ret (or
                  (if dont-ignore-menu
                      (where-is-internal function (current-global-map))
@@ -1656,7 +1717,7 @@ in effect)."
                     (where-is-internal function (current-global-map))))
                  (gethash function ergoemacs-where-is-global-hash)))
       (puthash (list function dont-ignore-menu) ret 
ergoemacs-shortcut-function-binding-hash)
-      ret)))
+      (symbol-value 'ret))))
 
 (defcustom ergoemacs-use-function-remapping t
   "Uses function remapping.
@@ -1787,7 +1848,7 @@ user-defined keys.
         (use-global-map old-global-map))
       (when ret2
         (setq ret (append ret2 ret)))
-      ret)))
+      (symbol-value 'ret))))
 
 (defun ergoemacs-shortcut-remap (function &optional keys)
   "Runs the FUNCTION or whatever `ergoemacs-shortcut-remap-list' returns.
@@ -1952,7 +2013,7 @@ Setup C-c and C-x keys to be described properly.")
             (overlay-put tmp-overlay 'priority 536870911))
           ;; (ergoemacs-debug-keymap 'override-text-map)
           ))))
-    tmp-overlay))
+    (symbol-value 'tmp-overlay)))
 
 (defun ergoemacs-install-shortcut-up--internal (text keymap &optional 
dont-complete)
   (let* ((keymap keymap)
@@ -2020,7 +2081,7 @@ Setup C-c and C-x keys to be described properly.")
                                    "")
                                  read-map)))
       (puthash hashkey read-map ergoemacs-extract-map-hash))
-    keymap))
+    (symbol-value 'keymap)))
 
 (defun ergoemacs-install-shortcuts-up ()
   "Installs ergoemacs shortcuts into overriding keymaps.
diff --git a/ergoemacs-test.el b/ergoemacs-test.el
index a570aee..55e1b90 100644
--- a/ergoemacs-test.el
+++ b/ergoemacs-test.el
@@ -211,7 +211,7 @@ sunt in culpa qui officia deserunt mollit anim id est 
laborum.")
     (when (file-exists-p w-file)
       (setq ret 't)
       (delete-file w-file))
-    ret))
+    (symbol-value 'ret)))
 
 (ert-deftest ergoemacs-test-global-key-set-before-1 ()
   "Test global set key before ergoemacs-mode loads."
diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el
index e5cb1d6..9e79181 100644
--- a/ergoemacs-theme-engine.el
+++ b/ergoemacs-theme-engine.el
@@ -51,9 +51,6 @@
 ;; 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
-(require 'ergoemacs-advices)
-
 (defgroup ergoemacs-themes nil
   "Default Ergoemacs Layout"
   :group 'ergoemacs-mode)
@@ -170,42 +167,15 @@
                  (list (sexp :tag "Command")
                        (string :tag "Short Name"))))
 ;; Dummy variables
-(defvar ergoemacs-component-version-curr nil)
-(defvar ergoemacs-component-version-list nil)
-(defvar ergoemacs-component-version-fixed-layout nil)
-(defvar ergoemacs-component-version-fixed-layout-rm nil)
-(defvar ergoemacs-component-version-redundant-keys nil)
-(defvar ergoemacs-component-version-minor-mode-layout nil)
-(defvar ergoemacs-component-version-variable-layout-rm nil)
-(defvar ergoemacs-component-version-variable-layout nil)
-
-(defvar ergoemacs-theme-save-variables '())
-
-(defvar skip-first)
-(defvar component-version)
-(defvar minor-mode-layout)
-(defvar fixed-layout) (defvar variable-layout)
-(defvar fixed-layout-rm) (defvar variable-layout-rm)
-(defvar redundant-keys) (defvar defined-keys)
-(defvar versions)
-
-(defvar ergoemacs-hook)
-(defvar ergoemacs-hook-modify-keymap)
-(defvar ergoemacs-hook-full-shortcut-map)
-(defvar ergoemacs-hook-always)
-
-(defun ergoemacs--with-hook (hook plist body)
-  (let ((ergoemacs-hook hook)
-        (ergoemacs-hook-modify-keymap
-         (or (plist-get plist ':modify-keymap)
-             (plist-get plist ':modify-map)))
-        (ergoemacs-hook-full-shortcut-map
-         (or (plist-get plist ':full-shortcut-keymap)
-             (plist-get plist ':full-shortcut-map)
-             (plist-get plist ':full-map)
-             (plist-get plist ':full-keymap)))
-        (ergoemacs-hook-always (plist-get plist ':always)))
-    (funcall body)))
+(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.
@@ -240,13 +210,12 @@ particular it:
     ;; Allow
     ;; (component name)
     (unless (or (keywordp (first remaining)) (boundp 'skip-first))
-      (push `(:name . ,(if (condition-case nil
-                               (stringp (first remaining))
-                             (error nil))
-                           (pop remaining)
-                         (symbol-name (pop remaining))))
-            extracted-key-accu)
-      (when (or (consp (first remaining)) (symbolp (first remaining)))
+      (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)))
@@ -270,43 +239,87 @@ particular it:
                (cond
                 (last-was-version
                  (setq last-was-version nil)
-                 `(when (boundp 'component-version)
-                    (setq component-version
-                          ,(if (stringp elt) elt (symbol-name elt)))))
-                ((eq elt ':version)
+                 (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)
-                ((eq (car-safe elt) 'global-reset-key)
+                ((condition-case err
+                     (eq (nth 0 elt) 'global-reset-key)
+                   (error nil))
                  `(ergoemacs-theme-component--global-reset-key ,(nth 1 elt)))
-                ((eq (car-safe elt) 'global-unset-key)
+                ((condition-case err
+                     (eq (nth 0 elt) 'global-unset-key)
+                   (error nil))
                  `(ergoemacs-theme-component--global-set-key ,(nth 1 elt) nil))
-                ((eq (car-safe elt) 'setq)
+                ((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)))
-                ((eq (car-safe elt) 'set)
+                ((condition-case err
+                     (eq (nth 0 elt) 'set)
+                   (error nil))
                  `(ergoemacs-theme-component--set (nth 1 elt) ,(nth 2 elt)))
-                ((condition-case nil
-                     (string-match "-mode\\'" (symbol-name (nth 0 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))
-                 `(ergoemacs-theme-component--mode ',(nth 0 elt) ,(nth 1 elt)))
-                ((eq (car-safe elt) 'global-set-key)
-                 `(ergoemacs-theme-component--global-set-key
-                   ,(nth 1 elt) ',(nth 2 elt)))
-                ((eq (car-safe elt) 'define-key)
                  (if (equal (nth 1 elt) '(current-global-map))
-                     `(ergoemacs-theme-component--global-set-key ,(nth 2 elt) 
',(nth 3 elt))
-                   `(ergoemacs-theme-component--define-key ',(nth 1 elt) ,(nth 
2 elt) ',(nth 3 elt))))
-                ((or (eq (car-safe elt) 'with-hook)
-                     (and (eq (car-safe elt) 'when)
-                          (condition-case nil
-                              (string-match "-\\(hook\\|mode\\)\\'"
-                                            (symbol-name (nth 1 elt)))
+                     (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* (skip-first
-                        (tmp (ergoemacs--parse-keys-and-body (cdr (cdr elt)))))
-                   `(ergoemacs--with-hook ',(nth 1 elt)
-                                          ',(nth 0 tmp)
-                                          (lambda () ,@(nth 1 tmp)))))
+                 (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
@@ -340,21 +353,17 @@ particular it:
     (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))
+      (setq ergoemacs-component-version-minor-mode-layout (symbol-value 
'ergoemacs-component-version-minor-mode-layout)))
     (unless ergoemacs-component-version-fixed-layout
-      (setq ergoemacs-component-version-fixed-layout fixed-layout))
+      (setq ergoemacs-component-version-fixed-layout (symbol-value 
'fixed-layout)))
     (unless ergoemacs-component-version-fixed-layout-rm
-      (setq ergoemacs-component-version-fixed-layout-rm fixed-layout-rm))
+      (setq ergoemacs-component-version-fixed-layout-rm (symbol-value 
'fixed-layout-rm)))
     (unless ergoemacs-component-version-fixed-layout
-      (setq ergoemacs-component-version-variable-layout variable-layout))
+      (setq ergoemacs-component-version-variable-layout (symbol-value 
'variable-layout)))
     (unless ergoemacs-component-version-fixed-layout-rm
-      (setq ergoemacs-component-version-variable-layout-rm variable-layout-rm))
+      (setq ergoemacs-component-version-variable-layout-rm (symbol-value 
'variable-layout-rm)))
     (unless ergoemacs-component-version-redundant-keys
-      (setq ergoemacs-component-version-redundant-keys redundant-keys))))
-
-(defvar ergoemacs-force-variable-reg)
-(defvar ergoemacs-variable-reg)
-(defvar ergoemacs-just-first-reg)
+      (setq ergoemacs-component-version-redundant-keys (symbol-value 
'redundant-keys)))))
 
 (defun ergoemacs-theme-component--rm-key (key)
   "Remove KEY from `ergoemacs-mode' keymaps"
@@ -405,7 +414,7 @@ will take out KEY from 
`ergoemacs-component-version-redundant-keys'"
 When fixed-layout and variable-layout are bound"
   (cond
    ((and (boundp 'ergoemacs-hook)
-         (string-match "mode\\'" (symbol-name 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)
@@ -434,15 +443,14 @@ When fixed-layout and variable-layout are bound"
       (if (not command)
           (mapc ;; Remove command from lists.
            (lambda(y)
-             (let ((tmp '()))
+             (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))
+           '(ergoemacs-component-version-fixed-layout 
ergoemacs-component-version-variable-layout))
         (if (not variable-p)
             (progn ;; Fixed Layout component
               (setq ergoemacs-component-version-fixed-layout
@@ -477,7 +485,7 @@ When fixed-layout and variable-layout are bound"
          (not component-version)
          (boundp 'redundant-keys) (boundp 'defined-keys))
     (let ((kd (key-description key)) cd jf)
-      (if (not command)                 ; redundant key
+      (if (not command) ; redundant key
           (push kd redundant-keys)
         (setq cd (assoc command ergoemacs-function-short-names)) ; Short key 
description
         (when cd
@@ -526,10 +534,10 @@ When fixed-layout and variable-layout are bound"
              a-key
              jf found-1-p found-2-p)
         (when (and (boundp 'emulation-setup) (boundp 'ergoemacs-hook)
-                   (string-match "mode\\'" (symbol-name ergoemacs-hook)))
-          (pushnew ergoemacs-hook emulation-setup :test #'eq))
+                   (string-match "mode$" (symbol-name ergoemacs-hook)))
+          (add-to-list 'emulation-setup ergoemacs-hook nil 'eq))
         (when (boundp 'minor-mode-hook-list)
-          (pushnew hook minor-mode-hook-list :test #'eq))
+          (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
@@ -556,22 +564,18 @@ When fixed-layout and variable-layout are bound"
           ;; 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))
+                                            (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))))
-                       (pushnew (if modify-keymap-p keymap
+                       (add-to-list 'lst (if modify-keymap-p keymap
                                            (or (and (boundp 'ergoemacs-hook)
-                                                    (string-match "mode\\'" 
(symbol-name ergoemacs-hook))
-                                                    ergoemacs-hook)
-                                               t))
-                                lst :test #'eq)
+                                                    (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)
@@ -595,13 +599,12 @@ When fixed-layout and variable-layout are bound"
           (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))
+                                              (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-component--ignore-globally-defined-key (key)
   "Adds KEY to `ergoemacs-global-override-rm-keys' and 
`ergoemacs-global-override-map' if globally redefined."
   (let ((no-ergoemacs-advice t)
@@ -612,7 +615,7 @@ When fixed-layout and variable-layout are bound"
         (when (and (ergoemacs-global-changed-p key)
                    (or (commandp lk t)
                        (keymapp lk)))
-          (pushnew key ergoemacs-global-override-rm-keys :test #'equal)
+          (add-to-list 'ergoemacs-global-override-rm-keys key)
           (throw 'found-global-command t))
         (setq key (substring key 0 (- (length key) 1)))))))
 
@@ -629,9 +632,9 @@ DEF can be:
 
 "
   (cond
-   ((consp def)
+   ((eq 'cons (type-of def))
     (let (found)
-      (if (condition-case nil
+      (if (condition-case err
               (stringp (nth 0 def))
             (error nil))
           (progn
@@ -644,15 +647,15 @@ DEF can be:
         (mapc
          (lambda(new-def)
            (unless found
-             (when (condition-case nil
+             (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 nil
+      (symbol-value 'found)))
+   ((condition-case err
         (interactive-form def)
       (error nil))
     (cond
@@ -679,22 +682,20 @@ DEF can be:
       (ergoemacs-theme-component--ignore-globally-defined-key key)
       (define-key keymap key def)))
     t)
-   ((condition-case nil
+   ((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 nil
+   ((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))
+                         (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
@@ -765,14 +766,14 @@ Formatted for use with `ergoemacs-theme-component-hash' 
it will return ::version
           (if best-version
               (setq ret (concat "::" best-version))
             (setq ret (concat "::" smallest-version))))
-        ret)
+        (symbol-value 'ret))
     ""))
 
 (defun ergoemacs-theme--install-shortcut-item (key args keymap lookup-keymap
                                                    full-shortcut-map-p)
   (let (fn-lst)
     (cond
-     ((condition-case nil
+     ((condition-case err
           (interactive-form (nth 0 args))
         (error nil))
       (setq fn-lst (ergoemacs-shortcut-remap-list
@@ -832,7 +833,7 @@ When map-name is t or ends in -mode, it is for a keymap put 
in
 
 This function does not finalize maps by installing them into the original maps.
 "
-  (if (consp component)
+  (if (eq (type-of component) 'cons)
       (let ((ret nil) ;; List of components.
             already-done-list
             (version version)
@@ -892,7 +893,7 @@ This function does not finalize maps by installing them 
into the original maps.
                     (push keymap-list ret)))
                 new-ret))))
          (reverse component))
-        ret)
+        (symbol-value 'ret))
     ;; Single component
     (let ((true-component (replace-regexp-in-string ":\\(fixed\\|variable\\)" 
""
                                                     (or (and (stringp 
component) component)
@@ -906,7 +907,7 @@ This function does not finalize maps by installing them 
into the original maps.
           (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)
+      (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)
@@ -952,8 +953,7 @@ This function does not finalize maps by installing them 
into the original maps.
                       (reverse keys))
                      (unless (equal map '(keymap))
                        (push `(,map-name ,always-p ,map
-                                         ,full-shortcut-map-p)
-                             fixed-maps)))))
+                                         ,full-shortcut-map-p) fixed-maps)))))
                keymap-list)
               (unless (equal fixed-maps '())
                 (puthash (concat true-component version ":" (symbol-name hook) 
":maps") fixed-maps
@@ -1036,14 +1036,14 @@ This function does not finalize maps by installing them 
into the original maps.
                    (push 'keymap composed-map)
                    (setq tmp `(,map-name ,(or (nth 1 keymap-list) (nth 1 
fixed-map))
                                          ,composed-map ,full-shortcut-map-p))
-                   tmp)))
+                   (symbol-value 'tmp))))
              variable-maps))
       (mapc
        (lambda(keymap-list)
          (unless (member (nth 0 keymap-list) already-done-list)
            (push keymap-list ret)))
        fixed-maps)
-      ret)))
+      (symbol-value 'ret))))
 
 (defun ergoemacs-theme-component-keymaps (component &optional version)
   "Gets the keymaps for COMPONENT for component VERSION.
@@ -1056,8 +1056,9 @@ components listed.
 
 Returns list of: read-keymap shortcut-keymap keymap shortcut-list 
unbind-keymap rm-keys emulation-setup vars.
 "
-  (if (consp component)
-      (let (k-l
+  (if (eq (type-of component) 'cons)
+      (let ((ret nil)
+            k-l
             (l0 '())
             (l1 '())
             (l2 '())
@@ -1106,13 +1107,14 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
              (when (nth 7 new-ret)
                (setq l7 (append l7 (nth 7 new-ret))))))
          (reverse component))
-        (list
-         (make-composed-keymap l0)
-         (make-composed-keymap l1)
-         (make-composed-keymap l2)
-         l3
-         (make-composed-keymap l4)
-         l5 l6 l7))
+        (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
@@ -1139,7 +1141,7 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
                                                        (symbol-name 
component))))
           (only-fixed (string-match ":fixed" (or (and (stringp component) 
component)
                                                  (symbol-name component)))))
-      (when (string-match "::\\([0-9.]+\\)\\'" true-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)
@@ -1177,12 +1179,11 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
             (setq fixed-read (make-sparse-keymap))
             (mapc
              (lambda(x)
-               (when (stringp (nth 0 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))
-                   (pushnew (match-string 1 (nth 0 x)) input-keys
-                            :test #'equal))
+                 (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)))
@@ -1229,11 +1230,10 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
             (setq variable-read (make-sparse-keymap))
             (mapc
              (lambda(x)
-               (when (stringp (nth 0 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))
-                   (pushnew (match-string 1 (nth 0 x)) input-keys
-                            :test #'equal))
+                 (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))
@@ -1258,16 +1258,17 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
             (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))))
-      (let* ((empty-map (make-sparse-keymap))
-             (f (lambda (m) (unless (equal m empty-map) m))))
-        ;; Turn empty maps into nil values.
-        (setq fixed-read        (funcall f fixed-read))
-        (setq fixed-shortcut    (funcall f fixed-shortcut))
-        (setq fixed             (funcall f fixed))
-        (setq variable-read     (funcall f variable-read))
-        (setq variable-shortcut (funcall f variable-shortcut))
-        (setq variable          (funcall f variable))
-        (setq unbind            (funcall f unbind)))
+      (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)))
@@ -1308,12 +1309,12 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
   "Run `ergoemacs-mode' HOOK."
   (let (deactivate-mark
         ;; Emulation variable for map.
-        (emulation-var (if (not (string-match "mode\\'" (symbol-name hook)))
+        (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 (string-match "mode$" (symbol-name hook))
       (unless (boundp hook)
         (set-default hook nil)
         (set hook nil))
@@ -1327,7 +1328,7 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
                (replace (nth 2 x)))
            (cond
             ((or (and (eq hook map-name)
-                      (string-match "mode\\'" (symbol-name map-name))
+                      (string-match "mode$" (symbol-name map-name))
                       (not (member (list hook map-name)
                                    ergoemacs-theme-hook-installed)))
                  (and (eq map-name 't)
@@ -1345,7 +1346,7 @@ Returns list of: read-keymap shortcut-keymap keymap 
shortcut-list unbind-keymap
                  (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))
+             (unless (string-match "mode$" (symbol-name map-name))
                (set map-name (copy-keymap replace)))
              (if always-modify-p
                  (setq all-always-p nil)
@@ -1362,15 +1363,17 @@ 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 (consp component)
-      (dolist (c component)
-        (ergoemacs-theme-component-make-hooks c remove-p))
-    (let ((true-component (replace-regexp-in-string
-                           ":\\(fixed\\|variable\\|:[0-9.]+\\)" ""
-                           (or (and (stringp component) component)
-                               (symbol-name component)))))
+  (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)
+<<<<<<< HEAD
          (when (string-match "hook\\'" (symbol-name hook))
            (fset (intern (concat "ergoemacs-for-" (symbol-name hook)))
                  `(lambda ()
@@ -1464,14 +1467,104 @@ added to the appropriate startup hooks.
         (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)))
+=======
+         (when (string-match "hook$" (symbol-name hook))
+           (eval (macroexpand
+                  `(defun ,(intern (concat "ergoemacs-for-" (symbol-name 
hook))) ()
+                     ,(format "Runs `ergoemacs-theme-hook' for `%s'" 
(symbol-name hook))
+                     (ergoemacs-theme-hook ',hook))))
+           (if remove-p
+               (eval
+                (macroexpand
+                 `(remove-hook ',hook ',(intern (concat "ergoemacs-for-" 
(symbol-name hook))))))
+             (eval
+              (macroexpand
+               `(add-hook ',hook ',(intern (concat "ergoemacs-for-" 
(symbol-name hook)))))))))
+       (gethash (concat true-component ":minor-list") 
ergoemacs-theme-component-hash)))))
+>>>>>>> parent of 8e95ab1... Stefan Monnier's Patch
 
 (defmacro ergoemacs-theme-component (&rest body-and-plist)
   "A component of an ergoemacs-theme."
   (declare (doc-string 2)
            (indent 2))
-  (let ((kb (ergoemacs--parse-keys-and-body body-and-plist)))
-    `(ergoemacs--theme-component ',(nth 0 kb) (lambda () ,@(nth 1 kb)))))
-
+  (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") (symbol-value 'fixed-layout) 
ergoemacs-theme-component-hash)
+       (puthash (concat name ":fixed-rm") (symbol-value 'fixed-layout-rm) 
ergoemacs-theme-component-hash)
+       (puthash (concat name ":variable") (symbol-value 'variable-layout) 
ergoemacs-theme-component-hash)
+       (puthash (concat name ":variable-rm") (symbol-value 
'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)
@@ -1508,18 +1601,18 @@ added to the appropriate startup hooks.
                (or (and (stringp component) component)
                    (symbol-name component))))
              vers)
-         (when (string-match "::\\([0-9.]+\\)\\'" true-component)
+         (when (string-match "::\\([0-9.]+\\)$" true-component)
            (setq true-component (replace-match "" nil nil true-component)))
          (mapc
           (lambda(ver)
-            (pushnew ver versions :test #'equal))
+            (add-to-list 'versions ver))
           (gethash (concat true-component ":version")
                    ergoemacs-theme-component-hash))))
      (append (plist-get theme-plist ':optional-off)
              (plist-get theme-plist ':optional-on)
              (plist-get theme-plist ':components)))
     (setq versions (sort versions 'string<))
-    versions))
+    (symbol-value 'versions)))
 
 (defun ergoemacs-theme-components (theme)
   "Get a list of components used for the current theme.
@@ -1547,7 +1640,7 @@ This respects `ergoemacs-theme-options'."
              (push x components)))))
      (reverse (plist-get theme-plist ':optional-off)))
     (setq components (reverse components))
-    components))
+    (symbol-value 'components)))
 
 (defun ergoemacs-theme-make-hooks (theme &optional remove-p)
   "Creates hooks for THEME.
@@ -1584,7 +1677,7 @@ Uses `ergoemacs-theme-component-keymaps-for-hook' and
     (mapcar
      (lambda(c)
        (if (or (eq (nth 0 c) 't)
-               (and (string-match "mode\\'" (symbol-name (nth 0 c)))
+               (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)))
@@ -1665,7 +1758,7 @@ and it dosen't show up on the ergoemacs-mode menu.
 TYPE can also be 'off, where the option will be included in the
 theme, but assumed to be disabled by default.
 "
-  (if (consp option)
+  (if (eq (type-of option) 'cons)
       (mapc
        (lambda(new-option)
          (let (ergoemacs-mode)
@@ -1697,7 +1790,7 @@ theme, but assumed to be disabled by default.
          (setq theme-plist (plist-put theme-plist ':optional-off off))
          (puthash (if (stringp theme) theme (symbol-name theme)) theme-plist
                   ergoemacs-theme-hash)))
-     (or (and theme (if (consp theme) theme (list theme)))
+     (or (and theme (or (and (eq (type-of theme) 'cons) theme) (list theme)))
          (ergoemacs-get-themes)))))
   (ergoemacs-theme-option-on option))
 
@@ -1706,7 +1799,7 @@ theme, but assumed to be disabled by default.
   "Turns OPTION on.
 When OPTION is a list turn on all the options in the list
 If OFF is non-nil, turn off the options instead."
-  (if (consp option)
+  (if (eq (type-of option) 'cons)
       (mapc
        (lambda(new-option)
          (let (ergoemacs-mode)
@@ -1907,7 +2000,7 @@ If OFF is non-nil, turn off the options instead."
        (lambda()
          (interactive)
          (set-default 'ergoemacs-smart-paste 'browse-kill-ring))
-       :enable (condition-case nil (interactive-form 'browse-kill-ring)
+       :enable (condition-case err (interactive-form 'browse-kill-ring)
                  (error nil))
        :button (:radio . (eq ergoemacs-smart-paste 'browse-kill-ring)))))
     (ergoemacs-sep-bash "--")
@@ -1935,7 +2028,7 @@ If OFF is non-nil, turn off the options instead."
              (ergoemacs-menus-on))
          (when (featurep 'ergoemacs-menus)
            (ergoemacs-menus-off))))
-     :button (:radio . ergoemacs-use-menus))
+     :button (:radio . (symbol-value 'ergoemacs-use-menus)))
     (ergoemacs-save
      menu-item "Save Settings for Future Sessions"
      (lambda ()
@@ -2030,18 +2123,18 @@ Uses `ergoemacs-theme-component-keymaps' and 
`ergoemacs-theme-components'"
     (push menu-keymap keys)
     (push 'keymap keys)
     (setq ret`(,@prior ,keys ,@ret))
-    ret))
+    (symbol-value '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 (consp 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 (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))
@@ -2100,10 +2193,10 @@ Returns new keymap."
                    map)
                  new-keymap))
           (push 'keymap new-keymap)
-          new-keymap)
+          (symbol-value 'new-keymap))
          (t
           (define-key new-keymap key nil)
-          new-keymap)))))
+          (symbol-value 'new-keymap))))))
 
 (defvar ergoemacs-theme-hook nil)
 (defun ergoemacs-theme-remove-key-list (list &optional no-message dont-install)
@@ -2194,7 +2287,7 @@ This also:
           (mapcar
            (lambda(x)
              (let (val val2)
-               (if (condition-case nil (or (= 1 (nth 1 x)) (= -1 (nth 1 x))) 
(error nil))
+               (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)))
@@ -2215,7 +2308,7 @@ This also:
           (mapcar
            (lambda(x)
              (let (val val2)
-               (if (condition-case nil (or (= 1 (nth 1 x)) (= -1 (nth 1 x))) 
(error nil))
+               (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)))
@@ -2332,7 +2425,7 @@ When SILENT is true, also include silent themes"
                     (append (gethash "defined-themes" ergoemacs-theme-hash)
                             (gethash "silent-themes" ergoemacs-theme-hash)))
                (gethash "defined-themes" ergoemacs-theme-hash))))
-    ret))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-get-themes-type (&optional silent)
   "Gets the customization types for `ergoemacs-theme'"
@@ -2377,8 +2470,8 @@ DIFFERENCES are the differences from the layout based on 
the functions.  These a
 `ergoemacs-fixed-key' = defines/replace fixed key with function by 
(ergoemacs-fixed-key KEY FUNCTION DESCRIPTION)
 "
   (declare (indent 1))
-  `(let ((pl (gethash (or ,based-on "standard") ergoemacs-theme-hash))
-        silent tmp)
+  `(let (silent pl tmp)
+     (setq pl (gethash (or ,based-on "standard") ergoemacs-theme-hash))
      (plist-put pl ':name ,(symbol-name name))
      (setq tmp (eval (plist-get pl ':components)))
      (push (intern (concat ,(symbol-name name) "-theme")) tmp)
diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index 8e363ec..6aa6224 100644
--- a/ergoemacs-themes.el
+++ b/ergoemacs-themes.el
@@ -36,12 +36,6 @@
 (require 'advice)
 (require 'ergoemacs-theme-engine)
 
-;; (defvar skip-first)
-;; (defvar component-version)
-;; (defvar fixed-layout) (defvar variable-layout)
-;; (defvar fixed-layout-rm) (defvar variable-layout-rm)
-;; (defvar redundant-keys) (defvar defined-keys)
-;; (defvar versions)
 
 (ergoemacs-theme-component standard-vars ()
   "Enabled/changed variables/modes"
diff --git a/ergoemacs-track.el b/ergoemacs-track.el
index 0a88d01..97f7f0d 100644
--- a/ergoemacs-track.el
+++ b/ergoemacs-track.el
@@ -215,7 +215,7 @@
                         'home)
                        ((= 4 (nth i ergoemacs-track-row))
                         'bottom))))
-     ret)))
+     (symbol-value 'ret))))
 
 (defvar ergoemacs-key-hash nil
   "Key hash")
@@ -249,7 +249,7 @@ LAST-PLIST is the last property list returned by this 
function or nil if nothing
   (if layout
       (let ((ret (gethash (cons (cons key1 key2) (cons last-plist layout)) 
ergoemacs-key-hash)))
         (if ret
-            ret
+            (symbol-value 'ret)
           (let ((kp1 (gethash (cons layout key1) ergoemacs-key-hash))
                 (kp2 (gethash (cons layout key2) ergoemacs-key-hash))
                 kpl kpl1
@@ -411,7 +411,7 @@ LAST-PLIST is the last property list returned by this 
function or nil if nothing
                              :finger-n ,(plist-get kp2 :finger-n)
                              :key ,key2)))))
           (puthash (cons (cons key1 key2) (cons last-plist layout)) ret 
ergoemacs-key-hash)
-          ret))
+          (symbol-value 'ret)))
     (let (ret)
       (setq ret
             (mapcar
@@ -427,7 +427,7 @@ LAST-PLIST is the last property list returned by this 
function or nil if nothing
                  (puthash lay (+ dist (plist-get ret :d)) 
ergoemacs-distance-hash)
                  `(,lay ,ret)))
              (ergoemacs-get-layouts)))
-      ret)))
+      (symbol-value 'ret))))
 
 (defvar ergoemacs-last-distance-plist nil
   "Last distance plist")
diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el
index e60301e..8b6cd4c 100644
--- a/ergoemacs-translate.el
+++ b/ergoemacs-translate.el
@@ -80,7 +80,7 @@
           ;; Save it so the user doesn't see the buffer popup very much
           ;; (if at all).
           (add-to-list 'ergoemacs-display-char-list (list (list face char 
window-system) ret))
-          ret))
+          (symbol-value 'ret)))
     (error nil)))
 
 (defvar ergoemacs-use-unicode-char t
@@ -103,7 +103,7 @@ This assumes `ergoemacs-use-unicode-char' is non-nil.  When
   (if (not code) ""
     (let (deactivate-mark
           (ret (replace-regexp-in-string
-                " +\\'" "" (replace-regexp-in-string "\\` +" "" code)))
+                " +$" "" (replace-regexp-in-string "^ +" "" code)))
           (case-fold-search nil)) 
       (when ergoemacs-use-ergoemacs-key-descriptions
         (save-match-data
@@ -197,7 +197,7 @@ This assumes `ergoemacs-use-unicode-char' is non-nil.  When
               (while (re-search-forward "Ctl[+]" nil t)
                 (replace-match "^")))
             (setq ret (buffer-string)))))
-      ret)))
+      (symbol-value 'ret))))
 
 (defun ergoemacs-pretty-key-rep-internal ()
   (let (case-fold-search)
@@ -227,7 +227,7 @@ This assumes `ergoemacs-use-unicode-char' is non-nil.  When
               (insert code)
               (ergoemacs-pretty-key-rep-internal)
               (setq ret (buffer-string)))))
-        ret)
+        (symbol-value 'ret))
     (when ergoemacs-use-ergoemacs-key-descriptions
       (ergoemacs-pretty-key-rep-internal))))
 
@@ -253,7 +253,7 @@ This assumes `ergoemacs-use-unicode-char' is non-nil.  When
           ;; Save it so the user doesn't see the buffer popup very much
           ;; (if at all).
           (add-to-list 'ergoemacs-display-char-list (list (list face char 
window-system) ret))
-          ret))
+          (symbol-value 'ret)))
     (error nil)))
 
 ;;; Actual Translations
@@ -365,7 +365,7 @@ This also creates functions:
 
     (eval (macroexpand
            `(defvar ,(intern (concat "ergoemacs-" (symbol-name (plist-get 
arg-plist ':name)) "-modal-map"))
-              ',keymap-modal
+              ',(symbol-value 'keymap-modal)
               ,(concat "Ergoemacs modal override map for "
                       (symbol-name (plist-get arg-plist ':name))
                       " translation.
@@ -373,7 +373,7 @@ This keymap is made in `ergoemacs-translation'"))))
 
     (eval (macroexpand
            `(defvar ,(intern (concat "ergoemacs-" (symbol-name (plist-get 
arg-plist ':name)) "-translation-local-map"))
-              ',keymap
+              ',(symbol-value 'keymap)
               ,(concat "Ergoemacs translation local map for "
                       (symbol-name (plist-get arg-plist ':name))
                       " translation setup.
@@ -609,7 +609,7 @@ Translates C-A into C-S-a."
             (setq ret (concat (match-string 1 ret)
                               (match-string 2 ret)
                               (upcase (match-string 3 ret)))))))
-      ret)))
+      (symbol-value 'ret))))
 
 (defun ergoemacs-shift-translate-install (trans-plist ret-plist)
   "Install shift translation"
@@ -634,7 +634,7 @@ Translates C-A into C-S-a."
       (setq ret (plist-put ret name shift-translated))
       (setq ret (plist-put ret k (read-kbd-macro shift-translated t)))
       (setq ret (plist-put ret p (ergoemacs-pretty-key shift-translated))))
-    ret))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-translation-install (trans-plist orig-key ret-plist)
   "Installs the translation.
@@ -720,7 +720,7 @@ properties are also added:
     (setq ret (plist-put ret key (read-kbd-macro new-key t)))
     (setq ret (plist-put ret pretty (ergoemacs-pretty-key new-key)))
     (setq ret (ergoemacs-shift-translate-install trans-plist ret))
-    ret))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-translate (key)
   "Translates KEY and returns a plist of the translations.
@@ -849,9 +849,9 @@ and `ergoemacs-pretty-key' descriptions.
            (lambda(key plist)
              (setq ret (ergoemacs-translation-install plist orig-key ret)))
            ergoemacs-translations)
-          (puthash orig-key ret ergoemacs-translate-hash)
-          (puthash key ret ergoemacs-translate-hash)
-          ret))))
+          (puthash orig-key (symbol-value 'ret) ergoemacs-translate-hash)
+          (puthash key (symbol-value 'ret) ergoemacs-translate-hash)
+          (symbol-value 'ret)))))
 
 (defun ergoemacs-setup-translation (layout &optional base-layout)
   "Setup translation from BASE-LAYOUT to LAYOUT."
@@ -946,7 +946,7 @@ If JUST-TRANSLATE is non-nil, just return the KBD code, not 
the actual emacs key
       (let ((new-key (gethash `(,key ,just-translate ,only-first 
,ergoemacs-translation-from ,ergoemacs-translation-to)
                               ergoemacs-kbd-hash)))
         (if new-key
-            new-key
+            (symbol-value 'new-key)
           (setq new-key key)
           (cond
            ((eq system-type 'windows-nt)
@@ -990,7 +990,6 @@ If JUST-TRANSLATE is non-nil, just return the KBD code, not 
the actual emacs key
 For example, on dvorak, change C-j to C-c (copy/command)."
   :type 'boolean
   :set 'ergoemacs-set-default
-  :initialize #'custom-initialize-default
   :group 'ergoemacs-mode)
 
 (defun ergoemacs-get-kbd-translation (pre-kbd-code &optional dont-swap)
@@ -999,7 +998,7 @@ For example, on dvorak, change C-j to C-c (copy/command)."
               "[Cc]\\(?:on\\)?tro?l[+-]" "C-"
               (replace-regexp-in-string
                "[Aa]lt[+-]" "M-" pre-kbd-code))))
-    ret))
+    (symbol-value 'ret)))
 
 (defun ergoemacs-key-fn-lookup (function &optional use-apps)
   "Looks up the key binding for FUNCTION based on.
@@ -1018,7 +1017,7 @@ Based on `ergoemacs-with-ergoemacs'"
        (while (and ret (not (eq (elt (nth 0 ret) 0) 'apps)))
          (pop ret)))
      (setq ret (nth 0 ret))
-     ret)))
+     (symbol-value 'ret))))
 
 (provide 'ergoemacs-translate)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/ergoemacs-unbind.el b/ergoemacs-unbind.el
index 0eb5181..4f9a6ab 100644
--- a/ergoemacs-unbind.el
+++ b/ergoemacs-unbind.el
@@ -30,7 +30,6 @@
 ;;; Code:
 
 (require 'edmacro)
-(eval-when-compile (require 'cl))
 
 (defvar ergoemacs-emacs-default-bindings
   '(
@@ -635,22 +634,17 @@
 (defvar ergoemacs-unbind-keymap (make-sparse-keymap)
   "Keymap for `ergoemacs-unbind-keys'")
 
-(defvar ergoemacs--last)
-(defvar ergoemacs--fn)
-
-(defvar ergoemacs-shortcut-keymap)
-(defvar ergoemacs-keymap)
-
-(defun ergoemacs-undefined ()
+(defun ergoemacs-undefined (&optional arg)
   "Ergoemacs Undefined key, tells where to perform the old action."
-  (interactive)
-  (let* ((key-kbd (or ergoemacs-single-command-keys
-                      (this-single-command-keys)))
+  (interactive "P")
+  (let* ((key-kbd (or ergoemacs-single-command-keys 
(this-single-command-keys)))
          (key (key-description key-kbd))
-         (ergoemacs--fn (assoc key ergoemacs-emacs-default-bindings))
+         (fn (assoc key ergoemacs-emacs-default-bindings))
          tmp
          (local-fn nil)
-         (ergoemacs--last (substring key -1)))
+         (last (substring key -1))
+         (ergoemacs-where-is-skip t)
+         (curr-fn nil))
     ;; Lookup local key, if present and then issue that
     ;; command instead...
     ;;
@@ -664,26 +658,27 @@
           ;; Lookup in ergoemacs-keymap
           (setq local-fn (lookup-key ergoemacs-keymap key-kbd)))
         (functionp local-fn))
-      (ergoemacs-debug "WARNING: The command %s is undefined when it shouldn't 
be..." local-fn)
+      (ergoemacs-debug "WARNING: The command %s is undefined when if shouldn't 
be..." local-fn)
       (ergoemacs-vars-sync) ;; Try to fix issue.
       (setq tmp (key-binding key-kbd))
       (when (and tmp (not (equal tmp 'ergoemacs-undefined)))
         (setq local-fn tmp))
-      (when (and (boundp 'keyfreq-mode) keyfreq-mode (boundp 'keyfreq-table))
-        (let* ((command 'ergoemacs-undefined)
-               (count (gethash (cons major-mode command) keyfreq-table)))
-          (cond
-           ((not count))
-           ((= count 1)
-            (remhash (cons major-mode command) keyfreq-table))
-           (count
-            (puthash (cons major-mode command) (- count 1)
-                     keyfreq-table)))
-          ;; Add local-fn to counter.
-          (setq command local-fn)
-          (setq count (gethash (cons major-mode command) keyfreq-table))
-          (puthash (cons major-mode command) (if count (+ count 1) 1)
-                   keyfreq-table)))
+      (when (featurep 'keyfreq)
+        (when keyfreq-mode
+          (let ((command 'ergoemacs-undefined) count)
+            (setq count (gethash (cons major-mode command) keyfreq-table))
+            (cond
+             ((not count))
+             ((= count 1)
+              (remhash (cons major-mode command) keyfreq-table))
+             (count
+              (puthash (cons major-mode command) (- count 1)
+                       keyfreq-table)))
+            ;; Add local-fn to counter.
+            (setq command local-fn)
+            (setq count (gethash (cons major-mode command) keyfreq-table))
+            (puthash (cons major-mode command) (if count (+ count 1) 1)
+                     keyfreq-table))))
       (setq this-command local-fn)
       (condition-case err
           (call-interactively local-fn)
@@ -693,7 +688,7 @@
         ;; defined there.
         (setq local-fn (get-char-property (point) 'local-map))
         (if (and local-fn
-                 (condition-case nil
+                 (condition-case err
                      (keymapp local-fn)
                    (error nil)))
             (setq local-fn (lookup-key local-fn key-kbd))
@@ -702,21 +697,22 @@
             (setq local-fn nil)))
         (functionp local-fn))
       (setq this-command local-fn) ; Don't record this command.
-      (when (and (boundp 'keyfreq-mode) keyfreq-mode (boundp 'keyfreq-table))
-        (let ((command 'ergoemacs-undefined) count)
-          (setq count (gethash (cons major-mode command) keyfreq-table))
-          (cond
-           ((not count))
-           ((= count 1)
-            (remhash (cons major-mode command) keyfreq-table))
-           (count
-            (puthash (cons major-mode command) (- count 1)
-                     keyfreq-table)))
-          ;; Add local-fn to counter.
-          (setq command local-fn)
-          (setq count (gethash (cons major-mode command) keyfreq-table))
-          (puthash (cons major-mode command) (if count (+ count 1) 1)
-                   keyfreq-table)))
+      (when (featurep 'keyfreq)
+        (when keyfreq-mode
+          (let ((command 'ergoemacs-undefined) count)
+            (setq count (gethash (cons major-mode command) keyfreq-table))
+            (cond
+             ((not count))
+             ((= count 1)
+              (remhash (cons major-mode command) keyfreq-table))
+             (count
+              (puthash (cons major-mode command) (- count 1)
+                       keyfreq-table)))
+            ;; Add local-fn to counter.
+            (setq command local-fn)
+            (setq count (gethash (cons major-mode command) keyfreq-table))
+            (puthash (cons major-mode command) (if count (+ count 1) 1)
+                     keyfreq-table))))
       (condition-case err
           (call-interactively local-fn)
         (error (beep) (message "%s" err))))
@@ -732,13 +728,17 @@
 
 (defun ergoemacs-reset-global-where-is ()
   "Reset `ergoemacs-where-is-global-hash'."
-  (clrhash ergoemacs-where-is-global-hash)
-  (dolist (x ergoemacs-emacs-default-bindings)
-    (let ((key (read-kbd-macro (nth 0 x))))
-      (dolist (fn (nth 1 x))
-        (let ((keys (gethash fn ergoemacs-where-is-global-hash)))
-          (pushnew key keys :test #'equal)
-          (puthash fn keys ergoemacs-where-is-global-hash))))))
+  (setq ergoemacs-where-is-global-hash (make-hash-table :test 'equal))
+  (mapc
+   (lambda(x)
+     (let ((key (read-kbd-macro (nth 0 x))))
+       (mapc
+        (lambda(fn)
+          (let ((keys (gethash fn ergoemacs-where-is-global-hash)))
+            (add-to-list 'keys key)
+            (puthash fn keys ergoemacs-where-is-global-hash)))
+        (nth 1 x))))
+   ergoemacs-emacs-default-bindings))
 
 
 ;;;###autoload
@@ -747,14 +747,19 @@
   (setq ergoemacs-emacs-default-bindings
         (mapcar
          (lambda(elt)
-           (let* ((first (nth 0  elt))
-                  (last (nth 1 elt))
-                  (fn (lookup-key global-map (read-kbd-macro first))))
+           (let ((first (nth 0  elt))
+                 (last (nth 1 elt))
+                 fn)
+             (setq fn (lookup-key global-map (read-kbd-macro first)))
              (if (not (functionp fn))
                  elt
               ;; FIXME: Use `push' or `cl-pushnew' instead of
                ;; `add-to-list'.
+<<<<<<< HEAD
                (pushnew 'last fn :test #'equal)
+=======
+               (add-to-list 'last fn)
+>>>>>>> parent of 8e95ab1... Stefan Monnier's Patch
                `(,first ,last))))
          ergoemacs-emacs-default-bindings))
   (ergoemacs-reset-global-where-is))
@@ -762,12 +767,12 @@
   
 (defun ergoemacs-format-where-is-buffer (&optional include-menu-bar 
include-alias)
   "Format a buffer created from a `where-is' command."
-  (when (and (boundp 'ergoemacs--fn)
-             (eq (nth 0 (nth 1 ergoemacs--fn)) 'digit-argument))
+  (when (and (boundp 'fn)
+             (eq (nth 0 (nth 1 fn)) 'digit-argument))
     (goto-char (point-min))
     (while (re-search-forward "\\<\\([CMS]-\\)+" nil t)
-      (when (and (boundp 'ergoemacs--last)
-                 (not (save-match-data (looking-at ergoemacs--last))))
+      (when (and (boundp 'last)
+                 (not (save-match-data (looking-at last))))
         (replace-match "")
         (delete-char 1)
         (when (looking-at " *, *")
@@ -805,7 +810,7 @@
 (defvar ergoemacs-global-changed-cache '()
   "Cache of global variables that have changed.")
 
-(defun ergoemacs-global-fix-default-bindings (kbd-code function)
+(defun ergoemacs-global-fix-defualt-bindings (kbd-code function)
   "Helper function to fix `ergoemacs-emacs-default-bindings' based on 
currently running emacs."
   (interactive)
   (with-temp-buffer
@@ -828,10 +833,10 @@ This should only be run when no global keys have been set.
 "
   (let* ((key-code
           (cond
-           ((stringp key)
+           ((eq (type-of key) 'string)
             (if is-variable
                 (ergoemacs-kbd key)
-              (condition-case nil
+              (condition-case err
                   (read-kbd-macro key)
                 (error (read-kbd-macro
                         (encode-coding-string
@@ -845,7 +850,7 @@ This should only be run when no global keys have been set.
             (when (or fix complain)
               (let* ((key-function (lookup-key (current-global-map) key-code 
t))
                      (old-bindings (assoc key-kbd 
ergoemacs-emacs-default-bindings))
-                     (trans-function (if (condition-case nil
+                     (trans-function (if (condition-case err
                                              (keymapp key-function)
                                            (error nil))
                                          'prefix
@@ -857,7 +862,7 @@ This should only be run when no global keys have been set.
             nil
           (let* ((key-function (lookup-key (current-global-map) key-code t))
                  (old-bindings (assoc key-kbd 
ergoemacs-emacs-default-bindings))
-                 (trans-function (if (condition-case nil
+                 (trans-function (if (condition-case err
                                          (keymapp key-function)
                                        (error nil))
                                      'prefix
@@ -873,7 +878,7 @@ This should only be run when no global keys have been set.
                 (while (< i trans-function)
                   (aset prefix-vector i (elt key-as-vector i))
                   (setq i (+ 1 i)))
-                (unless (condition-case nil ; If it is a prefix vector,
+                (unless (condition-case err ; If it is a prefix vector,
                                         ; assume not globally
                                         ; changed
                             (keymapp (lookup-key (current-global-map) 
prefix-vector))
@@ -896,23 +901,29 @@ This should only be run when no global keys have been set.
                              trans-function old-bindings)
                     (when fix
                       (unless (integerp trans-function)
-                        (ergoemacs-global-fix-default-bindings key-kbd 
trans-function))))
+                        (ergoemacs-global-fix-defualt-bindings key-kbd 
trans-function))))
                   (add-to-list 'ergoemacs-global-changed-cache key-kbd))
               (add-to-list 'ergoemacs-global-not-changed-cache key-kbd))
-            has-changed))))))
+            (symbol-value 'has-changed)))))))
 
-(defun ergoemacs-warn-globally-changed-keys (&optional fix) ;FIXME: fix unused!
+(defun ergoemacs-warn-globally-changed-keys (&optional fix)
   "Warns about globally changed keys. If FIX is true, fix the ergoemacs-unbind 
file."
   (interactive)
-  (dolist (x ergoemacs-emacs-default-bindings)
-    (ergoemacs-global-changed-p (nth 0 x) nil t t))
+  (mapc
+   (lambda(x)
+     (ergoemacs-global-changed-p (nth 0 x) nil t t))
+   ergoemacs-emacs-default-bindings)
   (message "Ergoemacs Keys warnings for this layout:")
-  (dolist (x (symbol-value (ergoemacs-get-fixed-layout)))
-    (and (stringp (nth 0 x))
-         (ergoemacs-global-changed-p (nth 0 x) nil t t)))
-  (dolist (x (symbol-value (ergoemacs-get-variable-layout)))
-    (and (stringp (nth 0 x))
-         (ergoemacs-global-changed-p (nth 0 x) t t))))
+  (mapc
+   (lambda(x)
+     (and (eq 'string (type-of (nth 0 x)))
+          (ergoemacs-global-changed-p (nth 0 x) nil t t)))
+      (symbol-value (ergoemacs-get-fixed-layout)))
+  (mapc
+   (lambda(x)
+     (and (eq 'string (type-of (nth 0 x)))
+          (ergoemacs-global-changed-p (nth 0 x) t t)))
+   (symbol-value (ergoemacs-get-variable-layout))))
 
 
 



reply via email to

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