branch: externals/ergoemacs-mode commit 5450f4d057959406d6f7713657811642f732003c Author: Stefan Monnier <monn...@iro.umontreal.ca> Commit: Stefan Monnier <monn...@iro.umontreal.ca>
Address the many warnings emitted by the compiler Move defvaraliases before the corresponding var declarations. Add `FIXME`s. Use lexical-binding also when calling `eval`. Adjust a few docstrings to use the imperative. Unquote lambdas. Remove unused vars. * ergoemacs-command-loop.el (ergoemacs-command-loop--spinner-display): Don't call `eval` when `cadr` does the trick. * ergoemacs-component.el (ergoemacs-component-struct--create-hooks): Only use `eval` for the part that needs it. * ergoemacs-functions.el (ergoemacs-emacs-exe): The invocation-name and invocation-directory functions are obsoleted in Emacs-27. (ergoemacs--default-dir-name): New function. (ergoemacs-shell-here-directory-change-hook, ergoemacs-shell-here) (ergoemacs-eshell-here): Use it. * ergoemacs-lib.el (ergoemacs-menu--filter): Use a closure instead of `(lambda ...). * ergoemacs-macros.el (ergoemacs-test-layout): Mark `macro` as a variable that might be left unused. (ergoemacs): Prefer `fboundp` tests; Simplify. * ergoemacs-mode.el (ergoemacs-load-aliases): Don't use `eval`. * ergoemacs-test.el: Use lexical-binding. Use cl-lib. (ergoemacs-test-dired-sort-files): Reduce redundancy. Don't assume that two copies of the "same" function are `equal`. * ergoemacs-translate.el: Use cl-lib. --- ergoemacs-command-loop.el | 30 +++--- ergoemacs-component.el | 33 +++--- ergoemacs-functions.el | 41 +++---- ergoemacs-layouts.el | 34 +++--- ergoemacs-lib.el | 52 ++++----- ergoemacs-macros.el | 92 ++++++++-------- ergoemacs-map-properties.el | 25 +++-- ergoemacs-map.el | 12 +-- ergoemacs-mode.el | 35 +++--- ergoemacs-test.el | 257 +++++++++++++++++++++----------------------- ergoemacs-theme-engine.el | 3 +- ergoemacs-themes.el | 3 +- ergoemacs-translate.el | 14 +-- 13 files changed, 316 insertions(+), 315 deletions(-) diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el index 9808459..7776f9e 100644 --- a/ergoemacs-command-loop.el +++ b/ergoemacs-command-loop.el @@ -106,11 +106,11 @@ "Determines if mark was active before ergoemacs command loop.") +(define-obsolete-variable-alias 'ergoemacs-universal-fns 'ergoemacs-command-loop--universal-functions "Ergoemacs-v5.16") + (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 "Ergoemacs-v5.16") - (defvar ergoemacs-command-loop--next-key-hash (let ((hash (make-hash-table))) (puthash 'event-apply-shift-modifier (list '(shift) :force) hash) @@ -129,14 +129,14 @@ (defvar ergoemacs-command-loop--help-last-key nil) +(define-obsolete-variable-alias 'ergoemacs-read-key-delay 'ergoemacs-command-loop--decode-event-delay "Ergoemacs-v5.16") + (defvar ergoemacs-command-loop--decode-event-delay 0.01 "Timeout for `ergoemacs-command-loop--decode-event'. 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 "Ergoemacs-v5.16") - (defvar ergoemacs-command-loop--history nil "History of command loop locations.") @@ -367,7 +367,7 @@ Ergoemacs-mode sets up: :ctl-to-alt :unchorded :normal." (next-key-is-control-meta (control meta)) (next-key-is-meta-control (control meta)) (next-key-is-quoted nil))) - (eval (macroexpand-all + (eval (macroexpand-all ;FIXME: Why macroexpand-all? `(progn (defun ,(intern (concat "ergoemacs-command-loop--" (symbol-name (nth 0 arg)))) () ,(format "Ergoemacs function to allow %s to be the emacs modifiers" (nth 1 arg)) @@ -382,7 +382,8 @@ Ergoemacs-mode sets up: :ctl-to-alt :unchorded :normal." (message "Dummy Function for %s" (ergoemacs :modifier-desc ,(nth 1 arg)))) (defalias ',(intern (concat "ergoemacs-read-key-force-" (symbol-name (nth 0 arg)))) ',(intern (concat "ergoemacs-command-loop--force-" (symbol-name (nth 0 arg))))) (puthash ',(intern (concat "ergoemacs-command-loop--force-" (symbol-name (nth 0 arg)))) '(,(nth 1 arg) :force) ergoemacs-command-loop--next-key-hash) - (puthash ',(intern (concat "ergoemacs-read-key-force-" (symbol-name (nth 0 arg)))) '(,(nth 1 arg) :force) ergoemacs-command-loop--next-key-hash))))) + (puthash ',(intern (concat "ergoemacs-read-key-force-" (symbol-name (nth 0 arg)))) '(,(nth 1 arg) :force) ergoemacs-command-loop--next-key-hash))) + t)) (defvar ergoemacs-last-command-event nil "`ergoemacs-mode' command loop last read command.") @@ -1556,10 +1557,10 @@ instead of `format'." (apply #'ergoemacs-command-loop--spinner-display args)) (setq ergoemacs-command-loop--spinner-display :max))) (when (eq ergoemacs-message-level ergoemacs-command-loop--spinner-display) - (let* ((string (or (and (listp string) - (eq (car string) 'quote) - (eval string)) - string)) + (let* ((string (if (and (listp string) + (eq (car string) 'quote)) + (cadr string) + string)) (rest (or (and (listp string) (concat " " (apply #'format (apply #'ergoemacs-key-description--unicode-char string) args))) (and (not string) "") @@ -1568,9 +1569,12 @@ instead of `format'." (when (not ergoemacs-command-loop--spinner-list) (setq ergoemacs-command-loop--spinner-list (nth 1 (assoc ergoemacs-command-loop-spinner ergoemacs-command-loop-spinners)) ergoemacs-command-loop--spinner-i 0)) - (ergoemacs-command-loop--message "%s%s" (nth (mod (setq ergoemacs-command-loop--spinner-i (+ 1 ergoemacs-command-loop--spinner-i)) - (length ergoemacs-command-loop--spinner-list)) ergoemacs-command-loop--spinner-list) - rest)))))) + (ergoemacs-command-loop--message + "%s%s" (nth (mod (setq ergoemacs-command-loop--spinner-i + (+ 1 ergoemacs-command-loop--spinner-i)) + (length ergoemacs-command-loop--spinner-list)) + ergoemacs-command-loop--spinner-list) + rest)))))) (defun ergoemacs-command-loop--spinner-end () "Cancel the `ergoemacs-command-loop--spinner' timer." diff --git a/ergoemacs-component.el b/ergoemacs-component.el index 32bf32d..b49c4a5 100644 --- a/ergoemacs-component.el +++ b/ergoemacs-component.el @@ -1,6 +1,6 @@ ;;; ergoemacs-component.el --- Ergoemacs map interface -*- lexical-binding: t -*- -;; Copyright © 2013-2015 Free Software Foundation, Inc. +;; Copyright © 2013-2018 Free Software Foundation, Inc. ;; Filename: ergoemacs-component.el ;; Description: @@ -169,9 +169,9 @@ if the package is deferred." (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) + (run-with-idle-timer defer nil #'require package ;; (lambda() + ;; (message (format "Defer: %s %s" package defer)) + ;; (require package) ;; (ergoemacs-component-struct--apply-inits)) ) ) @@ -432,7 +432,7 @@ Allows the component not to be calculated." (defvar ergoemacs-component-struct--define-key-temp-map nil) (defun ergoemacs-component-struct--define-key-get-def (def) - "Gets the `ergoemacs-mode' function definition for DEF." + "Get the `ergoemacs-mode' function definition for DEF." (let (tmp) (cond ((and (consp def) (memq (nth 0 def) '(kbd read-kbd-macro)) @@ -958,15 +958,19 @@ OBJ is the current object being modified, passed to (defvar ergoemacs-component-struct--create-hooks nil) (defun ergoemacs-component-struct--create-hooks (&optional obj) - "Gets a list of hooks that need to be defined eor OBJ." + "Get a list of hooks that need to be defined for OBJ." (dolist (hook (ergoemacs-component-struct--hooks obj)) - (eval `(progn - (defun ,(intern (concat "ergoemacs--" (symbol-name hook))) () + (let ((fun-name (intern (concat "ergoemacs--" (symbol-name hook))))) + ;; FIXME: Since Emacs-25 we could use a closure with a computed docstring, + ;; using (:documentation <exp>). + (eval `(defun ,fun-name () + ;; FIXME: This describes a *function* (placed on a hook) and + ;; not a hook, AFAICT. ,(format "`ergoemacs-mode' hook for `%s'" (symbol-name hook)) (ergoemacs-component-struct--composed-hook ',hook)) - ;; (push ) - (push ',hook ergoemacs-component-struct--create-hooks) - (add-hook ',hook #',(intern (concat "ergoemacs--" (symbol-name hook)))))))) + t) + (push hook ergoemacs-component-struct--create-hooks) + (add-hook hook fun-name)))) (defun ergoemacs-component-struct--rm-hooks () "Remove hooks. @@ -1112,7 +1116,10 @@ to prevent infinite recursion." ((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)) + ;; FIXME: avoid `eval', e.g. by making + ;; ergoemacs-component-struct-ensure hold a function rather than + ;; an expression. + (when (ignore-errors (eval ensure t)) (ergoemacs-component-struct--ensure package-name defer autoloads))) ((consp ensure) (dolist (elt ensure) @@ -1192,7 +1199,7 @@ to prevent infinite recursion." (nth 3 init)))) (t (condition-case err - (eval (nth 0 init)) + (eval (nth 0 init) t) (error (progn (ergoemacs-warn "%s while evaluating %s" err (nth 0 init)) (debug err)))) diff --git a/ergoemacs-functions.el b/ergoemacs-functions.el index 437c5d6..235f852 100644 --- a/ergoemacs-functions.el +++ b/ergoemacs-functions.el @@ -356,8 +356,12 @@ 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 (if (fboundp 'invocation-name) (invocation-name) + (if (boundp 'invocation-name) invocation-name))) + (emacs-dir (if (fboundp 'invocation-directory) (invocation-directory) + (if (boundp 'invocation-directory) invocation-directory))) + ;; FIXME: The quotes can't be quite right; better use something like + ;; `shell-quote-argument'. (full-exe (concat "\"" (expand-file-name emacs-exe emacs-dir) "\""))) full-exe)) @@ -1310,8 +1314,8 @@ Based on the value of `major-mode' and (defun ergoemacs-camelize-method (s &optional char) "Convert under_score string S to CamelCase string." (mapconcat 'identity (ergoemacs-mapcar-head - '(lambda (word) (downcase word)) - '(lambda (word) (capitalize (downcase word))) + #'downcase + (lambda (word) (capitalize (downcase word))) (split-string s (or char "_"))) "")) (defun ergoemacs-camel-bounds (camel-case-chars) @@ -1581,7 +1585,7 @@ by `ergoemacs-maximum-number-of-files-to-open'. (y-or-n-p (format "Open more than %s files? " ergoemacs-maximum-number-of-file-to-open))))) (when do-it (cond - ((eq system-type 'windows-nt) + ((fboundp 'w32-shell-execute) (dolist (f-path my-file-list) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" f-path t t)))) @@ -1597,13 +1601,14 @@ by `ergoemacs-maximum-number-of-files-to-open'. "Show current file in desktop (OS's file manager)." (interactive) (cond - ((eq system-type 'windows-nt) + ((fboundp 'w32-shell-execute) (w32-shell-execute "explore" (replace-regexp-in-string "/" "\\" default-directory t t))) ((eq system-type 'darwin) (shell-command "open .")) ((eq system-type 'gnu/linux) (let ((process-connection-type nil)) (start-process "" nil "xdg-open" "."))))) +;; FIXME: Why default to (cons nil nil) instead of just nil? (defvar ergoemacs-recently-closed-buffers (cons nil nil) "A list of recently closed buffers. The max number to track is controlled by the variable `ergoemacs-recently-closed-buffers-max'.") (defvar ergoemacs-recently-closed-buffers-max 30 "The maximum length for `ergoemacs-recently-closed-buffers'.") @@ -1787,8 +1792,8 @@ true; otherwise it is an emacs buffer." ;;; helm-mode functions -;;; This comes from https://github.com/emacs-helm/helm/pull/327, but -;;; was reverted so it is added back here. +;; This comes from https://github.com/emacs-helm/helm/pull/327, but +;; was reverted so it is added back here. (defcustom ergoemacs-helm-ff-ido-style-backspace t "Use backspace to navigate with `helm-find-files'. You will have to restart Emacs or reeval `helm-find-files-map' @@ -2419,14 +2424,18 @@ Guillemet -> quote, degree -> @, s-zed -> ss, upside-down ?! -> ?!." ;; Shell handling +(defun ergoemacs--default-dir-name () + (let ((afn (abbreviate-file-name default-directory))) + (if (fboundp 'w32-long-file-name) + (w32-long-file-name afn) ;; Fix case issues + afn))) + (defun ergoemacs-shell-here-directory-change-hook () "Renames buffer to reflect directory name." (let ((nbn (concat (cond - ((eq major-mode 'eshell-mode) "*eshell@") + ((derived-mode-p 'eshell-mode) "*eshell@") (t (replace-regexp-in-string "\\([*][^@]*[@]\\).*" "\\1" (buffer-name) t))) - (if (eq system-type 'windows-nt) - (w32-long-file-name (abbreviate-file-name default-directory)) ;; Fix case issues - (abbreviate-file-name default-directory)) "*"))) + (ergoemacs--default-dir-name) "*"))) (unless (string= nbn (buffer-name)) (setq nbn (generate-new-buffer-name nbn)) (rename-buffer nbn)))) @@ -2462,9 +2471,7 @@ Sends shell prompt string to process, then turns on (interactive) (let* ((shell (or shell-program 'shell)) (buf-prefix (or buffer-prefix (symbol-name shell))) - (name (concat "*" buf-prefix "@" (if (eq system-type 'windows-nt) - (w32-long-file-name (abbreviate-file-name default-directory)) ;; Fix case issues - (abbreviate-file-name default-directory)) "*"))) + (name (concat "*" buf-prefix "@" (ergoemacs--default-dir-name) "*"))) (set-buffer (get-buffer-create name)) (funcall shell name))) @@ -2486,9 +2493,7 @@ Sends shell prompt string to process, then turns on "Run/switch to an `eshell' process in the current directory" (interactive) (let* ((eshell-buffer-name - (concat "*eshell@" (if (eq system-type 'windows-nt) - (w32-long-file-name (abbreviate-file-name default-directory)) ;; Fix case issues - (abbreviate-file-name default-directory)) "*")) + (concat "*eshell@" (ergoemacs--default-dir-name) "*")) (eshell-exists-p (get-buffer eshell-buffer-name))) (if eshell-exists-p (switch-to-buffer eshell-exists-p) diff --git a/ergoemacs-layouts.el b/ergoemacs-layouts.el index 3aa0b95..372a780 100644 --- a/ergoemacs-layouts.el +++ b/ergoemacs-layouts.el @@ -1,6 +1,6 @@ ;;; ergoemacs-layouts.el --- keyboard layouts for ErgoEmacs -* lexical-binding: t -*- -;; Copyright (C) 2013, 2014 Free Software Foundation, Inc. +;; Copyright (C) 2013-2018 Free Software Foundation, Inc. ;; Maintainer: Matthew L. Fidler ;; Keywords: convenience @@ -44,6 +44,8 @@ ;; 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" "" @@ -70,8 +72,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" ";" "[" "]" "\\" @@ -97,6 +97,8 @@ "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" "ü" "+" "" @@ -121,6 +123,8 @@ "" "" "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" "/" "=" "\\" @@ -157,6 +161,8 @@ "" "" "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" "`" "+" "" @@ -230,8 +236,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" "è" "+" "" @@ -292,8 +296,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" "å" "\"" "" @@ -318,8 +320,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" ";" "[" "]" "\\" @@ -344,6 +344,8 @@ "" "" "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" "-" "=" "\\" "" "" "й" "ц" "у" "к" "е" "н" "г" "ш" "щ" "з" "х" "ъ" "" @@ -356,8 +358,6 @@ "" "" "Я" "Ч" "С" "М" "И" "Т" "Ь" "Б" "Ю" "," "" "" "") "Russian/Cryllic jcuken layout.") -(defvaralias 'ergoemacs-layout-jcuken 'ergoemacs-layout-ru) - (require 'help-mode) (defvar quail-keyboard-layout-alist) (defvar ergoemacs-keyboard-layout) @@ -395,11 +395,9 @@ If LAYOUT is unspecified, use `ergoemacs-keyboard-layout'." (alias (condition-case nil (indirect-variable variable) (error variable))) - (is-alias nil) (doc nil)) (setq doc (or (documentation-property variable 'variable-documentation) (progn - (setq is-alias t) (documentation-property alias 'variable-documentation)))) `(,variable menu-item ,(concat lay " - " doc) @@ -541,12 +539,12 @@ Otherwise, `ergoemacs-mode' will try to adjust based on your layout." when BASE is non-nil, the regular expression shows the regular expression matching the base layout." - (let ((reg (regexp-opt (ergoemacs-layouts--list t) t)) - (f1 "[\"`']\\(%s\\)[\"`']") + (let ((f1 "[\"`']\\(%s\\)[\"`']") (f2 "Base Layout: \\(%s\\)")) (format (cond (base f2) - (t f1)) (regexp-opt (ergoemacs-layouts--list) t)))) + (t f1)) + (regexp-opt (ergoemacs-layouts--list) t)))) (defun ergoemacs-layout-describe (&optional layout) "Display the full documentation of an `ergoemacs-mode' LAYOUT. @@ -560,14 +558,10 @@ LAYOUT can be either a symbol or string." (s (intern (concat "ergoemacs-layout-" layout))) (sv (and (boundp s) (symbol-value s))) (el-file (find-lisp-object-file-name s 'defvar)) - (alias (condition-case nil - (indirect-variable s) - (error s))) (doc (or (documentation-property s 'variable-documentation) (documentation-property s 'variable-documentation))) - pt png svg) (unless (featurep 'quail) (require 'quail)) diff --git a/ergoemacs-lib.el b/ergoemacs-lib.el index ba74d4f..fffb58e 100644 --- a/ergoemacs-lib.el +++ b/ergoemacs-lib.el @@ -26,6 +26,7 @@ ;; (require 'guide-key nil t) (require 'cl-lib) +(require 'find-func) (eval-when-compile (require 'ergoemacs-macros)) @@ -478,7 +479,7 @@ All other modes are assumed to be minor modes or unimportant. "Put `ergoemacs-mode' key bindings on menus." (let ((menu (or (and (not fn) menu) (funcall fn menu))) - tmp tmp2) + tmp2) ;; (when fn ;; (message "%s:\n\t%s" fn menu)) (if (not (ergoemacs-keymapp menu) ) @@ -502,36 +503,37 @@ All other modes are assumed to be minor modes or unimportant. ((and (ergoemacs-keymapp keymap) (ergoemacs-keymapp (cdr (cdr item)))) ;; JIT processing `(,(nth 0 item) menu-item ,(nth 1 item) ,(cdr (cdr item)) - :filter (lambda(bind) (ergoemacs-menu--filter bind nil ',keymap)))) + :filter ,(lambda(bind) (ergoemacs-menu--filter bind nil keymap)))) ((ergoemacs-keymapp (cdr (cdr item))) ;; JIT processing `(,(nth 0 item) menu-item ,(nth 1 item) ,(cdr (cdr item)) :filter ergoemacs-menu--filter)) ((ergoemacs-keymapp (car (cdr (cdr (cdr item))))) ;; (message "3:%s..." (substring (format "%s" item) 0 (min (length (format "%s" item)) 60))) - (if (setq tmp (plist-get item :filter)) - (mapcar - (lambda(elt) - (cond - ((eq elt :filter) - (setq tmp2 t) - :filter) - ((not tmp2) - elt) - ((eq elt 'ergoemacs-menu--filter) - (setq tmp2 nil) - 'ergoemacs-menu--filter) - ((ignore-errors - (and (consp elt) - (eq (nth 0 elt) 'lambda) - (eq (nth 0 (nth 2 elt)) 'ergoemacs-menu--filter))) - (setq tmp2 nil) - elt) - (t - (setq tmp2 nil) - `(lambda(bind) (ergoemacs-menu--filter bind ',tmp ',keymap))))) - item) - `(,@item :filter ergoemacs-menu--filter))) + (let ((tmp (plist-get item :filter))) + (if tmp + (mapcar + (lambda(elt) + (cond + ((eq elt :filter) + (setq tmp2 t) + :filter) + ((not tmp2) + elt) + ((eq elt 'ergoemacs-menu--filter) + (setq tmp2 nil) + 'ergoemacs-menu--filter) + ((ignore-errors + (and (consp elt) + (eq (nth 0 elt) 'lambda) + (eq (nth 0 (nth 2 elt)) 'ergoemacs-menu--filter))) + (setq tmp2 nil) + elt) + (t + (setq tmp2 nil) + (lambda(bind) (ergoemacs-menu--filter bind tmp keymap))))) + item) + `(,@item :filter ergoemacs-menu--filter)))) ((setq key (ergoemacs-menu--filter-key-menu-item item keymap)) (append item (cons :keys (cons key nil)))) (t item)))) diff --git a/ergoemacs-macros.el b/ergoemacs-macros.el index a23e9fa..2ac7d68 100644 --- a/ergoemacs-macros.el +++ b/ergoemacs-macros.el @@ -176,7 +176,7 @@ distinguish from the ASCII equivalents: `(ergoemacs-component-struct--define-key 'global-map ,(ergoemacs-theme-component--parse-key (nth 1 elt)) nil)) ((ignore-errors (eq (nth 0 elt) 'set)) ;; Currently doesn't support (setq a b c d ), but it should. - `(ergoemacs-component-struct--set ,(nth 1 elt) '(lambda() ,(nth 2 elt)))) + `(ergoemacs-component-struct--set ,(nth 1 elt) (lambda() ,(nth 2 elt)))) ((ignore-errors (eq (nth 0 elt) 'add-hook)) `(ergoemacs-component-struct--set ,(nth 1 elt) ,(nth 2 elt) (list t ,(nth 3 elt) ,(nth 4 elt)))) @@ -190,11 +190,11 @@ distinguish from the ASCII equivalents: (ret '())) (pop tmp-elt) (while (and (= 0 (mod (length tmp-elt) 2)) (< 0 (length tmp-elt))) - (push `(ergoemacs-component-struct--set (quote ,(pop tmp-elt)) '(lambda() ,(pop tmp-elt))) ret)) + (push `(ergoemacs-component-struct--set (quote ,(pop tmp-elt)) (lambda() ,(pop tmp-elt))) ret)) (push 'progn ret) ret)) ((ignore-errors (string-match "-mode$" (symbol-name (nth 0 elt)))) - `(ergoemacs-component-struct--set (quote ,(nth 0 elt)) '(lambda() ,(nth 1 elt)))) + `(ergoemacs-component-struct--set (quote ,(nth 0 elt)) (lambda() ,(nth 1 elt)))) ((ignore-errors (eq (nth 0 elt) 'global-set-key)) `(ergoemacs-component-struct--define-key 'global-map ,(ergoemacs-theme-component--parse-key (nth 1 elt)) ,(ergoemacs-theme-component--parse-fun (nth 2 elt)))) @@ -223,7 +223,7 @@ distinguish from the ASCII equivalents: (let ((tmp (ergoemacs-theme-component--parse (cdr (cdr elt)) t))) `(ergoemacs-component-struct--with-hook ',(nth 1 elt) ',(nth 0 tmp) - '(lambda () ,@(nth 1 tmp))))) + (lambda () ,@(nth 1 tmp))))) ((ignore-errors (memq (nth 0 elt) '(dolist when unless if))) `(,(car elt) ,(car (cdr elt)) ,@(macroexpand-all (ergoemacs-theme-component--parse-remaining (cdr (cdr elt)))))) ((ignore-errors (memq (nth 0 elt) '(ergoemacs-advice defadvice))) @@ -423,11 +423,15 @@ on the definition: :file -- File where the component was defined." (declare (doc-string 2) (indent 2)) - (let ((kb (make-symbol "body-and-plist"))) - (setq kb (ergoemacs-theme-component--parse body-and-plist)) + (let ((kb (ergoemacs-theme-component--parse body-and-plist))) `(let ((plist ',(nth 0 kb)) - (fun '(lambda () ,@(nth 1 kb)))) + (fun (lambda () ,@(nth 1 kb)))) + (defvar ergoemacs-component-hash) (unless (boundp 'ergoemacs-component-hash) + ;; FIXME: This places the "official one-and-only defvar" arbitrarily + ;; at the first file that runs ergoemacs-theme-component. Better would + ;; be to move this defvar outside of the macro, e.g. to + ;; ergoemacs-component.el. (defvar ergoemacs-component-hash (make-hash-table :test 'equal) "Hash of ergoemacs theme components")) (defvar ergoemacs-mode-reset) @@ -472,7 +476,7 @@ with :ergoemacs-require set to nil." (setq plist (plist-put plist :ergoemacs-require name))) (unless (plist-get plist :package-name) (setq plist (plist-put plist :package-name name))) - (macroexpand-all + (macroexpand-all ;FIXME: Why? `(ergoemacs-theme-component ,name () ,doc ,@plist @@ -538,6 +542,7 @@ with :ergoemacs-require set to t." `(edmacro-parse-keys ,(plist-get plist :macro) t))) (old-ergoemacs-keyboard-layout ergoemacs-keyboard-layout) (reset-ergoemacs nil)) + (ignore macro) (setq ergoemacs-theme ,(plist-get plist ':current-theme) ergoemacs-keyboard-layout ,(or (plist-get plist ':layout) "us") ergoemacs-command-loop-type nil @@ -670,7 +675,7 @@ The rest of the body is an `ergoemacs-theme-component' named (tmp (make-symbol "tmp")) (based-on (make-symbol "based-on"))) (setq kb (ergoemacs-theme-component--parse-keys-and-body body-and-plist)) - (setq tmp (eval (plist-get (nth 0 kb) :components))) + (setq tmp (eval (plist-get (nth 0 kb) :components) t)) (push (intern (concat (plist-get (nth 0 kb) :name) "-theme")) tmp) (setq tmp (plist-put (nth 0 kb) :components tmp)) (setq based-on (plist-get (nth 0 kb) :based-on)) @@ -682,7 +687,7 @@ The rest of the body is an `ergoemacs-theme-component' named ;; (message "Last Based-On: %s" based-on) (dolist (comp '(:optional-on :optional-off :options-menu)) (setq tmp (plist-put (nth 0 kb) comp - (eval (plist-get (nth 0 kb) comp))))) + (eval (plist-get (nth 0 kb) comp) t)))) (macroexpand-all `(let* ((based-on (ergoemacs-gethash ,based-on ergoemacs-theme-hash)) (curr-plist ',tmp) @@ -849,74 +854,69 @@ When arg1 can be a property. The following properties are supported: (arg3 (nth 2 args)) (arg4 (nth 3 args))) (cond - ((and arg1 (symbolp arg1) (eq arg1 :reset-prefix)) - (if (>= 25 emacs-major-version) + ((eq arg1 :reset-prefix) + (if (fboundp 'prefix-command-preserve-state) `(prefix-command-preserve-state) `(reset-this-command-lengths))) - ((and arg1 (symbolp arg1) (eq arg1 :set-selection)) - (if (>= 25 emacs-major-version) - `(gui-set-selection ,@(cdr args)) - `(x-set-selection ,@(cdr args)))) - ((and arg1 (symbolp arg1) (eq arg1 :set-selection)) - (if (>= 25 emacs-major-version) + ((eq arg1 :get-selection) + (if (fboundp 'gui-set-selection) + `(gui-get-selection ,@(cdr args)) + `(x-get-selection ,@(cdr args)))) + ((eq arg1 :set-selection) + (if (fboundp 'gui-set-selection) `(gui-set-selection ,@(cdr args)) `(x-set-selection ,@(cdr args)))) - ((and arg1 (symbolp arg1) (eq arg1 :width)) + ((eq arg1 :width) `(ergoemacs-mode--eval-width ,arg2)) - ((and arg1 (symbolp arg1) (eq arg1 :mode-if) arg2) + ((and (eq arg1 :mode-if) arg2) `(ergoemacs-mode-line--if ,arg2 ,arg3 ,arg4)) - ((and arg1 (symbolp arg1) (memq arg1 '(:sep :separator))) + ((memq arg1 '(:sep :separator)) `(ergoemacs-mode-line--sep ,@(cdr args))) - ((and arg1 (symbolp arg1) (memq arg1 '(:sep-right :separator-right))) + ((memq arg1 '(:sep-right :separator-right)) `(ergoemacs-mode-line--sep 'right ,@(cdr args))) - ((and arg1 (symbolp arg1) (memq arg1 '(:sep-left :separator-left))) + ((memq arg1 '(:sep-left :separator-left)) `(ergoemacs-mode-line--sep 'left ,@(cdr args))) - ((and arg1 (symbolp arg1) (eq arg1 :custom-p) (symbolp arg2)) + ((and (eq arg1 :custom-p) (symbolp arg2)) (if (fboundp 'custom-variable-p) `(custom-variable-p ,arg2) `(user-variable-p ,arg2))) - ((and arg1 (symbolp arg1) (eq arg1 :apply-key) arg2 arg3) + ((and (eq arg1 :apply-key) arg2 arg3) `(ergoemacs-translate--apply-key ,@(cdr args))) - ((and arg1 (symbolp arg1) (eq arg1 :spinner) arg2) + ((and (eq arg1 :spinner) arg2) `(ergoemacs-command-loop--spinner-display ,@(cdr args))) - ((and arg1 (symbolp arg1) (eq arg1 :define-key) arg2 arg3) + ((and (eq arg1 :define-key) arg2 arg3) `(ergoemacs-translate--define-key ,arg2 ,arg3 ,arg4)) - ((and arg1 (symbolp arg1) (eq arg1 :ignore-global-changes-p) (not arg2) (not arg3)) + ((and (eq arg1 :ignore-global-changes-p) (not arg2) (not arg3)) `(ergoemacs-map-properties--ignore-global-changes-p)) - ((and arg1 (symbolp arg1) (eq arg1 :user-before) (not arg2) (not arg3)) + ((and (eq arg1 :user-before) (not arg2) (not arg3)) `(ergoemacs-map-properties--before-ergoemacs)) - ((and arg1 (symbolp arg1) (eq arg1 :user-after) (not arg2) (not arg3)) + ((and (eq arg1 :user-after) (not arg2) (not arg3)) `(ergoemacs-map-properties--before-ergoemacs t)) - ((and arg1 (symbolp arg1) (eq arg1 :modal-p)) + ((eq arg1 :modal-p) `(ergoemacs-command-loop--modal-p)) - ((and arg1 (symbolp arg1) (eq arg1 :combine) arg2 arg3) + ((and (eq arg1 :combine) arg2 arg3) `(ergoemacs-command-loop--combine ,arg2 ,arg3)) - ((and arg1 (symbolp arg1) (memq arg1 '(:unicode-or-alt :unicode))) + ((memq arg1 '(:unicode-or-alt :unicode)) `(ergoemacs-key-description--unicode-char ,@(cdr args))) - ((and arg1 (symbolp arg1) (eq arg1 :modifier-desc) - arg2) + ((and (eq arg1 :modifier-desc) arg2) `(mapconcat #'ergoemacs-key-description--modifier ,arg2 "")) - ((and arg1 (symbolp arg1) (eq arg1 :current-version)) + ((eq arg1 :current-version) `(ergoemacs-theme--get-version)) - ((and arg1 (symbolp arg1) (eq arg1 :current-theme)) + ((eq arg1 :current-theme) `(or (and ergoemacs-theme (stringp ergoemacs-theme) ergoemacs-theme) (and ergoemacs-theme (symbolp ergoemacs-theme) (symbol-name ergoemacs-theme)) "standard")) - ((and arg1 (symbolp arg1) - (memq arg1 ergoemacs--map-properties-list)) + ((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) + ((and arg1 (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)) + ((eq arg1 :global-map) `(ergoemacs-map-properties--original (or ergoemacs-saved-global-map global-map))) - ((and arg1 (symbolp arg1) - (eq arg1 :revert-global-map)) + ((eq arg1 :revert-global-map) `(ergoemacs-map-properties--original (or ergoemacs-saved-global-map global-map) :setcdr)) - ((and arg1 (symbolp arg1) - (eq arg1 :remap) arg2) + ((and (eq arg1 :remap) arg2) `(progn (setq this-command (or (key-binding (vector 'ergoemacs-remap ,arg2) t nil (point)) ,arg2)) (call-interactively (or (key-binding (vector 'ergoemacs-remap ,arg2) t nil (point)) ,arg2)))) diff --git a/ergoemacs-map-properties.el b/ergoemacs-map-properties.el index 248a033..0799e4c 100644 --- a/ergoemacs-map-properties.el +++ b/ergoemacs-map-properties.el @@ -1,6 +1,6 @@ ;;; ergoemacs-map-properties.el --- Ergoemacs map interface -*- lexical-binding: t -*- -;; Copyright © 2013-2015 Free Software Foundation, Inc. +;; Copyright © 2013-2018 Free Software Foundation, Inc. ;; Filename: ergoemacs-map-properties.el ;; Description: @@ -467,9 +467,9 @@ This tests if HOOK is: (stringp tmp) (string-match-p "^Ergoemacs protect local" tmp))) fn - `(lambda() "Ergoemacs protect local" - (ergoemacs-map-properties--protect-local ',hook ',fn) - (funcall ',fn)))) + (lambda() "Ergoemacs protect local" + (ergoemacs-map-properties--protect-local hook fn) + (funcall fn)))) hook-value)) (t ;; For now do nothing hook-value)))))))) @@ -558,7 +558,7 @@ These keymaps are saved in `ergoemacs-map-properties--hook-map-hash'." (unless (equal icicle-search-key-prefix "\M-s\M-s") (ergoemacs :define-key new-map icicle-search-key-prefix icicle-search-map)) (when (and (boundp 'icicle-top-level-key-bindings) (custom-variable-p 'icicle-top-level-key-bindings)) - (setq standard (eval (car (get 'icicle-top-level-key-bindings 'standard-value)))) + (setq standard (eval (car (get 'icicle-top-level-key-bindings 'standard-value)) t)) ;; After determine if anything has changed... ;; Lifted partially from icicles (dolist (key-def icicle-top-level-key-bindings) @@ -566,7 +566,7 @@ These keymaps are saved in `ergoemacs-map-properties--hook-map-hash'." (setq key (car key-def) command (cadr key-def) condition (car (cddr key-def))) - (when (eval condition) + (when (eval condition t) (if (symbolp key) (icicle-remap key command new-map (current-global-map)) (ergoemacs :define-key new-map key command)))))) @@ -914,9 +914,11 @@ 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)) + (let (;; (parent (keymap-parent keymap)) (breadcrumb-base ergoemacs-map--breadcrumb) (struct (or struct (ergoemacs-gethash map-key ergoemacs-map-properties--key-struct))) + ;; FIXME: This `struct' refers to the arg rather than to the var + ;; we just defined on the previous line!! (comp (plist-get struct :composed)) (comp-list (ergoemacs-map-properties--composed-list keymap)) from-prop-p @@ -953,7 +955,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 @@ -984,7 +985,10 @@ STRUCT is the keymap structure for the current map." (setq old-plist (list :map-key map-key)) (unless indirect-p (push (cons 'ergoemacs-labeled - `(lambda() (interactive) ',old-plist)) map)) + ;; FIXME: These functions have no effect at all, so + ;; I strongly doubt they need to be interactive! + (lambda() (interactive) old-plist)) + map)) (unless indirect-p (when label (push label map)) @@ -1004,7 +1008,8 @@ STRUCT is the keymap structure for the current map." (if indirect-p (puthash keymap old-plist ergoemacs-map-properties--indirect-keymaps) (unless (ignore-errors (ergoemacs-setcdr keymap (cdr map))) - (cl-pushnew (cons old-plist (cdr keymap)) ergoemacs-map-properties--const-keymaps))) + (cl-pushnew (cons old-plist (cdr keymap)) + ergoemacs-map-properties--const-keymaps))) map))))) (defun ergoemacs-map-properties--empty-p (keymap &optional labeled-is-keymap-p) diff --git a/ergoemacs-map.el b/ergoemacs-map.el index 1c02a02..7ec5209 100644 --- a/ergoemacs-map.el +++ b/ergoemacs-map.el @@ -1,6 +1,6 @@ ;;; ergoemacs-map.el --- Ergoemacs map interface -*- lexical-binding: t -*- -;; Copyright © 2013-2015 Free Software Foundation, Inc. +;; Copyright © 2013-2018 Free Software Foundation, Inc. ;; Filename: ergoemacs-map.el ;; Description: @@ -35,6 +35,7 @@ (require 'cl-lib) (eval-when-compile (require 'ergoemacs-macros)) +(require 'ergoemacs-component) (defvar cl-struct-ergoemacs-component-struct-tags) (defvar ergoemacs-breadcrumb-hash) @@ -59,7 +60,6 @@ (defvar ess-language) (defvar ergoemacs-mode--fast-p) (defvar ergoemacs-remap-ignore) -(defvar ergoemacs-component-struct--composed-hook-minibuffer) (declare-function ergoemacs-timing-- "ergoemacs-mode") @@ -71,14 +71,6 @@ (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") -(declare-function ergoemacs-component-struct--get "ergoemacs-component") -(declare-function ergoemacs-component-struct--lookup-hash "ergoemacs-component") -(declare-function ergoemacs-component-struct--lookup-list "ergoemacs-component") -(declare-function ergoemacs-component-struct--minor-mode-map-alist "ergoemacs-component") -(declare-function ergoemacs-component-struct--rm-hooks "ergoemacs-component") -(declare-function ergoemacs-component-struct--translated-list "ergoemacs-component") - (declare-function ergoemacs-command-loop--minibuffer-supported-p "ergoemacs-command-loop") (declare-function ergoemacs-theme--get-version "ergoemacs-theme-engine") diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el index fd4ff97..4db418e 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -709,8 +709,8 @@ SYMBOL is the symbol to set, NEW-VALUE is it's value." "Remove `ergoemacs-mode' overriding keymap `ergoemacs-override-keymap'." (remove-hook 'emulation-mode-map-alists 'ergoemacs-override-alist)) -(add-hook 'ergoemacs-mode-startup-hook 'ergoemacs-setup-override-keymap) -(add-hook 'ergoemacs-mode-shudown-hook 'ergoemacs-setup-override-keymap) +(add-hook 'ergoemacs-mode-startup-hook #'ergoemacs-setup-override-keymap) +(add-hook 'ergoemacs-mode-shudown-hook #'ergoemacs-setup-override-keymap) @@ -766,7 +766,7 @@ not be useful. However instead of using (defun ergoemacs-load-aliases () "Load aliases defined in `ergoemacs-aliases'." (dolist (x ergoemacs-aliases) - (eval (macroexpand `(defalias ',(nth 0 x) ',(nth 1 x)))))) + (defalias (nth 0 x) (nth 1 x)))) (autoload 'ergoemacs-component "ergoemacs-macros") (autoload 'ergoemacs-theme-component "ergoemacs-macros") @@ -829,6 +829,8 @@ Valid values are: "Display Options for `ergoemacs-mode'." :group 'ergoemacs-mode) +(define-obsolete-variable-alias 'ergoemacs-use-unicode-char 'ergoemacs-display-unicode-characters "Ergoemacs-v5.16") + (defcustom ergoemacs-display-unicode-characters t "Use unicode characters when available." :type 'boolean @@ -836,7 +838,8 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-unicode-char 'ergoemacs-display-unicode-characters "Ergoemacs-v5.16") +(define-obsolete-variable-alias 'ergoemacs-use-ergoemacs-key-descriptions 'ergoemacs-display-ergoemacs-key-descriptions "Ergoemacs-v5.16") + (defcustom ergoemacs-display-ergoemacs-key-descriptions t "Use ergoemacs key descriptions (Alt+)." @@ -845,7 +848,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-ergoemacs-key-descriptions 'ergoemacs-display-ergoemacs-key-descriptions "Ergoemacs-v5.16") +(define-obsolete-variable-alias 'ergoemacs-use-unicode-brackets 'ergoemacs-display-use-unicode-brackets-around-keys "Ergoemacs-v5.16") (defcustom ergoemacs-display-use-unicode-brackets-around-keys t @@ -855,8 +858,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 "Ergoemacs-v5.16") - +(define-obsolete-variable-alias 'ergoemacs-use-small-symbols 'ergoemacs-display-small-symbols-for-key-modifiers "Ergoemacs-v5.16") (defcustom ergoemacs-display-small-symbols-for-key-modifiers nil "Use small symbols to represent alt+ ctl+ on windows/linux." @@ -865,7 +867,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 "Ergoemacs-v5.16") +(define-obsolete-variable-alias 'ergoemacs-capitalize-keys 'ergoemacs-display-capitalize-keys "Ergoemacs-v5.16") (defcustom ergoemacs-display-capitalize-keys 'with-modifiers "Capitalize keys like Ctrl+C. @@ -878,8 +880,10 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-capitalize-keys 'ergoemacs-display-capitalize-keys "Ergoemacs-v5.16") +(define-obsolete-variable-alias 'ergoemacs-pretty-key-use-face 'ergoemacs-display-key-use-face-p "Ergoemacs-v5.16") +;; FIXME: The suffix "-p" stands for "predicate", i.e. a *function* +;; returning a boolean value. Shouldn't be used for variables. (defcustom ergoemacs-display-key-use-face-p t "Use a button face for keys." :type 'boolean @@ -887,9 +891,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 "Ergoemacs-v5.16") - - (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." @@ -946,12 +947,14 @@ 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 "Ergoemacs-v5.16") + (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 "Ergoemacs-v5.16") +(define-obsolete-variable-alias 'ergoemacs-read-swaps 'ergoemacs-command-loop-swap-translation "Ergoemacs-v5.16") (defcustom ergoemacs-command-loop-swap-translation '(((:normal :normal) :unchorded-ctl) @@ -970,8 +973,6 @@ Valid values are: (sexp :tag "Translated Type"))) :group 'ergoemacs-command-loop) -(define-obsolete-variable-alias 'ergoemacs-read-swaps 'ergoemacs-command-loop-swap-translation "Ergoemacs-v5.16") - (defcustom ergoemacs-command-loop-type :full "Type of `ergoemacs-mode' command loop." :type '(choice @@ -1015,6 +1016,8 @@ Valid values are: :type '(repeat string) :group 'ergoemacs-modal) +(define-obsolete-variable-alias 'ergoemacs-default-cursor 'ergoemacs-default-cursor-color "Ergoemacs-v5.16") + (defcustom ergoemacs-default-cursor-color nil "Default cursor color. @@ -1025,8 +1028,6 @@ 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 "Ergoemacs-v5.16") - (defcustom ergoemacs-modal-emacs-state-modes '(archive-mode bbdb-mode diff --git a/ergoemacs-test.el b/ergoemacs-test.el index b0680dd..787e457 100644 --- a/ergoemacs-test.el +++ b/ergoemacs-test.el @@ -1,6 +1,6 @@ -;;; ergoemacs-test.el --- tests for ErgoEmacs issues +;;; ergoemacs-test.el --- tests for ErgoEmacs issues -*- lexical-binding:t -*- -;; Copyright © 2013-2015 Free Software Foundation, Inc. +;; Copyright © 2013-2018 Free Software Foundation, Inc. ;; Maintainer: Matthew L. Fidler ;; Keywords: convenience @@ -28,9 +28,10 @@ ;;; Code: -(eval-when-compile - (require 'cl) +(eval-when-compile + (require 'cl-lib) (require 'ergoemacs-macros)) +(require 'ergoemacs-component) ;For ergoemacs-component-struct-plist (declare-function ergoemacs-translate--keymap "ergoemacs-translate") (declare-function ergoemacs-mode-reset "ergoemacs-mode") @@ -41,6 +42,13 @@ (defvar ergoemacs-keyboard-layout) (defvar ergoemacs-theme) (defvar ergoemacs-command-loop-type) +(defvar ergoemacs-ctl-c-or-ctl-x-delay) +(defvar ergoemacs-handle-ctl-c-or-ctl-x) +(defvar ergoemacs-end-of-comment-line) +(defvar ergoemacs-back-to-indentation) +(defvar ergoemacs-read-input-keys) +(defvar ergoemacs-is-user-defined-map-change-p) +(defvar ergoemacs-use-function-remapping) (defvar ergoemacs-dir) (defvar ergoemacs-mode) (defvar dired-sort-map) @@ -88,6 +96,7 @@ ;;; Not sure why `cl-gensym' is called, probably from `ert'/`elp'? ;; Suppress: "the function `cl-gensym' might not be defined at ;; runtime" warning. +;; FIXME: The warning doesn't seem to appear any more in recent Emacsen anyway. (autoload 'cl-gensym "cl-macs.el") (defvar ergoemacs-test-lorem-ipsum "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed @@ -172,11 +181,9 @@ sunt in culpa qui officia deserunt mollit anim id est laborum.") (defun ergoemacs-test () "Test ergoemacs issues." (interactive) - (let ((ret t) - (test)) - (elp-instrument-package "ergoemacs-") - (ert '(and "^ergoemacs-test-" (not (tag :require-input)))) - (call-interactively 'elp-results))) + (elp-instrument-package "ergoemacs-") + (ert '(and "^ergoemacs-test-" (not (tag :require-input)))) + (call-interactively 'elp-results)) ;; Test isearch @@ -355,22 +362,22 @@ Tests issue #347" (ert-deftest ergoemacs-test-shift-select-subword () "Test for mark working with shift-selection of `subword-forward'." :tags '(:shift-select) - (let (ret) - (ergoemacs-test-layout - :macro "M-Y M-x" - :theme "reduction" - :layout "colemak" - (save-excursion - (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) - (delete-region (point-min) (point-max)) - (insert ergoemacs-test-lorem-ipsum) - (subword-mode 1) - (goto-char (point-max)) - (beginning-of-line) - (execute-kbd-macro macro) - (when (looking-at " in culpa qui") - (setq ret t)) - (kill-buffer (current-buffer)))))) + (ergoemacs-test-layout + :macro "M-Y M-x" + :theme "reduction" + :layout "colemak" + (save-excursion + (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) + (delete-region (point-min) (point-max)) + (insert ergoemacs-test-lorem-ipsum) + (subword-mode 1) + (goto-char (point-max)) + (beginning-of-line) + (execute-kbd-macro macro) + (when (looking-at " in culpa qui") + ;; (setq ret t) + ) + (kill-buffer (current-buffer))))) ;;; Copy/Paste @@ -378,8 +385,7 @@ Tests issue #347" (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)) + (let ((ergoemacs-handle-ctl-c-or-ctl-x 'both)) (ergoemacs-test-layout :macro "C-v" (save-excursion @@ -574,7 +580,7 @@ not using cua or cutting line. I think kill-region is what is meant." (ert-deftest ergoemacs-test-function-M-e-only-one-char-issue-306 () "Tests Issue #306." :tags '(:calc) - (let ((ergoemacs-test-fn t) + (let (;; (ergoemacs-test-fn t) (ergoemacs-read-input-keys nil)) (ergoemacs-test-layout :layout "us" @@ -587,7 +593,7 @@ not using cua or cutting line. I think kill-region is what is meant." (fundamental-mode) (should (or (eq (key-binding (kbd "M-e")) 'backward-kill-word) (eq (key-binding (kbd "M-e")) (command-remapping 'backward-kill-word (point))))) - (setq ergoemacs-test-fn nil) + ;; (setq ergoemacs-test-fn nil) (goto-char (point-max)) (execute-kbd-macro macro) (should (string= "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed @@ -640,23 +646,22 @@ Grep finished (matches found) at Fri Aug 22 08:30:37 (ergoemacs-test-layout :layout "colemak" :macro "M-m" - (let (ret) - (save-excursion - (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) - (delete-region (point-min) (point-max)) - (insert "abc\n* TODO Fix org C-a issue") - (org-mode) - (goto-char (point-max)) - (execute-kbd-macro macro) - (ignore-errors - (should (string= (buffer-substring (point) (point-at-eol)) - "Fix org C-a issue"))) - (kill-buffer (current-buffer)))))) + (save-excursion + (switch-to-buffer (get-buffer-create "*ergoemacs-test*")) + (delete-region (point-min) (point-max)) + (insert "abc\n* TODO Fix org C-a issue") + (org-mode) + (goto-char (point-max)) + (execute-kbd-macro macro) + (ignore-errors + (should (string= (buffer-substring (point) (point-at-eol)) + "Fix org C-a issue"))) + (kill-buffer (current-buffer))))) (ert-deftest ergoemacs-test-org-respect-keys-issue-304 () "Tests Issue #304. `org-mode' should respect the keys used." - (let ((ergoemacs-test-fn t)) + (let () ;; (ergoemacs-test-fn t) (ergoemacs-test-layout :layout "us" :theme "standard" @@ -678,7 +683,7 @@ Grep finished (matches found) at Fri Aug 22 08:30:37 (ert-deftest ergoemacs-test-calc-300 () "Test Calc undo" :tags '(:calc :interactive) - (let ((ergoemacs-test-fn t)) + (let () ;; (ergoemacs-test-fn t) (ergoemacs-test-layout :theme "reduction" :layout "colemak" @@ -690,7 +695,7 @@ Grep finished (matches found) at Fri Aug 22 08:30:37 (ert-deftest ergoemacs-test-calc-fries-ergoemacs-mode () "After calc has entered some numbers, it fries ergoemacs-mode." :tags '(:calc :interactive) - (let ((ergoemacs-test-fn t)) + (let () ;; (ergoemacs-test-fn t) (ergoemacs-test-layout :theme "reduction" :layout "colemak" @@ -716,24 +721,22 @@ Test next and prior translation." (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)))))) - + (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 @@ -915,7 +918,7 @@ Should test issue #142" (w-file (expand-file-name "global-test" ergoemacs-dir)) (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) (setq sk - (format "(%s '(lambda() (interactive) (with-temp-file \"%s\" (insert \"Ok\"))))" + (format "(%s (lambda() (interactive) (with-temp-file \"%s\" (insert \"Ok\"))))" (cond ((eq ergoemacs 'define-key) (format "define-key global-map (kbd \"%s\") " test-key)) @@ -1377,9 +1380,9 @@ Should test issue #142" (let ((ergoemacs-is-user-defined-map-change-p t)) (add-hook 'ergoemacs-test-major-mode-hook - '(lambda() - (interactive) - (define-key ergoemacs-test-major-mode-map (kbd "C-w") 'ergoemacs-close-current-buffer)))) + (lambda() + (interactive) + (define-key ergoemacs-test-major-mode-map (kbd "C-w") 'ergoemacs-close-current-buffer)))) (ert-deftest ergoemacs-test-issue-349 () "Unbind <f6>" @@ -1416,8 +1419,7 @@ Should test issue #142" (ert-deftest ergoemacs-test-ignore-ctl-w () "Keep user-defined C-w in major-mode `ergoemacs-test-major-mode'. Part of addressing Issue #147." - (let (ret - (ergoemacs-use-function-remapping t)) + (let ((ergoemacs-use-function-remapping t)) (with-temp-buffer (ergoemacs-test-major-mode) (when (not (current-local-map)) @@ -1432,8 +1434,7 @@ Part of addressing Issue #147." Part of addressing Issue #147." :tags '(:interactive) (ergoemacs-test-layout - (let (ret - (ergoemacs-use-function-remapping t)) + (let ((ergoemacs-use-function-remapping t)) (with-temp-buffer (ergoemacs-test-major-mode) (when (not (current-local-map)) @@ -1450,8 +1451,7 @@ Tests Issue #372." (ergoemacs-test-layout :layout "us" :theme "reduction" - (let (ret - (ergoemacs-use-function-remapping t)) + (let ((ergoemacs-use-function-remapping t)) (with-temp-buffer (ergoemacs-test-major-mode) (when (not (current-local-map)) @@ -1461,54 +1461,40 @@ Tests Issue #372." (ert-deftest ergoemacs-test-dired-sort-files () "Test Issue #340" - (add-hook 'dired-mode-hook (lambda () - (interactive) - (make-local-variable 'dired-sort-map) - (setq dired-sort-map (make-sparse-keymap)) - (define-key dired-mode-map "s" dired-sort-map) - (define-key dired-sort-map "s" - '(lambda () "sort by Size" - (interactive) (dired-sort-other (concat dired-listing-switches "-AlS --si --time-style long-iso")))) - (define-key dired-sort-map "." - '(lambda () "sort by eXtension" - (interactive) (dired-sort-other (concat dired-listing-switches "X")))) - (define-key dired-sort-map "t" - '(lambda () "sort by Time" - (interactive) (dired-sort-other (concat dired-listing-switches "t")))) - (define-key dired-sort-map "n" - '(lambda () "sort by Name" - (interactive) (dired-sort-other (concat dired-listing-switches "")))) - ;; Use "|", not "r". - (define-key dired-mode-map "|" 'dired-sort-menu-toggle-reverse) - )) - (dired ergoemacs-dir) - (ergoemacs-map--modify-active) - (should (equal (key-binding (kbd "s s")) '(lambda () "sort by Size" (interactive) (dired-sort-other (concat dired-listing-switches "-AlS --si --time-style long-iso"))))) - (should (equal (key-binding (kbd "s .")) '(lambda () "sort by eXtension" (interactive) (dired-sort-other (concat dired-listing-switches "X"))))) - (should (equal (key-binding (kbd "s t")) '(lambda () "sort by Time" (interactive) (dired-sort-other (concat dired-listing-switches "t"))))) - (should (equal (key-binding (kbd "s n")) '(lambda () "sort by Name" (interactive) (dired-sort-other (concat dired-listing-switches ""))))) - (should (equal (key-binding (kbd "|")) 'dired-sort-menu-toggle-reverse)) - (kill-buffer (current-buffer)) - (remove-hook 'dired-mode-hook (lambda () - (interactive) - (make-local-variable 'dired-sort-map) - (setq dired-sort-map (make-sparse-keymap)) - (define-key dired-mode-map "s" dired-sort-map) - (define-key dired-sort-map "s" - '(lambda () "sort by Size" - (interactive) (dired-sort-other (concat dired-listing-switches "-AlS --si --time-style long-iso")))) - (define-key dired-sort-map "." - '(lambda () "sort by eXtension" - (interactive) (dired-sort-other (concat dired-listing-switches "X")))) - (define-key dired-sort-map "t" - '(lambda () "sort by Time" - (interactive) (dired-sort-other (concat dired-listing-switches "t")))) - (define-key dired-sort-map "n" - '(lambda () "sort by Name" - (interactive) (dired-sort-other (concat dired-listing-switches "")))) - ;; Use "|", not "r". - (define-key dired-mode-map "|" 'dired-sort-menu-toggle-reverse) - ))) + (let* ((ds-map (make-sparse-keymap)) + (dh-fun + (lambda () + (set (make-local-variable 'dired-sort-map) ds-map) + ;; FIXME: This modifies the global dired-mode-map!! + (define-key dired-mode-map "s" dired-sort-map) + ;; Use "|", not "r". + ;; FIXME: This modifies the global dired-mode-map!! + (define-key dired-mode-map "|" 'dired-sort-menu-toggle-reverse))) + (funs `(("s" . + ,(lambda () "sort by Size" + ;; FIXME: Does the body of those functions matter? + (interactive) (dired-sort-other (concat dired-listing-switches "-AlS --si --time-style long-iso")))) + ("." . + ,(lambda () "sort by eXtension" + (interactive) (dired-sort-other (concat dired-listing-switches "X")))) + ("t" . + ,(lambda () "sort by Time" + (interactive) (dired-sort-other (concat dired-listing-switches "t")))) + ("n" . + ,(lambda () "sort by Name" + (interactive) (dired-sort-other (concat dired-listing-switches ""))))))) + (dolist (f funs) + (define-key ds-map (car f) (cdr f))) + (add-hook 'dired-mode-hook dh-fun) + (dired ergoemacs-dir) + (ergoemacs-map--modify-active) + (should (equal (key-binding (kbd "s s")) (cdr (assoc "s" funs)))) + (should (equal (key-binding (kbd "s .")) (cdr (assoc "." funs)))) + (should (equal (key-binding (kbd "s t")) (cdr (assoc "t" funs)))) + (should (equal (key-binding (kbd "s n")) (cdr (assoc "n" funs)))) + (should (equal (key-binding (kbd "|")) 'dired-sort-menu-toggle-reverse)) + (kill-buffer (current-buffer)) + (remove-hook 'dired-mode-hook dh-fun))) (ert-deftest ergoemacs-test-quail-translations () @@ -1552,7 +1538,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))))) @@ -1562,7 +1548,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))))) @@ -1724,7 +1710,7 @@ hash appropriaetly." "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)) + ;; (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"))) "\")" @@ -1778,9 +1764,11 @@ hash appropriaetly." 0.05 nil (lambda() (throw 'found-key (mapcar (lambda(key) (if (consp key) - (key-binding (eval key)) - (key-binding key))) ',keys))))) - ,minibuffer-call) nil)) + (key-binding (eval key t)) + (key-binding key))) + ',keys))))) + ,minibuffer-call) + nil)) (ert-deftest ergoemacs-test-icy-407-minibuffer () "Test minibuffer keybindings for `icy-mode'. @@ -1790,15 +1778,14 @@ 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)) + (ergoemacs-test-layout + :layout "us" + :theme "standard" + (should (equal (ergoemacs-minibuffer-key-bindings + (call-interactively 'icicle-execute-extended-command) + [f11] [f12] (kbd "M-o") (kbd "M-s") (kbd "M-r")) + '(previous-history-element next-history-element forward-word ergoemacs-move-cursor-next-pane kill-word)))) + (icy-mode -1)) (provide 'ergoemacs-test) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el index 053c73e..1f3d846 100644 --- a/ergoemacs-theme-engine.el +++ b/ergoemacs-theme-engine.el @@ -52,7 +52,8 @@ (eval-when-compile (require 'ergoemacs-macros) - (require 'cl)) + (require 'cl-lib)) +(require 'find-func) (defvar ergoemacs-mode) (defvar ergoemacs-require) diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el index f831f4d..7644c2b 100644 --- a/ergoemacs-themes.el +++ b/ergoemacs-themes.el @@ -29,8 +29,9 @@ ;;; Code: (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'ergoemacs-macros)) +(require 'ergoemacs-component) (declare-function ergoemacs-theme-component--create-component "ergoemacs-theme") (declare-function ergoemacs-component-struct--create-component "ergoemacs-component") diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el index e97d857..3961507 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)) @@ -644,7 +644,7 @@ 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 '()) @@ -691,14 +691,16 @@ When NAME is a symbol, setup the translation function for the symbol." ergoemacs-translation-hash) (let ((name-str (and (symbolp name) (substring (symbol-name name) 1)))) (eval - (macroexpand + (macroexpand ;FIXME: Why? `(progn (defvar ,(intern (concat "ergoemacs-translate--" name-str "-map")) (make-sparse-keymap) ,(concat "Ergoemacs local map for translation :" name-str " while completing a key sequence.")) (define-obsolete-variable-alias ',(intern (concat "ergoemacs-" name-str "-translation-local-map")) - ',(intern (concat "ergoemacs-translate--" name-str "-map")))))) + ',(intern (concat "ergoemacs-translate--" name-str "-map")) + "Ergoemacs-v5.16"))) + t) (ergoemacs-map-properties--label-map (intern (concat "ergoemacs-translate--" name-str "-map")) t) (ergoemacs (symbol-value (intern (concat "ergoemacs-translate--" name-str "-map"))) :only-local-modifications-p t) ;; @@ -709,8 +711,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)