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

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

[elpa] 31/35: ergoemacs-keyboard-quit calls 【q】 when applicable


From: Matthew Fidler
Subject: [elpa] 31/35: ergoemacs-keyboard-quit calls 【q】 when applicable
Date: Fri, 11 Jul 2014 22:33:32 +0000

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

commit e7c0a54bb259aa4bef34cb54eb00d1e4a2d73954
Author: Matthew L. Fidler <address@hidden>
Date:   Fri Jul 11 07:31:14 2014 -0500

    ergoemacs-keyboard-quit calls 【q】 when applicable
---
 ergoemacs-shortcuts.el |   73 +++++++++++++++++++++++++++++-------------------
 1 files changed, 44 insertions(+), 29 deletions(-)

diff --git a/ergoemacs-shortcuts.el b/ergoemacs-shortcuts.el
index 46efa81..4a4be25 100644
--- a/ergoemacs-shortcuts.el
+++ b/ergoemacs-shortcuts.el
@@ -511,35 +511,50 @@ It will replace anything defined by 
`ergoemacs-translation'"
 (declare-function ergoemacs-modal-toggle "ergoemacs-modal.el")
 (declare-function cua-clear-rectangle-mark "cua-rect.el")
 (defun ergoemacs-keyboard-quit ()
-  "Replacement for `keyboard-quit' and `minibuffer-keyboard-quit'."
-  (cond
-   ((minibufferp)
-    (minibuffer-keyboard-quit))
-   ((and (boundp 'cua--rectangle) cua--rectangle
-         (boundp 'cua-mode) cua-mode
-         (fboundp 'cua-clear-rectangle-mark))
-    (cua-clear-rectangle-mark))
-   (t
-    (let (defined-fn
-           ergoemacs-shortcut-keys
-           ergoemacs-no-shortcut-keys
-           ergoemacs-read-input-keys
-           ergoemacs-mode)
-      (setq defined-fn (ergoemacs-key-fn-lookup 'keyboard-quit))
-      (setq defined-fn
-            (condition-case err
-                (ergoemacs-real-key-binding defined-fn)
-              (error nil)))
-      (cond
-       (defined-fn
-         (ergoemacs-read-key-call defined-fn))
-       ((and ergoemacs-modal
-             (let ((hash (gethash (nth 0 ergoemacs-modal-list) 
ergoemacs-translations)))
-               (and hash
-                    (not (plist-get hash ':modal-always))))) ;; Exit modal 
-        (ergoemacs-modal-toggle (nth 0 ergoemacs-modal-list)))
-       (t
-        (keyboard-quit))))))
+  "Replacement for `keyboard-quit' and `minibuffer-keyboard-quit'.
+
+- In a minibuffer, do `minibuffer-keyboard-quit'.  When a
+- `cua-mode' rectangle is active, clear the selected rectangle.
+- If the 【q】 key is bound to a non self-insert function, exit
+  by this function. (By convention, the 【q】 key is often quit)
+- If `ergoemacs-mode' knows of the quit function, use that
+- If an `ergoemacs-mode' modal translation is active, deactivate it.
+- Otherwise issue `keyboard-quit'
+"
+  (let (tmp)
+    (cond
+     ((minibufferp)
+      (minibuffer-keyboard-quit))
+     ((and (boundp 'cua--rectangle) cua--rectangle
+           (boundp 'cua-mode) cua-mode
+           (fboundp 'cua-clear-rectangle-mark))
+      (cua-clear-rectangle-mark))
+     ((or (progn
+            (setq tmp (key-binding "q"))
+            (and (not (symbolp tmp)) (commandp tmp t)))
+          (not (string-match "self-insert" (symbol-name tmp))))
+      (call-interactively (key-binding "q")))
+     (t
+      (let (defined-fn
+             ergoemacs-shortcut-keys
+             ergoemacs-no-shortcut-keys
+             ergoemacs-read-input-keys
+             ergoemacs-mode)
+        (setq defined-fn (ergoemacs-key-fn-lookup 'keyboard-quit))
+        (setq defined-fn
+              (condition-case err
+                  (ergoemacs-real-key-binding defined-fn)
+                (error nil)))
+        (cond
+         (defined-fn
+           (ergoemacs-read-key-call defined-fn))
+         ((and ergoemacs-modal
+               (let ((hash (gethash (nth 0 ergoemacs-modal-list) 
ergoemacs-translations)))
+                 (and hash
+                      (not (plist-get hash ':modal-always))))) ;; Exit modal 
+          (ergoemacs-modal-toggle (nth 0 ergoemacs-modal-list)))
+         (t
+          (keyboard-quit)))))))
   (setq ergoemacs-describe-key nil))
 
 



reply via email to

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