mlf176f2 pushed a commit to branch externals/ergoemacs-mode in repository elpa.
commit d623faad49c183d9c78b40e2cfd674d4891bebfb Author: Matthew L. Fidler <[email protected]> Date: Mon Jun 16 09:09:55 2014 -0500 Revert "Fixed shortcut keys." This reverts commit e55ace8e645ff45b0cf335d3ace77d11e8d647dd. --- ergoemacs-advices.el | 5 +-- ergoemacs-mode.el | 38 ++++++++++++++++++++++++++++++++--- ergoemacs-shortcuts.el | 51 ++++++++++++++++++++++++++++++++--------------- 3 files changed, 71 insertions(+), 23 deletions(-) diff --git a/ergoemacs-advices.el b/ergoemacs-advices.el index 4cd4f15..9b1cba6 100644 --- a/ergoemacs-advices.el +++ b/ergoemacs-advices.el @@ -208,9 +208,8 @@ will add MAP to substitution." (progn (setq test (key-description (nth 0 test-hash))) (ergoemacs-pretty-key test)) - (let (ergoemacs-modal - ergoemacs-repeat-keys ergoemacs-read-input-keys - ergoemacs-shortcut-keys) + (let (ergoemacs-modal ergoemacs-repeat-keys ergoemacs-read-input-keys + ergoemacs-shortcut-keys) (ergoemacs-pretty-key (ergoemacs-real-substitute-command-keys (or (and map (concat map string)) string)))))))) diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el index 57b57a0..5e93d47 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -480,6 +480,9 @@ bindings the keymap is: (when (and (intern-soft (format "ergoemacs-%s-hook" major-mode))) (funcall (intern-soft (format "ergoemacs-%s-hook" major-mode)))))) (buffer-list)) + (setq ergoemacs-shortcut-keys t) + (setq ergoemacs-read-input-keys t) ; Hasn't completely been + ; fixed. (when (key-binding [ergoemacs-single-command-keys]) (if (not ergoemacs-read-key-overriding-overlay-save) (setq overriding-terminal-local-map ergoemacs-read-key-overriding-terminal-local-save) @@ -488,6 +491,7 @@ bindings the keymap is: ;; Fix `substitute-command-keys' (fset 'substitute-command-keys (symbol-function 'ergoemacs-substitute-command-keys)) (fset 'completing-read (symbol-function 'ergoemacs-completing-read)) + (setq ergoemacs-unbind-keys t) (add-hook 'pre-command-hook 'ergoemacs-pre-command-hook) (ergoemacs-populate-pre-command-hook) (add-hook 'minibuffer-setup-hook #'ergoemacs-minibuffer-setup) @@ -631,6 +635,30 @@ However instead of using M-a `eval-buffer', you could use M-a `eb'" (when ergoemacs-use-aliases (ergoemacs-load-aliases)) +(defun ergoemacs-vars-sync () + "Sync variables. +`ergoemacs-mode' `ergoemacs-shortcut-keys', `ergoemacs-read-input-keys' +`ergoemacs-unbind-keys'." + (if (assq 'ergoemacs-mode minor-mode-map-alist) + (when (or ergoemacs-mode ergoemacs-shortcut-keys + ergoemacs-unbind-keys + ergoemacs-save-variables) + (unless ergoemacs-mode + (setq ergoemacs-mode t) + (ergoemacs-debug "WARNING: ergoemacs-mode was turned off; Turning on.")) + (unless ergoemacs-unbind-keys + (setq ergoemacs-unbind-keys t) + (ergoemacs-debug "WARNING: ergoemacs-unbind-keys was turned off; Turning on."))) + (when ergoemacs-mode + (setq ergoemacs-mode nil) + (ergoemacs-debug "WARNING: ergoemacs-mode was turned on; Turning off.")) + (unless ergoemacs-unbind-keys + (setq ergoemacs-unbind-keys nil) + (ergoemacs-debug "WARNING: ergoemacs-unbind-keys was turned on; Turning off.")) + (unless ergoemacs-shortcut-keys + (setq ergoemacs-shortcut-keys nil) + (ergoemacs-debug "WARNING: ergoemacs-shortcut-keys was turned on; Turning off.")))) + (defun ergoemacs-shuffle-keys (&optional force-update) "Shuffle ergoemacs keymaps in `minor-mode-map-alist'." (when (or force-update (not (eq (car (nth 0 minor-mode-map-alist)) 'ergoemacs-mode))) @@ -725,6 +753,7 @@ These hooks are deferred to make sure `this-command' is set appropriately.") (condition-case err (progn (ergoemacs-restore-post-command-hook) + (ergoemacs-vars-sync) (when (and ergoemacs-repeat-keys (keymapp ergoemacs-repeat-keymap) (not (lookup-key ergoemacs-repeat-keymap (this-single-command-keys)))) @@ -747,7 +776,9 @@ These hooks are deferred to make sure `this-command' is set appropriately.") (format "<override> %s" (key-description (this-single-command-keys)))))) (cond - ((commandp key-binding) + ((condition-case err + (interactive-form key-binding) + (error nil)) (setq this-command key-binding)))) (when (and (or (not (boundp 'saved-overriding-map)) (eq saved-overriding-map t)) @@ -781,11 +812,10 @@ These hooks are deferred to make sure `this-command' is set appropriately.") (condition-case err (progn (when ergoemacs-mode - ;; FIXME Not sure where this is turning off - (setq ergoemacs-shortcut-keys t) (ergoemacs-shuffle-keys) (when (not unread-command-events) - (ergoemacs-install-shortcuts-up))) + (ergoemacs-install-shortcuts-up) + (ergoemacs-vars-sync))) (when (not ergoemacs-mode) (ergoemacs-remove-shortcuts))) (error (message "Error %s" err)))) diff --git a/ergoemacs-shortcuts.el b/ergoemacs-shortcuts.el index e8cbfec..41d6f60 100644 --- a/ergoemacs-shortcuts.el +++ b/ergoemacs-shortcuts.el @@ -932,17 +932,33 @@ FORCE-KEY forces keys like <escape> to work properly. (setq ret (ergoemacs-read-key-lookup-get-ret fn)) (or ret (commandp fn t))) (unless ret - (setq fn (or (command-remapping fn (point)) fn)) - (when (memq fn ergoemacs-universal-fns) - (setq ret (ergoemacs-read-key-lookup-get-ret---universal fn))) - (unless ret - (setq ergoemacs-single-command-keys key) - (ergoemacs-read-key--echo-command - pretty-key (or (and (symbolp fn) (symbol-name fn)) - (ergoemacs-unicode-char "λ" "lambda"))) - (ergoemacs-read-key-call fn nil key) - (setq ergoemacs-single-command-keys nil) - (setq ret 'function)))) + (cond + ((and ergoemacs-shortcut-keys (not ergoemacs-describe-key) + (not ergoemacs-single-command-keys)) + (if (nth 0 hash) + (progn + (setq fn (nth 0 hash))) + (setq fn (key-binding key)) + (setq fn (or (command-remapping fn (point)) fn))) + (ergoemacs-read-key--echo-command pretty-key fn) + ;; 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 + ;; into unread-command-events. + (ergoemacs-read-key--send-unread key lookup use-override) + (setq ret 'shortcut-workaround)) + (t + (setq fn (or (command-remapping fn (point)) fn)) + (when (memq fn ergoemacs-universal-fns) + (setq ret (ergoemacs-read-key-lookup-get-ret---universal fn))) + (unless ret + (setq ergoemacs-single-command-keys key) + (ergoemacs-read-key--echo-command + pretty-key (or (and (symbolp fn) (symbol-name fn)) + (ergoemacs-unicode-char "λ" "lambda"))) + (ergoemacs-read-key-call fn nil key) + (setq ergoemacs-single-command-keys nil) + (setq ret 'function)))))) ;; Does this call an override or major/minor mode function? ((progn (setq fn (or @@ -951,10 +967,11 @@ FORCE-KEY forces keys like <escape> to work properly. (key-binding key)) ;; Call unbound or global key? (if (eq (lookup-key ergoemacs-unbind-keymap key) 'ergoemacs-undefined) 'ergoemacs-undefined - (if (keymapp (key-binding key)) - (setq ret 'keymap) - (ergoemacs-with-global - (key-binding key)))))) + (let (ergoemacs-read-input-keys) + (if (keymapp (key-binding key)) + (setq ret 'keymap) + (ergoemacs-with-global + (key-binding key))))))) (setq ret (ergoemacs-read-key-lookup-get-ret fn)) (or ret (commandp fn t))) (unless ret @@ -982,7 +999,9 @@ FORCE-KEY forces keys like <escape> to work properly. (when ergoemacs-modal (setq ergoemacs-modal-save ergoemacs-modal)) (setq erogemacs-modal nil) - (set-default 'ergoemacs-modal nil)))) + (set-default 'ergoemacs-modal nil)) + (when ergoemacs-single-command-keys + (setq ergoemacs-read-input-keys nil)))) (defun ergoemacs-read-key-add-translation (key-plist trans) "Adds `ergoemacs-translation-keymap' to KEY-PLIST for TRANS translation.
