branch: externals/ergoemacs-mode commit f3f4bf066d7453efa7b55b85fb46bd3aa4bab848 Author: Matthew Fidler <514778+mattfid...@users.noreply.github.com> Commit: Matthew Fidler <514778+mattfid...@users.noreply.github.com>
Revert "Merge remote-tracking branch 'elpa/externals/ergoemacs-mode'" This reverts commit b61ece84cfbbe4f47de2e57ae42c0511068b8df3, reversing changes made to ad3ec45ebbfdfaca052253c550102fd665b3bd1b. --- .gitignore | 3 - ergoemacs-command-loop.el | 33 +++-- ergoemacs-component.el | 33 ++--- ergoemacs-functions.el | 43 +++---- ergoemacs-layouts.el | 34 +++-- ergoemacs-lib.el | 64 +++++---- ergoemacs-macros.el | 307 ++++++++++++++++++++++---------------------- ergoemacs-map-properties.el | 25 ++-- ergoemacs-map.el | 12 +- ergoemacs-mode.el | 36 +++--- ergoemacs-test.el | 255 +++++++++++++++++++----------------- ergoemacs-theme-engine.el | 12 +- ergoemacs-themes.el | 7 +- ergoemacs-translate.el | 32 ++--- 14 files changed, 450 insertions(+), 446 deletions(-) diff --git a/.gitignore b/.gitignore index aa6f6df..be4d2c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ *~ ~* out/* -ChangeLog -*-autoloads.el -*-pkg.el *.elc \#*\# .\#* diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el index ee39cc8..8628dbb 100644 --- a/ergoemacs-command-loop.el +++ b/ergoemacs-command-loop.el @@ -1,6 +1,6 @@ ;;; ergoemacs-command-loop.el --- Keyboard translation functions -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2016 Free Software Foundation, Inc. ;; Filename: ergoemacs-command-loop.el ;; Description: @@ -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) + (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) + (defvar ergoemacs-command-loop--history nil "History of command loop locations.") @@ -369,7 +369,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 ;FIXME: Why macroexpand-all? + (eval (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)) @@ -384,8 +384,7 @@ 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))) - t)) + (puthash ',(intern (concat "ergoemacs-read-key-force-" (symbol-name (nth 0 arg)))) '(,(nth 1 arg) :force) ergoemacs-command-loop--next-key-hash))))) (defvar ergoemacs-last-command-event nil "`ergoemacs-mode' command loop last read command.") @@ -1648,10 +1647,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 (if (and (listp string) - (eq (car string) 'quote)) - (cadr string) - string)) + (let* ((string (or (and (listp string) + (eq (car string) 'quote) + (eval string)) + string)) (rest (or (and (listp string) (concat " " (apply #'format (apply #'ergoemacs-key-description--unicode-char string) args))) (and (not string) "") @@ -1660,12 +1659,10 @@ 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 3701e67..3740e57 100644 --- a/ergoemacs-component.el +++ b/ergoemacs-component.el @@ -1,6 +1,6 @@ ;;; ergoemacs-component.el --- Ergoemacs map interface -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2015 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) - "Get the `ergoemacs-mode' function definition for DEF." + "Gets the `ergoemacs-mode' function definition for DEF." (let (tmp) (cond ((and (consp def) (memq (nth 0 def) '(kbd read-kbd-macro)) @@ -978,19 +978,15 @@ OBJ is the current object being modified, passed to (defvar ergoemacs-component-struct--create-hooks nil) (defun ergoemacs-component-struct--create-hooks (&optional obj) - "Get a list of hooks that need to be defined for OBJ." + "Gets a list of hooks that need to be defined eor OBJ." (dolist (hook (ergoemacs-component-struct--hooks obj)) - (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. + (eval `(progn + (defun ,(intern (concat "ergoemacs--" (symbol-name hook))) () ,(format "`ergoemacs-mode' hook for `%s'" (symbol-name hook)) (ergoemacs-component-struct--composed-hook ',hook)) - t) - (push hook ergoemacs-component-struct--create-hooks) - (add-hook hook fun-name)))) + ;; (push ) + (push ',hook ergoemacs-component-struct--create-hooks) + (add-hook ',hook #',(intern (concat "ergoemacs--" (symbol-name hook)))))))) (defun ergoemacs-component-struct--rm-hooks () "Remove hooks. @@ -1136,10 +1132,7 @@ 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))) - ;; FIXME: avoid `eval', e.g. by making - ;; ergoemacs-component-struct-ensure hold a function rather than - ;; an expression. - (when (ignore-errors (eval ensure t)) + (when (ignore-errors (eval ensure)) (ergoemacs-component-struct--ensure package-name defer autoloads))) ((consp ensure) (dolist (elt ensure) @@ -1219,7 +1212,7 @@ to prevent infinite recursion." (nth 3 init)))) (t (condition-case err - (eval (nth 0 init) t) + (eval (nth 0 init)) (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 b9dc43c..5c46645 100644 --- a/ergoemacs-functions.el +++ b/ergoemacs-functions.el @@ -1,6 +1,6 @@ ;;; ergoemacs-functions.el --- miscellaneous functions for ErgoEmacs -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2015 Free Software Foundation, Inc. ;; Maintainer: Matthew L. Fidler ;; Authors: Xah Lee, Matthew Fidler, Drew Adams, Ting-Yu Lin, David @@ -357,12 +357,8 @@ If TERMINAL is non-nil, run the terminal version" (defun ergoemacs-emacs-exe () "Get the Emacs executable for testing purposes." - (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'. + (let* ((emacs-exe (invocation-name)) + (emacs-dir (invocation-directory)) (full-exe (concat "\"" (expand-file-name emacs-exe emacs-dir) "\""))) full-exe)) @@ -1321,8 +1317,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 - #'downcase - (lambda (word) (capitalize (downcase word))) + '(lambda (word) (downcase word)) + '(lambda (word) (capitalize (downcase word))) (split-string s (or char "_"))) "")) (defun ergoemacs-camel-bounds (camel-case-chars) @@ -1592,7 +1588,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 - ((fboundp 'w32-shell-execute) + ((eq system-type 'windows-nt) (dolist (f-path my-file-list) (w32-shell-execute "open" (replace-regexp-in-string "/" "\\" f-path t t)))) @@ -1608,14 +1604,13 @@ by `ergoemacs-maximum-number-of-files-to-open'. "Show current file in desktop (OS's file manager)." (interactive) (cond - ((fboundp 'w32-shell-execute) + ((eq system-type 'windows-nt) (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'.") @@ -1799,8 +1794,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' @@ -2426,18 +2421,14 @@ 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 - ((derived-mode-p 'eshell-mode) "*eshell@") + ((eq major-mode 'eshell-mode) "*eshell@") (t (replace-regexp-in-string "\\([*][^@]*[@]\\).*" "\\1" (buffer-name) t))) - (ergoemacs--default-dir-name) "*"))) + (if (eq system-type 'windows-nt) + (w32-long-file-name (abbreviate-file-name default-directory)) ;; Fix case issues + (abbreviate-file-name default-directory)) "*"))) (unless (string= nbn (buffer-name)) (setq nbn (generate-new-buffer-name nbn)) (rename-buffer nbn)))) @@ -2476,7 +2467,9 @@ 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 "@" (ergoemacs--default-dir-name) "*"))) + (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)) "*"))) (set-buffer (get-buffer-create name)) (funcall shell name))) @@ -2498,7 +2491,9 @@ 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@" (ergoemacs--default-dir-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)) "*")) (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 78615ab..dc3f913 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-2018 Free Software Foundation, Inc. +;; Copyright (C) 2013, 2014 Free Software Foundation, Inc. ;; Maintainer: Matthew L. Fidler ;; Keywords: convenience @@ -69,8 +69,6 @@ ;; 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" "" @@ -97,6 +95,8 @@ "" ">" "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,8 +122,6 @@ "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" "ü" "+" "" @@ -148,8 +146,6 @@ "" "" "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" "/" "=" "\\" @@ -186,8 +182,6 @@ "" "" "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" "`" "+" "" @@ -261,6 +255,8 @@ "" "|" ":" "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" "è" "+" "" @@ -321,6 +317,8 @@ "" "»" "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" "å" "\"" "" @@ -345,6 +343,8 @@ "" "" "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,8 +369,6 @@ "" "" "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" "-" "=" "\\" "" "" "й" "ц" "у" "к" "е" "н" "г" "ш" "щ" "з" "х" "ъ" "" @@ -383,6 +381,8 @@ "" "" "Я" "Ч" "С" "М" "И" "Т" "Ь" "Б" "Ю" "," "" "" "") "Russian/Cryllic jcuken layout.") +(defvaralias 'ergoemacs-layout-jcuken 'ergoemacs-layout-ru) + (require 'help-mode) (defvar quail-keyboard-layout-alist) (defvar ergoemacs-keyboard-layout) @@ -420,9 +420,11 @@ 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) @@ -564,12 +566,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 ((f1 "[\"`']\\(%s\\)[\"`']") + (let ((reg (regexp-opt (ergoemacs-layouts--list t) t)) + (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. @@ -583,10 +585,14 @@ 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 98ced48..8cd92a6 100644 --- a/ergoemacs-lib.el +++ b/ergoemacs-lib.el @@ -1,6 +1,6 @@ ;;; ergoemacs-lib.el --- Ergoemacs libraries -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2015 Free Software Foundation, Inc. ;; Author: Matthew L. Fidler, Xah Lee ;; Maintainer: @@ -26,7 +26,6 @@ ;; (require 'guide-key nil t) (require 'cl-lib) -(require 'find-func) (eval-when-compile (require 'ergoemacs-macros)) @@ -258,13 +257,13 @@ ergoemacs THEME." (unless (member (list option theme type remove) ergoemacs-require) (push (list option theme type remove) ergoemacs-require)) (if ergoemacs-require--ini-p - (if (consp option) + (if (eq (type-of option) 'cons) (dolist (new-option option) (let (ergoemacs-mode) (ergoemacs-require new-option theme type))) (let ((option-sym (or (and option (stringp option) (intern option)) option))) - (dolist (theme (or (and theme (or (and (consp theme) theme) (list theme))) + (dolist (theme (or (and theme (or (and (eq (type-of theme) 'cons) theme) (list theme))) (ergoemacs-theme--list))) (let ((theme-plist (ergoemacs-gethash (if (and theme (stringp theme)) theme (symbol-name theme)) @@ -353,8 +352,7 @@ All other modes are assumed to be minor modes or unimportant. (push first all)) (push (list elt 'menu-item name - elt) - ret)) + elt) ret)) (push (downcase (symbol-name elt)) added-modes) (push elt modes))))) (dolist (elt (append @@ -375,8 +373,7 @@ All other modes are assumed to be minor modes or unimportant. (push first all)) (push (list (cdr elt) 'menu-item name - (cdr elt)) - ret)) + (cdr elt)) ret)) (push (downcase (symbol-name (cdr elt))) added-modes) (push (cdr elt) modes))))) (setq modes (sort ret (lambda(x1 x2) (string< (downcase (nth 2 x2)) @@ -479,7 +476,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))) - tmp2) + tmp tmp2) ;; (when fn ;; (message "%s:\n\t%s" fn menu)) (if (not (ergoemacs-keymapp menu) ) @@ -503,37 +500,36 @@ 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))) - (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)))) + (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))) ((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 2ac7d68..4cb1dda 100644 --- a/ergoemacs-macros.el +++ b/ergoemacs-macros.el @@ -1,6 +1,6 @@ ;;; ergoemacs-macros.el --- Macros for ergoemacs-mode -*- lexical-binding: t -*- -;; Copyright © 2013, 2014, 2015, 2018 Free Software Foundation, Inc. +;; Copyright © 2013, 2014 Free Software Foundation, Inc. ;; Maintainer: Matthew L. Fidler ;; Keywords: convenience @@ -52,63 +52,66 @@ If SYMBOL is void, return nil" (ignore-errors (symbol-value ,symbol)))) ;; This shouldn't be called at run-time; This fixes the byte-compile warning. -(defun ergoemacs-theme-component--parse - (keys-and-body &optional skip-first) - "Parse KEYS-AND-BODY, optionally skipping the name and +(fset 'ergoemacs-theme-component--parse + #'(lambda(keys-and-body &optional skip-first) + "Parse KEYS-AND-BODY, optionally skipping the name and documentation with SKIP-FIRST. Uses `ergoemacs-theme-component--parse-keys-and-body' and `ergoemacs-theme-component--parse-remaining'." - (ergoemacs-theme-component--parse-keys-and-body - keys-and-body - 'ergoemacs-theme-component--parse-remaining - skip-first)) - -(defun ergoemacs-theme-component--parse-key-str (str) - "Wrap C-i, C-m and C-[ in <>." - (cond - ((not (stringp str)) str) - ((string-match-p "^\\(?:M-\\|S-\\)*C-\\(?:M-\\|S-\\)*[im[]$" str) (concat "<" str ">")) - (t str))) - -(defun ergoemacs-theme-component--parse-key (item) - "Change `kbd' and `read-kbd-macro' on C-i, C-m, and C-[ to allow calling on GUI." - (cond - ((not (consp item)) item) - ((eq (nth 0 item) 'kbd) - (list 'kbd (ergoemacs-theme-component--parse-key-str (nth 1 item)))) - ((eq (nth 0 item) 'read-kbd-macro) - (list 'read-kbd-macro (ergoemacs-theme-component--parse-key-str (nth 1 item)) (nth 2 item))) - (t item))) - -(defun ergoemacs-theme-component--parse-fun (fun) - "Determine how FUN should be used with `ergoemacs-component-struct--define-key'." - (let (tmp) - (or (and (ergoemacs-keymapp (ergoemacs-sv fun)) `(quote ,fun)) - (ignore-errors - (and (consp fun) - (stringp (nth 0 fun)) - (symbolp (nth 1 fun)) - (eq (nth 1 fun) :emacs) - (setq tmp (lookup-key global-map (read-kbd-macro (nth 0 fun)))) - (commandp tmp) - `(quote ,tmp))) - (ignore-errors - (and (consp fun) - (eq 'quote (nth 0 fun)) - (consp (nth 1 fun)) - (stringp (nth 0 (nth 1 fun))) - (symbolp (nth 1 (nth 1 fun))) - (eq (nth 1 (nth 1 fun)) :emacs) - (setq tmp (lookup-key global-map (read-kbd-macro (nth 0 (nth 1 fun))))) - (commandp tmp) - `(quote ,tmp))) - (ignore-errors - (and (consp fun) - (stringp (nth 0 fun)) - (symbolp (nth 1 fun)) - `(quote ,fun))) - fun))) + (ergoemacs-theme-component--parse-keys-and-body + keys-and-body + 'ergoemacs-theme-component--parse-remaining + skip-first))) + +(fset 'ergoemacs-theme-component--parse-key-str + #'(lambda (str) + "Wraps C-i, C-m and C-[ in <>." + (cond + ((not (stringp str)) str) + ((string-match-p "^\\(?:M-\\|S-\\)*C-\\(?:M-\\|S-\\)*[im[]$" str) (concat "<" str ">")) + (t str)))) + +(fset 'ergoemacs-theme-component--parse-key + #'(lambda (item) + "Changes `kbd' and `read-kbd-macro' on C-i, C-m, and C-[ to allow calling on GUI." + (cond + ((not (consp item)) item) + ((eq (nth 0 item) 'kbd) + (list 'kbd (ergoemacs-theme-component--parse-key-str (nth 1 item)))) + ((eq (nth 0 item) 'read-kbd-macro) + (list 'read-kbd-macro (ergoemacs-theme-component--parse-key-str (nth 1 item)) (nth 2 item))) + (t item)))) + +(fset 'ergoemacs-theme-component--parse-fun + #'(lambda (fun) + "Determine how FUN should be used with `ergoemacs-component-struct--define-key'." + (let (tmp) + (or (and (ergoemacs-keymapp (ergoemacs-sv fun)) `(quote ,fun)) + (ignore-errors + (and (consp fun) + (stringp (nth 0 fun)) + (symbolp (nth 1 fun)) + (eq (nth 1 fun) :emacs) + (setq tmp (lookup-key global-map (read-kbd-macro (nth 0 fun)))) + (commandp tmp) + `(quote ,tmp))) + (ignore-errors + (and (consp fun) + (eq 'quote (nth 0 fun)) + (consp (nth 1 fun)) + (stringp (nth 0 (nth 1 fun))) + (symbolp (nth 1 (nth 1 fun))) + (eq (nth 1 (nth 1 fun)) :emacs) + (setq tmp (lookup-key global-map (read-kbd-macro (nth 0 (nth 1 fun))))) + (commandp tmp) + `(quote ,tmp))) + (ignore-errors + (and (consp fun) + (stringp (nth 0 fun)) + (symbolp (nth 1 fun)) + `(quote ,fun))) + fun)))) ;;;###autoload (defun ergoemacs-theme-component--parse-remaining (remaining) @@ -176,7 +179,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 +193,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 +226,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,15 +426,11 @@ on the definition: :file -- File where the component was defined." (declare (doc-string 2) (indent 2)) - (let ((kb (ergoemacs-theme-component--parse body-and-plist))) + (let ((kb (make-symbol "body-and-plist"))) + (setq kb (ergoemacs-theme-component--parse body-and-plist)) `(let ((plist ',(nth 0 kb)) - (fun (lambda () ,@(nth 1 kb)))) - (defvar ergoemacs-component-hash) + (fun '(lambda () ,@(nth 1 kb)))) (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) @@ -476,7 +475,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 ;FIXME: Why? + (macroexpand-all `(ergoemacs-theme-component ,name () ,doc ,@plist @@ -542,7 +541,6 @@ 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 @@ -581,25 +579,26 @@ with :ergoemacs-require set to t." (defvar ergoemacs-theme-components--modified-plist nil "Modified plist.") -(defun ergoemacs-theme-component--add-ensure (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)))))) - -(defun ergoemacs-theme-component--parse-keys-and-body - (keys-and-body &optional parse-function skip-first) - "Split KEYS-AND-BODY into keyword-and-value pairs and the remaining body. +(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. KEYS-AND-BODY should have the form of a property list, with the exception that only keywords are permitted as keys and that the @@ -613,37 +612,38 @@ This has been stolen directly from ert by Christian Ohler <oh...@gnu.org> Afterward it was modified for use with `ergoemacs-mode' to use additional parsing routines defined by PARSE-FUNCTION." - (let ((extracted-key-accu '()) - plist - (remaining keys-and-body)) - ;; Allow - ;; (component name) - (unless (or (keywordp (cl-first remaining)) skip-first) - (push (cons ':name (if (stringp (cl-first remaining)) - (pop remaining) - (symbol-name (pop remaining)))) - extracted-key-accu) - (when (memq (type-of (cl-first remaining)) '(symbol cons)) - (setq remaining (cdr remaining))) - (when (stringp (cl-first remaining)) - (push (cons ':description (pop remaining)) extracted-key-accu))) - (while (and (consp remaining) (keywordp (cl-first remaining))) - (let ((keyword (pop remaining))) - (unless (consp remaining) - (error "Value expected after keyword %S in %S" - keyword keys-and-body)) - (when (assoc keyword extracted-key-accu) - (ergoemacs-warn "Keyword %S appears more than once in %S" keyword - keys-and-body)) - (push (cons keyword (pop remaining)) extracted-key-accu))) - (setq extracted-key-accu (nreverse extracted-key-accu)) - (setq plist (cl-loop for (key . value) in extracted-key-accu - collect key - collect value)) - (when parse-function - (setq remaining - (funcall parse-function remaining))) - (list plist remaining))) + (let ((extracted-key-accu '()) + plist + (remaining keys-and-body)) + ;; Allow + ;; (component name) + (unless (or (keywordp (cl-first remaining)) skip-first) + (if (condition-case nil + (stringp (cl-first remaining)) + (error nil)) + (push (cons ':name (pop remaining)) extracted-key-accu) + (push (cons ':name (symbol-name (pop remaining))) extracted-key-accu)) + (when (memq (type-of (cl-first remaining)) '(symbol cons)) + (setq remaining (cdr remaining))) + (when (stringp (cl-first remaining)) + (push (cons ':description (pop remaining)) extracted-key-accu))) + (while (and (consp remaining) (keywordp (cl-first remaining))) + (let ((keyword (pop remaining))) + (unless (consp remaining) + (error "Value expected after keyword %S in %S" + keyword keys-and-body)) + (when (assoc keyword extracted-key-accu) + (ergoemacs-warn "Keyword %S appears more than once in %S" keyword + keys-and-body)) + (push (cons keyword (pop remaining)) extracted-key-accu))) + (setq extracted-key-accu (nreverse extracted-key-accu)) + (setq plist (cl-loop for (key . value) in extracted-key-accu + collect key + collect value)) + (when parse-function + (setq remaining + (funcall parse-function remaining))) + (list plist remaining)))) ;;;###autoload (defmacro ergoemacs-theme (&rest body-and-plist) @@ -675,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) t)) + (setq tmp (eval (plist-get (nth 0 kb) :components))) (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)) @@ -687,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) t)))) + (eval (plist-get (nth 0 kb) comp))))) (macroexpand-all `(let* ((based-on (ergoemacs-gethash ,based-on ergoemacs-theme-hash)) (curr-plist ',tmp) @@ -750,8 +750,6 @@ This is compatibility layer. - `ergoemacs-fixed-key' = defines/replace fixed key with function by (ergoemacs-fixed-key KEY FUNCTION DESCRIPTION)." (declare (indent 1)) - ;; FIXME: Why `macroexpand-all', given that the output will itself go through - ;; macroexpand(-all) anyway? (macroexpand-all `(let (silent pl tmp) (setq pl (ergoemacs-gethash (or ,based-on "standard") ergoemacs-theme-hash)) @@ -854,69 +852,74 @@ When arg1 can be a property. The following properties are supported: (arg3 (nth 2 args)) (arg4 (nth 3 args))) (cond - ((eq arg1 :reset-prefix) - (if (fboundp 'prefix-command-preserve-state) + ((and arg1 (symbolp arg1) (eq arg1 :reset-prefix)) + (if (>= 25 emacs-major-version) `(prefix-command-preserve-state) `(reset-this-command-lengths))) - ((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) + ((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) `(gui-set-selection ,@(cdr args)) `(x-set-selection ,@(cdr args)))) - ((eq arg1 :width) + ((and arg1 (symbolp arg1) (eq arg1 :width)) `(ergoemacs-mode--eval-width ,arg2)) - ((and (eq arg1 :mode-if) arg2) + ((and arg1 (symbolp arg1) (eq arg1 :mode-if) arg2) `(ergoemacs-mode-line--if ,arg2 ,arg3 ,arg4)) - ((memq arg1 '(:sep :separator)) + ((and arg1 (symbolp arg1) (memq arg1 '(:sep :separator))) `(ergoemacs-mode-line--sep ,@(cdr args))) - ((memq arg1 '(:sep-right :separator-right)) + ((and arg1 (symbolp arg1) (memq arg1 '(:sep-right :separator-right))) `(ergoemacs-mode-line--sep 'right ,@(cdr args))) - ((memq arg1 '(:sep-left :separator-left)) + ((and arg1 (symbolp arg1) (memq arg1 '(:sep-left :separator-left))) `(ergoemacs-mode-line--sep 'left ,@(cdr args))) - ((and (eq arg1 :custom-p) (symbolp arg2)) + ((and arg1 (symbolp arg1) (eq arg1 :custom-p) (symbolp arg2)) (if (fboundp 'custom-variable-p) `(custom-variable-p ,arg2) `(user-variable-p ,arg2))) - ((and (eq arg1 :apply-key) arg2 arg3) + ((and arg1 (symbolp arg1) (eq arg1 :apply-key) arg2 arg3) `(ergoemacs-translate--apply-key ,@(cdr args))) - ((and (eq arg1 :spinner) arg2) + ((and arg1 (symbolp arg1) (eq arg1 :spinner) arg2) `(ergoemacs-command-loop--spinner-display ,@(cdr args))) - ((and (eq arg1 :define-key) arg2 arg3) + ((and arg1 (symbolp arg1) (eq arg1 :define-key) arg2 arg3) `(ergoemacs-translate--define-key ,arg2 ,arg3 ,arg4)) - ((and (eq arg1 :ignore-global-changes-p) (not arg2) (not arg3)) + ((and arg1 (symbolp arg1) (eq arg1 :ignore-global-changes-p) (not arg2) (not arg3)) `(ergoemacs-map-properties--ignore-global-changes-p)) - ((and (eq arg1 :user-before) (not arg2) (not arg3)) + ((and arg1 (symbolp arg1) (eq arg1 :user-before) (not arg2) (not arg3)) `(ergoemacs-map-properties--before-ergoemacs)) - ((and (eq arg1 :user-after) (not arg2) (not arg3)) + ((and arg1 (symbolp arg1) (eq arg1 :user-after) (not arg2) (not arg3)) `(ergoemacs-map-properties--before-ergoemacs t)) - ((eq arg1 :modal-p) + ((and arg1 (symbolp arg1) (eq arg1 :modal-p)) `(ergoemacs-command-loop--modal-p)) - ((and (eq arg1 :combine) arg2 arg3) + ((and arg1 (symbolp arg1) (eq arg1 :combine) arg2 arg3) `(ergoemacs-command-loop--combine ,arg2 ,arg3)) - ((memq arg1 '(:unicode-or-alt :unicode)) + ((and arg1 (symbolp arg1) (memq arg1 '(:unicode-or-alt :unicode))) `(ergoemacs-key-description--unicode-char ,@(cdr args))) - ((and (eq arg1 :modifier-desc) arg2) + ((and arg1 (symbolp arg1) (eq arg1 :modifier-desc) + arg2) `(mapconcat #'ergoemacs-key-description--modifier ,arg2 "")) - ((eq arg1 :current-version) + ((and arg1 (symbolp arg1) (eq arg1 :current-version)) `(ergoemacs-theme--get-version)) - ((eq arg1 :current-theme) + ((and arg1 (symbolp arg1) (eq arg1 :current-theme)) `(or (and ergoemacs-theme (stringp ergoemacs-theme) ergoemacs-theme) (and ergoemacs-theme (symbolp ergoemacs-theme) (symbol-name ergoemacs-theme)) "standard")) - ((memq arg1 ergoemacs--map-properties-list) + ((and arg1 (symbolp arg1) + (memq arg1 ergoemacs--map-properties-list)) `(,(intern (format "ergoemacs-map-properties--%s" (substring (symbol-name arg1) 1))) ,@(cdr args))) - ((and arg1 (eq arg2 :new-command) arg3) + ((and arg1 arg2 (eq arg2 :new-command) arg3) ;; (ergoemacs arg1 :new-command 'next-line) `(ergoemacs-map-properties--new-command ,arg1 ,arg3)) - ((eq arg1 :global-map) + ((and arg1 (symbolp arg1) + (eq arg1 :global-map)) `(ergoemacs-map-properties--original (or ergoemacs-saved-global-map global-map))) - ((eq arg1 :revert-global-map) + ((and arg1 (symbolp arg1) + (eq arg1 :revert-global-map)) `(ergoemacs-map-properties--original (or ergoemacs-saved-global-map global-map) :setcdr)) - ((and (eq arg1 :remap) arg2) + ((and arg1 (symbolp arg1) + (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 ae32aa6..6793600 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-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2015 Free Software Foundation, Inc. ;; Filename: ergoemacs-map-properties.el ;; Description: @@ -470,9 +470,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)))))))) @@ -561,7 +561,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)) t)) + (setq standard (eval (car (get 'icicle-top-level-key-bindings 'standard-value)))) ;; After determine if anything has changed... ;; Lifted partially from icicles (dolist (key-def icicle-top-level-key-bindings) @@ -569,7 +569,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 t) + (when (eval condition) (if (symbolp key) (icicle-remap key command new-map (current-global-map)) (ergoemacs :define-key new-map key command)))))) @@ -919,11 +919,9 @@ 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 @@ -960,6 +958,7 @@ 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 @@ -990,10 +989,7 @@ STRUCT is the keymap structure for the current map." (setq old-plist (list :map-key map-key)) (unless indirect-p (push (cons 'ergoemacs-labeled - ;; FIXME: These functions have no effect at all, so - ;; I strongly doubt they need to be interactive! - (lambda() (interactive) old-plist)) - map)) + `(lambda() (interactive) ',old-plist)) map)) (unless indirect-p (when label (push label map)) @@ -1013,8 +1009,7 @@ 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 35b05f9..8702952 100644 --- a/ergoemacs-map.el +++ b/ergoemacs-map.el @@ -1,6 +1,6 @@ ;;; ergoemacs-map.el --- Ergoemacs map interface -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2015 Free Software Foundation, Inc. ;; Filename: ergoemacs-map.el ;; Description: @@ -35,7 +35,6 @@ (require 'cl-lib) (eval-when-compile (require 'ergoemacs-macros)) -(require 'ergoemacs-component) (defvar cl-struct-ergoemacs-component-struct-tags) (defvar ergoemacs-breadcrumb-hash) @@ -60,6 +59,7 @@ (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,6 +71,14 @@ (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 a19ddd6..001c343 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -1,6 +1,6 @@ ;;; ergoemacs-mode.el --- Emacs mode based on common modern interface and ergonomics. -*- lexical-binding: t -*- -;; Copyright © 2007-2010, 2012-2018 Free Software Foundation, Inc. +;; Copyright © 2007-2010, 2012-2016 Free Software Foundation, Inc. ;; Author: Xah Lee <x...@xahlee.org> ;; David Capello <davidcape...@gmail.com> @@ -780,7 +780,7 @@ not be useful. However instead of using (defun ergoemacs-load-aliases () "Load aliases defined in `ergoemacs-aliases'." (dolist (x ergoemacs-aliases) - (defalias (nth 0 x) (nth 1 x)))) + (eval (macroexpand `(defalias ',(nth 0 x) ',(nth 1 x)))))) (autoload 'ergoemacs-component "ergoemacs-macros") (autoload 'ergoemacs-theme-component "ergoemacs-macros") @@ -843,8 +843,6 @@ 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 @@ -852,8 +850,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-char 'ergoemacs-display-unicode-characters) (defcustom ergoemacs-display-ergoemacs-key-descriptions t "Use ergoemacs key descriptions (Alt+)." @@ -862,7 +859,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-ergoemacs-key-descriptions 'ergoemacs-display-ergoemacs-key-descriptions) (defcustom ergoemacs-display-use-unicode-brackets-around-keys t @@ -872,7 +869,8 @@ 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-use-unicode-brackets 'ergoemacs-display-use-unicode-brackets-around-keys) + (defcustom ergoemacs-display-small-symbols-for-key-modifiers nil "Use small symbols to represent alt+ ctl+ on windows/linux." @@ -881,7 +879,7 @@ 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-use-small-symbols 'ergoemacs-display-small-symbols-for-key-modifiers) (defcustom ergoemacs-display-capitalize-keys 'with-modifiers "Capitalize keys like Ctrl+C. @@ -894,10 +892,8 @@ 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") +(define-obsolete-variable-alias 'ergoemacs-capitalize-keys 'ergoemacs-display-capitalize-keys) -;; 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 @@ -905,6 +901,9 @@ 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." @@ -952,7 +951,7 @@ Valid values are: "Options for `ergoemacs-command-loop'." :group 'ergoemacs-mode) -(define-obsolete-variable-alias 'ergoemacs-read-blink 'ergoemacs-command-loop-blink-character "Ergoemacs-v5.16") +(define-obsolete-variable-alias 'ergoemacs-read-blink 'ergoemacs-command-loop-blink-character) (defcustom ergoemacs-command-loop-blink-character (ergoemacs :unicode-or-alt "•" "·" "-") "Blink character." @@ -961,14 +960,12 @@ 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-swaps 'ergoemacs-command-loop-swap-translation "Ergoemacs-v5.16") +(define-obsolete-variable-alias 'ergoemacs-read-blink-timeout 'ergoemacs-command-loop-blink-rate) (defcustom ergoemacs-command-loop-swap-translation '(((:normal :normal) :unchorded-ctl) @@ -987,6 +984,7 @@ 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." @@ -1031,8 +1029,6 @@ 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. @@ -1043,6 +1039,8 @@ 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 @@ -1254,7 +1252,7 @@ also perform `outline-next-visible-heading'" :group 'ergoemacs-mode) -;; (define-obsolete-face-alias 'ergoemacs-key-description-kbd 'ergoemacs-display-key-face "" "Ergoemacs-v5.16") +;; (define-obsolete-face-alias 'ergoemacs-key-description-kbd 'ergoemacs-display-key-face "") ;;; Options not supported now diff --git a/ergoemacs-test.el b/ergoemacs-test.el index e9b8919..c62330a 100644 --- a/ergoemacs-test.el +++ b/ergoemacs-test.el @@ -1,6 +1,6 @@ -;;; ergoemacs-test.el --- tests for ErgoEmacs issues -*- lexical-binding:t -*- +;;; ergoemacs-test.el --- tests for ErgoEmacs issues -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2016 Free Software Foundation, Inc. ;; Maintainer: Matthew L. Fidler ;; Keywords: convenience @@ -28,10 +28,9 @@ ;;; Code: -(eval-when-compile - (require 'cl-lib) +(eval-when-compile + (require 'cl) (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") @@ -42,13 +41,6 @@ (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) @@ -96,7 +88,6 @@ ;;; 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 @@ -181,9 +172,11 @@ sunt in culpa qui officia deserunt mollit anim id est laborum.") (defun ergoemacs-test () "Test ergoemacs issues." (interactive) - (elp-instrument-package "ergoemacs-") - (ert '(and "^ergoemacs-test-" (not (tag :require-input)))) - (call-interactively 'elp-results)) + (let ((ret t) + (test)) + (elp-instrument-package "ergoemacs-") + (ert '(and "^ergoemacs-test-" (not (tag :require-input)))) + (call-interactively 'elp-results))) ;; Test isearch @@ -362,22 +355,22 @@ Tests issue #347" (ert-deftest ergoemacs-test-shift-select-subword () "Test for mark working with shift-selection of `subword-forward'." :tags '(:shift-select) - (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))))) + (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)))))) ;;; Copy/Paste @@ -385,7 +378,8 @@ Tests issue #347" (ert-deftest ergoemacs-test-copy-paste-issue-184 () "Issue #184; Not replace the \"selected all\" by paste." :tags '(:copy :interactive) - (let ((ergoemacs-handle-ctl-c-or-ctl-x 'both)) + (let ((ret t) + (ergoemacs-handle-ctl-c-or-ctl-x 'both)) (ergoemacs-test-layout :macro "C-v" (save-excursion @@ -580,7 +574,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" @@ -593,7 +587,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 @@ -646,22 +640,23 @@ Grep finished (matches found) at Fri Aug 22 08:30:37 (ergoemacs-test-layout :layout "colemak" :macro "M-m" - (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))))) + (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)))))) (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" @@ -683,7 +678,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" @@ -695,7 +690,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" @@ -721,22 +716,24 @@ Test next and prior translation." (ert-deftest ergoemacs-test-modal-alt-mode-horizontal-position () "Tests Issue #213" - (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))))) + (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 @@ -918,7 +915,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)) @@ -1422,9 +1419,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>" @@ -1461,7 +1458,8 @@ 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 ((ergoemacs-use-function-remapping t)) + (let (ret + (ergoemacs-use-function-remapping t)) (with-temp-buffer (ergoemacs-test-major-mode) (when (not (current-local-map)) @@ -1476,7 +1474,8 @@ Part of addressing Issue #147." Part of addressing Issue #147." :tags '(:interactive) (ergoemacs-test-layout - (let ((ergoemacs-use-function-remapping t)) + (let (ret + (ergoemacs-use-function-remapping t)) (with-temp-buffer (ergoemacs-test-major-mode) (when (not (current-local-map)) @@ -1493,7 +1492,8 @@ Tests Issue #372." (ergoemacs-test-layout :layout "us" :theme "reduction" - (let ((ergoemacs-use-function-remapping t)) + (let (ret + (ergoemacs-use-function-remapping t)) (with-temp-buffer (ergoemacs-test-major-mode) (when (not (current-local-map)) @@ -1503,40 +1503,54 @@ Tests Issue #372." (ert-deftest ergoemacs-test-dired-sort-files () "Test Issue #340" - (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))) + (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) + ))) (ert-deftest ergoemacs-test-quail-translations () @@ -1580,7 +1594,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))))) - (cl-letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) t))) + (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))))) @@ -1590,7 +1604,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)))))) - (cl-letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) nil))) + (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))))) @@ -1752,7 +1766,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"))) "\")" @@ -1806,9 +1820,9 @@ hash appropriaetly." 0.05 nil (lambda() (throw 'found-key (mapcar (lambda(key) (if (consp key) - (key-binding (eval key t)) - (key-binding key))) - ',keys))))) + (key-binding (eval key)) + (key-binding key))) + ',keys))))) ,minibuffer-call) nil)) @@ -1820,14 +1834,15 @@ M-s = `ergoemacs-move-cursor-next-pane' M-r = `kill-word'" :tags '(:icy-mode :interactive) (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)) + (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) diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el index 46ca472..e5c54f9 100644 --- a/ergoemacs-theme-engine.el +++ b/ergoemacs-theme-engine.el @@ -1,6 +1,6 @@ ;;; ergoemacs-theme-engine.el --- Ergoemacs map interface -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2015 Free Software Foundation, Inc. ;; Filename: ergoemacs-theme-engine.el ;; Description: @@ -52,8 +52,7 @@ (eval-when-compile (require 'ergoemacs-macros) - (require 'cl-lib)) -(require 'find-func) + (require 'cl)) (defvar ergoemacs-mode) (defvar ergoemacs-require) @@ -136,7 +135,7 @@ This respects `ergoemacs-theme-options'." ;;;###autoload (defun ergoemacs-theme-set-version (version) - "Set the current themes default VERSION." + "Sets the current themes default VERSION" (let (found) (setq ergoemacs-theme-version (mapcar @@ -160,7 +159,7 @@ Uses `ergoemacs-theme-option-on'." "Turns OPTION on. When OPTION is a list turn on all the options in the list If OFF is non-nil, turn off the options instead." - (if (consp option) + (if (eq (type-of option) 'cons) (dolist (new-option option) (let (ergoemacs-mode) (ergoemacs-theme-option-on new-option no-custom off))) @@ -408,7 +407,8 @@ When AT-END is non-nil, append a $ to the regular expression." (lambda() (interactive) (ergoemacs-save 'ergoemacs-smart-paste 'browse-kill-ring)) - :enable (commandp 'browse-kill-ring) + :enable (condition-case err (interactive-form 'browse-kill-ring) + (error nil)) :button (:radio . (eq ergoemacs-smart-paste 'browse-kill-ring))))) (ergoemacs-sep-bash "--") (ergoemacs-bash diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el index e0b585d..0763a2a 100644 --- a/ergoemacs-themes.el +++ b/ergoemacs-themes.el @@ -1,6 +1,6 @@ ;;; ergoemacs-themes.el --- ErgoEmacs keybindings and themes -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2015 Free Software Foundation, Inc. ;; Maintainer: Matthew L. Fidler ;; Authors: Matthew L. Fidler, Xah Lee, Drew Adams @@ -28,10 +28,9 @@ ;; ;;; Code: -(eval-when-compile - (require 'cl-lib) +(eval-when-compile + (require 'cl) (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 282dd2b..a3b9f88 100644 --- a/ergoemacs-translate.el +++ b/ergoemacs-translate.el @@ -1,6 +1,6 @@ ;;; ergoemacs-translate.el --- Keyboard translation functions -*- lexical-binding: t -*- -;; Copyright © 2013-2018 Free Software Foundation, Inc. +;; Copyright © 2013-2014 Free Software Foundation, Inc. ;; Filename: ergoemacs-translate.el ;; Description: @@ -51,7 +51,7 @@ ;;; Code: (eval-when-compile - (require 'cl-lib) + (require 'cl) (require 'ergoemacs-macros)) @@ -698,7 +698,7 @@ For keys, the list consists of: (push key ret)) ret)) -(cl-defstruct ergoemacs-translation-struct +(defstruct ergoemacs-translation-struct "A basic ergoemacs translation structure." (name "default-name") (translation '()) @@ -745,16 +745,14 @@ 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 ;FIXME: Why? + (macroexpand `(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")) - "Ergoemacs-v5.16"))) - t) + ',(intern (concat "ergoemacs-translate--" name-str "-map")))))) (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) ;; @@ -765,8 +763,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") - (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)))))) + (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)))))) (add-hook 'ergoemacs-mode-intialize-hook #'ergoemacs-translate--setup-translation) @@ -892,18 +890,23 @@ If TYPE is unspecified, assume :normal translation" (defun ergoemacs-translate--no-gui (event) "Remove any gui elements to the EVENT. -If there are no gui elements, return nil." +If there are no gui elements, retun nil." (if (vectorp event) - (apply #'vector (mapcar (lambda (x) (or (ergoemacs-translate--no-gui x) x)) event)) + (eval `(vector ,@(mapcar (lambda(x) (let ((ret (or (ergoemacs-translate--no-gui x) x))) + (if (symbolp ret) + `(quote ,ret) + ret))) event))) (let* ((last-event event) (last-mod (ergoemacs-translate--event-modifiers last-event)) (last-basic-event (ergoemacs-translate--event-basic-type last-event)) - new-mod) + new-mod + new-event) (when (memq 'ergoemacs-gui last-mod) (dolist (elt last-mod) (unless (eq elt 'ergoemacs-gui) (push elt new-mod))) - (ergoemacs-translate--event-convert-list `(,@new-mod ,last-basic-event)))))) + (setq new-event (ergoemacs-translate--event-convert-list `(,@new-mod ,last-basic-event)))) + new-event))) (defvar ergoemacs-translate--parent-map nil "Parent map for keymaps when completing a key sequence.") @@ -1217,8 +1220,7 @@ If :type is :quail use the 180 length string that (encode-char (with-temp-buffer (insert char) - (char-before)) - 'unicode)) + (char-before)) 'unicode)) font (ergoemacs-key-description--display-char-p char)) (when font (setq font (or (font-get font :name)