branch: externals/ergoemacs-mode commit dde41b4262296ca8892fed1a0c8488128de282f7 Author: Matthew Fidler <514778+mattfid...@users.noreply.github.com> Commit: Matthew Fidler <514778+mattfid...@users.noreply.github.com>
Fix some more warnings and test icy stuff only when icy is there --- ergoemacs-map-properties.el | 15 +--- ergoemacs-mode.el | 32 +++++---- ergoemacs-test.el | 164 +++++++++++++++++++++++--------------------- ergoemacs-theme-engine.el | 4 +- ergoemacs-themes.el | 2 +- ergoemacs-translate.el | 8 +-- 6 files changed, 111 insertions(+), 114 deletions(-) diff --git a/ergoemacs-map-properties.el b/ergoemacs-map-properties.el index dda0928..e6b6426 100644 --- a/ergoemacs-map-properties.el +++ b/ergoemacs-map-properties.el @@ -908,7 +908,7 @@ When DROP is non-nil, drop any found maps from `ergoemacs-map-properties--known- ;; (message "%s" map-list) ergoemacs-map-properties--get-or-generate-map-key)))))) -(defun ergoemacs-map-properties--label (keymap &optional map-key struct) +(defun ergoemacs-map-properties--label (keymap &optional map-key struct-in) "Label an `ergoemacs-mode' touched KEYMAP. MAP-KEY is the identifier of the map name. STRUCT is the keymap structure for the current map." @@ -920,8 +920,7 @@ STRUCT is the keymap structure for the current map." (error "Will not label a composed map's members to %s" map-key)) (t (let* ((breadcrumb-base ergoemacs-map--breadcrumb) - (struct (or struct (ergoemacs-gethash map-key ergoemacs-map-properties--key-struct))) - (comp (plist-get struct :composed)) + (comp (plist-get (or struct-in (ergoemacs-gethash map-key ergoemacs-map-properties--key-struct)) :composed)) (comp-list (ergoemacs-map-properties--composed-list keymap)) from-prop-p (i 0)) @@ -946,14 +945,13 @@ STRUCT is the keymap structure for the current map." (t (let* ((map keymap) (map-key (or map-key - (plist-get struct :map-key) + (plist-get struct-in :map-key) (ergoemacs-map-properties--get-or-generate-map-key map))) char-table indirect-p 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 @@ -992,13 +990,6 @@ STRUCT is the keymap structure for the current map." (push char-table map)) (push 'keymap map))) (when parent - ;; (if (and breadcrumb-base (not (string= breadcrumb-base ""))) - ;; (setq ergoemacs-map--breadcrumb (concat breadcrumb-base "-parent")) - ;; (when (setq ergoemacs-map-properties--breadcrumb (gethash map-key ergoemacs-breadcrumb-hash)) - ;; (setq ergoemacs-map-properties--breadcrumb (format "%s-parent" ergoemacs-map-properties--breadcrumb)) - ;; ;; (message "Set %s!" ergoemacs-map-properties--breadcrumb) - ;; )) - ;; (ergoemacs :label parent nil (plist-get struct :parent)) (set-keymap-parent map parent) (setq ergoemacs-map--breadcrumb breadcrumb-base))) (if indirect-p diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el index 001c343..16b0c2c 100644 --- a/ergoemacs-mode.el +++ b/ergoemacs-mode.el @@ -96,6 +96,9 @@ (declare-function ergoemacs-layouts--customization-type "ergoemacs-layouts") +(declare-function ergoemacs-map-properties--label "ergoemacs-map-properties") +(declare-function ergoemacs-map-- "ergoemacs-map") + (declare-function persistent-soft-fetch "persistent-soft") (declare-function persistent-soft-flush "persistent-soft") (declare-function persistent-soft-location-destroy "persistent-flush") @@ -169,6 +172,7 @@ Added beginning-of-buffer Alt+n (QWERTY notation) and end-of-buffer Alt+Shift+n" (defcustom ergoemacs-keyboard-mirror nil "Specifies which keyboard layout to mirror." + :type 'sexp :set #'ergoemacs-set-default :initialize #'custom-initialize-default :group 'ergoemacs-mode) @@ -628,6 +632,7 @@ When STORE-P is non-nil, save the tables." (dot ("⠁" "⠂" "⠄" "⡀" "⢀" "⠠" "⠐" "⠈")) (fish (">))'>" " >))'>" " >))'>" " >))'>" " >))'>" " <'((<" " <'((<" " <'((<"))) "Spinners for long commands with `ergoemacs-command-loop'." + :type 'sexp :group 'ergoemacs-command-loop) (defcustom ergoemacs-command-loop-spinner (or (and ergoemacs-use-unicode-symbols 'dots) 'standard) @@ -843,6 +848,8 @@ Valid values are: "Display Options for `ergoemacs-mode'." :group 'ergoemacs-mode) +(define-obsolete-variable-alias 'ergoemacs-use-unicode-char 'ergoemacs-display-unicode-characters) + (defcustom ergoemacs-display-unicode-characters t "Use unicode characters when available." :type 'boolean @@ -850,7 +857,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-unicode-char 'ergoemacs-display-unicode-characters) +(define-obsolete-variable-alias 'ergoemacs-use-ergoemacs-key-descriptions 'ergoemacs-display-ergoemacs-key-descriptions) (defcustom ergoemacs-display-ergoemacs-key-descriptions t "Use ergoemacs key descriptions (Alt+)." @@ -859,8 +866,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) - +(define-obsolete-variable-alias 'ergoemacs-use-unicode-brackets 'ergoemacs-display-use-unicode-brackets-around-keys) (defcustom ergoemacs-display-use-unicode-brackets-around-keys t "Use unicode brackets." @@ -869,8 +875,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-unicode-brackets 'ergoemacs-display-use-unicode-brackets-around-keys) - +(define-obsolete-variable-alias 'ergoemacs-use-small-symbols 'ergoemacs-display-small-symbols-for-key-modifiers) (defcustom ergoemacs-display-small-symbols-for-key-modifiers nil "Use small symbols to represent alt+ ctl+ on windows/linux." @@ -879,7 +884,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-use-small-symbols 'ergoemacs-display-small-symbols-for-key-modifiers) +(define-obsolete-variable-alias 'ergoemacs-capitalize-keys 'ergoemacs-display-capitalize-keys) (defcustom ergoemacs-display-capitalize-keys 'with-modifiers "Capitalize keys like Ctrl+C. @@ -892,7 +897,7 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-capitalize-keys 'ergoemacs-display-capitalize-keys) +(define-obsolete-variable-alias 'ergoemacs-pretty-key-use-face 'ergoemacs-display-key-use-face-p) (defcustom ergoemacs-display-key-use-face-p t "Use a button face for keys." @@ -901,9 +906,6 @@ Valid values are: :initialize #'custom-initialize-default :group 'ergoemacs-display) -(define-obsolete-variable-alias 'ergoemacs-pretty-key-use-face 'ergoemacs-display-key-use-face-p) - - (defface ergoemacs-display-key-face '((t :inverse-video t :box (:line-width 1 :style released-button) :weight bold)) "Button Face for an `ergoemacs-mode' pretty key." @@ -960,12 +962,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) + (defcustom ergoemacs-command-loop-blink-rate 0.4 "Rate that the ergoemacs-command loop cursor blinks." :type 'number :group 'ergoemacs-command-loop) -(define-obsolete-variable-alias 'ergoemacs-read-blink-timeout 'ergoemacs-command-loop-blink-rate) +(define-obsolete-variable-alias 'ergoemacs-read-swaps 'ergoemacs-command-loop-swap-translation) (defcustom ergoemacs-command-loop-swap-translation '(((:normal :normal) :unchorded-ctl) @@ -984,8 +988,6 @@ Valid values are: (sexp :tag "Translated Type"))) :group 'ergoemacs-command-loop) -(define-obsolete-variable-alias 'ergoemacs-read-swaps 'ergoemacs-command-loop-swap-translation) - (defcustom ergoemacs-command-loop-type nil "Type of `ergoemacs-mode' command loop." :type '(choice @@ -1029,6 +1031,8 @@ Valid values are: :type '(repeat string) :group 'ergoemacs-modal) +(define-obsolete-variable-alias 'ergoemacs-default-cursor 'ergoemacs-default-cursor-color) + (defcustom ergoemacs-default-cursor-color nil "Default cursor color. @@ -1039,8 +1043,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) - (defcustom ergoemacs-modal-emacs-state-modes '(archive-mode bbdb-mode diff --git a/ergoemacs-test.el b/ergoemacs-test.el index c62330a..3ffcde2 100644 --- a/ergoemacs-test.el +++ b/ergoemacs-test.el @@ -29,12 +29,14 @@ ;;; Code: (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'ergoemacs-macros)) (declare-function ergoemacs-translate--keymap "ergoemacs-translate") (declare-function ergoemacs-mode-reset "ergoemacs-mode") +(declare-function icy-mode "icy-mode") + (defvar ergoemacs-translate--parent-map) (defvar ergoemacs-map--) (defvar ergoemacs-layout-us) @@ -1156,41 +1158,42 @@ Should test issue #142" (ert-deftest ergoemacs-test-397-test-4 () "Test M-s is switch pane." :tags '(:slow :icicles :interactive) - (let* ((emacs-exe (ergoemacs-emacs-exe)) - (w-file (expand-file-name "global-test" ergoemacs-dir)) - (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) - (with-temp-file temp-file - (insert "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "ergoemacs-mode"))) "\")" - "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "icicles"))) "\")" - "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" - (or (and (boundp 'wait-for-me) - "(setq debug-on-error t debug-on-quit t)") "") - "(setq ergoemacs-theme nil)" - "(setq ergoemacs-keyboard-layout \"us\")" - "(require 'icicles)\n" - "(require 'ergoemacs-mode)\n" - "(ergoemacs-mode 1)\n" - "(setq icicle-search-key-prefix (kbd \"C-f\"))\n" - "(icy-mode 1)\n" - "(when (eq (key-binding (kbd \"M-s\")) 'ergoemacs-move-cursor-next-pane)\n" - "(with-temp-file \"" w-file "\")\n" - " (message \"Passed\")" - " (insert \"Found\"))\n" - (or (and (boundp 'wait-for-me) "") - "(kill-emacs)"))) - (byte-compile-file temp-file) - (message "%s" - (shell-command-to-string - (format "%s %s -Q -l %s" - emacs-exe (if (boundp 'wait-for-me) "-debug-init" "--batch") - temp-file))) - (should (file-exists-p w-file)) - (when (file-exists-p temp-file) - (delete-file temp-file)) - (when (file-exists-p (concat temp-file "c")) - (delete-file (concat temp-file "c"))) - (when (file-exists-p w-file) - (delete-file w-file)))) + (if (not (locate-library "icicles")) (should t) + (let* ((emacs-exe (ergoemacs-emacs-exe)) + (w-file (expand-file-name "global-test" ergoemacs-dir)) + (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) + (with-temp-file temp-file + (insert "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "ergoemacs-mode"))) "\")" + "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "icicles"))) "\")" + "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" + (or (and (boundp 'wait-for-me) + "(setq debug-on-error t debug-on-quit t)") "") + "(setq ergoemacs-theme nil)" + "(setq ergoemacs-keyboard-layout \"us\")" + "(require 'icicles)\n" + "(require 'ergoemacs-mode)\n" + "(ergoemacs-mode 1)\n" + "(setq icicle-search-key-prefix (kbd \"C-f\"))\n" + "(icy-mode 1)\n" + "(when (eq (key-binding (kbd \"M-s\")) 'ergoemacs-move-cursor-next-pane)\n" + "(with-temp-file \"" w-file "\")\n" + " (message \"Passed\")" + " (insert \"Found\"))\n" + (or (and (boundp 'wait-for-me) "") + "(kill-emacs)"))) + (byte-compile-file temp-file) + (message "%s" + (shell-command-to-string + (format "%s %s -Q -l %s" + emacs-exe (if (boundp 'wait-for-me) "-debug-init" "--batch") + temp-file))) + (should (file-exists-p w-file)) + (when (file-exists-p temp-file) + (delete-file temp-file)) + (when (file-exists-p (concat temp-file "c")) + (delete-file (concat temp-file "c"))) + (when (file-exists-p w-file) + (delete-file w-file))))) (ert-deftest ergoemacs-test-397-test-2 () "Test that defining C-SPC after ergoemacs-mode loads will give `set-mark-command'." @@ -1594,7 +1597,7 @@ Tests Issue #372." (should (string= (key-description (kbd "M-TAB")) (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "C-TAB" t) 0) :ctl-to-alt))))) - (letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) t))) + (cl-letf (((symbol-function 'display-graphic-p) (lambda(&rest _ignore) t))) ;; Test M-i -> ^i -> TAB (should (string= "<C-i>" (key-description (vector (ergoemacs-translate--event-mods (elt (read-kbd-macro "M-i" t) 0) :ctl-to-alt))))) @@ -1604,7 +1607,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))))) @@ -1765,48 +1768,49 @@ hash appropriaetly." (ert-deftest ergoemacs-test-407 () "Test M-s is switch pane." :tags '(:require-input :interactive) - (let* ((emacs-exe (ergoemacs-emacs-exe)) - (w-file (expand-file-name "global-test" ergoemacs-dir)) - (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) - (with-temp-file temp-file - (insert "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "ergoemacs-mode"))) "\")" - "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "icicles"))) "\")" - "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" - (or (and (boundp 'wait-for-me) - "(setq debug-on-error t debug-on-quit t)") "") - "(setq ergoemacs-theme nil)" - "(setq ergoemacs-keyboard-layout \"us\")" - "(require 'ergoemacs-mode)\n" - "(ergoemacs-mode 1)\n" - "(require 'icicles)\n" - "(icy-mode 1)\n" - "(ergoemacs-theme-component reclaim-C-f ()\n" - " \"We need to give at least one sequence to reclaim C-f from isearch and get the new icicle-search-key-prefix picked up.\"\n" - "(global-set-key (kbd \"C-f .\") 'isearch-forward-symbol-at-point))" - "(ergoemacs-require 'reclaim-C-f)" - "(setq icicle-search-key-prefix (kbd \"C-f\"))" - "(ergoemacs-package smart-mode-line :ensure t (sml/setup))" - "(ergoemacs-package srefactor :ensure t)" - "(ergoemacs-package virtualenvwrapper :ensure t)" - "(defun test-freeze ()\n" - "(interactive)\n" - "(yes-or-no-p \"Are you sure you want to remove this file? \"))" - "(global-set-key (kbd \"C-1\") 'test-freeze)" - "(insert \"Try C-1 to see if emacs freezes.\\nThen try M-a test-freeze.\\nM-a calc, do something and then exit with q it should exit\nMake sure M-o goes forward word in icy ergoemacs-mode.\")" - ;; (or (and (boundp 'wait-for-me) "") - ;; "(kill-emacs)") - )) - (byte-compile-file temp-file) - (message "%s" - (shell-command-to-string - (format "%s %s -Q -l %s" - emacs-exe "-debug-init" - temp-file))) - - (when (file-exists-p temp-file) - (delete-file temp-file)) - (when (file-exists-p (concat temp-file "c")) - (delete-file (concat temp-file "c"))))) + (if (not (locate-library "icicles")) (should t) + (let* ((emacs-exe (ergoemacs-emacs-exe)) + (w-file (expand-file-name "global-test" ergoemacs-dir)) + (temp-file (make-temp-file "ergoemacs-test" nil ".el"))) + (with-temp-file temp-file + (insert "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "ergoemacs-mode"))) "\")" + "(add-to-list 'load-path \"" (expand-file-name (file-name-directory (locate-library "icicles"))) "\")" + "(eval-when-compile (require 'ergoemacs-macros) (require 'cl))" + (or (and (boundp 'wait-for-me) + "(setq debug-on-error t debug-on-quit t)") "") + "(setq ergoemacs-theme nil)" + "(setq ergoemacs-keyboard-layout \"us\")" + "(require 'ergoemacs-mode)\n" + "(ergoemacs-mode 1)\n" + "(require 'icicles)\n" + "(icy-mode 1)\n" + "(ergoemacs-theme-component reclaim-C-f ()\n" + " \"We need to give at least one sequence to reclaim C-f from isearch and get the new icicle-search-key-prefix picked up.\"\n" + "(global-set-key (kbd \"C-f .\") 'isearch-forward-symbol-at-point))" + "(ergoemacs-require 'reclaim-C-f)" + "(setq icicle-search-key-prefix (kbd \"C-f\"))" + "(ergoemacs-package smart-mode-line :ensure t (sml/setup))" + "(ergoemacs-package srefactor :ensure t)" + "(ergoemacs-package virtualenvwrapper :ensure t)" + "(defun test-freeze ()\n" + "(interactive)\n" + "(yes-or-no-p \"Are you sure you want to remove this file? \"))" + "(global-set-key (kbd \"C-1\") 'test-freeze)" + "(insert \"Try C-1 to see if emacs freezes.\\nThen try M-a test-freeze.\\nM-a calc, do something and then exit with q it should exit\nMake sure M-o goes forward word in icy ergoemacs-mode.\")" + ;; (or (and (boundp 'wait-for-me) "") + ;; "(kill-emacs)") + )) + (byte-compile-file temp-file) + (message "%s" + (shell-command-to-string + (format "%s %s -Q -l %s" + emacs-exe "-debug-init" + temp-file))) + + (when (file-exists-p temp-file) + (delete-file temp-file)) + (when (file-exists-p (concat temp-file "c")) + (delete-file (concat temp-file "c")))))) ;;; minibuffer tests... ;;; Related to: http://emacs.stackexchange.com/questions/10393/how-can-i-answer-a-minibuffer-prompt-from-elisp diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el index 196fc4c..366f21f 100644 --- a/ergoemacs-theme-engine.el +++ b/ergoemacs-theme-engine.el @@ -52,7 +52,7 @@ (eval-when-compile (require 'ergoemacs-macros) - (require 'cl)) + (require 'cl-lib)) (defvar ergoemacs-mode) (defvar ergoemacs-require) @@ -665,7 +665,7 @@ See also `find-function-recenter-line' and `find-function-after-hook'." # should be like ErgoEmacs. # If none of the keys work, try replacing all instances of \\e with \\M-. # That's means changing Esc to Meta key. -\nset editing-mode emacs") tmp key-string) +\nset editing-mode emacs") key-string) (with-temp-buffer (dolist (cmds ergoemacs-theme-create-bash-functions) (dolist (cmd cmds) diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el index 0763a2a..c6ce2f4 100644 --- a/ergoemacs-themes.el +++ b/ergoemacs-themes.el @@ -29,7 +29,7 @@ ;;; Code: (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'ergoemacs-macros)) (declare-function ergoemacs-theme-component--create-component "ergoemacs-theme") diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el index a3b9f88..2659479 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)) @@ -698,7 +698,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 '()) @@ -763,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") - (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)