branch: externals/ergoemacs-mode commit 89b618b44c81f3c25a3fcb968a2f2031e2741f62 Merge: de74f45 d30b431 Author: Walter Landry <wlan...@caltech.edu> Commit: Walter Landry <wlan...@caltech.edu>
Merge branch 'master' into ergoterm --- ergoemacs-advice.el | 6 -- ergoemacs-command-loop.el | 218 ++++++++++++++++++---------------------------- ergoemacs-component.el | 1 - ergoemacs-mode.el | 5 -- ergoemacs-themes.el | 13 ++- ergoemacs-translate.el | 32 +------ 6 files changed, 103 insertions(+), 172 deletions(-) diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el index e2320d3..ecb93b9 100644 --- a/ergoemacs-advice.el +++ b/ergoemacs-advice.el @@ -361,12 +361,6 @@ TYPE is the type of translation installed." ad-do-it (ergoemacs-mode--undefined-advice))) -(ergoemacs-advice handle-shift-selection () - "Allow `ergoemacs-mode' to do shift selection on keys like Alt+# to Alt+3." - :type :before - (when (eq 'ergoemacs-command-loop--shift-translate (key-binding (this-single-command-keys))) - (setq this-command-keys-shift-translated t))) - (provide 'ergoemacs-advice) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ergoemacs-advice.el ends here diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el index 8628dbb..3a28560 100644 --- a/ergoemacs-command-loop.el +++ b/ergoemacs-command-loop.el @@ -184,7 +184,6 @@ ignore the post-command hooks.") (defvar ergoemacs-command-loop-time-before-blink) (defvar ergoemacs-command-loop-blink-character) (defvar ergoemacs-command-loop-blink-rate) -(defvar ergoemacs-command-loop-hide-shift-translations) (defvar ergoemacs-mode) (defvar ergoemacs-command-loop-type) (defvar ergoemacs-keymap) @@ -801,9 +800,6 @@ KEYS is the keys information" (push 'ergoemacs-timeout unread-command-events)) (setq ergoemacs-command--timeout-keys nil)))) -(defvar ergoemacs-this-command-keys-shift-translated nil - "ergoemacs override of shift translation in command loop.") - (defun ergoemacs-command--echo-prefix () "Echos prefix keys in the ergoemacs-mode way." (let ((keys (this-single-command-keys)) @@ -821,8 +817,6 @@ KEYS is the keys information" ((eq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut) (push 'ergoemacs-timeout unread-command-events)) ((not (region-active-p))) ;; active - ((and (or ergoemacs-this-command-keys-shift-translated this-command-keys-shift-translated) - (eq ergoemacs-handle-ctl-c-or-ctl-x 'both))) ((and (not ergoemacs-ctl-c-or-ctl-x-delay) ;; Immediate (eq ergoemacs-handle-ctl-c-or-ctl-x 'both)) (push 'ergoemacs-timeout unread-command-events)) @@ -905,8 +899,7 @@ read." ;; Don't echo the uncommon hyper/super/alt translations (alt is ;; not the alt key...) (dolist (tr trans) - (unless (or (memq 'hyper (nth 0 tr)) (memq 'super (nth 0 tr)) (memq 'alt (nth 0 tr)) - (and ergoemacs-command-loop-hide-shift-translations (memq 'shift (nth 0 tr)))) + (unless (or (memq 'hyper (nth 0 tr)) (memq 'super (nth 0 tr)) (memq 'alt (nth 0 tr))) (if (member (list (nth 1 tr) (nth 0 tr)) trans) (when (not (member (list (nth 1 tr) (nth 0 tr)) double)) (push tr double)) @@ -1560,8 +1553,7 @@ needed (and resotre them to the original values)." "Call the COMMAND interactively. Also handle mouse events (if possible.) The RECORD-FLAG and KEYS are sent to `ergoemacs-command-loop--grow-interactive'." (ergoemacs-command-loop--sync-point) - (setq ergoemacs-last-command-was-ergoemacs-ignore-p nil - this-command-keys-shift-translated (or ergoemacs-this-command-keys-shift-translated this-command-keys-shift-translated)) + (setq ergoemacs-last-command-was-ergoemacs-ignore-p nil) (cond ((and (eventp last-command-event) (consp last-command-event) @@ -1577,8 +1569,7 @@ The RECORD-FLAG and KEYS are sent to `ergoemacs-command-loop--grow-interactive'. (ergoemacs-specials (ergoemacs-command-loop--grow-interactive command record-flag keys))) (t - (ergoemacs-command-loop--grow-interactive command record-flag keys))) - (setq ergoemacs-this-command-keys-shift-translated nil)) + (ergoemacs-command-loop--grow-interactive command record-flag keys)))) (defun ergoemacs-command-loop-start () @@ -1831,8 +1822,7 @@ Emacs versions)." "Key sequence %s aborted by %s" (ergoemacs-key-description last-current-key) (ergoemacs-key-description raw-key)) - (setq quit-flag t - ergoemacs-this-command-keys-shift-translated nil)) + (setq quit-flag t)) ;; Handle local commands. ((and (or modal-p (not (equal current-key raw-key))) @@ -2138,106 +2128,90 @@ pressed the translated key by changing ;; Make sure to lookup the keys in the selected buffer (ergoemacs-command-loop--sync-point) (let ((trials (ergoemacs-translate--trials key)) - tmp tmp2 ret) - (setq this-command-keys-shift-translated nil) - (catch 'found-command - (dolist (cur-key trials) - (when cur-key - (let* ((orig-key cur-key) - (bind (key-binding orig-key t)) - (meta-key (ergoemacs-translate--meta-to-escape cur-key)) - (esc-key (ergoemacs-translate--escape-to-meta cur-key)) - (new-key (or meta-key esc-key)) - (new-binding (and new-key (key-binding new-key))) - (global (and new-key - (list (lookup-key ergoemacs-keymap orig-key t) - (lookup-key ergoemacs-keymap new-key t))))) - ;; Prefer non-global keys. - (when (eq bind 'undefined) - (setq bind nil)) - (when (eq new-binding 'undefined) - (setq new-binding nil)) - (cond - ((not new-key) - (setq new-key orig-key)) - ((not (memq bind global)) - (setq new-key orig-key)) - ((and new-binding (not (memq new-binding global))) - (setq bind new-binding))) - (unless bind - (cond - ((or (ergoemacs-keymapp (setq tmp (lookup-key input-decode-map orig-key))) - (and (not (integerp tmp)) (commandp tmp))) - (setq bind tmp)) - ((or (ergoemacs-keymapp (setq tmp (lookup-key local-function-key-map orig-key))) - (and (not (integerp tmp)) (commandp tmp))) - (setq bind tmp)) - ((or (ergoemacs-keymapp (setq tmp (lookup-key key-translation-map orig-key))) - (and (not (integerp tmp)) (commandp tmp))) - (setq bind tmp)))) - (when (and orig-key - (setq ret bind - ret (if (and (eq ret 'ergoemacs-map-undefined) - (equal orig-key (nth 0 trials)) - (nth 1 trials)) nil ret))) + tmp tmp2 ret) + (catch 'found-command + (dolist (cur-key trials) + (when cur-key + (let* ((orig-key cur-key) + (bind (key-binding orig-key t)) + (meta-key (ergoemacs-translate--meta-to-escape cur-key)) + (esc-key (ergoemacs-translate--escape-to-meta cur-key)) + (new-key (or meta-key esc-key)) + (new-binding (and new-key (key-binding new-key))) + (global (and new-key + (list (lookup-key ergoemacs-keymap orig-key t) + (lookup-key ergoemacs-keymap new-key t))))) + ;; Prefer non-global keys. + (when (eq bind 'undefined) + (setq bind nil)) + (when (eq new-binding 'undefined) + (setq new-binding nil)) (cond - ((equal orig-key (nth 0 trials)) - (setq ergoemacs-command-loop--single-command-keys new-key) - ;; (message "History %s" (length ergoemacs-command-loop--history)) - (when (and (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - (ergoemacs-keymapp ret) - (setq tmp (lookup-key ret [ergoemacs-timeout]))) - (cond - ((eq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut) - (setq ret tmp)) - ((< 1 (length ergoemacs-command-loop--history))) - ((not (region-active-p))) ;; its a key sequence. - - ((and (or ergoemacs-this-command-keys-shift-translated this-command-keys-shift-translated) - (eq ergoemacs-handle-ctl-c-or-ctl-x 'both))) - - ;; Immediate - ((and (not ergoemacs-ctl-c-or-ctl-x-delay) - (eq ergoemacs-handle-ctl-c-or-ctl-x 'both)) + ((not new-key) + (setq new-key orig-key)) + ((not (memq bind global)) + (setq new-key orig-key)) + ((and new-binding (not (memq new-binding global))) + (setq bind new-binding))) + (unless bind + (cond + ((or (ergoemacs-keymapp (setq tmp (lookup-key input-decode-map orig-key))) + (and (not (integerp tmp)) (commandp tmp))) + (setq bind tmp)) + ((or (ergoemacs-keymapp (setq tmp (lookup-key local-function-key-map orig-key))) + (and (not (integerp tmp)) (commandp tmp))) + (setq bind tmp)) + ((or (ergoemacs-keymapp (setq tmp (lookup-key key-translation-map orig-key))) + (and (not (integerp tmp)) (commandp tmp))) + (setq bind tmp)))) + (when (and orig-key + (setq ret bind + ret (if (and (eq ret 'ergoemacs-map-undefined) + (equal orig-key (nth 0 trials)) + (nth 1 trials)) nil ret))) + (cond + ((equal orig-key (nth 0 trials)) + (setq ergoemacs-command-loop--single-command-keys new-key) + ;; (message "History %s" (length ergoemacs-command-loop--history)) + (when (and (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) + (ergoemacs-keymapp ret) + (setq tmp (lookup-key ret [ergoemacs-timeout]))) + (cond + ((eq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut) + (setq ret tmp)) + ((< 1 (length ergoemacs-command-loop--history))) + ((not (region-active-p))) ;; its a key sequence. + + ;; Immediate + ((and (not ergoemacs-ctl-c-or-ctl-x-delay) + (eq ergoemacs-handle-ctl-c-or-ctl-x 'both)) + (setq ret tmp)) + + (t ;; with delay + (if ergoemacs-command-loop--decode-event-timeout-p + (setq tmp2 nil + ergoemacs-command-loop--decode-event-timeout-p nil)) + (setq tmp2 (with-timeout (ergoemacs-ctl-c-or-ctl-x-delay nil) + (ergoemacs-command-loop--read-event nil key))) + (if (not tmp2) + (setq ret tmp) ;; timeout, use copy/cut + ;; Actual key + (setq ret (ergoemacs-command-loop--key-lookup (vconcat key (vector tmp2)))))))) + (ergoemacs-command-loop--message-binding new-key ret)) + ((equal orig-key (nth 1 trials)) ;; `ergoemacs-mode' shift translation + (setq ergoemacs-command-loop--single-command-keys (nth 0 trials)) + + ;; Shift+Control+c + (when (and (ergoemacs-keymapp ret) + (setq tmp (lookup-key ret [ergoemacs-timeout])) + (eq ergoemacs-handle-ctl-c-or-ctl-x 'both)) (setq ret tmp)) - - (t ;; with delay - (if ergoemacs-command-loop--decode-event-timeout-p - (setq tmp2 nil - ergoemacs-command-loop--decode-event-timeout-p nil)) - (setq tmp2 (with-timeout (ergoemacs-ctl-c-or-ctl-x-delay nil) - (ergoemacs-command-loop--read-event nil key))) - (if (not tmp2) - (setq ret tmp) ;; timeout, use copy/cut - ;; Actual key - (setq ret (ergoemacs-command-loop--key-lookup (vconcat key (vector tmp2)))))))) - (ergoemacs-command-loop--message-binding new-key ret)) - ((equal orig-key (nth 1 trials)) ;; `ergoemacs-mode' shift translation - (setq this-command-keys-shift-translated t - ergoemacs-command-loop--single-command-keys (nth 0 trials)) - - ;; Shift+Control+c - (when (and (ergoemacs-keymapp ret) - (setq tmp (lookup-key ret [ergoemacs-timeout])) - (eq ergoemacs-handle-ctl-c-or-ctl-x 'both)) - (setq ret tmp)) - (ergoemacs-command-loop--message-binding new-key ret key)) - (t - (ergoemacs-command-loop--message-binding new-key ret key) - (setq ergoemacs-command-loop--single-command-keys new-key))) - (throw 'found-command ret)))))) - ret))) - -(defun ergoemacs-command-loop--execute-handle-shift-selection (function) - "Allow `ergoemacs-mode' command loop to handle shift selection. - -This will apply `handle-shift-selection' when FUNCTION is -considered a shift-selection compatible function. - -This allows shift-selection of non-letter keys. -For instance in QWERTY M-> is shift translated to M-." - (when (ergoemacs :movement-p function) - (handle-shift-selection))) + (ergoemacs-command-loop--message-binding new-key ret key)) + (t + (ergoemacs-command-loop--message-binding new-key ret key) + (setq ergoemacs-command-loop--single-command-keys new-key))) + (throw 'found-command ret)))))) + ret))) (defun ergoemacs-command-loop--execute-rm-keyfreq (command) "Remove COMMAND from `keyfreq-mode' counts." @@ -2297,7 +2271,6 @@ For instance in QWERTY M-> is shift translated to M-." (ergoemacs-command-loop--execute-modify-command-list command) ;; Handle Shift Selection - (ergoemacs-command-loop--execute-handle-shift-selection this-command) (when keys (setq ergoemacs-command-loop--single-command-keys keys) @@ -2316,24 +2289,7 @@ For instance in QWERTY M-> is shift translated to M-." (setq ergoemacs-command-loop--single-command-keys nil))))) ;; (ergoemacs-command-loop--spinner-end) )) -(defun ergoemacs-command-loop--shift-timeout () - "This is the shift-timeout function for a key." - (interactive) - (let ((shift-trans (ergoemacs-translate--emacs-shift (this-single-command-keys)))) - (if (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut) - (setq unread-command-events (append (ergoemacs-translate--emacs-shift shift-trans) '(ergoemacs-timeout))) - (setq ergoemacs-this-command-keys-shift-translated t) - (ergoemacs-command-loop--internal shift-trans)))) - -(defun ergoemacs-command-loop--shift-translate () - "Shift translation." - (interactive) - (let ((shift-trans (ergoemacs-translate--emacs-shift (this-single-command-keys) 'ergoemacs-shift))) - (message "%s->%s" (key-description (this-single-command-keys)) - (key-description shift-trans)) - (setq ergoemacs-this-command-keys-shift-translated t - this-command-keys-shift-translated t) - (ergoemacs-command-loop--call-interactively (key-binding shift-trans)))) + (provide 'ergoemacs-command-loop) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ergoemacs-command-loop.el ends here diff --git a/ergoemacs-component.el b/ergoemacs-component.el index 3740e57..25368d8 100644 --- a/ergoemacs-component.el +++ b/ergoemacs-component.el @@ -461,7 +461,6 @@ Allows the component not to be calculated." (ergoemacs-gethash (nth 1 def) ergoemacs-translation-hash))) `(lambda(&optional arg) (interactive "P") - (setq ergoemacs-this-command-keys-shift-translated t) (ergoemacs-command-loop ,(nth 0 def) ',(nth 1 def)))) ((ergoemacs-keymapp (ergoemacs-sv def)) (ergoemacs-sv def)) diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el index 001c343..f884116 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -994,11 +994,6 @@ Valid values are: (const :tag "No command loop support" nil)) :group 'ergoemacs-comamnd-loop) -(defcustom ergoemacs-command-loop-hide-shift-translations t - "Hide shift translations in the command loop help." - :type 'boolean - :group 'ergoemacs-command-loop) - (defcustom ergoemacs-command-loop-echo-keystrokes 1 "The amount of time before `ergoemacs-mode' displays keystrokes." diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el index 5f25367..ff41141 100644 --- a/ergoemacs-themes.el +++ b/ergoemacs-themes.el @@ -299,14 +299,18 @@ (global-set-key (kbd "<S-down-mouse-1>") 'mouse-save-then-kill) (global-set-key (kbd "<S-mouse-1>") 'ignore) (global-set-key (kbd "C-+") 'text-scale-increase) + (global-set-key (kbd "C-=") 'text-scale-increase) (global-set-key (kbd "C--") 'text-scale-decrease) + (global-set-key (kbd "C-_") 'text-scale-decrease) (global-set-key (kbd "C-.") 'keyboard-quit) + (global-set-key (kbd "C->") 'keyboard-quit) + (global-set-key (kbd "C-") 'keyboard-quit) (global-set-key (kbd "C-/") 'info) (global-set-key (kbd "C-0") 'ergoemacs-text-scale-normal-size) + (global-set-key (kbd "C-)") 'ergoemacs-text-scale-normal-size) (global-set-key (kbd "C-<next>") 'ergoemacs-next-user-buffer) (global-set-key (kbd "C-<pause>") 'kill-compilation) ; stop compilation/find/grep (global-set-key (kbd "C-<prior>") 'ergoemacs-previous-user-buffer) - (global-set-key (kbd "C-=") 'text-scale-increase) (global-set-key (kbd "C-?") 'info) (global-set-key (kbd "C-S-<next>") 'ergoemacs-next-emacs-buffer) (global-set-key (kbd "C-S-<prior>") 'ergoemacs-previous-emacs-buffer) @@ -319,6 +323,7 @@ (global-set-key (kbd "C-S-w") 'delete-frame) (global-set-key (kbd "C-`") 'other-frame) + (global-set-key (kbd "C-~") 'other-frame) (global-set-key (kbd "C-a") 'mark-whole-buffer) (global-set-key (kbd "C-f") 'isearch-forward) (global-set-key (kbd "C-l") 'goto-line) @@ -876,9 +881,11 @@ (global-unset-key (kbd "C-x 1")) (global-set-key (kbd "M-3") 'delete-other-windows) + (global-set-key (kbd "M-#") 'delete-other-windows) (global-unset-key (kbd "C-x 0")) (global-set-key (kbd "M-2") 'delete-window) + (global-set-key (kbd "M-@") 'delete-window) (global-unset-key (kbd "C-x 3")) (global-set-key (kbd "M-4") '(split-window-below split-window-horizontally)) @@ -898,6 +905,7 @@ :version 5.7.5 (global-set-key (kbd "M-0") 'delete-window) + (global-set-key (kbd "M-)") 'delete-window) :version 5.7.5 (define-key term-raw-map (kbd "M-0") 'delete-window) ) @@ -935,6 +943,7 @@ "Text Transformation" (global-unset-key (kbd "M-;")) (global-set-key (kbd "M-'") '("M-;" :emacs)) + (global-set-key (kbd "M-\"") '("M-;" :emacs)) (global-set-key (kbd "M-w") 'ergoemacs-shrink-whitespaces) @@ -969,7 +978,9 @@ (global-set-key (kbd "M-8") '(er/expand-region ergoemacs-extend-selection)) (global-set-key (kbd "M-*") '(er/mark-inside-quotes ergoemacs-select-text-in-quote)) (global-set-key (kbd "M-6") 'ergoemacs-select-current-block) + (global-set-key (kbd "M-^") 'ergoemacs-select-current-block) (global-set-key (kbd "M-7") 'ergoemacs-select-current-line) + (global-set-key (kbd "M-&") 'ergoemacs-select-current-line) ;; Mode specific changes (define-key term-raw-map (kbd "M-S-SPC") 'mark-paragraph) diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el index a3b9f88..015d3b9 100644 --- a/ergoemacs-translate.el +++ b/ergoemacs-translate.el @@ -158,9 +158,6 @@ modifier occurred, such as in `ergoemacs-translate--meta-to-escape'. (defvar ergoemacs-translate--define-key-if-defined-p t "Define a key if even if it is already defined in the keymap.") -(defvar ergoemacs-translate--define-key-replacement-function nil - "When non-nil, use the replacement function for defining a key.") - (defun ergoemacs-translate--meta-to-escape (key-seq) "Escapes a KEY-SEQ M-q becomes ESC q. @@ -232,24 +229,6 @@ If no changes are performed, return nil." (setq ret new-key)) ret))) -(defun ergoemacs-translate--ergoemacs-shift-select (key) - "Translate KEY to allow `ergoemacs-mode' shift translation. - -This will shift translate Alt+# to Alt+3." - (let (modifiers basic) - (when (and (vectorp key) - ;; only makes sense for single key combinations. - (= (length key) 1) - ;; Doesn't make sense if shifted... - (not (or (memq 'shift (setq modifiers (ergoemacs-translate--event-modifiers (aref key 0)))) - (memq 'ergoemacs-shift modifiers))) - ;; Only define if emacs doesn't handle shift selection. - (not (eq (event-convert-list (list 'shift (setq basic (event-basic-type (aref key 0))))) - (ergoemacs-translate--event-convert-list (list 'ergoemacs-shift basic))))) - (setq ergoemacs-translate--define-key-if-defined-p nil - ergoemacs-translate--define-key-replacement-function 'ergoemacs-command-loop--shift-translate) - (vector (ergoemacs-translate--event-convert-list (append modifiers (list 'ergoemacs-shift basic))))))) - (defun ergoemacs-translate--ergoemacs-timeout (key) "Translates KEY to allow Shift translation to default to key sequence. @@ -265,8 +244,7 @@ seleceted (instead of copying the text)." (not (or (memq 'shift (setq modifiers (ergoemacs-translate--event-modifiers (aref key 0)))) (memq 'ergoemacs-shift modifiers)))) (setq basic (ergoemacs-translate--event-basic-type (aref key 0)) - ergoemacs-translate--define-key-if-defined-p nil - ergoemacs-translate--define-key-replacement-function 'ergoemacs-command-loop--shift-timeout) + ergoemacs-translate--define-key-if-defined-p nil) (vector (ergoemacs-translate--event-convert-list (append modifiers (list 'shift basic))))))) (defun ergoemacs-translate--to-string (key) @@ -288,8 +266,7 @@ If no chanegs are performed, return nil." ergoemacs-translate--swap-menu ergoemacs-translate--to-string ergoemacs-translate--to-vector - ergoemacs-translate--ergoemacs-timeout - ergoemacs-translate--ergoemacs-shift-select) + ergoemacs-translate--ergoemacs-timeout) "Functions to apply to key. These functions take a key as an argument and translate it in @@ -305,8 +282,7 @@ variants are created using `ergoemacs-translate--apply-funs'." (dolist (fn ergoemacs-translate--apply-funs) (when (setq test-key (funcall fn key)) (apply function test-key args) - (setq ergoemacs-translate--define-key-if-defined-p t - ergoemacs-translate--define-key-replacement-function nil))))) + (setq ergoemacs-translate--define-key-if-defined-p t))))) @@ -326,7 +302,7 @@ This uses `ergoemacs-translate--apply-key'" key (lambda(new-key) (when (or ergoemacs-translate--define-key-if-defined-p (not (lookup-key keymap new-key))) - (define-key keymap new-key (or ergoemacs-translate--define-key-replacement-function def))))) + (define-key keymap new-key def)))) (setq ergoemacs-define-key-after-p nil))) (defun ergoemacs-translate--event-modifier-hash (&optional layout)