branch: externals/ergoemacs-mode commit 68682380605628942300fb6fbb738831f07127ce Merge: 21cab2a 5b285ea Author: Walter Landry <wlan...@caltech.edu> Commit: Walter Landry <wlan...@caltech.edu>
Merge branch 'master' into ergoterm --- Makefile | 4 +- ergoemacs-advice.el | 5 +- ergoemacs-command-loop.el | 209 +++--------------------- ergoemacs-component.el | 122 +------------- ergoemacs-debug.el | 4 +- ergoemacs-functions.el | 58 +------ ergoemacs-layouts.el | 14 +- ergoemacs-lib.el | 46 +----- ergoemacs-macros.el | 194 +--------------------- ergoemacs-map-properties.el | 39 +---- ergoemacs-map.el | 3 +- ergoemacs-mode.el | 256 ++--------------------------- ergoemacs-test.el | 386 +++++++++----------------------------------- ergoemacs-theme-engine.el | 55 ++----- ergoemacs-themes.el | 340 +++----------------------------------- ergoemacs-translate.el | 32 ++-- 16 files changed, 181 insertions(+), 1586 deletions(-) diff --git a/Makefile b/Makefile index 09b4822..6f0a0d7 100644 --- a/Makefile +++ b/Makefile @@ -105,12 +105,12 @@ start0: $(EMACS) -Q -L . -L .. -l ergoemacs-mode -l ergoemacs-test --eval "(ergoemacs-mode)" ert : - $(EMACS) $(EMACS_BATCH) -L . -L .. -l cl -l ergoemacs-mode -l ergoemacs-test --eval \ + $(EMACS) $(EMACS_BATCH) -L . -L .. -l cl-lib -l ergoemacs-mode -l ergoemacs-test --eval \ "(progn (setq ergoemacs-command-loop-type nil) \ (ert-run-tests-batch-and-exit '(and \"$(TESTS)\" $(SELECT) (not (tag :interactive)))))" || exit 1; \ erti : - $(EMACS) $(EMACS_BATCH) -L . -L .. -l cl -l ergoemacs-mode -l ergoemacs-test --eval \ + $(EMACS) $(EMACS_BATCH) -L . -L .. -l cl-lib -l ergoemacs-mode -l ergoemacs-test --eval \ "(progn (setq ergoemacs-command-loop-type nil) \ (fset 'ert--print-backtrace 'ignore) \ (ert-run-tests-batch-and-exit '(and \"$(TESTS)\" $(SELECT) (not (tag :interactive)))))" || exit 1; \ diff --git a/ergoemacs-advice.el b/ergoemacs-advice.el index e2320d3..7cfd3ad 100644 --- a/ergoemacs-advice.el +++ b/ergoemacs-advice.el @@ -330,10 +330,7 @@ TYPE is the type of translation installed." (type (or type :normal)) (translation (ergoemacs-translate--get type)) (local-keymap (ergoemacs-translate--keymap translation)) - (local-key (substring keys -1)) - modal-p) - (when (setq modal-p (ergoemacs :modal-p)) - (setq local-keymap (ergoemacs-translation-struct-keymap-modal modal-p))) + (local-key (substring keys -1))) (if (lookup-key local-keymap local-key) (let ((i 1)) ;; Setup history (setq ergoemacs-command-loop--history nil) diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el index 8628dbb..abde7ec 100644 --- a/ergoemacs-command-loop.el +++ b/ergoemacs-command-loop.el @@ -69,7 +69,6 @@ (declare-function ergoemacs-translation-struct-p "ergoemacs-translate") (declare-function ergoemacs-translation-struct-text "ergoemacs-translate") (declare-function ergoemacs-translation-struct-translation "ergoemacs-translate") -(declare-function ergoemacs-translation-struct-unchorded "ergoemacs-translate") (declare-function ergoemacs-key-description--modifier "ergoemacs-key-description") @@ -89,9 +88,6 @@ (defvar ergoemacs-default-cursor-color) (defvar ergoemacs-echo-function) (defvar ergoemacs-map--quit-map) -(defvar ergoemacs-modal-emacs-state-modes) -(defvar ergoemacs-modal-ignored-buffers) -(defvar ergoemacs-modal-ignored-keymap) (defvar ergoemacs-mode-started-p) (defvar guide-key/guide-key-sequence) (defvar keyfreq-mode) @@ -109,8 +105,6 @@ (defvar ergoemacs-command-loop--universal-functions '(universal-argument ergoemacs-universal-argument ergoemacs-command-loop--universal-argument) "List of `ergoemacs-mode' recognized functions.") -(define-obsolete-variable-alias 'ergoemacs-universal-fns 'ergoemacs-command-loop--universal-functions) - (defvar ergoemacs-command-loop--next-key-hash (let ((hash (make-hash-table))) (puthash 'event-apply-shift-modifier (list '(shift) :force) hash) @@ -135,8 +129,6 @@ This is to distinguish events in a terminal, like xterm. It needs to be less than `ergoemacs-command-loop-blink-rate'.") -(define-obsolete-variable-alias 'ergoemacs-read-key-delay 'ergoemacs-command-loop--decode-event-delay) - (defvar ergoemacs-command-loop--history nil "History of command loop locations.") @@ -177,9 +169,6 @@ ignore the post-command hooks.") (defvar ergoemacs-command-loop--echo-keystrokes-complete nil "Echoed keystrokes, keep echoing active.") -(defvar ergoemacs-command-loop--modal-stack '() - "The Modal Stack.") - (defvar ergoemacs-command-loop-swap-translation) (defvar ergoemacs-command-loop-time-before-blink) (defvar ergoemacs-command-loop-blink-character) @@ -188,87 +177,8 @@ ignore the post-command hooks.") (defvar ergoemacs-mode) (defvar ergoemacs-command-loop-type) (defvar ergoemacs-keymap) -(defvar ergoemacs-handle-ctl-c-or-ctl-x) -(defvar ergoemacs-ctl-c-or-ctl-x-delay) -(defun ergoemacs-command-loop--modal-show () - "Show modal translation. -Returns the mode-line text." - (let (tmp color text) - (ergoemacs-save-buffer-state - (cond - ((setq tmp (ergoemacs :modal-p)) - (setq color (ergoemacs-translation-struct-modal-color tmp)) - (if color - (set-cursor-color color) - (when ergoemacs-default-cursor-color - (set-cursor-color ergoemacs-default-cursor-color))) - (setq text (ergoemacs-translation-struct-text tmp)) - (when (functionp text) - (setq text (funcall text))) - (if text - (ergoemacs-mode-line ;; Indicate Alt+ in mode-line - text) - (ergoemacs-mode-line)) - (or text "Unnamed")) - (t - (when ergoemacs-default-cursor-color - (set-cursor-color ergoemacs-default-cursor-color)) - (ergoemacs-mode-line) - nil))))) - -(defun ergoemacs-command-loop--modal-p () - "Determine if the command should be modal. -If so return the translation." - (if (not ergoemacs-command-loop--modal-stack) nil - (let* ((translation (nth 0 ergoemacs-command-loop--modal-stack)) - (always) - tmp - ret) - (when (ergoemacs-translation-struct-p translation) - (setq always (ergoemacs-translation-struct-modal-always translation)) - (cond - ((and (minibufferp) - (not always))) - ((and (not always) - (memq major-mode ergoemacs-modal-emacs-state-modes))) - ((and (not always) - (catch 'match-modal - (dolist (reg ergoemacs-modal-ignored-buffers) - ((when (and (setq tmp (buffer-name)) (stringp tmp) (string-match reg tmp)) - (throw 'match-modal t)))) - nil))) - (t - (setq ret translation)))) - ret))) - -(defun ergoemacs-command-loop--modal-pop () - "Turn off the last ergoemacs modal in the modal-stack." - (when ergoemacs-command-loop--modal-stack - (ergoemacs-command-loop--modal (ergoemacs-translation-struct-key (nth 0 ergoemacs-command-loop--modal-stack))))) - -(defun ergoemacs-command-loop--modal (type) - "Toggle ergoemacs command modes. - -The TYPE is the type of command translation/modal keymaps that are installed." - (cond - ((or (not ergoemacs-command-loop--modal-stack) ;; First time to turn on - (not (eq (ergoemacs-translation-struct-key (nth 0 ergoemacs-command-loop--modal-stack)) type)) ;; New modal - ) - (push (ergoemacs-translate--get type) ergoemacs-command-loop--modal-stack) - (unless ergoemacs-default-cursor-color - (setq ergoemacs-default-cursor-color - (or (frame-parameter nil 'cursor-color) "black"))) - (ergoemacs-command-loop--message "%s command mode installed" (ergoemacs-command-loop--modal-show))) - - (t ;; Turn off. - (setq ergoemacs-command-loop--modal-stack (cdr ergoemacs-command-loop--modal-stack)) - (if (ergoemacs :modal-p) - (ergoemacs-command-loop--message "%s command mode resumed." (ergoemacs-command-loop--modal-show)) - (ergoemacs-command-loop--modal-show) - (ergoemacs-command-loop--message "Resume regular ergoemacs-mode"))))) - (defun ergoemacs-command-loop--redefine-quit-key (&optional key) "Redefines the quit-key in Emacs to KEY or Ctrl+g. @@ -313,7 +223,7 @@ This is called through `ergoemacs-command-loop'" ;; Command loop hasn't started. (setq current-prefix-arg '(4)) (setq ergoemacs-command-loop-start t) - (ergoemacs-command-loop nil (ergoemacs-command-loop--modal-p) nil t)) + (ergoemacs-command-loop nil nil nil t)) ((not current-prefix-arg) (setq current-prefix-arg '(4) ergoemacs-command-loop--universal t @@ -592,12 +502,6 @@ This is not done when the event is [ergoemacs-ignore]" ((not (numberp ergoemacs-command-loop-echo-keystrokes)) prompt) ((= 0 ergoemacs-command-loop-echo-keystrokes) prompt) ((< last-event-time ergoemacs-command-loop-echo-keystrokes) nil) - ;; ((and (not ergoemacs-command-loop--echo-keystrokes-complete) - ;; (numberp ergoemacs-command-loop-echo-keystrokes) - ;; (or (= 0 ergoemacs-command-loop-echo-keystrokes) - ;; (< last-event-time ergoemacs-command-loop-echo-keystrokes))) nil) - ;; ((and (< last-event-time ergoemacs-command-loop-time-before-blink) (string= prompt "")) nil) - ;; ((and (< last-event-time ergoemacs-command-loop-time-before-blink) ) nil) (t (setq ergoemacs-command-loop--echo-keystrokes-complete t) prompt))) @@ -663,11 +567,9 @@ inconjunction with `input-method-function' to translate keys if (ergoemacs-keymapp test-ret)) ;; The translation needs more keys... (if timeout-key - (setq next-key (with-timeout (ergoemacs-ctl-c-or-ctl-x-delay - (progn - (setq ergoemacs-command-loop--decode-event-timeout-p t) + (setq next-key (progn + (setq ergoemacs-command-loop--decode-event-timeout-p t) nil)) - (ergoemacs-command-loop--history nil ergoemacs-command-loop--decode-event-delay current-key))) (setq next-key (ergoemacs-command-loop--history nil ergoemacs-command-loop--decode-event-delay current-key))) (when next-key ;; Since a key was read, save it to be read later. (push last-command-event new-ergoemacs-input)) @@ -806,8 +708,7 @@ KEYS is the keys information" (defun ergoemacs-command--echo-prefix () "Echos prefix keys in the ergoemacs-mode way." - (let ((keys (this-single-command-keys)) - ret timeout) + (let ((keys (this-single-command-keys))) (when (and ergoemacs-command--timeout-timer (not (equal keys ergoemacs-command--timeout-keys))) (cancel-timer ergoemacs-command--timeout-timer) @@ -815,21 +716,15 @@ KEYS is the keys information" ergoemacs-command--timeout-timer nil)) (unless (or (equal [] keys) (ergoemacs-command-loop-p)) - (when (ergoemacs-keymapp (setq ret (key-binding keys))) - (when (setq timeout (key-binding (vconcat keys [ergoemacs-timeout]))) + (when (ergoemacs-keymapp (key-binding keys)) + (when (key-binding (vconcat keys [ergoemacs-timeout])) (cond - ((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)) (t (setq ergoemacs-command--timeout-keys keys - ergoemacs-command--timeout-timer - (run-at-time t ergoemacs-ctl-c-or-ctl-x-delay #'ergoemacs-command--timer-timeout))))) + ergoemacs-command--timeout-timer (ergoemacs-command--timer-timeout) + ) + ))) (unless unread-command-events (ergoemacs-command-loop--message "%s" (ergoemacs-command-loop--key-msg @@ -877,7 +772,6 @@ read." (text (ergoemacs-translation-struct-text translation)) (unchorded (ergoemacs-translation-struct-unchorded translation)) (trans (ergoemacs-translation-struct-translation translation)) - (modal (ergoemacs :modal-p)) (keys nil) (blink-on nil) input @@ -885,19 +779,7 @@ read." mod-keys tmp reset-key-p double) - ;; Setup modal translation - (when (and (eq type :normal) modal) - (setq type (ergoemacs-translation-struct-key modal) - local-keymap (ergoemacs-translation-struct-keymap-modal modal) - text (ergoemacs-translation-struct-text modal) - unchorded (ergoemacs-translation-struct-unchorded modal) - trans (ergoemacs-translation-struct-translation modal) - tmp translation - translation modal - modal tmp - tmp nil)) - ;; (ergoemacs-command-loop--read-key (read-kbd-macro "C-x" t) :unchorded-ctl) (when (functionp text) (setq text (funcall text))) @@ -984,17 +866,6 @@ read." ergoemacs-last-command-event last-command-event)) (t ;; Translate the key appropriately. - (when (and modal (lookup-key ergoemacs-modal-ignored-keymap (vector input))) - ;; Swap back, or ignore the modal translation. - (setq type (ergoemacs-translation-struct-key modal) - local-keymap (ergoemacs-translation-struct-keymap-modal modal) - text (ergoemacs-translation-struct-text modal) - unchorded (ergoemacs-translation-struct-unchorded modal) - trans (ergoemacs-translation-struct-translation modal) - tmp translation - translation modal - modal tmp - tmp nil)) (setq raw-input input input (ergoemacs-translate--event-mods input type) last-command-event input @@ -1130,7 +1001,7 @@ KEY is the key being read, or sequence being read. TYPE is the translation being used. -INITIAL-KEY-TYPE ist he key type that is used fot the initial +INITIAL-KEY-TYPE is the key type that is used fot the initial translation. UNIVERSAL is if the function will be calling a universal @@ -1193,7 +1064,7 @@ appropriate value based on the COMMAND." TYPE is the type of command loop to check for. By default this is the :full command loop." (and - (or (eq ergoemacs-command-loop-type (or type :full)) (ergoemacs :modal-p)) + (eq ergoemacs-command-loop-type (or type :full)) (ergoemacs-command-loop--minibuffer-supported-p) (catch 'excluded-variables (dolist (var ergoemacs-command-loop--excluded-variables) @@ -1235,9 +1106,9 @@ to start with (ergoemacs-command-loop-full-p)) (if ergoemacs-last-command-was-ergoemacs-ignore-p (unless (eq ergoemacs-last-command-was-ergoemacs-ignore-p :idle) - (run-with-idle-timer 0.05 nil (lambda() - (setq ergoemacs-last-command-was-ergoemacs-ignore-p :idle) - (ergoemacs-command-loop-start)))) + (run-with-timer 0.0 nil (lambda() + (setq ergoemacs-last-command-was-ergoemacs-ignore-p :idle) + (ergoemacs-command-loop-start)))) (push 'ergoemacs-ignore unread-command-events)))) (add-hook 'ergoemacs-post-command-hook #'ergoemacs-command-loop--start-with-post-command-hook) @@ -1698,7 +1569,7 @@ They don't exactly behave like their Emacs equivalents." (defun ergoemacs-command-loop--install-timer () "Install the `ergoemacs-command-loop--timer'." (setq ergoemacs-command-loop--timer - (run-with-idle-timer 0.05 nil #'ergoemacs-command-loop--timer))) + (run-with-timer 0.0 nil #'ergoemacs-command-loop--timer))) (defun ergoemacs-command-loop--remove-timer () "Remove `ergoemacs-command-loop--timer'." @@ -1779,7 +1650,6 @@ Emacs versions)." raw-key current-key last-current-key (translation (ergoemacs-translate--get type)) (local-keymap (ergoemacs-translate--keymap translation)) - modal-p tmp command) (unwind-protect (progn @@ -1819,8 +1689,6 @@ Emacs versions)." current-key (nth 1 raw-key) raw-key (nth 0 raw-key) continue-read nil) - (when (setq modal-p (ergoemacs :modal-p)) - (setq local-keymap (ergoemacs-translation-struct-keymap-modal modal-p))) (cond ;; Handle quit commands ((and last-current-key @@ -1834,16 +1702,14 @@ Emacs versions)." (setq quit-flag t ergoemacs-this-command-keys-shift-translated nil)) ;; Handle local commands. - ((and (or modal-p - (not (equal current-key raw-key))) + ((and (not (equal current-key raw-key)) (setq command (lookup-key local-keymap raw-key)) (not (ergoemacs-keymapp command)) ;; Ignore locally ;; Already handled by `ergoemacs-command-loop--read-key' (not (ergoemacs-gethash command ergoemacs-command-loop--next-key-hash)) ;; If a command has :ergoemacs-local property of :force, don't ;; worry about looking up a key, just run the function. - (or modal-p - (and (symbolp command) (eq (get command :ergoemacs-local) :force)) + (or (and (symbolp command) (eq (get command :ergoemacs-local) :force)) (not (key-binding current-key t)))) (pop ergoemacs-command-loop--history) ;; Don't recored local events (setq ergoemacs-command-loop--single-command-keys last-current-key @@ -2138,7 +2004,7 @@ 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) + tmp ret) (setq this-command-keys-shift-translated nil) (catch 'found-command (dolist (cur-key trials) @@ -2183,44 +2049,11 @@ pressed the translated key by changing (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)) - (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) @@ -2320,10 +2153,8 @@ For instance in QWERTY M-> is shift translated to M-." "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)))) + (setq ergoemacs-this-command-keys-shift-translated t) + (ergoemacs-command-loop--internal shift-trans))) (defun ergoemacs-command-loop--shift-translate () "Shift translation." diff --git a/ergoemacs-component.el b/ergoemacs-component.el index 3740e57..6519dfd 100644 --- a/ergoemacs-component.el +++ b/ergoemacs-component.el @@ -28,9 +28,7 @@ ;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Code: -;; (require 'guide-key nil t) + (require 'cl-lib) (eval-when-compile @@ -55,7 +53,6 @@ (defvar ergoemacs-theme-version) (defvar ergoemacs-translate--translation-hash) (defvar ergoemacs-translation-hash) -(defvar package--initialized) (declare-function diminish "diminish") (declare-function diminish-undo "diminish") @@ -95,8 +92,6 @@ (declare-function ergoemacs-key-description--keymap "ergoemacs-key-description") (declare-function ergoemacs-key-description--unicode-char "ergoemacs-key-description") -(declare-function package-installed-p "package") - (declare-function ergoemacs-layout--regexp "ergoemacs-layouts") (declare-function ergoemacs-layouts--list "ergoemacs-layouts") @@ -144,7 +139,6 @@ (variable-prefixes '([apps] [menu] [27]) :read-only t) (package-name nil) (autoloads nil) - (ensure nil) (layout "us" :read-only t) (calculated-layouts (make-hash-table :test 'equal)) (relative-to 'global-map) @@ -152,48 +146,8 @@ (defvar ergoemacs-component-struct--define-key-current nil) -(defvar ergoemacs-component-struct--ensure-refreshed-p t) -(defun ergoemacs-component-struct--ensure (package &optional defer autoloads) - "Ensure PACKAGE is installed. - -When DEFER is non-nil, dont `require' the package, just make sure -it is installed. - -The AUTOLOADS is a list of functions that need to be autoloaded -if the package is deferred." - (when package - (ergoemacs-timing ensure - (ergoemacs-timing (intern (format "ensure-%s" package)) - (let ((package (or (and (symbolp package) package) - (and (stringp package) (intern package))))) - (unless (or defer (featurep package)) - (require package nil t)) - (when (and package (not (featurep package)) (numberp defer)) - (run-with-idle-timer defer nil #'require package ;; `(lambda() - ;; (message ,(format "Defer: %s %s" package defer)) - ;; (require ,package) - ;; (ergoemacs-component-struct--apply-inits)) - ) - ) - (when (and defer autoloads) - (dolist (c autoloads) - (unless (fboundp (car c)) - (autoload (car c) (format "%s" (cdr c)) nil t)))) - (unless (featurep package) - (unless package--initialized - (package-initialize)) - (if (package-installed-p package) t - (unless ergoemacs-component-struct--ensure-refreshed-p - (package-refresh-contents) - (setq ergoemacs-component-struct--ensure-refreshed-p t)) - (unless (progn (ignore-errors (package-install package)) - (package-installed-p package)) - (ergoemacs-warn "ergoemacs-mode could not install %s." package)) - (unless defer - (require package nil t))))))))) - (defun ergoemacs-component-struct--parse-list (list function &rest args) - "Handle :bind and :mode LIST and call FUNCTION. + "Handle :bind LIST and call FUNCTION. The FUNCTION calls the with the first argument as the string piece and the second argument the symbol piece of the definition. @@ -210,8 +164,6 @@ It also passes ARGS if any are specified." (setq arg1 (pop list) arg2 (pop list)))) ((and (consp list) (stringp (car list))) - ;; :list ("C-." . ace-jump-mode) - ;; :list ("C-." ace-jump-mode) (apply function (car list) (or (and (consp (cdr list)) (nth 1 list)) (cdr list)) @@ -239,32 +191,6 @@ binding assumes KEYMAP is `global-map'." (ergoemacs-component-struct--parse-list bind #'ergoemacs-component-struct--handle-bind-1 keymap))) -(defun ergoemacs-component-struct--handle-mode-1 (regexpr mode) - "Add (cons REGEXPR MODE) to `auto-mode-alist'. -Also autoload MODE. - -Requires `ergoemacs-component-struct--define-key-current' to be -an `ergoemacs-component-struct' object." - ;; (message "Handle Mode #2: %s %s" regexpr mode) - (when (ergoemacs-component-struct-p ergoemacs-component-struct--define-key-current) - (let* ((c (cons regexpr mode)) - (obj ergoemacs-component-struct--define-key-current) - (package-name (ergoemacs-component-struct-package-name obj))) - (ergoemacs-component-struct--deferred - `(unless (member ',c auto-mode-alist) - (push ',c auto-mode-alist))) - (when (and package-name mode (not (fboundp mode))) - ;; Create autoload. - (autoload mode (format "%s, a major mode defined in %s" mode package-name) nil t) - (setq c (cons mode package-name)) - (unless (member c (ergoemacs-component-struct-autoloads obj)) - (push (cons mode package-name) (ergoemacs-component-struct-autoloads obj))))))) - -(defun ergoemacs-component-struct--handle-mode (mode) - "Handle MODE list from :mode keyword." - (when mode - (ergoemacs-component-struct--parse-list mode #'ergoemacs-component-struct--handle-mode-1))) - (defun ergoemacs-component-struct--create-component (plist body file) "Create ergoemacs component. @@ -284,7 +210,6 @@ FILE is the file name where the component was created." :variable-modifiers (or (plist-get plist :variable-modifiers) '(meta)) :variable-prefixes (or (plist-get plist :variable-prefixes) '([apps] [menu] [27])) :package-name (plist-get plist :package-name) - :ensure (plist-get plist :ensure) :layout (or (plist-get plist :layout) "us") :defer (plist-get plist :defer))) (let* ((tmp (plist-get plist :bind-keymap)) @@ -320,13 +245,6 @@ FILE is the file name where the component was created." (setf (ergoemacs-component-struct-defer ergoemacs-component-struct--define-key-current) t)) (ergoemacs-component-struct--handle-bind tmp 'ergoemacs-override-keymap) - ;; Handle :mode - (setq tmp (plist-get plist :mode)) - (when (and tmp (not defer-present-p) (not defer)) - (setq defer-present-p t defer t) - (setf (ergoemacs-component-struct-defer ergoemacs-component-struct--define-key-current) t)) - (ergoemacs-component-struct--handle-mode tmp) - ;; Handle :commands (setq tmp (plist-get plist :commands)) (when (and tmp (not defer-present-p) (not defer)) @@ -1071,7 +989,6 @@ OBJECT is the `ergoemacs-component-struct' object being changed." (defvar ergoemacs-component-struct--deferred-functions '()) (defvar ergoemacs-component-struct--apply-inits-first-p t) -(defvar ergoemacs-component-struct--apply-ensure-p nil) (defvar ergoemacs-component-struct--applied-plists nil) (defvar ergoemacs-component-echo-loaded-file-p nil) @@ -1096,10 +1013,9 @@ to prevent infinite recursion." (when (eq ergoemacs-component-struct--refresh-variables t) (setq ergoemacs-component-struct--refresh-variables ergoemacs-component-struct--applied-inits)) (let* ((obj (or obj (ergoemacs-theme-components))) - package-name ensure defer comp tmp autoloads) + tmp) (when ergoemacs-component-struct--apply-inits-first-p - (setq ergoemacs-component-struct--apply-inits-first-p nil - ergoemacs-component-struct--apply-ensure-p t) + (setq ergoemacs-component-struct--apply-inits-first-p nil) (if (not ergoemacs-mode--fast-p) (setq ergoemacs--start-emacs-state-2 (ergoemacs--emacs-state)) ;; Check to see if emacs state has changed. @@ -1117,33 +1033,6 @@ to prevent infinite recursion." 'ergoemacs--last-start-emacs-state-2 ergoemacs--last-start-emacs-state-2)) (ergoemacs-mode-clear-cache t) (ergoemacs-warn "ergoemacs-mode cache reset AFTER loading; Keys may be slightly inconsistent until emacs restart."))))) - (when ergoemacs-component-struct--apply-ensure-p - (setq ergoemacs-component-struct--apply-ensure-p nil) - ;; Ensure packages - (dolist (elt obj) - (setq comp (ergoemacs-component-struct--lookup-hash elt) - package-name (ergoemacs-component-struct-package-name comp) - ensure (ergoemacs-component-struct-ensure comp) - autoloads (ergoemacs-component-struct-autoloads comp) - defer (ergoemacs-component-struct-defer comp)) - (cond - ((eq ensure t) - (ergoemacs-component-struct--ensure package-name defer autoloads)) - ((and ensure (symbolp ensure)) - (ergoemacs-component-struct--ensure ensure defer autoloads)) - ((and (consp ensure) (memq (car ensure) '(memq member and or if when = string= not string< eq equal))) - (when (ignore-errors (eval ensure)) - (ergoemacs-component-struct--ensure package-name defer autoloads))) - ((consp ensure) - (dolist (elt ensure) - (cond - ((and elt (symbolp elt)) - (ergoemacs-component-struct--ensure elt defer autoloads)) - ((stringp elt) - (ergoemacs-component-struct--ensure (intern elt) defer autoloads))) - (setq autoloads nil))) - ((stringp ensure) - (ergoemacs-component-struct--ensure (intern ensure) defer autoloads))))) ;; Turn on plist options (like :diminish) (dolist (elt obj) (unless (memq elt ergoemacs-component-struct--applied-plists) @@ -1192,7 +1081,7 @@ to prevent infinite recursion." (when (ignore-errors (boundp (nth 1 (nth 1 (nth 0 init))))) (apply 'add-to-list (nth 1 (nth 1 (nth 0 init))) (cdr (cdr (nth 0 init)))) (push (nth 0 init) ergoemacs-component-struct--deferred-functions))))) - ((memq (car (nth 0 init)) '(push pushnew cl-pushnew)) + ((memq (car (nth 0 init)) '(push cl-pushnew)) (when (ignore-errors (boundp (nth 2 (nth 0 init)))) (if (ignore-errors (eq 'quote (nth 1 (nth 1 (nth 0 init))))) (ignore-errors @@ -1735,7 +1624,6 @@ lists. It can also be the symbol name of the package. uu When TYPE is non-nil, the function turns off the diminish modifications with `diminish-undo'" - (ignore-errors (ergoemacs-component-struct--ensure 'diminish)) (require 'diminish nil t) (if (not (featurep 'diminish)) (message "Error installing diminish package.") diff --git a/ergoemacs-debug.el b/ergoemacs-debug.el index 465e959..2123777 100644 --- a/ergoemacs-debug.el +++ b/ergoemacs-debug.el @@ -28,9 +28,7 @@ ;; along with this program. If not, see <http://www.gnu.org/licenses/>. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;;; Code: -;; (require 'guide-key nil t) + (require 'cl-lib) (eval-when-compile diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el index 5c46645..0f8888c 100644 --- a/ergoemacs-functions.el +++ b/ergoemacs-functions.el @@ -38,7 +38,6 @@ (defvar apropos-do-all) (defvar cua--last-killed-rectangle) (defvar dirtrack-list) -(defvar ergoemacs-command-loop--modal-stack) (defvar ergoemacs-dir) (defvar ergoemacs-keyboard-layout) (defvar ergoemacs-mode) @@ -66,7 +65,6 @@ (declare-function ergoemacs-map-- "ergoemacs-map") (declare-function ergoemacs-mode "ergoemacs-mode") -(declare-function ergoemacs-command-loop--modal-pop "ergoemacs-command-loop") (declare-function ergoemacs-theme-describe "ergoemacs-theme-engine") (declare-function helm-attrset "helm") @@ -102,21 +100,6 @@ '(delete-backward-char delete-char kill-word backward-kill-word) "Defines deletion functions that ergoemacs is aware of.") -(defcustom ergoemacs-ctl-c-or-ctl-x-delay 0.2 - "Delay before sending Cut or Copy. -This is applied when using Ctrl+c and Ctrl+x." - :type '(choice (number :tag "Inhibit delay") - (const :tag "No delay" nil)) - :group 'ergoemacs-mode) - -(defcustom ergoemacs-handle-ctl-c-or-ctl-x 'both - "Type of Copy and Paste handling for `ergoemacs-mode'." - :type '(choice - (const :tag "C-c/C-x only copy/cut" only-copy-cut) - (const :tag "C-c/C-x only Emacs C-c and C-x" only-C-c-and-C-x) - (const :tag "C-c/C-x copy/paste when region active, Emacs C-c/C-x otherwise." both)) - :group 'ergoemacs-mode) - (defvar ergoemacs-revert-buffer 0) (defun ergoemacs-revert-buffer () "Ergoemacs replacement of `revert-buffer'. @@ -357,8 +340,8 @@ If TERMINAL is non-nil, run the terminal version" (defun ergoemacs-emacs-exe () "Get the Emacs executable for testing purposes." - (let* ((emacs-exe (invocation-name)) - (emacs-dir (invocation-directory)) + (let* ((emacs-exe invocation-name) + (emacs-dir invocation-directory) (full-exe (concat "\"" (expand-file-name emacs-exe emacs-dir) "\""))) full-exe)) @@ -1629,26 +1612,6 @@ by `ergoemacs-maximum-number-of-files-to-open'. (when (> (length ergoemacs-recently-closed-buffers) ergoemacs-recently-closed-buffers-max) (setq ergoemacs-recently-closed-buffers (butlast ergoemacs-recently-closed-buffers 1))))) -(defun ergoemacs-redo () - "Redo using either `redo' or `undo-tree-redo'. -Installs `undo-tree' if not present." - (interactive "*") - (require 'undo-tree nil t) - (cond - ((fboundp 'redo) - (call-interactively 'redo)) - ((fboundp 'undo-tree-redo) - (call-interactively 'undo-tree-redo)) - (t - (if (not (yes-or-no-p "Redo command not found, install undo-tree for redo?")) - (error "Redo not found, need undo-tree or redo commands present.") - (package-refresh-contents) ;;available in gnu elpa. - (package-initialize) - (package-install 'undo-tree) - (require 'undo-tree) - (undo-tree-mode 1) - (call-interactively 'undo-tree-redo))))) - (defun ergoemacs-keyboard-quit () "Quit the current command/process. Similar to `keyboard-quit', with the following changes: @@ -1658,9 +1621,6 @@ Similar to `keyboard-quit', with the following changes: • When a region is active, (see `region-active-p') deactivate the region with the function `deactivate-mark'. -• When `ergoemacs-mode' is in a modal command mode, exit that - command mode. - • When \"C-g\" is bound to something other than ergoemacs / standard quit commands, run that command. @@ -1677,8 +1637,6 @@ Similar to `keyboard-quit', with the following changes: (setq saved-region-selection nil) (let (select-active-regions) (deactivate-mark))) - (ergoemacs-command-loop--modal-stack - (ergoemacs-command-loop--modal-pop)) ((and (setq bind (key-binding [7])) ;; C-g (not (memq bind '(ergoemacs-keyboard-quit minibuffer-keyboard-quit keyboard-quit)))) (call-interactively bind)) @@ -2342,12 +2300,6 @@ If arg is a negative prefix, copy file path only" :type 'string :group 'ergoemacs-mode) -;;; Unaccent region taken and modified from Drew Adam's unaccent.el - -(require 'strings nil t) ;; (no error if not found): region-description - -;;;;;;;;;;;;;;;;;;;;;;;; - (defvar ergoemacs-reverse-iso-chars-alist '(;; Trema/umlaut (äëïöü) (ÄËÏÖÜ) @@ -2433,8 +2385,6 @@ Guillemet -> quote, degree -> @, s-zed -> ss, upside-down ?! -> ?!." (setq nbn (generate-new-buffer-name nbn)) (rename-buffer nbn)))) -;; (add-hook 'dirtrack-directory-change-hook 'ergoemacs-shell-here-directory-change-hook) - (defun ergoemacs-shell-here-hook () "Hook for `ergoemacs-shell-here'. Sends shell prompt string to process, then turns on @@ -2460,8 +2410,6 @@ Sends shell prompt string to process, then turns on (shell-dirtrack-mode -1) (dirtrack-mode 1)))))) -;; (add-hook 'shell-mode-hook 'ergoemacs-shell-here-hook) - (defun ergoemacs-shell-here (&optional shell-program buffer-prefix) "Runs/switches to a shell process in the current directory." (interactive) @@ -2485,8 +2433,6 @@ Sends shell prompt string to process, then turns on (ergoemacs-shell-here nil "MSYS")) (error "Need to specify `ergoemacs-msys'."))) -;; (add-hook 'eshell-post-command-hook 'ergoemacs-shell-here-directory-change-hook) - (defun ergoemacs-eshell-here () "Run/switch to an `eshell' process in the current directory" (interactive) diff --git a/ergoemacs-layouts.el b/ergoemacs-layouts.el index dc3f913..2049b9b 100644 --- a/ergoemacs-layouts.el +++ b/ergoemacs-layouts.el @@ -69,6 +69,7 @@ ;; From Baptiste Fouques ;; changed to bepo because it breaks how I run things (unfortunately)... +(defvaralias 'ergoemacs-layout-bépo 'ergoemacs-layout-bepo) (defvar ergoemacs-layout-bepo '("" "$" "\"" "«" "»" "(" ")" "@" "+" "-" "/" "*" "=" "%" "" "" "" "b" "é" "p" "o" "è" "^" "v" "d" "l" "j" "z" "w" "" @@ -95,8 +96,6 @@ "" ">" "W" "X" "C" "V" "B" "N" "?" "." "/" "+" "" "" "") "Belgian AZERTY.") -(defvaralias 'ergoemacs-layout-bépo 'ergoemacs-layout-bepo) - (defvar ergoemacs-layout-colemak '("" "`" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "-" "=" "" "" "" "q" "w" "f" "p" "g" "j" "l" "u" "y" ";" "[" "]" "\\" @@ -122,6 +121,7 @@ "Danish layout.") ;; From Thomas Rikl +(defvaralias 'ergoemacs-layout-ge 'ergoemacs-layout-de) (defvar ergoemacs-layout-de '("" "" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "ß" "" "" "" "" "q" "w" "e" "r" "t" "z" "u" "i" "o" "p" "ü" "+" "" @@ -146,6 +146,7 @@ "" "" "K" "Y" "Ö" "Ä" "Q" "J" "G" "W" "V" "Z" "" "" "") "German BU-TECK Layout. URL `http://www.adnw.de'.") +(defvaralias 'ergoemacs-layout-us_dvorak 'ergoemacs-layout-dv) (defvar ergoemacs-layout-dv '("" "`" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "[" "]" "" "" "" "'" "," "." "p" "y" "f" "g" "c" "r" "l" "/" "=" "\\" @@ -182,6 +183,7 @@ "" "" "Z" "Ĉ" "C" "V" "B" "N" "M" ";" ":" "?" "" "" "") "Esperanto (displaced semicolon and quote, obsolete) layout.") +(defvaralias 'ergoemacs-layout-sp 'ergoemacs-layout-es) (defvar ergoemacs-layout-es '("" "°" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "'" "¡" "" "" "" "q" "w" "e" "r" "t" "y" "u" "i" "o" "p" "`" "+" "" @@ -255,8 +257,6 @@ "" "|" ":" "Q" "J" "K" "X" "B" "M" "W" "V" "Z" "" "" "") "UK Dvorak layout.") -(defvaralias 'ergoemacs-layout-ge 'ergoemacs-layout-de) - (defvar ergoemacs-layout-it '("" "\\" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "'" "¡" "" "" "" "q" "w" "e" "r" "t" "y" "u" "i" "o" "p" "è" "+" "" @@ -317,8 +317,6 @@ "" "»" "Y" "Ç" "J" "B" "K" "Q" "V" "G" "F" "Z" "" "" "") "PT Nativo layout URL `http://xahlee.info/kbd/pt-nativo_keyboard_layout.html'.") -(defvaralias 'ergoemacs-layout-sp 'ergoemacs-layout-es) - (defvar ergoemacs-layout-sw '("" "½" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "+" "’" "" "" "" "q" "w" "e" "r" "t" "y" "u" "i" "o" "p" "å" "\"" "" @@ -343,8 +341,6 @@ "" "" "Z" "X" "C" "V" "B" "N" "M" "<" ">" "?" "" "" "") "US English QWERTY layout.") -(defvaralias 'ergoemacs-layout-us_dvorak 'ergoemacs-layout-dv) - (defvar ergoemacs-layout-workman '("" "`" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "-" "=" "" "" "" "q" "d" "r" "w" "b" "j" "f" "u" "p" ";" "[" "]" "\\" @@ -369,6 +365,7 @@ "" "" "Z" "X" "M" "C" "V" "K" "L" "<" ">" "?" "" "" "") "US Workman layout. URL `http://www.workmanlayout.com/blog/'.") +(defvaralias 'ergoemacs-layout-jcuken 'ergoemacs-layout-ru) (defvar ergoemacs-layout-ru '("" "" "1" "2" "3" "4" "5" "6" "7" "8" "9" "0" "-" "=" "\\" "" "" "й" "ц" "у" "к" "е" "н" "г" "ш" "щ" "з" "х" "ъ" "" @@ -381,7 +378,6 @@ "" "" "Я" "Ч" "С" "М" "И" "Т" "Ь" "Б" "Ю" "," "" "" "") "Russian/Cryllic jcuken layout.") -(defvaralias 'ergoemacs-layout-jcuken 'ergoemacs-layout-ru) (require 'help-mode) (defvar quail-keyboard-layout-alist) diff --git a/ergoemacs-lib.el b/ergoemacs-lib.el index 8cd92a6..7050c9a 100644 --- a/ergoemacs-lib.el +++ b/ergoemacs-lib.el @@ -44,12 +44,7 @@ (defvar ergoemacs-require) (defvar ergoemacs-theme-hash) (defvar ergoemacs-timing-hash) -(defvar ergoemacs-component-struct--apply-ensure-p) -(defvar package-archives) - -(defvar tabbar-mode) -(defvar ergoemacs-handle-ctl-c-or-ctl-x) (defvar ergoemacs-dir) @@ -77,10 +72,6 @@ (declare-function ergoemacs-component-find-definition "ergoemacs-component") (declare-function ergoemacs-component-find-1 "ergoemacs-component") -(declare-function tabbar-install-faces "tabbar-ruler") -(declare-function tabbar-mode "tabbar") - - (defun ergoemacs-setcdr (var val &optional default) "Use `setcdr' on VAL to VAL. If VAL is a symbol, use `ergoemacs-sv' to determine the value. @@ -253,7 +244,6 @@ When TYPE is nil, assume the type is 'required-hidden REMOVE represents when you would remove the OPTION from the ergoemacs THEME." - (setq ergoemacs-component-struct--apply-ensure-p t) (unless (member (list option theme type remove) ergoemacs-require) (push (list option theme type remove) ergoemacs-require)) (if ergoemacs-require--ini-p @@ -406,39 +396,12 @@ All other modes are assumed to be minor modes or unimportant. (push `(,(intern current-letter) menu-item ,current-letter (keymap ,@cur-lst)) ret)) ;; Now create nested menu. - `(keymap ,@ret - (separator1 menu-item "--") - (package menu-item "Manage Packages" list-packages)))) - -(defun ergoemacs-menu-tabbar-toggle () - "Enables/Disables (and installs if not present) a tab-bar for emacs." - (interactive) - (require 'package nil t) - (if (not (fboundp 'tabbar-mode)) - (let ((package-archives '(("melpa" . "http://melpa.org/packages/")))) - (require 'tabbar-ruler nil t) - (if (fboundp 'tabbar-install-faces) - (tabbar-install-faces) - (when (fboundp 'package-install) - (package-refresh-contents) - (package-initialize) - (package-install 'tabbar-ruler) - (require 'tabbar-ruler nil t) - (tabbar-install-faces)))) - (if (not (featurep 'tabbar-ruler)) - (require 'tabbar-ruler nil t) - (if tabbar-mode - (tabbar-mode -1) - (tabbar-mode 1))))) + `(keymap ,@ret))) (defun ergoemacs-menu--filter-key-shortcut (cmd &optional keymap) "Figures out ergoemacs-mode menu's preferred key-binding for CMD." (cond ((not cmd)) - ((and (memq ergoemacs-handle-ctl-c-or-ctl-x '(only-copy-cut both)) - (eq cmd 'ergoemacs-cut-line-or-region)) (ergoemacs-key-description--menu (kbd "C-x")) ) - ((and (memq ergoemacs-handle-ctl-c-or-ctl-x '(only-copy-cut both)) - (eq cmd 'ergoemacs-copy-line-or-region)) (ergoemacs-key-description--menu (kbd "C-c"))) (t ;;; FIXME: faster startup by creating component alists ;; SLOW: 2-seconds @@ -446,12 +409,6 @@ All other modes are assumed to be minor modes or unimportant. (when (memq (elt key 0) '(menu-bar remap again redo cut copy paste help open find ergoemacs-remap execute)) (setq key nil)) (and key (ergoemacs-key-description--menu key))) - ;; (let ((key (ergoemacs-gethash cmd (ergoemacs (ergoemacs :global-map) :where-is)))) - ;; (when key - ;; (setq key (nth 0 key))) - ;; (when (memq (elt key 0) '(menu-bar remap again redo cut copy paste help open find ergoemacs-remap execute)) - ;; (setq key nil)) - ;; (or (and key (ergoemacs-key-description--menu key)) "")) ))) @@ -706,7 +663,6 @@ EVENT is used when this is called from a mouse event." (let ((sym (format "%s" symname))) (unless (catch 'found (dolist (lst '(("initialize-\\(.*\\)\\'" "Initialize ") - ("ensure-\\(.*\\)\\'" "Ensure ") ("create-component-\\(.*\\)\\'" "Create Component ") ("translate-keymap-\\(.*\\)\\'" "Translate Keymap "))) (when (string-match (nth 0 lst) sym) diff --git a/ergoemacs-macros.el b/ergoemacs-macros.el index 4cb1dda..ee8c41a 100644 --- a/ergoemacs-macros.el +++ b/ergoemacs-macros.el @@ -252,12 +252,10 @@ macro." :bind* :bind-keymap* :commands - :mode :interpreter :defer :demand :diminish - :ensure :package-name :ergoemacs-require :no-load @@ -334,7 +332,7 @@ This accepts the following keywords: :defer -- Should this package's loading be deferred? When using :commands :bind :bind* :bind-keymap :bind-keymap* - :mode or :interperter, defer is implied. When :package-name + or :interperter, defer is implied. When :package-name is nil, this dosen't do anything. :demand -- Prevent deferred loading in all cases @@ -350,30 +348,8 @@ This accepts the following keywords: By default this is nil. -:mode -- Modes to be added to `auto-mode-alist'. This can be a string such as: - -(ergoemacs-package ruby-mode - :mode \"\\\\.rb\\\\'\") - -or a list - -(ergoemacs-package ruby-mode - :mode (\"\\\\.rb\\\\'\" . ruby-mode)) - -or a list of modes: - -(ergoemacs-package ess-site - :ensure ess - :mode ((\"\\\\.R\\\\'\" . R.mode) - (\"\\\\.[Ss][Aa][Ss]\\\\'\" . SAS-mode))) - Borrowed from `use-package'. -:ensure -- If the package should be installed by `package' if not present. - -This can be t to install the :package-name symbol. Otherwise -it can be a list of symbols or single symbol. - :package-name -- Name of package to load. When non-nil any key defition to a single command will create an autoload for that command. @@ -443,159 +419,9 @@ on the definition: ,(when (plist-get (nth 0 kb) :ergoemacs-require) `(ergoemacs-require ',(intern (plist-get (nth 0 kb) :name))))))) -(defmacro ergoemacs-package (name &rest keys-and-body) - "Defines a required package named NAME. - -KEYS-AND-BODY will be processed by -`ergoemacs-theme-component--parse-keys-and-body'. - -The documentation of the supported keys are in -`ergoemacs-theme-component'. - -The NAME will be assumed to be the :package-name keyword. - -By default, this package also set the :ergoemacs-require to t, -requiring the ergoemacs theme component immediately. To turn off -this feature, you can specify :ergoemacs-require nil in the body -of the `ergoemacs-package' macro. Another option is to use -`ergoemacs-autoload', which is the same as `ergoemacs-package' -with :ergoemacs-require set to nil." - (declare (indent 2)) - (let ((kb (make-symbol "body-and-plist")) - (plist (make-symbol "plist")) - (body (make-symbol "body")) - (doc (make-symbol "doc"))) - (setq kb (ergoemacs-theme-component--parse-keys-and-body keys-and-body nil t) - plist (nth 0 kb) - body (nth 1 kb)) - (when (equal (car body) '()) - (setq body (cdr body))) - (setq doc (if (stringp (car body)) (pop body) (symbol-name name))) - (unless (memq :ergoemacs-require plist) ;; Its a required theme component. - (setq plist (plist-put plist :ergoemacs-require name))) - (unless (plist-get plist :package-name) - (setq plist (plist-put plist :package-name name))) - (macroexpand-all - `(ergoemacs-theme-component ,name () - ,doc - ,@plist - ;; (require ',name) - ,@body)))) - -(defmacro ergoemacs-autoload (name &rest keys-and-body) - "Defines a required package named NAME. - -KEYS-AND-BODY will be processed by -`ergoemacs-theme-component--parse-keys-and-body'. - -The documentation of the supported keys are in -`ergoemacs-theme-component'. - -The NAME will be assumed to be the :package-name keyword. - -By default, this package also set the :ergoemacs-require to nil, -deferring the ergoemacs theme component until it is required by -the user by either `ergoemacs-require' or turning it on/off in an -ergoemacs-mode theme. To turn off this feature, you can -specify :ergoemacs-require t in the body of the -`ergoemacs-autoload' macro. Another option is to use -`ergoemacs-package', which is the same as `ergoemacs-autoload' -with :ergoemacs-require set to t." - (declare (indent 2)) - (let ((kb (make-symbol "body-and-plist")) - (plist (make-symbol "plist")) - (body (make-symbol "body")) - (doc (make-symbol "doc"))) - (setq kb (ergoemacs-theme-component--parse-keys-and-body keys-and-body nil t) - plist (nth 0 kb) - body (nth 1 kb)) - (when (equal (car body) '()) - (setq body (cdr body))) - (setq doc (if (stringp (car body)) (pop body) (symbol-name name))) - (unless (plist-get plist :package-name) - (setq plist (plist-put plist :package-name name))) - (macroexpand-all - `(ergoemacs-theme-component ,name () - ,doc - ,@plist - ,@body)))) - -;;;###autoload -(defmacro ergoemacs-test-layout (&rest keys-and-body) - (let ((kb (make-symbol "body-and-plist")) - (plist (make-symbol "plist")) - (body (make-symbol "body"))) - (setq kb (ergoemacs-theme-component--parse-keys-and-body keys-and-body nil t) - plist (nth 0 kb) - body (nth 1 kb)) - (macroexpand-all - `(let ((old-ergoemacs-theme (ergoemacs :current-theme)) - (old-type ergoemacs-command-loop-type) - (old-paste interprogram-paste-function) - (old-cut interprogram-cut-function) - ;; (old-kill kill-ring) - ;; (old-pointer kill-ring-yank-pointer) - (old-version (ergoemacs :current-version)) - (macro - ,(if (plist-get plist :macro) - `(edmacro-parse-keys ,(plist-get plist :macro) t))) - (old-ergoemacs-keyboard-layout ergoemacs-keyboard-layout) - (reset-ergoemacs nil)) - (setq ergoemacs-theme ,(plist-get plist ':current-theme) - ergoemacs-keyboard-layout ,(or (plist-get plist ':layout) "us") - ergoemacs-command-loop-type nil - interprogram-paste-function nil - interprogram-cut-function nil - ;; kill-ring nil - ;; kill-ring-yank-pointer nil - - ;; Make sure the copy functions don't think the last - ;; command was a copy. - last-command 'ergoemacs-test) - (ergoemacs-theme-set-version ,(or (plist-get plist ':version) nil)) - (unless (and (equal old-ergoemacs-theme ergoemacs-theme) - (equal old-ergoemacs-keyboard-layout ergoemacs-keyboard-layout) - (equal old-version (ergoemacs :current-vresion))) - (setq reset-ergoemacs t) - (ergoemacs-mode-reset)) - - ,(if (plist-get plist :cua) - `(cua-mode 1)) - (unwind-protect - (progn - ,@body) - (setq ergoemacs-command-loop-type old-type - ergoemacs-theme old-ergoemacs-theme - ergoemacs-keyboard-layout old-ergoemacs-keyboard-layout - interprogram-paste-function old-paste - interprogram-cut-function old-cut - ;; kill-ring old-kill - ;; kill-ring-yank-pointer old-pointer - ) - (ergoemacs-theme-set-version old-version) - (when reset-ergoemacs - (ergoemacs-mode-reset))))))) - (defvar ergoemacs-theme-components--modified-plist nil "Modified plist.") -(fset 'ergoemacs-theme-component--add-ensure - #'(lambda (plist pkg) - "Add PKG to the :ensure keyword." - (let ((cur-ensure (plist-get plist :ensure)) - (cur-pkg (intern (format "%s" (plist-get plist :package-name))))) - (cond - ((eq cur-ensure t) - (setq ergoemacs-theme-components--modified-plist - (plist-put plist :ensure (list pkg cur-pkg)))) - ((not cur-ensure) - (setq ergoemacs-theme-components--modified-plist - (plist-put plist :ensure pkg))) - ((not (memq pkg cur-ensure)) - (push pkg cur-ensure) - (setq ergoemacs-theme-components--modified-plist - (plist-put plist :ensure cur-ensure))))))) - (fset 'ergoemacs-theme-component--parse-keys-and-body #'(lambda (keys-and-body &optional parse-function skip-first) "Split KEYS-AND-BODY into keyword-and-value pairs and the remaining body. @@ -864,16 +690,6 @@ When arg1 can be a property. The following properties are supported: (if (>= 25 emacs-major-version) `(gui-set-selection ,@(cdr args)) `(x-set-selection ,@(cdr args)))) - ((and arg1 (symbolp arg1) (eq arg1 :width)) - `(ergoemacs-mode--eval-width ,arg2)) - ((and arg1 (symbolp arg1) (eq arg1 :mode-if) arg2) - `(ergoemacs-mode-line--if ,arg2 ,arg3 ,arg4)) - ((and arg1 (symbolp arg1) (memq arg1 '(:sep :separator))) - `(ergoemacs-mode-line--sep ,@(cdr args))) - ((and arg1 (symbolp arg1) (memq arg1 '(:sep-right :separator-right))) - `(ergoemacs-mode-line--sep 'right ,@(cdr args))) - ((and arg1 (symbolp arg1) (memq arg1 '(:sep-left :separator-left))) - `(ergoemacs-mode-line--sep 'left ,@(cdr args))) ((and arg1 (symbolp arg1) (eq arg1 :custom-p) (symbolp arg2)) (if (fboundp 'custom-variable-p) `(custom-variable-p ,arg2) @@ -890,8 +706,6 @@ When arg1 can be a property. The following properties are supported: `(ergoemacs-map-properties--before-ergoemacs)) ((and arg1 (symbolp arg1) (eq arg1 :user-after) (not arg2) (not arg3)) `(ergoemacs-map-properties--before-ergoemacs t)) - ((and arg1 (symbolp arg1) (eq arg1 :modal-p)) - `(ergoemacs-command-loop--modal-p)) ((and arg1 (symbolp arg1) (eq arg1 :combine) arg2 arg3) `(ergoemacs-command-loop--combine ,arg2 ,arg3)) ((and arg1 (symbolp arg1) (memq arg1 '(:unicode-or-alt :unicode))) @@ -909,9 +723,6 @@ When arg1 can be a property. The following properties are supported: (memq arg1 ergoemacs--map-properties-list)) `(,(intern (format "ergoemacs-map-properties--%s" (substring (symbol-name arg1) 1))) ,@(cdr args))) - ((and arg1 arg2 (eq arg2 :new-command) arg3) - ;; (ergoemacs arg1 :new-command 'next-line) - `(ergoemacs-map-properties--new-command ,arg1 ,arg3)) ((and arg1 (symbolp arg1) (eq arg1 :global-map)) `(ergoemacs-map-properties--original (or ergoemacs-saved-global-map global-map))) @@ -969,8 +780,7 @@ When arg1 can be a property. The following properties are supported: :keymap -- Local Keymap for translation :keymap-modal -- Modal keymap for overrides. :modal-always -- If the modal state is always on, regardless of - the values of `ergoemacs-modal-ignored-buffers', - `ergoemacs-modal-emacs-state-modes' `minibufferp' + the values of `minibufferp' The following arguments allow the keyboard presses to be translated: - :meta - :control diff --git a/ergoemacs-map-properties.el b/ergoemacs-map-properties.el index 6793600..c5fe061 100644 --- a/ergoemacs-map-properties.el +++ b/ergoemacs-map-properties.el @@ -35,8 +35,6 @@ (eval-when-compile (require 'ergoemacs-macros)) -(require 'package) - (defvar ergoemacs-translate--parent-map) (defvar ergoemacs-translate--modal-parent-map) (defvar ergoemacs--gzip) @@ -594,9 +592,7 @@ These keymaps are saved in `ergoemacs-map-properties--hook-map-hash'." "Hash Table of defined/undefined keys.") (defvar ergoemacs-map-properties--deferred-hooks-directory-regexp - (concat "\\`" (regexp-opt (append package-directory-list - (list package-user-dir) - (list (file-name-directory (locate-library "abbrev"))) + (concat "\\`" (regexp-opt (append (list (file-name-directory (locate-library "abbrev"))) ergoemacs-directories-where-keys-from-hook-are-deferred) t)) "Regular experssion of libraries where maps are deferred.") @@ -818,8 +814,6 @@ When LABEL-EMPTY-P is non-nil, also label empty maps." (mapatoms #'ergoemacs-map-properties--label-map)) ;; Startup and load functions -;;(add-hook 'ergoemacs-mode-after-init-emacs 'ergoemacs-map-properties--label-unlabeled) -;;(add-hook 'ergoemacs-mode-after-load-hook 'ergoemacs-map-properties--label-unlabeled) (defun ergoemacs-map-properties--label-known () "Label known maps." @@ -919,9 +913,7 @@ STRUCT is the keymap structure for the current map." (map-key (error "Will not label a composed map's members to %s" map-key)) (t - (let ((parent (keymap-parent keymap)) - (breadcrumb-base ergoemacs-map--breadcrumb) - (struct (or struct (ergoemacs-gethash map-key ergoemacs-map-properties--key-struct))) + (let ((breadcrumb-base ergoemacs-map--breadcrumb) (comp (plist-get struct :composed)) (comp-list (ergoemacs-map-properties--composed-list keymap)) from-prop-p @@ -941,10 +933,6 @@ STRUCT is the keymap structure for the current map." (if comp (ergoemacs :label map nil (pop comp)) (ergoemacs :label map))) - ;; (when parent - ;; (when (and breadcrumb-base (not (string= breadcrumb-base ""))) - ;; (setq ergoemacs-map--breadcrumb (concat breadcrumb-base "-parent"))) - ;; (ergoemacs :label parent nil (plist-get struct :parent))) (if from-prop-p (setq ergoemacs-map-properties--breadcrumb breadcrumb-base) (setq ergoemacs-map--breadcrumb breadcrumb-base)))))) @@ -958,7 +946,6 @@ STRUCT is the keymap structure for the current map." old-plist (breadcrumb-base ergoemacs-map--breadcrumb) (parent (keymap-parent map)) - (struct (or struct (ergoemacs-gethash map-key ergoemacs-map-properties--key-struct))) label tmp1 tmp2) (unwind-protect (progn @@ -997,13 +984,6 @@ STRUCT is the keymap structure for the current map." (push char-table map)) (push 'keymap map))) (when parent - ;; (if (and breadcrumb-base (not (string= breadcrumb-base ""))) - ;; (setq ergoemacs-map--breadcrumb (concat breadcrumb-base "-parent")) - ;; (when (setq ergoemacs-map-properties--breadcrumb (gethash map-key ergoemacs-breadcrumb-hash)) - ;; (setq ergoemacs-map-properties--breadcrumb (format "%s-parent" ergoemacs-map-properties--breadcrumb)) - ;; ;; (message "Set %s!" ergoemacs-map-properties--breadcrumb) - ;; )) - ;; (ergoemacs :label parent nil (plist-get struct :parent)) (set-keymap-parent map parent) (setq ergoemacs-map--breadcrumb breadcrumb-base))) (if indirect-p @@ -1113,21 +1093,6 @@ KEYMAP can be an `ergoemacs-map-properties--key-struct' of the keymap as well." (setq ret (ergoemacs keymap :extract-lookup))) ret)) -(defun ergoemacs-map-properties--new-command (keymap command &optional relative-map) - "In KEYMAP, get the COMMAND equivalent binding relative to the RELATIVE-MAP." - (and command keymap - (let* (ret - (hash-table (ergoemacs (or relative-map ergoemacs-saved-global-map global-map) :where-is)) - (cmd-list (ergoemacs-gethash command hash-table))) - (if (not cmd-list) nil - (catch 'found-new - (dolist (key cmd-list) - (when (and (setq ret (lookup-key keymap key t)) - (or (and (commandp ret t) (not (memq ret ergoemacs-remap-ignore))) - (and (integerp ret) (setq ret nil)))) - (throw 'found-new t)) - (setq ret nil)) t) ret)))) - (defun ergoemacs-map-properties--revert-original (keymap &rest type) "Revert KEYMAP. diff --git a/ergoemacs-map.el b/ergoemacs-map.el index 8702952..4c5505a 100644 --- a/ergoemacs-map.el +++ b/ergoemacs-map.el @@ -68,7 +68,6 @@ (declare-function ergoemacs-warn "ergoemacs-lib") (declare-function ergoemacs-setcdr "ergoemacs-lib") -(declare-function ergoemacs-command-loop--modal "ergoemacs-command-loop") (declare-function ergoemacs-command-loop--spinner-display "ergoemacs-command-loop") (declare-function ergoemacs-component-struct--create-hooks "ergoemacs-component") @@ -897,7 +896,7 @@ modifications to that keymap." ((memq 'add-keymap-witness lookup-keymap) ;; Don't translate complete tranisent maps. lookup-keymap) ((and lookup-keymap (symbolp lookup-keymap) (ergoemacs-gethash lookup-keymap ergoemacs-translation-hash)) - (ergoemacs-command-loop--modal lookup-keymap)) + nil) ((consp (ergoemacs lookup-keymap :map-key)) ;; Ignore already installed. lookup-keymap) ((and lookup-keymap (ergoemacs lookup-keymap :dont-modify-p)) diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el index 001c343..210a0be 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -49,25 +49,15 @@ (eval-when-compile (require 'ergoemacs-macros)) -(require 'easymenu) (require 'undo-tree nil t) (provide 'ergoemacs-mode) -(require 'package) (require 'kmacro) (require 'printing) (pr-update-menus) -(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/")) -(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/")) -(add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")) - (defvar ergoemacs--system (replace-regexp-in-string "[^0-9A-Za-z]+" "-" (concat emacs-version "-" system-configuration))) -(when (and (string= package-user-dir (locate-user-emacs-file "elpa")) - (not (file-exists-p (locate-user-emacs-file "elpa")))) - (setq package-user-dir (locate-user-emacs-file (format "elpa-%s" ergoemacs--system)))) - (defvar cl-struct-ergoemacs-component-struct-tags) (defvar ergoemacs-component-struct--refresh-variables) (defvar ergoemacs-keyboard-layout) @@ -75,9 +65,6 @@ (defvar ergoemacs-require--ini-p) (defvar ergoemacs-require) (defvar pcache-directory) -(defvar ergoemacs-component-struct--apply-ensure-p) - -(require 'package) (declare-function ergoemacs-key-description--unicode-char "ergoemacs-key-description") @@ -169,6 +156,7 @@ Added beginning-of-buffer Alt+n (QWERTY notation) and end-of-buffer Alt+Shift+n" (defcustom ergoemacs-keyboard-mirror nil "Specifies which keyboard layout to mirror." + :type 'sexp :set #'ergoemacs-set-default :initialize #'custom-initialize-default :group 'ergoemacs-mode) @@ -209,8 +197,6 @@ The TEXT will be what the mode-line is set to be." "[" ergoemacs-keyboard-layout "]"))))) minor-mode-alist))))) -(require 'lookup-word-on-internet nil "NOERROR") - (defconst ergoemacs-font-lock-keywords '(("(\\(ergoemacs\\(?:-theme-component\\|-theme\\|-component\\|-require\\|-remove\\|-advice\\|-translation\\|-cache\\|-timing\\|-package\\|-autoload\\)\\)\\_>[ \t']*\\(\\(?:\\sw\\|\\s_\\)+\\)?" (1 font-lock-keyword-face) @@ -315,8 +301,7 @@ The `execute-extended-command' is now \\[execute-extended-command]. (add-hook 'pre-command-hook #'ergoemacs-pre-command-hook) (add-hook 'post-command-hook #'ergoemacs-post-command-hook) (add-hook 'after-load-functions #'ergoemacs-after-load-functions) - (setq ergoemacs-require--ini-p t - ergoemacs-component-struct--apply-ensure-p t) + (setq ergoemacs-require--ini-p t) (ergoemacs-setup-override-keymap) (if refresh-p (message "Ergoemacs-mode keys refreshed (%s:%s)" @@ -325,8 +310,7 @@ The `execute-extended-command' is now \\[execute-extended-command]. (modify-all-frames-parameters ergoemacs-mode--default-frame-alist) (unless (assoc 'cursor-type ergoemacs-mode--default-frame-alist) (modify-all-frames-parameters (list (cons 'cursor-type 'box)))) - (setq ergoemacs-mode--default-frame-alist nil - ergoemacs-component-struct--apply-ensure-p t) + (setq ergoemacs-mode--default-frame-alist nil) (run-hooks 'ergoemacs-mode-shutdown-hook) (remove-hook 'post-command-hook #'ergoemacs-post-command-hook) (remove-hook 'pre-command-hook #'ergoemacs-pre-command-hook) @@ -425,8 +409,7 @@ This is structured by valid keyboard layouts for "Hash table of `ergoemacs-mode' timing.") (defvar ergoemacs-timing--locations - '((ensure . "ergoemacs-component.el") - (remove-global-map-map-keymap . "ergoemacs-component.el") + '((remove-global-map-map-keymap . "ergoemacs-component.el") (remove-local-keymap-map-keymap . "ergoemacs-component.el") (translate-keymap . "ergoemacs-component.el") (describe-keymap . "ergoemacs-key-description.el") @@ -466,7 +449,7 @@ This is structured by valid keyboard layouts for (defvar ergoemacs--component-file-mod-time-list nil) (defun ergoemacs--emacs-state () "Return MD5 represting current Emacs state." - (let* ((state (format "%s %s %s %s %s" ergoemacs--system features package-alist load-path ergoemacs--component-file-mod-time-list)) + (let* ((state (format "%s %s %s %s" ergoemacs--system features load-path ergoemacs--component-file-mod-time-list)) (md5 (md5 state))) ;; (message "%s->%s" md5 state) md5)) @@ -595,22 +578,13 @@ When STORE-P is non-nil, save the tables." ergoemacs-theme-engine ergoemacs-translate ergoemacs-macros - ;; ergoemacs-themes )) (unless (featurep pkg) (ergoemacs-timing (intern (format "load-%s" pkg)) (load (symbol-name pkg))))) (require 'unicode-fonts nil t) -;; (when (featurep 'unicode-fonts) -;; (require 'persistent-soft nil t) -;; (when (featurep 'persistent-soft) -;; (unicode-fonts-setup))) - - (defcustom ergoemacs-use-unicode-symbols nil - ;; (and (featurep 'persistent-soft) - ;; (featurep 'unicode-fonts)) "Use unicode symbols in display." :type 'boolean :group 'ergoemacs-mode) @@ -843,6 +817,7 @@ Valid values are: "Display Options for `ergoemacs-mode'." :group 'ergoemacs-mode) +(define-obsolete-variable-alias 'ergoemacs-use-unicode-char 'ergoemacs-display-unicode-characters) (defcustom ergoemacs-display-unicode-characters t "Use unicode characters when available." :type 'boolean @@ -850,8 +825,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-unicode-char 'ergoemacs-display-unicode-characters) - +(define-obsolete-variable-alias 'ergoemacs-use-ergoemacs-key-descriptions 'ergoemacs-display-ergoemacs-key-descriptions) (defcustom ergoemacs-display-ergoemacs-key-descriptions t "Use ergoemacs key descriptions (Alt+)." :type 'boolean @@ -859,9 +833,8 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-ergoemacs-key-descriptions 'ergoemacs-display-ergoemacs-key-descriptions) - +(define-obsolete-variable-alias 'ergoemacs-use-unicode-brackets 'ergoemacs-display-use-unicode-brackets-around-keys) (defcustom ergoemacs-display-use-unicode-brackets-around-keys t "Use unicode brackets." :type 'boolean @@ -869,9 +842,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-unicode-brackets 'ergoemacs-display-use-unicode-brackets-around-keys) - - +(define-obsolete-variable-alias 'ergoemacs-use-small-symbols 'ergoemacs-display-small-symbols-for-key-modifiers) (defcustom ergoemacs-display-small-symbols-for-key-modifiers nil "Use small symbols to represent alt+ ctl+ on windows/linux." :type 'boolean @@ -879,8 +850,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-small-symbols 'ergoemacs-display-small-symbols-for-key-modifiers) - +(define-obsolete-variable-alias 'ergoemacs-capitalize-keys 'ergoemacs-display-capitalize-keys) (defcustom ergoemacs-display-capitalize-keys 'with-modifiers "Capitalize keys like Ctrl+C. `ergoemacs-mode' should show Ctrl+Shift+C if you are pressing these keys." @@ -892,8 +862,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-capitalize-keys 'ergoemacs-display-capitalize-keys) - +(define-obsolete-variable-alias 'ergoemacs-pretty-key-use-face 'ergoemacs-display-key-use-face-p) (defcustom ergoemacs-display-key-use-face-p t "Use a button face for keys." :type 'boolean @@ -901,9 +870,6 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-pretty-key-use-face 'ergoemacs-display-key-use-face-p) - - (defface ergoemacs-display-key-face '((t :inverse-video t :box (:line-width 1 :style released-button) :weight bold)) "Button Face for an `ergoemacs-mode' pretty key." @@ -960,13 +926,13 @@ Valid values are: (const :tag "No cursor" nil)) :group 'ergoemacs-command-loop) +(define-obsolete-variable-alias 'ergoemacs-read-blink-timeout 'ergoemacs-command-loop-blink-rate) (defcustom ergoemacs-command-loop-blink-rate 0.4 "Rate that the ergoemacs-command loop cursor blinks." :type 'number :group 'ergoemacs-command-loop) -(define-obsolete-variable-alias 'ergoemacs-read-blink-timeout 'ergoemacs-command-loop-blink-rate) - +(define-obsolete-variable-alias 'ergoemacs-read-swaps 'ergoemacs-command-loop-swap-translation) (defcustom ergoemacs-command-loop-swap-translation '(((:normal :normal) :unchorded-ctl) ((:normal :unchorded-ctl) :ctl-to-alt) @@ -984,8 +950,6 @@ Valid values are: (sexp :tag "Translated Type"))) :group 'ergoemacs-command-loop) -(define-obsolete-variable-alias 'ergoemacs-read-swaps 'ergoemacs-command-loop-swap-translation) - (defcustom ergoemacs-command-loop-type nil "Type of `ergoemacs-mode' command loop." :type '(choice @@ -1020,15 +984,7 @@ Valid values are: :group 'ergoemacs-command-loop) -(defgroup ergoemacs-modal nil - "Modal `ergoemacs-mode'." - :group 'ergoemacs-mode) -(defcustom ergoemacs-modal-ignored-buffers - '("^ \\*load\\*" "^[*]e?shell[*]" "^[*]R.*[*]$") - "Buffers where modal ergoemacs-mode is ignored." - :type '(repeat string) - :group 'ergoemacs-modal) - +(define-obsolete-variable-alias 'ergoemacs-default-cursor 'ergoemacs-default-cursor-color) (defcustom ergoemacs-default-cursor-color nil "Default cursor color. @@ -1039,189 +995,7 @@ color. Otherwise this will be nil A color string as passed to (color :tag "Color")) :group 'ergoemacs-modal) -(define-obsolete-variable-alias 'ergoemacs-default-cursor 'ergoemacs-default-cursor-color) - -(defcustom ergoemacs-modal-emacs-state-modes - '(archive-mode - bbdb-mode - bookmark-bmenu-mode - bookmark-edit-annotation-mode - browse-kill-ring-mode - bzr-annotate-mode - calc-mode - cfw:calendar-mode - completion-list-mode - Custom-mode - debugger-mode - delicious-search-mode - desktop-menu-blist-mode - desktop-menu-mode - doc-view-mode - dvc-bookmarks-mode - dvc-diff-mode - dvc-info-buffer-mode - dvc-log-buffer-mode - dvc-revlist-mode - dvc-revlog-mode - dvc-status-mode - dvc-tips-mode - ediff-mode - ediff-meta-mode - efs-mode - Electric-buffer-menu-mode - emms-browser-mode - emms-mark-mode - emms-metaplaylist-mode - emms-playlist-mode - etags-select-mode - fj-mode - gc-issues-mode - gdb-breakpoints-mode - gdb-disassembly-mode - gdb-frames-mode - gdb-locals-mode - gdb-memory-mode - gdb-registers-mode - gdb-threads-mode - gist-list-mode - gnus-article-mode - gnus-browse-mode - gnus-group-mode - gnus-server-mode - gnus-summary-mode - google-maps-static-mode - ibuffer-mode - jde-javadoc-checker-report-mode - magit-commit-mode - magit-diff-mode - magit-key-mode - magit-log-mode - magit-mode - magit-reflog-mode - magit-show-branches-mode - magit-branch-manager-mode ;; New name for magit-show-branches-mode - magit-stash-mode - magit-status-mode - magit-wazzup-mode - mh-folder-mode - monky-mode - notmuch-hello-mode - notmuch-search-mode - notmuch-show-mode - occur-mode - org-agenda-mode - package-menu-mode - proced-mode - rcirc-mode - rebase-mode - recentf-dialog-mode - reftex-select-bib-mode - reftex-select-label-mode - reftex-toc-mode - sldb-mode - slime-inspector-mode - slime-thread-control-mode - slime-xref-mode - shell-mode - sr-buttons-mode - sr-mode - sr-tree-mode - sr-virtual-mode - tar-mode - tetris-mode - tla-annotate-mode - tla-archive-list-mode - tla-bconfig-mode - tla-bookmarks-mode - tla-branch-list-mode - tla-browse-mode - tla-category-list-mode - tla-changelog-mode - tla-follow-symlinks-mode - tla-inventory-file-mode - tla-inventory-mode - tla-lint-mode - tla-logs-mode - tla-revision-list-mode - tla-revlog-mode - tla-tree-lint-mode - tla-version-list-mode - twittering-mode - urlview-mode - vc-annotate-mode - vc-dir-mode - vc-git-log-view-mode - vc-svn-log-view-mode - vm-mode - vm-summary-mode - w3m-mode - wab-compilation-mode - xgit-annotate-mode - xgit-changelog-mode - xgit-diff-mode - xgit-revlog-mode - xhg-annotate-mode - xhg-log-mode - xhg-mode - xhg-mq-mode - xhg-mq-sub-mode - xhg-status-extra-mode) - "Modes that should come up in `ergoemacs-mode' state." - :type '(repeat symbol) - :group 'ergoemacs-modal) - -(defvar ergoemacs-modal-list '()) (defvar ergoemacs-translate--translation-hash) -(defvar ergoemacs-modal-ignored-keymap - (let ((ret (make-sparse-keymap)) - (mods '(control meta shift hyper super alt)) - tmp - key) - (dolist (char '("<f1>" - "<f2>" - "<f3>" - "<f4>" - "<f5>" - "<f6>" - "<f7>" - "<f8>" - "<f9>" - "<f10>" - "<f11>" - "<f12>" - "<apps>" "<menu>" - "RET" "ESC" "DEL" "TAB" - "<home>" - "<next>" - "<prior>" - "<end>" - "<insert>" - "<deletechar>")) - (define-key ret (setq key (read-kbd-macro char t)) 'ergoemacs-ignore-modal) - (setq key (elt key 0)) - (dolist (mod1 mods) - (setq tmp (vector (event-convert-list (list mod1 key)))) - (ignore-errors (define-key ret tmp 'ignore)) - (when (setq tmp (ergoemacs-translate--meta-to-escape tmp)) - (ignore-errors (define-key ret tmp 'ignore))) - (dolist (mod2 mods) - (setq tmp (vector (event-convert-list (list mod1 mod2 key)))) - (ignore-errors (define-key ret tmp 'ignore)) - (when (setq tmp (ergoemacs-translate--meta-to-escape tmp)) - (ignore-errors (define-key ret tmp 'ignore))) - (dolist (mod3 mods) - (setq tmp (vector (event-convert-list (list mod1 mod2 mod3 key)))) - (ignore-errors (define-key ret tmp 'ignore)) - (when (setq tmp (ergoemacs-translate--meta-to-escape tmp)) - (ignore-errors (define-key ret tmp 'ignore))) - (dolist (mod4 mods) - (setq tmp (vector (event-convert-list (list mod1 mod2 mod3 mod4 key)))) - (ignore-errors (define-key ret tmp 'ignore)) - (when (setq tmp (ergoemacs-translate--meta-to-escape tmp)) - (ignore-errors (define-key ret tmp 'ignore)))))))) - ret) - "`ergoemacs-mode' keys to ignore the modal translation. -Typically function keys") (defcustom ergoemacs-translate-keys nil "Try differnt key combinations to lookup unfound command. @@ -1300,7 +1074,7 @@ also perform `outline-next-visible-heading'" (puthash 'ergoemacs-load-time (vector 1 ergoemacs--load-time ergoemacs--load-time ergoemacs--load-time (or load-file-name buffer-file-name)) ergoemacs-timing-hash) -(run-with-idle-timer 0.05 nil #'ergoemacs-mode-after-init-emacs) +(run-with-timer 0.0 nil #'ergoemacs-mode-after-init-emacs) (add-hook 'emacs-startup-hook #'ergoemacs-mode-after-init-emacs) (provide 'ergoemacs-mode) diff --git a/ergoemacs-test.el b/ergoemacs-test.el index c62330a..08addb5 100644 --- a/ergoemacs-test.el +++ b/ergoemacs-test.el @@ -29,7 +29,7 @@ ;;; Code: (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'ergoemacs-macros)) (declare-function ergoemacs-translate--keymap "ergoemacs-translate") @@ -80,7 +80,6 @@ (declare-function ergoemacs-translate--quail-to-ergoemacs "ergoemacs-translate") (declare-function ergoemacs-translate-layout "ergoemacs-translate") (declare-function ergoemacs-translate--get "ergoemacs-translate") -(declare-function ergoemacs-unchorded-alt-modal "ergoemacs-translate") (declare-function ergoemacs-translate--event-modifiers "ergoemacs-translate") (require 'ert) @@ -180,6 +179,64 @@ sunt in culpa qui officia deserunt mollit anim id est laborum.") ;; Test isearch +;; This does not seem to work for interactive tests when I set the +;; layout to "us" +(defmacro ergoemacs-test-layout (&rest keys-and-body) + (let ((kb (make-symbol "body-and-plist")) + (plist (make-symbol "plist")) + (body (make-symbol "body"))) + (setq kb (ergoemacs-theme-component--parse-keys-and-body keys-and-body nil t) + plist (nth 0 kb) + body (nth 1 kb)) + (macroexpand-all + `(let ((old-ergoemacs-theme (ergoemacs :current-theme)) + (old-type ergoemacs-command-loop-type) + (old-paste interprogram-paste-function) + (old-cut interprogram-cut-function) + ;; (old-kill kill-ring) + ;; (old-pointer kill-ring-yank-pointer) + (old-version (ergoemacs :current-version)) + (macro + ,(if (plist-get plist :macro) + `(edmacro-parse-keys ,(plist-get plist :macro) t))) + (old-ergoemacs-keyboard-layout ergoemacs-keyboard-layout) + (reset-ergoemacs nil)) + (setq ergoemacs-theme ,(plist-get plist ':current-theme) + ergoemacs-keyboard-layout ,(or (plist-get plist ':layout) "us") + ergoemacs-command-loop-type nil + interprogram-paste-function nil + interprogram-cut-function nil + ;; kill-ring nil + ;; kill-ring-yank-pointer nil + + ;; Make sure the copy functions don't think the last + ;; command was a copy. + last-command 'ergoemacs-test) + (ergoemacs-theme-set-version ,(or (plist-get plist ':version) nil)) + (unless (and (equal old-ergoemacs-theme ergoemacs-theme) + (equal old-ergoemacs-keyboard-layout ergoemacs-keyboard-layout) + (equal old-version (ergoemacs :current-vresion))) + (setq reset-ergoemacs t) + (ergoemacs-mode-reset)) + + ,(if (plist-get plist :cua) + `(cua-mode 1)) + (unwind-protect + (progn + ,@body) + (setq ergoemacs-command-loop-type old-type + ergoemacs-theme old-ergoemacs-theme + ergoemacs-keyboard-layout old-ergoemacs-keyboard-layout + interprogram-paste-function old-paste + interprogram-cut-function old-cut + ;; kill-ring old-kill + ;; kill-ring-yank-pointer old-pointer + ) + (ergoemacs-theme-set-version old-version) + (when reset-ergoemacs + (ergoemacs-mode-reset))))))) + + (ert-deftest ergoemacs-test-isearch-C-f-backspace () "Test Backspace in `isearch-mode'" :tags '(:search :interactive) @@ -283,22 +340,6 @@ Tests issue #347" (isearch-mode -1)) (kill-buffer (current-buffer))))) -;; Not sure why; Fixed but test dosesn't work -;; (ert-deftest ergoemacs-test-isearch-isearch-backward-repeats-backward () -;; "Tests backward isearch remapping is correct." -;; :tags '(:search) -;; (ergoemacs-test-layout -;; :macro "M-j ars M-j M-i" -;; :layout "colemak" -;; :theme "reduction" -;; (save-excursion -;; (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) -;; (delete-region (point-min) (point-max)) -;; (insert "aars1\nars2\nars3\nars4") -;; (goto-char (point-max)) -;; (execute-kbd-macro macro) -;; (should (looking-at "rs3"))))) - ;;; Shift Selection (ert-deftest ergoemacs-test-shift-select-move-no-mark () "Tests another shifted selection" @@ -374,55 +415,6 @@ Tests issue #347" ;;; Copy/Paste - -(ert-deftest ergoemacs-test-copy-paste-issue-184 () - "Issue #184; Not replace the \"selected all\" by paste." - :tags '(:copy :interactive) - (let ((ret t) - (ergoemacs-handle-ctl-c-or-ctl-x 'both)) - (ergoemacs-test-layout - :macro "C-v" - (save-excursion - (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) - (delete-region (point-min) (point-max)) - (insert ergoemacs-test-lorem-ipsum) - (goto-char (point-min)) - (push-mark) - (end-of-line) - (ergoemacs-copy-line-or-region) - (push-mark (point)) - (push-mark (point-max) nil t) - (goto-char (point-min)) - ;; Make sure the `pre-command-hook' and `post-command-hook' is - ;; run by calling the macro. - (execute-kbd-macro macro) - ;; (ergoemacs-paste) - (should (string= "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed\n" - (buffer-string))) - (kill-buffer (current-buffer)))))) - -(ert-deftest ergoemacs-test-copy-paste-issue-184-paste-should-clear-mark () - "Issue #186. -Selected mark would not be cleared after paste." - :tags '(:copy) - (ergoemacs-test-layout - (let ((ergoemacs-handle-ctl-c-or-ctl-x 'both)) - (save-excursion - (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) - (delete-region (point-min) (point-max)) - (insert ergoemacs-test-lorem-ipsum) - (goto-char (point-min)) - (push-mark) - (end-of-line) - (ergoemacs-copy-line-or-region) - (push-mark (point)) - (push-mark (point-max) nil t) - (goto-char (point-min)) - (ergoemacs-paste) - (should (or deactivate-mark (not mark-active))) - (kill-buffer (current-buffer)))))) - - (ert-deftest ergoemacs-test-copy-paste-cut-line-or-region () "Issue #68. kill-ring function name is used and such doesn't exist. It errs when @@ -444,49 +436,6 @@ not using cua or cutting line. I think kill-region is what is meant." (should ret)))) -(ert-deftest ergoemacs-test-copy-paste-issue-130-cut () - "Attempts to test Issue #130 -- Cut" - :tags '(:copy :interactive) - (ergoemacs-test-layout - (let ((ret t) - (ergoemacs-ctl-c-or-ctl-x-delay 0.1) - (ergoemacs-handle-ctl-c-or-ctl-x 'both)) - (save-excursion - (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) - (delete-region (point-min) (point-max)) - (insert ergoemacs-test-lorem-ipsum) - (push-mark (point)) - (push-mark (point-max) nil t) - (goto-char (point-min)) - (ergoemacs-command-loop--internal "C-x <ergoemacs-timeout>") - (setq ret (string= "" (buffer-string))) - (kill-buffer (current-buffer))) - (should ret)))) - -(ert-deftest ergoemacs-test-copy-paste-issue-130-copy () - "Attempts to test Issue #130 -- Copy" - :tags '(:copy :interactive) - (ergoemacs-test-layout - (let ((ergoemacs-ctl-c-or-ctl-x-delay 0.1) - (ergoemacs-handle-ctl-c-or-ctl-x 'both) - (txt "Text\n123")) - (with-temp-buffer - (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) - (delete-region (point-min) (point-max)) - (insert txt) - (push-mark (point)) - (push-mark (point-max) nil t) - ;; (message "Region Active: %s" transient-mark-mode) - (setq last-command nil - this-command nil) - (goto-char (point-min)) - (ergoemacs-command-loop--internal "C-c <ergoemacs-timeout>") - (goto-char (point-max)) - (ergoemacs-paste) - (should (string= (concat txt txt) - (buffer-string))) - (kill-buffer (current-buffer)))))) - (ert-deftest ergoemacs-test-copy-paste-apps-cut () "Tests <apps> x on QWERTY cutting a region, not just a line." :tags '(:copy :interactive) @@ -699,43 +648,6 @@ Grep finished (matches found) at Fri Aug 22 08:30:37 (call-interactively 'calc-quit) (should (eq (key-binding (kbd "M-u")) 'previous-line))))) -;;; Modal - -(ert-deftest ergoemacs-test-modal-preserve-mark () - "Issue #101. -Test next and prior translation." - (with-temp-buffer - (insert ergoemacs-test-lorem-ipsum) - (goto-char (point-min)) - (ergoemacs-translate--get :unchorded-alt) ;; Load translation - (ergoemacs-unchorded-alt-modal) - (set-mark (point)) - (forward-char 3) - (ergoemacs-unchorded-alt-modal) - (should mark-active))) - -(ert-deftest ergoemacs-test-modal-alt-mode-horizontal-position () - "Tests Issue #213" - (let (ret) - (ergoemacs-test-layout - :layout "colemak" - :macro "i u u" - (save-excursion - (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) - (delete-region (point-min) (point-max)) - (insert ergoemacs-test-lorem-ipsum) - (goto-char (point-max)) - (beginning-of-line) - (ergoemacs-translate--get :unchorded-alt) - (ergoemacs-unchorded-alt-modal) - (execute-kbd-macro macro) - (looking-at ".*? ") - (ignore-errors (should (string= (match-string 0) "eprehenderit "))) - (ergoemacs-unchorded-alt-modal) - (kill-buffer (current-buffer)))))) - - - ;;; Command Loop (ert-deftest ergoemacs-test-command-loop-apps-e-t-_ () @@ -1120,7 +1032,7 @@ Should test issue #142" (w-file (expand-file-name "global-test" ergoemacs-dir)) (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) (with-temp-file temp-file - (insert "(eval-when-compile (load (expand-file-name \"ergoemacs-macros\")) (require 'cl))" + (insert "(eval-when-compile (load (expand-file-name \"ergoemacs-macros\")) (require 'cl-lib))" (or (and (boundp 'wait-for-me) "(setq debug-on-error t debug-on-quit t)") "") "(setq ergoemacs-theme nil)" @@ -1150,47 +1062,6 @@ Should test issue #142" (delete-file w-file)))) (defvar ergoemacs-component-hash) -(ergoemacs-package icicles - :ensure t) - -(ert-deftest ergoemacs-test-397-test-4 () - "Test M-s is switch pane." - :tags '(:slow :icicles :interactive) - (let* ((emacs-exe (ergoemacs-emacs-exe)) - (w-file (expand-file-name "global-test" ergoemacs-dir)) - (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) - (with-temp-file temp-file - (insert "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "ergoemacs-mode"))) "\")" - "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "icicles"))) "\")" - "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" - (or (and (boundp 'wait-for-me) - "(setq debug-on-error t debug-on-quit t)") "") - "(setq ergoemacs-theme nil)" - "(setq ergoemacs-keyboard-layout \"us\")" - "(require 'icicles)\n" - "(require 'ergoemacs-mode)\n" - "(ergoemacs-mode 1)\n" - "(setq icicle-search-key-prefix (kbd \"C-f\"))\n" - "(icy-mode 1)\n" - "(when (eq (key-binding (kbd \"M-s\")) 'ergoemacs-move-cursor-next-pane)\n" - "(with-temp-file \"" w-file "\")\n" - " (message \"Passed\")" - " (insert \"Found\"))\n" - (or (and (boundp 'wait-for-me) "") - "(kill-emacs)"))) - (byte-compile-file temp-file) - (message "%s" - (shell-command-to-string - (format "%s %s -Q -l %s" - emacs-exe (if (boundp 'wait-for-me) "-debug-init" "--batch") - temp-file))) - (should (file-exists-p w-file)) - (when (file-exists-p temp-file) - (delete-file temp-file)) - (when (file-exists-p (concat temp-file "c")) - (delete-file (concat temp-file "c"))) - (when (file-exists-p w-file) - (delete-file w-file)))) (ert-deftest ergoemacs-test-397-test-2 () "Test that defining C-SPC after ergoemacs-mode loads will give `set-mark-command'." @@ -1199,7 +1070,7 @@ Should test issue #142" (w-file (expand-file-name "global-test" ergoemacs-dir)) (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) (with-temp-file temp-file - (insert "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" + (insert "(eval-when-compile (require 'ergoemacs-macros) (require 'cl-lib))" (or (and (boundp 'wait-for-me) "(setq debug-on-error t debug-on-quit t)") "") "(setq ergoemacs-theme nil)" @@ -1289,7 +1160,7 @@ Should test issue #142" (w-file (expand-file-name "global-test" ergoemacs-dir)) (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) (with-temp-file temp-file - (insert "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" + (insert "(eval-when-compile (require 'ergoemacs-macros) (require 'cl-lib))" (or (and (boundp 'wait-for-me) "(setq debug-on-error t debug-on-quit t)") "") "(ergoemacs-theme-component my-theme01 ()\n" @@ -1336,7 +1207,7 @@ Should test issue #142" (w-file (expand-file-name "global-test" ergoemacs-dir)) (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) (with-temp-file temp-file - (insert "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" + (insert "(eval-when-compile (require 'ergoemacs-macros) (require 'cl-lib))" "(setq ergoemacs-keyboard-layout \"sw\")\n" "(require 'ergoemacs-mode)\n" "(message \"Binding 1: %s\" (key-binding (kbd \"M-J\")))\n" @@ -1365,47 +1236,15 @@ Should test issue #142" (when (file-exists-p w-file) (delete-file w-file)))) -(ert-deftest ergoemacs-test-issue-437 () - "Test windmove bindings should be set everywhere." - :tags '(:slow) - (let* ((emacs-exe (ergoemacs-emacs-exe)) - (w-file (expand-file-name "global-test" ergoemacs-dir)) - (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) - (with-temp-file temp-file - (insert "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" - (or (and (boundp 'wait-for-me) - "(setq debug-on-error t debug-on-quit t)") "") - "(ergoemacs-package foo \n" - ":bind* ((\"<M-left>\" . windmove-left)" - "(\"<M-right>\" . windmove-right)" - "(\"<M-up>\" . windmove-up)" - "(\"<M-down>\" . windmove-down)))" - "(setq ergoemacs-mode--start-p t)" - "(ergoemacs-mode 1)\n" - "(when (and (eq (key-binding (kbd \"<M-left>\")) 'windmove-left)\n" - " (eq (key-binding (kbd \"<M-right>\")) 'windmove-right)\n" - " (eq (key-binding (kbd \"<M-up>\")) 'windmove-up)\n" - " (eq (key-binding (kbd \"<M-down>\")) 'windmove-down))\n" - "(with-temp-file \"" w-file "\")\n" - " (message \"Passed\")" - " (insert \"Found\"))\n" - (or (and (boundp 'wait-for-me) "") - "(kill-emacs)"))) - (byte-compile-file temp-file) - (message "%s" - (shell-command-to-string - (format "%s %s -Q -L %s -l %s -l %s" - emacs-exe (if (boundp 'wait-for-me) "-debug-init" "--batch") - (expand-file-name (file-name-directory (locate-library "ergoemacs-mode"))) - (expand-file-name (file-name-sans-extension (locate-library "ergoemacs-mode"))) - temp-file))) - (should (file-exists-p w-file)) - (when (file-exists-p temp-file) - (delete-file temp-file)) - (when (file-exists-p (concat temp-file "c")) - (delete-file (concat temp-file "c"))) - (when (file-exists-p w-file) - (delete-file w-file)))) +;; Issue 437 +;; +;; Can override an ergoemacs binding when loading the new mode. For +;; example, this code changes M-left to M-right. +;; +;; (add-hook 'org-mode-hook +;; (lambda () +;; (define-key org-mode-map (kbd "<M-left>") 'org-metaright) +;; )) ;;; Not sure why this doesn't actually use `ergoemacs-test-major-mode-map'. (define-derived-mode ergoemacs-test-major-mode fundamental-mode "ET" @@ -1470,7 +1309,7 @@ Part of addressing Issue #147." (should (not (eq (key-binding [ergoemacs-remap kill-region]) 'ergoemacs-close-current-buffer)))))) (ert-deftest ergoemacs-test-keep-ctl-s () - "Keep mode-defined C-s in major-mode `ergoemacs-test-major-mode'. + "Keep ergoemacs defined C-s in major-mode `ergoemacs-test-major-mode'. Part of addressing Issue #147." :tags '(:interactive) (ergoemacs-test-layout @@ -1482,11 +1321,13 @@ Part of addressing Issue #147." (use-local-map ergoemacs-test-major-mode-map)) (ergoemacs-map--modify-active) (should (eq (key-binding (kbd "C-s")) 'save-buffer)) - (should (eq (key-binding [ergoemacs-remap isearch-forward]) 'search-forward)))))) - + ) + ) + ) + ) (ert-deftest ergoemacs-test-keep-alt-s () - "Keep mode-defined M-s in major-mode `ergoemacs-test-major-mode'. + "Keep ergoemacs defined M-s in major-mode `ergoemacs-test-major-mode'. Tests Issue #372." :tags '(:interactive) (ergoemacs-test-layout @@ -1562,8 +1403,6 @@ Tests Issue #372." "Test ergoemacs-mode translations" :tags '(:translate) (should (string= "A" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "A" t) 0)))))) - (should (string= "M-A" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "A" t) 0) :unchorded-alt))))) - (should (string= "C-S-a" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "A" t) 0) :unchorded-ctl))))) (should (string= "M-A" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "C-S-a" t) 0) :ctl-to-alt))))) ;; DEL = ^?, doesn't seem to have the issues that RET, ESC, and TAB has. @@ -1594,7 +1433,7 @@ Tests Issue #372." (should (string= (key-description (kbd "M-TAB")) (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "C-TAB" t) 0) :ctl-to-alt))))) - (letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) t))) + (cl-letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) t))) ;; Test M-i -> ^i -> TAB (should (string= "<C-i>" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "M-i" t) 0) :ctl-to-alt))))) @@ -1604,7 +1443,7 @@ Tests Issue #372." ;; Test M-m -> ^m -> RET (should (string= "<C-m>" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "M-m" t) 0) :ctl-to-alt)))))) - (letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) nil))) + (cl-letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) nil))) ;; Test M-i -> ^i -> TAB (should (string= "TAB" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "M-i" t) 0) :ctl-to-alt))))) @@ -1762,52 +1601,6 @@ hash appropriaetly." :tags '(:translate :interactive) (should (eq (lookup-key (ergoemacs ergoemacs-translate--parent-map) (or (and (eq system-type 'windows-nt) [apps]) [menu])) 'ergoemacs-command-loop--swap-translation))) -(ert-deftest ergoemacs-test-407 () - "Test M-s is switch pane." - :tags '(:require-input :interactive) - (let* ((emacs-exe (ergoemacs-emacs-exe)) - (w-file (expand-file-name "global-test" ergoemacs-dir)) - (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) - (with-temp-file temp-file - (insert "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "ergoemacs-mode"))) "\")" - "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "icicles"))) "\")" - "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" - (or (and (boundp 'wait-for-me) - "(setq debug-on-error t debug-on-quit t)") "") - "(setq ergoemacs-theme nil)" - "(setq ergoemacs-keyboard-layout \"us\")" - "(require 'ergoemacs-mode)\n" - "(ergoemacs-mode 1)\n" - "(require 'icicles)\n" - "(icy-mode 1)\n" - "(ergoemacs-theme-component reclaim-C-f ()\n" - " \"We need to give at least one sequence to reclaim C-f from isearch and get the new icicle-search-key-prefix picked up.\"\n" - "(global-set-key (kbd \"C-f .\") 'isearch-forward-symbol-at-point))" - "(ergoemacs-require 'reclaim-C-f)" - "(setq icicle-search-key-prefix (kbd \"C-f\"))" - "(ergoemacs-package smart-mode-line :ensure t (sml/setup))" - "(ergoemacs-package srefactor :ensure t)" - "(ergoemacs-package virtualenvwrapper :ensure t)" - "(defun test-freeze ()\n" - "(interactive)\n" - "(yes-or-no-p \"Are you sure you want to remove this file? \"))" - "(global-set-key (kbd \"C-1\") 'test-freeze)" - "(insert \"Try C-1 to see if emacs freezes.\\nThen try M-a test-freeze.\\nM-a calc, do something and then exit with q it should exit\nMake sure M-o goes forward word in icy ergoemacs-mode.\")" - ;; (or (and (boundp 'wait-for-me) "") - ;; "(kill-emacs)") - )) - (byte-compile-file temp-file) - (message "%s" - (shell-command-to-string - (format "%s %s -Q -l %s" - emacs-exe "-debug-init" - temp-file))) - - (when (file-exists-p temp-file) - (delete-file temp-file)) - (when (file-exists-p (concat temp-file "c")) - (delete-file (concat temp-file "c"))))) - ;;; minibuffer tests... ;;; Related to: http://emacs.stackexchange.com/questions/10393/how-can-i-answer-a-minibuffer-prompt-from-elisp @@ -1826,25 +1619,6 @@ hash appropriaetly." ,minibuffer-call) nil)) -(ert-deftest ergoemacs-test-icy-407-minibuffer () - "Test minibuffer keybindings for `icy-mode'. -[f11] = `previous-history-element' -[f12] = `next-history-element' -M-s = `ergoemacs-move-cursor-next-pane' -M-r = `kill-word'" - :tags '(:icy-mode :interactive) - (icy-mode 1) - (let ((keys)) -(ergoemacs-test-layout - :layout "us" - :theme "standard" - (should (equal (ergoemacs-minibuffer-key-bindings - (call-interactively 'icicle-execute-extended-command) - [f11] [f12] (read-kbd-macro "M-o") (read-kbd-macro "M-s") (read-kbd-macro "M-r")) - '(previous-history-element next-history-element forward-word ergoemacs-move-cursor-next-pane kill-word))))) -(icy-mode -1)) - - (provide 'ergoemacs-test) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ergoemacs-test.el ends here diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el index e5c54f9..8269411 100644 --- a/ergoemacs-theme-engine.el +++ b/ergoemacs-theme-engine.el @@ -52,7 +52,7 @@ (eval-when-compile (require 'ergoemacs-macros) - (require 'cl)) + (require 'cl-lib)) (defvar ergoemacs-mode) (defvar ergoemacs-require) @@ -362,31 +362,6 @@ When AT-END is non-nil, append a $ to the regular expression." ,(ergoemacs-theme--menu-options theme) ,(ergoemacs-theme--version-menu theme) (ergoemacs-c-x-sep "--") - (ergoemacs-c-x-c-c - menu-item "Ctrl+C and Ctrl+X behavior" - (keymap - (c-c-c-x-emacs - menu-item "Ctrl+C and Ctrl+X are for Emacs Commands" - (lambda() - (interactive) - (ergoemacs-save 'ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - :button (:radio . (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x))) - (c-c-c-x-cua - menu-item "Ctrl+C and Ctrl+X are only Copy/Cut" - (lambda() - (interactive) - (ergoemacs-save 'ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut)) - :button (:radio . (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut))) - (c-c-c-x-both - menu-item "Ctrl+C and Ctrl+X are both Emacs Commands & Copy/Cut" - (lambda() - (interactive) - (ergoemacs-save 'ergoemacs-handle-ctl-c-or-ctl-x 'both)) - :button (:radio . (eq ergoemacs-handle-ctl-c-or-ctl-x 'both))) - (c-c-c-x-timeout - menu-item "Customize Ctrl+C and Ctrl+X Cut/Copy Timeout" - (lambda() (interactive) - (ergoemacs-save 'ergoemacs-ctl-c-or-ctl-x-delay))))) (c-v menu-item "Paste behavior" (keymap @@ -665,22 +640,23 @@ See also `find-function-recenter-line' and `find-function-after-hook'." # should be like ErgoEmacs. # If none of the keys work, try replacing all instances of \\e with \\M-. # That's means changing Esc to Meta key. -\nset editing-mode emacs") tmp) +\nset editing-mode emacs")) (with-temp-buffer (dolist (cmds ergoemacs-theme-create-bash-functions) (dolist (cmd cmds) (dolist (key-cmd (where-is-internal cmd nil)) - (setq key-string (key-description key-cmd)) - ;; Only set up the Meta bindings, not the regular arrow or - ;; Control bindings. That would require more complicated - ;; logic to get right. - (if (string-prefix-p "M-" key-string) - (setq ret (concat ret "\n\"\\" - (replace-regexp-in-string "M-" "e" key-string t) - "\": " - (symbol-name (nth 0 cmds)) - ) - ) + (let ((key-string (key-description key-cmd))) + ;; Only set up the Meta bindings, not the regular arrow or + ;; Control bindings. That would require more complicated + ;; logic to get right. + (if (string-prefix-p "M-" key-string) + (setq ret (concat ret "\n\"\\" + (replace-regexp-in-string "M-" "e" key-string t) + "\": " + (symbol-name (nth 0 cmds)) + ) + ) + ) ) ) ) @@ -732,8 +708,6 @@ See also `find-function-recenter-line' and `find-function-after-hook'." (ergoemacs-copy-all "copy all") (ergoemacs-copy-all "copy all") (ergoemacs-copy-line-or-region "copy") - (ergoemacs-ctl-c "Copy/Ctl+c") - (ergoemacs-ctl-x "Cut/Ctl+x") (ergoemacs-cut-all "✂ all") (ergoemacs-cut-all "✂ all") (ergoemacs-cut-line-or-region "✂ region") @@ -764,7 +738,6 @@ See also `find-function-recenter-line' and `find-function-after-hook'." (ergoemacs-text-scale-normal-size "Reset Zoom") (ergoemacs-toggle-camel-case "tog. camel") (ergoemacs-toggle-letter-case "tog. case") - (ergoemacs-unchorded-alt-modal "Alt+ Mode") (ergoemacs-universal-argument "Argument") (execute-extended-command "M-x") (find-file "Open") diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el index e16c402..39f3eab 100644 --- a/ergoemacs-themes.el +++ b/ergoemacs-themes.el @@ -19,17 +19,8 @@ ;; You should have received a copy of the GNU General Public License ;; along with ErgoEmacs. If not, see <http://www.gnu.org/licenses/>. -;;; Commentary: - -;; - -;; Todo: - -;; - -;;; Code: (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'ergoemacs-macros)) (declare-function ergoemacs-theme-component--create-component "ergoemacs-theme") @@ -48,13 +39,6 @@ (require 'advice) -;; (ergoemacs-package undo-tree -;; :ensure t -;; (global-undo-tree-mode 1)) - -;; (ergoemacs-package persistent-soft -;; :ensure t) - (ergoemacs-component standard-vars () "Enabled/changed variables/modes" (setq org-CUA-compatible t @@ -82,11 +66,6 @@ "Display info on the GNU project"))) " operating system.\n\n" "\n" - ;; :link ("Emacs Guided Tour" - ;; ,(lambda (_button) - ;; (browse-url "http://www.gnu.org/software/emacs/tour/")) - ;; "Browse http://www.gnu.org/software/emacs/tour/") - ;; "\tOverview of Emacs features at gnu.org\n" :link ("View Emacs Manual" ,(lambda (_button) (info-emacs-manual))) "\tView the Emacs manual using Info\n" :link ("Absence of Warranty" ,(lambda (_button) (describe-no-warranty))) @@ -150,18 +129,11 @@ :link ("Ordering Manuals" ,(lambda (_button) (view-order-manuals))) "\tBuying printed manuals from the FSF\n" "\n" - ;; :link ("Emacs Guided Tour" - ;; ,(lambda (_button) - ;; (browse-url "http://www.gnu.org/software/emacs/tour/")) - ;; "Browse http://www.gnu.org/software/emacs/tour/") - ;; "\tSee an overview of Emacs features at gnu.org" ))) (add-hook 'dirtrack-directory-change-hook 'ergoemacs-shell-here-directory-change-hook) (add-hook 'kill-buffer-hook 'ergoemacs-save-buffer-to-recently-closed) (add-hook 'shell-mode-hook 'ergoemacs-shell-here-hook) (add-hook 'eshell-post-command-hook 'ergoemacs-shell-here-directory-change-hook) - ;; (dolist (hook '(dired-after-readin-hook after-change-major-mode-hook)) - ;; (add-hook hook 'ergoemacs-setup-local-prefixes)) (shift-select-mode t) (delete-selection-mode 1) (setq recentf-menu-before "Close" @@ -188,19 +160,6 @@ :help "Customize recently opened files menu and options" :active t])) (recentf-mode (if noninteractive -1 1)) - ;; (setq cua--rectangle-modifier-key ergoemacs-cua-rect-modifier) - ;; (setq cua--rectangle-keymap (make-sparse-keymap)) - ;; (setq cua--rectangle-initialized nil) - ;; (setq cua--keymap-alist - ;; (progn - ;; (cua--init-rectangles) - ;; `((cua--ena-prefix-override-keymap . ,cua--prefix-override-keymap) - ;; (cua--ena-prefix-repeat-keymap . ,cua--prefix-repeat-keymap) - ;; (cua--ena-cua-keys-keymap . ,cua--cua-keys-keymap) - ;; (cua--ena-global-mark-keymap . ,cua--global-mark-keymap) - ;; (cua--rectangle . ,cua--rectangle-keymap) - ;; (cua--ena-region-keymap . ,cua--region-keymap) - ;; (cua-mode . ,cua-global-keymap)))) ) (ergoemacs-component save-options-on-exit () @@ -241,13 +200,9 @@ (define-key undo-tree-map (kbd "C-?") nil) (define-key undo-tree-map (kbd "M-_") nil) - (global-set-key (kbd "C-S-z") '(redo undo-tree-redo ergoemacs-redo)) - (global-set-key (kbd "M-S-z") '(redo undo-tree-redo ergoemacs-redo)) + (global-set-key (kbd "C-S-z") '(redo undo-tree-redo)) + (global-set-key (kbd "M-S-z") '(redo undo-tree-redo)) (global-set-key (kbd "<S-delete>") 'ergoemacs-cut-line-or-region) - (if (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - (global-set-key (kbd "C-c <ergoemacs-timeout>") - 'ergoemacs-copy-line-or-region) - ) (global-set-key (kbd "<C-insert>") 'ergoemacs-copy-line-or-region) (global-set-key (kbd "C-S-v") 'ergoemacs-paste-cycle) @@ -299,14 +254,17 @@ (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-/") '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 +277,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) @@ -328,11 +287,8 @@ (global-set-key (kbd "C-x k") nil) (global-set-key (kbd "C-w") 'ergoemacs-close-current-buffer) - (if (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - (global-set-key (kbd "C-x <ergoemacs-timeout>") 'ergoemacs-cut-line-or-region) - ) (global-set-key (kbd "C-x C-b") 'ibuffer) - (global-set-key (kbd "C-y") '(redo undo-tree-redo ergoemacs-redo) "↷ redo") + (global-set-key (kbd "C-y") '(redo undo-tree-redo) "↷ redo") (global-set-key (kbd "M-S-<next>") 'forward-page) (global-set-key (kbd "M-S-<prior>") 'backward-page) @@ -410,9 +366,6 @@ (define-key isearch-mode-map (kbd "C-M-f") 'isearch-occur) (define-key isearch-mode-map (kbd "<S-insert>") 'ergoemacs-paste) (define-key isearch-mode-map (kbd "C-S-v") 'ergoemacs-paste-cycle) - (if (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - (define-key isearch-mode-map (kbd "C-c") 'isearch-yank-word-or-char) - ) (define-key isearch-mode-map (kbd "M-c") 'isearch-yank-word-or-char) (define-key isearch-mode-map (kbd "M-v") 'ergoemacs-paste) (define-key isearch-mode-map (kbd "C-v") 'ergoemacs-paste)) @@ -475,17 +428,16 @@ (global-set-key (kbd "<C-f2>") 'ergoemacs-cut-all) (global-set-key (kbd "<C-f3>") 'ergoemacs-copy-all) (global-set-key (kbd "<C-f4>") 'ergoemacs-paste-cycle) - (global-set-key (kbd "<C-f5>") '(redo undo-tree-redo ergoemacs-redo)) + (global-set-key (kbd "<C-f5>") '(redo undo-tree-redo)) (global-set-key (kbd "<C-f8>") 'highlight-symbol-prev) (global-set-key (kbd "<C-f9>") 'highlight-symbol-next) (global-set-key (kbd "<M-f2>") 'ergoemacs-cut-all) (global-set-key (kbd "<M-f3>") 'ergoemacs-copy-all) - (global-set-key (kbd "<M-f5>") '(redo undo-tree-redo ergoemacs-redo)) + (global-set-key (kbd "<M-f5>") '(redo undo-tree-redo)) (global-set-key (kbd "<S-f3>") 'ergoemacs-toggle-letter-case) (global-set-key (kbd "<f11>") 'previous-line) (global-set-key (kbd "<f12>") 'next-line) (global-set-key (kbd "<f3>") 'ergoemacs-copy-line-or-region) - (global-set-key (kbd "<f6>") 'ergoemacs-unchorded-alt-modal) (global-set-key (kbd "<f8>") 'search-map) (global-set-key (kbd "<f8> <f8>") 'highlight-symbol-at-point) (global-set-key (kbd "<f8> <f9>") 'highlight-symbol-query-replace) @@ -776,22 +728,12 @@ (global-set-key (kbd "C-x u") nil) (global-set-key (kbd "M-z") '("C-_" :emacs)) - ;; Fixed Component; Note that <timeout> is the actual function. - (if (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - (progn - (global-set-key (kbd "C-c <ergoemacs-timeout>") 'ergoemacs-copy-line-or-region) - (global-set-key (kbd "C-x <ergoemacs-timeout>") 'ergoemacs-cut-line-or-region) - ) - ) (global-set-key (kbd "C-S-x") ("C-x" :normal)) (global-set-key (kbd "C-z") 'undo) - (global-set-key (kbd "C-S-z") '(redo undo-tree-redo ergoemacs-redo)) - (global-set-key (kbd "C-y") '(redo undo-tree-redo ergoemacs-redo)) + (global-set-key (kbd "C-S-z") '(redo undo-tree-redo)) + (global-set-key (kbd "C-y") '(redo undo-tree-redo)) ;; Mode specific changes - (if (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - (define-key isearch-mode-map (kbd "C-c") 'isearch-yank-word-or-char) - ) (define-key isearch-mode-map (kbd "M-c") 'isearch-yank-word-or-char) (define-key isearch-mode-map (kbd "M-v") 'ergoemacs-paste) (define-key isearch-mode-map (kbd "M-V") 'ergoemacs-paste-cycle) @@ -876,9 +818,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)) @@ -899,8 +843,6 @@ :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) ) (ergoemacs-component execute () @@ -936,6 +878,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) @@ -973,13 +916,6 @@ (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) - (define-key term-raw-map (kbd "M-8") '(er/expand-region ergoemacs-extend-selection)) - (define-key term-raw-map (kbd "M-*") '(er/mark-inside-quotes ergoemacs-select-text-in-quote)) - (define-key term-raw-map (kbd "M-6") 'ergoemacs-select-current-block) - (define-key term-raw-map (kbd "M-7") 'ergoemacs-select-current-line) ) (ergoemacs-component quit () @@ -1006,7 +942,6 @@ "<apps> SPC" set-mark-command "<apps> a" mark-whole-buffer "<apps> d" ("C-x" :ctl-to-alt) - "<apps> f" ("C-c" :unchorded-ctl) "<apps> h" help-map "<apps> h '" ergoemacs-describe-current-theme "<apps> h 1" describe-function @@ -1031,7 +966,7 @@ "<apps> x" ergoemacs-cut-line-or-region "<apps> c" ergoemacs-copy-line-or-region "<apps> v" ergoemacs-paste - "<apps> b" (redo undo-tree-redo ergoemacs-redo) + "<apps> b" (redo undo-tree-redo) "<apps> t" switch-to-buffer "<apps> z" undo "<apps> r" goto-map)) @@ -1249,7 +1184,7 @@ (ergoemacs-component ergoemacs-remaps () "Remaps for ergoemacs-mode" (when undo-tree-mode - (global-set-key [remap ergoemacs-redo] 'undo-tree-redo) + (global-set-key [remap redo] 'undo-tree-redo) (global-set-key [remap undo] 'undo-tree-undo)) (when mark-active (global-set-key (kbd "TAB") 'indent-region)) @@ -1261,8 +1196,6 @@ (global-set-key [remap shell] 'ergoemacs-shell-here) (global-set-key [remap universal-argument] 'ergoemacs-command-loop--universal-argument) - ;; (global-set-key [remap describe-key] - ;; 'ergoemacs-key-description) (global-set-key [remap describe-mode] 'ergoemacs-describe-major-mode) (global-set-key [remap ergoemacs-print-buffer-confirm] @@ -1273,25 +1206,15 @@ (when ivy-mode (setq ivy-use-virtual-buffers t) (global-set-key [remap isearch-forward] 'swiper) - ;; (global-set-key (kbd "C-c C-r") 'ivy-resume) - ;; (global-set-key (kbd "<f6>") 'ivy-resume) (global-set-key [remap execute-extended-command] 'counsel-M-x) (global-set-key [remap find-file] 'counsel-find-file) (global-set-key [remap describe-function] 'counsel-describe-function) (global-set-key [remap describe-variable] 'counsel-describe-variable) (global-set-key [remap find-library] 'counsel-find-library) (global-set-key [remap info-lookup-symbol] 'counsel-info-lookup-symbol) - ;; (global-set-key (kbd "<f2> u") 'counsel-unicode-char) - ;; (global-set-key (kbd "C-c g") 'counsel-git) (global-set-key [remap vc-git-grep] 'counsel-git-grep) - ;; (global-set-key (kbd "C-c k") 'counsel-ag) (global-set-key [remap locate] 'counsel-locate) - ;; (global-set-key (kbd "C-S-o") 'counsel-rhythmbox) - ;; (define-key read-expression-map (kbd "C-r") 'counsel-expression-history) (define-key ivy-minibuffer-map (kbd "M-RET") 'ivy-alt-done) - ;; (define-key ivy-minibuffer-map (kbd "C-RET") 'ivy-dispatching-done) - ;; (define-key ivy-minibuffer-map (kbd "M-S-RET") 'ivy-immediate-done) - ;; (define-key ivy-minibuffer-map [remap avy-goto-word-or-subword-1] 'ivy-avy) )) (ergoemacs-component ergoemacs-banish-shift () @@ -1370,14 +1293,12 @@ (open-shell-here menu-item ,(if (eq system-type 'windows-nt) "In Command Prompt" "In Shell") ergoemacs-shell-here) ,(if (eq system-type 'windows-nt) '(powershell-here menu-item "In PowerShell" ergoemacs-powershell-here :enable (fboundp 'powershell))) )) - ;; (open-last-closed menu-item "Open last closed" ergoemacs-open-last-closed) (kill-buffer menu-item "Close" ergoemacs-close-current-buffer) (separator1 menu-item "--") (save-buffer menu-item "Save" save-buffer) (write-file menu-item "Save As..." write-file) (revert-buffer menu-item "Revert to Saved" revert-buffer) (print-buffer menu-item "Print" ergoemacs-print-buffer-confirm) - ;; (ps-print-buffer-faces menu-item "Print (font+color)" ps-print-buffer-faces) (separator4 menu-item "--") (split-window-below menu-item "Split Window" split-window-below) @@ -1408,7 +1329,7 @@ (listp pending-undo-list) (consp buffer-undo-list))) :help "Undo last operation") - (redo menu-item "Redo" ergoemacs-redo + (redo menu-item "Redo" redo :enable (and (not buffer-read-only) (not (eq t buffer-undo-list)) @@ -1419,12 +1340,10 @@ (redo-sep menu-item "--") (cut menu-item "Cut" ergoemacs-cut-line-or-region :help "Delete text in Line/region and copy it to the clipboard" - :enable (or (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut) - (region-active-p))) + :enable (region-active-p)) (copy menu-item "Copy" ergoemacs-copy-line-or-region :help "Copy text in line/region to the clipboard" - :enable (or (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-copy-cut) - (region-active-p))) + :enable (region-active-p)) (paste menu-item "Paste" ergoemacs-paste :help "Paste text from clipboard") (paste-from-menu menu-item "Paste from Kill Menu" yank-menu @@ -1515,44 +1434,6 @@ (ergoemacs-eol-conversion 'mac)) :enable (not (ergoemacs-eol-p 'mac))))) ;; Taken/Adapted from menu+ by Drew Adams. - ;; (region menu-item "Region" - ;; (keymap - ;; (unaccent-region - ;; menu-item "Unaccent" unaccent-region ; Defined in `unaccent'. - ;; :help "Replace accented chars in the nonempty region by unaccented chars" - ;; :enable (and (not buffer-read-only) mark-active (> (region-end) (region-beginning)))) - ;; (separator-chars menu-item "--") - - - ;; (comment-region menu-item - ;; "(Un)Comment" comment-region - ;; :help "Comment or uncomment each line in the nonempty region" - ;; :enable (and comment-start (not buffer-read-only) mark-active - ;; (> (region-end) (region-beginning)))) - ;; (center-region menu-item - ;; "Center" center-region - ;; :help "Center each nonblank line that starts in the nonempty region" - ;; :enable (and (not buffer-read-only) mark-active (> (region-end) (region-beginning)))) - ;; ;; (indent-rigidly-region menu-item "Rigid Indent" - ;; ;; indent-rigidly - ;; ;; :help "Indent each line that starts in the nonempty region" - ;; ;; :enable (and (not buffer-read-only) mark-active (> (region-end) (region-beginning)))) - ;; (indent-region menu-item "Column/Mode Indent" indent-region - ;; :help "Indent each nonblank line in the nonempty region" - ;; :enable (and (not buffer-read-only) mark-active (> (region-end) (region-beginning)))) - - ;; (separator-indent menu-item "--") - ;; (abbrevs-region "Expand Abbrevs..." - ;; expand-region-abbrevs - ;; :help "Expand each abbrev in the nonempty region (with confirmation)" - ;; :enable (and (not buffer-read-only) mark-active (> (region-end) (region-beginning)))) - - ;; (macro-region menu-item - ;; "Exec Keyboard Macro" apply-macro-to-region-lines - ;; :help "Run keyboard macro at start of each line in the nonempty region" - ;; :enable (and last-kbd-macro mark-active (not buffer-read-only) - ;; (> (region-end) (region-beginning)))))) - ;; Taken/Adapted from menu+ by Drew Adams. (sort menu-item "Sort" (keymap (regexp-fields menu-item @@ -1594,72 +1475,6 @@ :enable (and (not buffer-read-only) mark-active (> (region-end) (region-beginning)))))) - ;; (search menu-item "Search" - ;; (keymap - ;; (search-forward menu-item "Text..." search-forward) - ;; (separator-repeat-search menu-item "--") - ;; (tags-srch menu-item "Search Tagged Files..." tags-search - ;; :help "Search for a regexp in all tagged files") - ;; (tags-continue menu-item "Continue Tags Search" tags-loop-continue - ;; :help "Continue last tags search operation") - ;; "Search")) - - ;; (i-search menu-item "Incremental Search" - ;; (keymap - ;; (isearch-forward menu-item "Forward String..." isearch-forward - ;; :help "Search forward for a string as you type it") - ;; (isearch-backward menu-item "Backward String..." isearch-backward - ;; :help "Search backwards for a string as you type it") - ;; (isearch-forward-regexp menu-item "Forward Regexp..." isearch-forward-regexp - ;; :help "Search forward for a regular expression as you type it") - ;; (isearch-backward-regexp menu-item "Backward Regexp..." isearch-backward-regexp - ;; :help "Search backwards for a regular expression as you type it") - ;; "Incremental Search")) - - ;; (replace menu-item "Replace" - ;; (keymap - ;; (query-replace menu-item "Replace String..." query-replace - ;; :enable (not buffer-read-only) - ;; :help "Replace string interactively, ask about each occurrence") - ;; (query-replace-regexp menu-item "Replace Regexp..." query-replace-regexp - ;; :enable (not buffer-read-only) - ;; :help "Replace regular expression interactively, ask about each occurrence") - ;; (separator-replace-tags menu-item "--") - ;; (tags-repl menu-item "Replace in Tagged Files..." tags-query-replace - ;; :help "Interactively replace a regexp in all tagged files") - ;; (tags-repl-continue menu-item "Continue Replace" tags-loop-continue - ;; :help "Continue last tags replace operation") - ;; "Replace")) - - ;; (goto menu-item "Go To" - ;; (keymap - ;; (go-to-line menu-item "Goto Line..." goto-line - ;; :help "Read a line number and go to that line") - ;; (separator-tags menu-item "--") - ;; (find-tag menu-item "Find Tag..." find-tag - ;; :help "Find definition of function or variable") - ;; (find-tag-otherw menu-item "Find Tag in Other Window..." find-tag-other-window - ;; :help "Find function/variable definition in another window") - ;; (next-tag menu-item "Find Next Tag" menu-bar-next-tag - ;; :enable (and - ;; (boundp 'tags-location-ring) - ;; (not - ;; (ring-empty-p tags-location-ring))) - ;; :help "Find next function/variable matching last tag name") - ;; (next-tag-otherw menu-item "Next Tag in Other Window" menu-bar-next-tag-other-window - ;; :enable (and - ;; (boundp 'tags-location-ring) - ;; (not - ;; (ring-empty-p tags-location-ring))) - ;; :help "Find next function/variable matching last tag name in another window") - ;; (apropos-tags menu-item "Tags Apropos..." tags-apropos - ;; :help "Find function/variables whose names match regexp") - ;; (separator-tag-file menu-item "--") - ;; (set-tags-name menu-item "Set Tags File Name..." visit-tags-table - ;; :help "Tell Tags commands which tag table file to use") - ;; "Go To")) - - ;; (bookmark menu-item "Bookmarks" menu-bar-bookmark-map) (separator-bookmark menu-item "--") (fill menu-item "Fill" fill-region :enable (and mark-active @@ -1788,45 +1603,7 @@ (blink-cursor menu-item "Cursor Blink" blink-cursor-mode :button (:toggle . blink-cursor-mode)) - ;; (auto-pair menu-item "Insert Matching Parentheses/Bracket" - ;; (lambda() (interactive) - ;; (cond - ;; ((fboundp 'smartparens-mode) - ;; (smartparens-mode)) - ;; ((fboundp 'autopair-global-mode) - ;; (autopair-global-mode)) - ;; (t (electric-pair-mode)))) - ;; :button (:toggle . - ;; (or - ;; (and (boundp 'smartparens-mode) smartparens-mode) - ;; (and (boundp 'auto-indent-mode) auto-indent-mode) - ;; electric-pair-mode))) - - (tabbar-mode menu-item "Tabbar" ergoemacs-menu-tabbar-toggle - :button (:toggle . (and (boundp 'tabbar-mode) - tabbar-mode))) - - - ;; (showhide-tool-bar menu-item "Tool-bar" tool-bar-mode :help "Turn tool-bar on/off" - ;; :button (:toggle . tool-bar-mode)) - - ;; (menu-bar-mode menu-item "Menu-bar" toggle-menu-bar-mode-from-frame :help "Turn menu-bar on/off" :button - ;; (:toggle menu-bar-positive-p - ;; (frame-parameter - ;; (menu-bar-frame-for-menubar) - ;; 'menu-bar-lines)) - ;; :keys "") - - ;; (showhide-tooltip-mode menu-item "Tooltips" tooltip-mode :help "Turn tooltips on/off" :visible - ;; (and - ;; (display-graphic-p) - ;; (fboundp 'x-show-tip)) - ;; :button - ;; (:toggle . tooltip-mode) - ;; :keys "") (separator-speedbar menu-item "--") - ;; (showhide-scroll-bar) - ;; (showhide-fringe) (showhide-speedbar menu-item "Speedbar" speedbar-frame-mode :help "Display a Speedbar quick-navigation frame" :button (:toggle and @@ -1835,8 +1612,6 @@ speedbar-frame) (frame-visible-p speedbar-frame))) - ;; (datetime-separator) - ;; (showhide-date-time) (linecolumn-separator "--") (line-number-mode menu-item "Line Numbers" line-number-mode :help "Show the current line number in the mode line" :button (:toggle and @@ -1948,13 +1723,6 @@ " Command Description..." Info-goto-emacs-command-node :help "Show emacs manual section about a command") - ;; Useless for ergoemacs... - ;; (key-desc menu-item - ;; " Key Description..." - ;; Info-goto-emacs-key-command-node - ;; :help "Show Emacs manual - ;; section that describes a key - ;; sequence.") (index menu-item " Index..." emacs-index-search @@ -2027,12 +1795,6 @@ (ergoemacs-theme lvl0 () "CUA-mode style" - (if (not (eq ergoemacs-handle-ctl-c-or-ctl-x 'only-C-c-and-C-x)) - (progn - (global-set-key (kbd "C-c <ergoemacs-timeout>") 'ergoemacs-copy-line-or-region) - (global-set-key (kbd "C-x <ergoemacs-timeout>") 'ergoemacs-cut-line-or-region) - ) - ) (global-set-key (kbd "<C-insert>") 'ergoemacs-copy-line-or-region) (global-set-key (kbd "C-S-v") 'ergoemacs-paste-cycle) @@ -2060,39 +1822,16 @@ "Set arrow keys in isearch." ;;left/right is backward/forward, up/down is history. press Return ;;to exit - ;; Xah Lee ;; See http://ergoemacs.org/emacs/emacs_isearch_by_arrow_keys.html (define-key isearch-mode-map (kbd "<up>") 'isearch-ring-retreat) (define-key isearch-mode-map (kbd "<down>") 'isearch-ring-advance) - ;; single key, useful (define-key isearch-mode-map (kbd "<left>") 'isearch-repeat-backward) - ;; single key, useful (define-key isearch-mode-map (kbd "<right>") 'isearch-repeat-forward)) (ergoemacs-component mode-line-major-mode-switch () "Switch major modes by clicking mode-name." (setq ergoemacs-swap-major-modes-when-clicking-major-mode-name t)) - -(ergoemacs-autoload multiple-cursors - "Multiple Cursors" - :bind (("M-*" mc/mark-next-like-this) - ("M-&" mc/edit-lines)) - :ensure t) - -(ergoemacs-autoload avy - "Avy" - :bind ("M-," 'avy-goto-word-or-subword-1) - :ensure t) - -(ergoemacs-autoload expand-region - "Expand Region" - :bind (("M-8" er/expand-region) - ("M-9" er/contract-region) - ("M-*". er/mark-inside-quotes)) - :ensure t) - - (ergoemacs-theme standard () "Standard Ergoemacs Theme" :components '(copy @@ -2196,8 +1935,6 @@ (define-key ergoemacs-keymap (kbd "M-U") nil) (define-key ergoemacs-keymap (kbd "M-O") nil) (define-key ergoemacs-keymap (kbd "M-N") nil) - ;; (define-key ergoemacs-keymap (kbd "M-G") nil) - ;; (define-key ergoemacs-keymap (kbd "M-S") nil) (define-key ergoemacs-keymap (kbd "M-A") nil) (define-key ergoemacs-keymap (kbd "M-J") nil) (define-key ergoemacs-keymap (kbd "M-L") nil)) @@ -2246,41 +1983,6 @@ (define-key map (if (eq system-type 'windows-nt) [M-apps] [M-menu]) 'ergoemacs-read-key-force-next-key-is-quoted) (define-key map (read-kbd-macro "SPC") 'ergoemacs-read-key-force-next-key-is-ctl) (define-key map (read-kbd-macro "M-SPC") 'ergoemacs-read-key-force-next-key-is-alt) - ;; (define-key map "G" 'ergoemacs-read-key-next-key-is-quoted) - ;; (define-key map "g" 'ergoemacs-read-key-next-key-is-alt) - map)) - -(ergoemacs-translation unchorded-ctl () - "Make the Ctl key sticky." - :text "<Ctl+>" - :unchorded '(control) - :shift '(control shift) - :meta '() - :control '(meta) - :keymap (let ((map (make-sparse-keymap))) - (define-key map [f1] 'ergoemacs-read-key-help) - (define-key map (read-kbd-macro "SPC") 'ergoemacs-read-key-force-next-key-is-quoted) - (define-key map (read-kbd-macro "M-SPC") 'ergoemacs-read-key-force-next-key-is-alt-ctl) - (define-key map "g" 'ergoemacs-read-key-force-next-key-is-alt) - (define-key map "G" 'ergoemacs-read-key-force-next-key-is-alt-ctl) map)) -(ergoemacs-translation unchorded-alt () - "Make the Alt key sticky." - :text "<Alt+>" - :unchorded '(meta) - :shift '(meta shift) - :meta '(meta shift) - :modal-color "red" - :keymap-modal (let ((map (make-sparse-keymap))) - (define-key map (read-kbd-macro "<return>") 'ergoemacs-unchorded-alt-modal) - (define-key map (read-kbd-macro "RET") 'ergoemacs-unchorded-alt-modal) - map)) - - (provide 'ergoemacs-themes) -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; ergoemacs-themes.el ends here -;; Local Variables: -;; coding: utf-8-emacs -;; End: diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el index a3b9f88..09281d2 100644 --- a/ergoemacs-translate.el +++ b/ergoemacs-translate.el @@ -51,7 +51,7 @@ ;;; Code: (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'ergoemacs-macros)) @@ -87,8 +87,6 @@ (declare-function ergoemacs-map-- "ergoemacs-map") -(declare-function ergoemacs-command-loop--modal-p "ergoemacs-command-loop") - (declare-function ergoemacs-translate--key-description "ergoemacs-translate") (fset #'ergoemacs-translate--key-description (symbol-function #'key-description)) @@ -698,14 +696,13 @@ For keys, the list consists of: (push key ret)) ret)) -(defstruct ergoemacs-translation-struct +(cl-defstruct ergoemacs-translation-struct "A basic ergoemacs translation structure." (name "default-name") (translation '()) (universal-argument nil) (negative-argument nil) (digit-argument nil) - (modal nil) (text "") (keymap (make-sparse-keymap)) (keymap-modal (make-sparse-keymap)) @@ -763,8 +760,8 @@ When NAME is a symbol, setup the translation function for the symbol." (fset (intern (concat "ergoemacs-" name-str type)) 'ergoemacs-translate--setup-command-loop) (when (string= type "-universal-argument") - (pushnew (intern (concat "ergoemacs-" name-str type)) ergoemacs-command-loop--universal-functions) - (pushnew (intern (concat "ergoemacs-translate--" name-str type)) ergoemacs-command-loop--universal-functions)))))) + (cl-pushnew (intern (concat "ergoemacs-" name-str type)) ergoemacs-command-loop--universal-functions) + (cl-pushnew (intern (concat "ergoemacs-translate--" name-str type)) ergoemacs-command-loop--universal-functions)))))) (add-hook 'ergoemacs-mode-intialize-hook #'ergoemacs-translate--setup-translation) @@ -775,7 +772,6 @@ When NAME is a symbol, setup the translation function for the symbol." -universal-argument -negative-argument -digit-argument - -modal translation (local-keymap (or (plist-get plist :keymap) (make-sparse-keymap))) (trans-keymap (intern (concat "ergoemacs-translate--" (plist-get plist :name) "-map")))) @@ -821,7 +817,6 @@ When NAME is a symbol, setup the translation function for the symbol." :universal-argument -universal-argument :negative-argument -negative-argument :digit-argument -digit-argument - :modal -modal :text (plist-get plist :text) :keymap local-keymap :keymap-modal (or (plist-get plist :keymap-modal) (make-sparse-keymap)) @@ -946,25 +941,16 @@ If there are no gui elements, retun nil." ;; (add-hook 'ergoemacs-mode-intialize-hook #'ergoemacs-translate--keymap-reset) (defun ergoemacs-translate--keymap (&optional translation) - "Get the keymap for TRANSLATION. -This takes into consideration the modal state of `ergoemacs-mode'." - (let* ((modal (ergoemacs :modal-p)) - (translation (or (and (ergoemacs-translation-struct-p translation) - (or (not modal) ;; prefer modal when :normal - (not (eq :normal (ergoemacs-translation-struct-key translation)))) + "Get the keymap for TRANSLATION." + (let* ((translation (or (and (ergoemacs-translation-struct-p translation) translation) - modal (ergoemacs-translate--get (or translation :normal)))) - (key (or (and modal (intern (concat ":" (ergoemacs-translation-struct-name translation) "-modal"))) - (ergoemacs-translation-struct-key translation))) + (key (ergoemacs-translation-struct-key translation)) (ret (ergoemacs-gethash key ergoemacs-translate--keymap-hash)) keymap) (unless ret - (if modal - (setq keymap (ergoemacs-translation-struct-keymap-modal translation) - ret keymap) - (setq keymap (ergoemacs-translation-struct-keymap translation) - ret (make-composed-keymap (ergoemacs keymap) (ergoemacs ergoemacs-translate--parent-map)))) + (setq keymap (ergoemacs-translation-struct-keymap translation) + ret (make-composed-keymap (ergoemacs keymap) (ergoemacs ergoemacs-translate--parent-map))) (puthash key ret ergoemacs-translate--keymap-hash)) ret))