[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 17/117: Add rudimentary guide-key support; F1/C-h activates guide
From: |
Matthew Fidler |
Subject: |
[elpa] 17/117: Add rudimentary guide-key support; F1/C-h activates guide-key |
Date: |
Fri, 25 Jul 2014 13:23:54 +0000 |
mlf176f2 pushed a commit to branch externals/ergoemacs-mode
in repository elpa.
commit e9a2ef9b730ee43d6139319b1394cb0b3fa3ff48
Author: Matthew L. Fidler <address@hidden>
Date: Tue Jul 15 09:15:18 2014 -0500
Add rudimentary guide-key support; F1/C-h activates guide-key
---
ergoemacs-advices.el | 25 ++++++++++-
ergoemacs-extras.el | 4 +-
ergoemacs-shortcuts.el | 117 +++++++++++++++++++++++++++---------------------
3 files changed, 92 insertions(+), 54 deletions(-)
diff --git a/ergoemacs-advices.el b/ergoemacs-advices.el
index f522326..bb4e07e 100644
--- a/ergoemacs-advices.el
+++ b/ergoemacs-advices.el
@@ -64,9 +64,30 @@ If `pre-command-hook' is used and `ergoemacs-mode' is remove
from `ergoemacs-pre
(defadvice describe-buffer-bindings (around ergoemacs-describe-buffer-bindings
activate)
"Describes buffer bindings without `ergoemacs-read-input-keys' enabled"
- (let (ergoemacs-read-input-keys)
+ (let (ergoemacs-read-input-keys
+ ergoemacs-read-shortcut-keys
+ ergoemacs-read-no-shortcut-keys)
ad-do-it))
+(defvar ergoemacs-read-key-last nil)
+(defadvice popwin:popup-buffer (around
ergoemacs-popwin:close-popup-window-if-necessary activate)
+ "Saves `ergoemacs-read-key' before popping up a window."
+ (when (and ergoemacs-mode ergoemacs-read-key)
+ (setq ergoemacs-read-key-last ergoemacs-read-key))
+ ad-do-it)
+
+(defadvice popwin:close-popup-window-if-necessary (around
ergoemacs-popwin:close-popup-window-if-necessary activate)
+ "Allows popup-window to be active while reading an `ergoemacs-mode' key via
`ergoemacs-read-key'"
+ (cond
+ ((and ergoemacs-mode ergoemacs-read-key ergoemacs-read-key-last
+ (equal ergoemacs-read-key-last ergoemacs-read-key))
+ nil)
+ ((and ergoemacs-mode ergoemacs-read-key ergoemacs-read-key-last
+ (not (equal ergoemacs-read-key-last ergoemacs-read-key)))
+ (setq ergoemacs-read-key-last nil)
+ (popwin:close-popup-window))
+ (t ad-do-it)))
+
(defadvice define-key (around ergoemacs-define-key-advice (keymap key def)
activate)
"This does the right thing when modifying `ergoemacs-keymap'.
Also adds keymap-flag for user-defined keys run with `run-mode-hooks'."
@@ -517,6 +538,8 @@ Uses `ergoemacs-real-key-binding' to get the key-binding."
(ergoemacs-with-global
(ergoemacs-real-key-binding key accept-default no-remap position)))
+
+
(defun ergoemacs-enable-c-advices (&optional disable)
"Enabling advices for C code and complex changes to functions.
DISABLE when non-nil.
diff --git a/ergoemacs-extras.el b/ergoemacs-extras.el
index 8d26c46..f7de815 100644
--- a/ergoemacs-extras.el
+++ b/ergoemacs-extras.el
@@ -421,9 +421,9 @@
(defvar ergoemacs-dir)
;;;###autoload
-(defun ergoemacs-ghpages (&optional arg)
+(defun ergoemacs-ghpages ()
"Generate github pages with o-blog."
- (interactive "P")
+ (interactive)
(let ((o-blog (expand-file-name (file-name-directory (locate-library
"o-blog"))))
(htmlize (expand-file-name (file-name-directory (locate-library
"htmlize"))))
(emacs-exe (invocation-name))
diff --git a/ergoemacs-shortcuts.el b/ergoemacs-shortcuts.el
index e9e5964..3f63e04 100644
--- a/ergoemacs-shortcuts.el
+++ b/ergoemacs-shortcuts.el
@@ -494,16 +494,25 @@ It will replace anything defined by
`ergoemacs-translation'"
(kbd (plist-get next-key ':normal)))
(ergoemacs-read-key-install-next-key next-key key pretty kbd))))
+(defvar guide-key-mode)
+(defvar ergoemacs-read-key nil
+ "Current key for `ergoemacs-read-key'")
(defun ergoemacs-read-key-help ()
"Show help for the current sequence KEY."
(interactive)
;; Eventually...
- (let ((cb (current-buffer))
- (key (and (boundp 'key) key)))
- (save-excursion
- (with-help-window (help-buffer)
- (set-buffer (help-buffer))
- (describe-buffer-bindings cb key)))))
+ (if (not ergoemacs-read-key) nil
+ (if guide-key-mode
+ (let ((key ergoemacs-read-key))
+ (guide-key/popup-function key)
+ t)
+ (let ((cb (current-buffer))
+ (key ergoemacs-read-key))
+ (save-excursion
+ (with-help-window (help-buffer)
+ (set-buffer (help-buffer))
+ (describe-buffer-bindings cb key)))
+ nil))))
(defvar ergoemacs-modal-list)
(declare-function minibuffer-keyboard-quit "delsel.el")
@@ -611,6 +620,7 @@ In addition, when the function is called:
"
(setq ergoemacs-deactivate-mark nil)
+ (setq ergoemacs-read-key-last [ergoemacs-read-key-call])
(cond
(ergoemacs-test-fn
(setq ergoemacs-test-fn function))
@@ -983,6 +993,7 @@ Otherwise add new translation to key-plist and return it."
key-plist))
(defvar ergoemacs-command-shortcuts-hash)
+
(defun ergoemacs-read-key (&optional key type initial-key-type universal)
"Read keyboard input and execute command.
The KEY is the keyboard input where the reading begins. If nil,
@@ -1004,7 +1015,7 @@ argument prompt.
pretty-key
pretty-key-undefined
next-key
- (key key)
+ (ergoemacs-read-key key)
key-trial
pretty-key-trial
orig-pretty-key
@@ -1019,8 +1030,8 @@ argument prompt.
(curr-universal nil)
ergoemacs--input tmp
history)
- (setq ergoemacs--input (ergoemacs-to-sequence key)
- key nil)
+ (setq ergoemacs--input (ergoemacs-to-sequence ergoemacs-read-key)
+ ergoemacs-read-key nil)
(while continue-read
(setq continue-read nil
force-key nil)
@@ -1041,19 +1052,23 @@ argument prompt.
(setq tmp "<return>")))
(if (string= tmp (key-description
(ergoemacs-key-fn-lookup 'keyboard-quit)))
- (if (and (not key))
- (ergoemacs-keyboard-quit)
- (unless (minibufferp)
- (let (message-log-max)
- (setq tmp (gethash type ergoemacs-translation-text))
- (message "%s%s%s Canceled with %s"
- (if ergoemacs-describe-key
- "Help for: " "")
- (if tmp (nth 5 tmp) "")
- (or pretty-key "")
- (if ergoemacs-use-ergoemacs-key-descriptions
- (plist-get next-key ':normal-pretty)
- (concat (plist-get next-key ':normal) " ")))))
+ (cond
+ ((and (not ergoemacs-read-key))
+ (ergoemacs-keyboard-quit))
+ (ergoemacs-read-key-last
+ (setq ergoemacs-read-key-last [exit-by-escape]
+ continue-read t))
+ (t (unless (minibufferp)
+ (let (message-log-max)
+ (setq tmp (gethash type ergoemacs-translation-text))
+ (message "%s%s%s Canceled with %s"
+ (if ergoemacs-describe-key
+ "Help for: " "")
+ (if tmp (nth 5 tmp) "")
+ (or pretty-key "")
+ (if ergoemacs-use-ergoemacs-key-descriptions
+ (plist-get next-key ':normal-pretty)
+ (concat (plist-get next-key ':normal) " "))))))
(setq ergoemacs-describe-key nil))
(setq tmp (plist-get next-key ':normal-key))
;; See if there is a local equivalent of this...
@@ -1071,7 +1086,7 @@ argument prompt.
ergoemacs--input (nth 1 tmp)
real-read nil
real-type (nth 0 tmp))
- (setq key nil
+ (setq ergoemacs-read-key nil
pretty-key nil
type 'normal
key-trial nil
@@ -1079,12 +1094,12 @@ argument prompt.
pretty-key-trial nil
pretty-key nil))
(if (and (eq local-fn 'ergoemacs-read-key-swap)
- (or (not curr-universal) key))
+ (or (not curr-universal) ergoemacs-read-key))
(progn
;; Swap translation
(when (and real-read
ergoemacs-backspace-will-undo-swap-translation)
(push (list type
- (listify-key-sequence key))
+ (listify-key-sequence ergoemacs-read-key))
history))
(setq type (ergoemacs-read-key-swap first-type type)
continue-read t))
@@ -1108,9 +1123,7 @@ argument prompt.
(setq force-key t)
(setq local-fn nil))
(if (eq local-fn 'ergoemacs-read-key-help)
- (progn
- (ergoemacs-read-key-help)
- (setq continue-read nil))
+ (setq continue-read (ergoemacs-read-key-help))
(if local-fn
(ergoemacs-read-key-call local-fn)
(setq pretty-key-undefined nil)
@@ -1125,7 +1138,7 @@ argument prompt.
(setq next-key (ergoemacs-read-key-add-translation next-key
(concat base "-shift-translated")))
(push (concat base "-shift-translated-et") key-trials)
- (when (and key ergoemacs-translate-emacs-keys)
+ (when (and ergoemacs-read-key ergoemacs-translate-emacs-keys)
(setq tmp (gethash (plist-get next-key
(intern (concat base "-key")))
ergoemacs-command-shortcuts-hash))
@@ -1133,18 +1146,18 @@ argument prompt.
(condition-case err
(interactive-form (nth 0 tmp))
(error nil)))
- (dolist (key (ergoemacs-shortcut-function-binding (nth 0
tmp)))
- (let ((key-base (concat ":" (md5 (format "%s" key))))
+ (dolist (ergoemacs-read-key
(ergoemacs-shortcut-function-binding (nth 0 tmp)))
+ (let ((key-base (concat ":" (md5 (format "%s"
ergoemacs-read-key))))
(ergoemacs-use-ergoemacs-key-descriptions t))
;; First add translation to next-key
(setq next-key
(plist-put next-key
(intern (concat key-base "-key"))
- key))
+ ergoemacs-read-key))
(setq next-key
(plist-put next-key
(intern key-base)
- (key-description key)))
+ (key-description ergoemacs-read-key)))
(setq next-key
(plist-put next-key
(intern (concat key-base "-pretty"))
@@ -1170,8 +1183,8 @@ argument prompt.
;; If :shift-translated is nil, go to next option.
(when (plist-get next-key (intern (concat tmp
"-key")))
(setq key-trial
- (if key
- (vconcat key (plist-get next-key (intern
(concat tmp "-key"))))
+ (if ergoemacs-read-key
+ (vconcat ergoemacs-read-key (plist-get
next-key (intern (concat tmp "-key"))))
(plist-get next-key (intern (concat tmp
"-key"))))
pretty-key-trial
(if pretty-key
@@ -1193,7 +1206,7 @@ argument prompt.
(setq local-fn
(if key-trial
(ergoemacs-read-key-lookup
- key pretty-key
+ ergoemacs-read-key pretty-key
key-trial pretty-key-trial
force-key) nil))
(setq ergoemacs-deactivate-mark deactivate-mark)
@@ -1201,29 +1214,29 @@ argument prompt.
((eq local-fn 'keymap)
;; Test to see if major/minor modes have an
;; override for this keymap, see Issue 243.
- (let ((new-fn (and key
(ergoemacs-with-major-and-minor-modes (ergoemacs-real-key-binding key-trial)))))
+ (let ((new-fn (and ergoemacs-read-key
(ergoemacs-with-major-and-minor-modes (ergoemacs-real-key-binding key-trial)))))
(if (ignore-errors (commandp new-fn t))
(progn
(setq local-fn 'major-minor-override-fn)
- (ergoemacs-read-key-call new-fn nil key))
+ (ergoemacs-read-key-call new-fn nil
ergoemacs-read-key))
(when real-read
(push (list type
- (listify-key-sequence key))
+ (listify-key-sequence
ergoemacs-read-key))
history))
(setq continue-read t
- key key-trial
+ ergoemacs-read-key key-trial
pretty-key pretty-key-trial)))
;; Found, exit
(throw 'ergoemacs-key-trials t))
((eq (type-of local-fn) 'cons)
(when real-read
(push (list type
- (listify-key-sequence key))
+ (listify-key-sequence
ergoemacs-read-key))
history))
;; ergoemacs-shortcut reset ergoemacs-read-key
(setq continue-read t
ergoemacs--input (ergoemacs-to-sequence (nth 0
local-fn))
- key nil
+ ergoemacs-read-key nil
pretty-key nil
type 'normal
real-type (nth 1 local-fn)
@@ -1237,7 +1250,7 @@ argument prompt.
(not current-prefix-arg))
(setq curr-universal t
continue-read t
- key nil
+ ergoemacs-read-key nil
pretty-key nil
key-trial nil
key-trials nil
@@ -1248,7 +1261,7 @@ argument prompt.
(listp current-prefix-arg))
(setq curr-universal t
continue-read t
- key nil
+ ergoemacs-read-key nil
pretty-key nil
key-trial nil
key-trials nil
@@ -1262,22 +1275,22 @@ argument prompt.
((eq local-fn 'keymap)
(when real-read
(push (list type
- (listify-key-sequence key))
+ (listify-key-sequence
ergoemacs-read-key))
history))
(setq continue-read t
- key key-trial
+ ergoemacs-read-key key-trial
pretty-key pretty-key-trial)
;; Found, exit
(throw 'ergoemacs-key-trials t))
((eq (type-of local-fn) 'cons)
(when real-read
(push (list type
- (listify-key-sequence key))
+ (listify-key-sequence
ergoemacs-read-key))
history))
;; ergoemacs-shortcut reset ergoemacs-read-key
(setq continue-read t
ergoemacs--input (ergoemacs-to-sequence (nth 0
local-fn))
- key nil
+ ergoemacs-read-key nil
pretty-key nil
type 'normal
real-type (nth 1 local-fn)
@@ -1291,7 +1304,7 @@ argument prompt.
(not current-prefix-arg))
(setq curr-universal t
continue-read t
- key nil
+ ergoemacs-read-key nil
pretty-key nil
key-trial nil
key-trials nil
@@ -1302,7 +1315,7 @@ argument prompt.
(listp current-prefix-arg))
(setq curr-universal t
continue-read t
- key nil
+ ergoemacs-read-key nil
pretty-key nil
key-trial nil
key-trials nil
@@ -1320,7 +1333,9 @@ argument prompt.
(beep)
(unless (minibufferp)
(let (message-log-max)
- (message "%s is undefined!"
pretty-key-undefined)))))))))))
+ (message "%s is undefined!" pretty-key-undefined)))))))))
+ (when (fboundp 'popwin:close-popup-window-if-necessary)
+ (popwin:close-popup-window-if-necessary))))
(when ergoemacs-deactivate-mark
(setq deactivate-mark ergoemacs-deactivate-mark
ergoemacs-mark-active nil))
- [elpa] 04/117: Lexical Scoping for ergoemacs-functions, (continued)
- [elpa] 04/117: Lexical Scoping for ergoemacs-functions, Matthew Fidler, 2014/07/25
- [elpa] 09/117: Fix copyright symbol, Matthew Fidler, 2014/07/25
- [elpa] 11/117: Fix Variable binding byte compile warnings, Matthew Fidler, 2014/07/25
- [elpa] 12/117: Lexical binding for ergoemacs-macros, Matthew Fidler, 2014/07/25
- [elpa] 10/117: Lexical binding for ergoemacs-theme-engine, Matthew Fidler, 2014/07/25
- [elpa] 15/117: Don't exit if region is active., Matthew Fidler, 2014/07/25
- [elpa] 16/117: Advise describe-buffer-bindings, Matthew Fidler, 2014/07/25
- [elpa] 06/117: Lexical binding for ergoemacs-layouts., Matthew Fidler, 2014/07/25
- [elpa] 18/117: Use save-match-data with ergoemacs-pretty-key, Matthew Fidler, 2014/07/25
- [elpa] 13/117: Remove pop dependence, Matthew Fidler, 2014/07/25
- [elpa] 17/117: Add rudimentary guide-key support; F1/C-h activates guide-key,
Matthew Fidler <=
- [elpa] 14/117: Attempt Lexical Scoping for ergoemacs-translate.el, Matthew Fidler, 2014/07/25
- [elpa] 20/117: Add left/right to pretty key descriptions, Matthew Fidler, 2014/07/25
- [elpa] 19/117: Pretty key cleanup, Matthew Fidler, 2014/07/25
- [elpa] 22/117: Fix guide-key-mode requirement, Matthew Fidler, 2014/07/25
- [elpa] 24/117: Comment ergoemacs-substitute-command-keys, Matthew Fidler, 2014/07/25
- [elpa] 21/117: Better guide-key support, Matthew Fidler, 2014/07/25
- [elpa] 25/117: Add command prompt here and powershell here, Matthew Fidler, 2014/07/25
- [elpa] 23/117: Fix (substitute-command-keys "\\[recover-session]"), Matthew Fidler, 2014/07/25
- [elpa] 27/117: Fix recursive loading in ergoemacs-mode source, Matthew Fidler, 2014/07/25
- [elpa] 30/117: Declare w32-long-file-name, Matthew Fidler, 2014/07/25