emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ergoemacs-mode 42833ac 264/325: Code cleanup


From: Stefan Monnier
Subject: [elpa] externals/ergoemacs-mode 42833ac 264/325: Code cleanup
Date: Sat, 23 Oct 2021 18:49:07 -0400 (EDT)

branch: externals/ergoemacs-mode
commit 42833ac1c1a3753def9457509d3f9b4a0d0bf1b2
Author: Matthew Fidler <514778+mattfidler@users.noreply.github.com>
Commit: Matthew Fidler <514778+mattfidler@users.noreply.github.com>

    Code cleanup
---
 ergoemacs-calculate-bindings.el |   1 +
 ergoemacs-command-loop.el       |   6 +-
 ergoemacs-layouts.el            |   5 +-
 ergoemacs-mode.el               |  16 +---
 ergoemacs-theme-engine.el       | 196 ----------------------------------------
 ergoemacs-themes.el             |   9 +-
 ergoemacs-translate.el          |   3 +-
 7 files changed, 15 insertions(+), 221 deletions(-)

diff --git a/ergoemacs-calculate-bindings.el b/ergoemacs-calculate-bindings.el
index 745bc94..2612d2e 100644
--- a/ergoemacs-calculate-bindings.el
+++ b/ergoemacs-calculate-bindings.el
@@ -108,6 +108,7 @@
 (defvar ergoemacs-keyboard-layout)
 
 (declare-function ergoemacs-translate--event-layout "ergoemacs-translate")
+(declare-function help--symbol-completion-table "help-fns")
 
 (defun ergoemacs-calculate-bindings-for-current-binding (keymap space)
   "Calculate ergoemcs keybindings for a KEYMAP and dislay in another buffer.
diff --git a/ergoemacs-command-loop.el b/ergoemacs-command-loop.el
index 8a225fe..3c3a872 100644
--- a/ergoemacs-command-loop.el
+++ b/ergoemacs-command-loop.el
@@ -1632,9 +1632,7 @@ The RECORD-FLAG and KEYS are sent to 
`ergoemacs-command-loop--grow-interactive'.
    ((and (symbolp command) (not (commandp command)))
     (ergoemacs-command-loop--message "Command `%s' cannot be called from a 
key" command))
    ((and (consp ergoemacs-command-loop-describe-key-functions)
-        (memq command ergoemacs-command-loop-describe-key-functions))
-    (ergoemacs-specials
-     (ergoemacs-command-loop--grow-interactive command record-flag keys)))
+        (memq command ergoemacs-command-loop-describe-key-functions)))
    (t
     (ergoemacs-command-loop--grow-interactive command record-flag keys)))
   (setq ergoemacs-this-command-keys-shift-translated nil))
@@ -2199,7 +2197,7 @@ pressed the translated key by changing
     ;; Make sure to lookup the keys in the selected buffer
     (ergoemacs-command-loop--sync-point)
     (let ((trials (ergoemacs-translate--trials key))
-        tmp tmp2 ret)
+        tmp ret)
       (setq this-command-keys-shift-translated nil)
     (catch 'found-command
       (dolist (cur-key trials)
diff --git a/ergoemacs-layouts.el b/ergoemacs-layouts.el
index 9b69ffb..521ecfa 100644
--- a/ergoemacs-layouts.el
+++ b/ergoemacs-layouts.el
@@ -535,7 +535,8 @@ expression matching the base layout."
         (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--prompt ()
   "Prompt for component or theme (when THEME-INSTEAD is non-nil)."
@@ -547,7 +548,7 @@ expression matching the base layout."
                                     "Describe ergoemacs layout (default %s): "
                                     c)
                                  "Describe ergoemacs layout: ")
-                               ergoemacs-layouts--list
+                               (ergoemacs-layouts--list)
                                nil t nil nil
                                (format "%s" c)))
     (list (or (and (equal val "") (format "%s" c)) val))))
diff --git a/ergoemacs-mode.el b/ergoemacs-mode.el
index be96b03..68fd90a 100644
--- a/ergoemacs-mode.el
+++ b/ergoemacs-mode.el
@@ -105,7 +105,6 @@ Added beginning-of-buffer Alt+n (QWERTY notation) and 
end-of-buffer Alt+Shift+n"
 (defcustom ergoemacs-display-key-use-face t
   "Use a button face for keys."
   :type 'boolean
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-display)
 
@@ -127,14 +126,12 @@ Added beginning-of-buffer Alt+n (QWERTY notation) and 
end-of-buffer Alt+Shift+n"
 (defcustom ergoemacs-keyboard-layout "us"
   (concat "Specifies which keyboard layout to use.")
   :type 'sexp
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-mode)
 
 (defcustom ergoemacs-keyboard-mirror nil
   "Specifies which keyboard layout to mirror."
   :type 'sexp
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-mode)
 
@@ -347,7 +344,7 @@ This is structured by valid keyboard layouts for
   :type 'boolean
   :group 'ergoemacs-mode)
 
-(defcustom ergoemacs-command-loop-spinners
+(defvar ergoemacs-command-loop-spinners
   '((standard ("|" "/" "-" "\\"))
     (arrows ("←" "↖" "↑" "↗" "→" "↘" "↓" "↙"))
     (bar-vertical ("▁" "▃" "▄" "▅" "▆" "▇" "█" "▇" "▆" "▅" "▄" "▃"))
@@ -359,8 +356,7 @@ This is structured by valid keyboard layouts for
     (dots ("⣾" "⣽" "⣻" "⢿" "⡿" "⣟" "⣯" "⣷"))
     (dot ("⠁" "⠂" "⠄" "⡀" "⢀" "⠠" "⠐" "⠈"))
     (fish (">))'>" " >))'>" "  >))'>" "   >))'>" "    >))'>" "   <'((<" "  
<'((<" " <'((<")))
-  "Spinners for long commands with `ergoemacs-command-loop'."
-  :group 'ergoemacs-command-loop)
+  "Spinners for long commands with `ergoemacs-command-loop'.")
 
 (defcustom ergoemacs-mode-turn-on-cua-mode t
   "Turn on cua mode when starting `ergoemacs-mode'."
@@ -478,7 +474,6 @@ Valid values are:
 " (ergoemacs-layouts--custom-documentation)
 )
   :type (ergoemacs-layouts--customization-type)
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-mode)
 
@@ -490,7 +485,6 @@ Valid values are:
 (defcustom ergoemacs-display-ergoemacs-key-descriptions t
   "Use ergoemacs key descriptions (Alt+)."
   :type 'boolean
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-display)
 
@@ -498,14 +492,12 @@ Valid values are:
 (defcustom ergoemacs-display-use-unicode-brackets-around-keys t
   "Use unicode brackets."
   :type 'boolean
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-display)
 
 (defcustom ergoemacs-display-small-symbols-for-key-modifiers nil
   "Use small symbols to represent alt+ ctl+ on windows/linux."
   :type 'boolean
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-display)
 
@@ -516,22 +508,18 @@ Valid values are:
           (const :tag "Don't Capitalize Keys" nil)
           (const :tag "Capitalize Keys with modifiers" with-modifiers)
           (const :tag "Capitalize Keys" t))
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-display)
 
 (defcustom ergoemacs-display-key-use-face-p t
   "Use a button face for keys."
   :type 'boolean
-  :set #'ergoemacs-set-default
   :initialize #'custom-initialize-default
   :group 'ergoemacs-display)
 
 (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."
-  ;; :set #'ergoemacs-set-default
-  ;; :initialize #'custom-initialize-default
   :group 'ergoemacs-display)
 
 (defcustom ergoemacs-excluded-major-modes
diff --git a/ergoemacs-theme-engine.el b/ergoemacs-theme-engine.el
index eb91156..cc3dcd0 100644
--- a/ergoemacs-theme-engine.el
+++ b/ergoemacs-theme-engine.el
@@ -79,206 +79,10 @@
 (declare-function ergoemacs-map--hashkey "ergoemacs-map")
 (declare-function ergoemacs-translate--svg-quote "ergoemacs-translate")
 
-(defun ergoemacs-theme-components--required-p (comp)
-  "Is COMP a required component?"
-  (let ((comp (or (and (stringp comp) (intern comp)) comp))
-        e2)
-    (catch 'found
-      (dolist (r ergoemacs-require)
-        (setq e2 (or (and (stringp (car r)) (intern (car r)))
-                     (car r)))
-        (when (eq comp e2)
-          (throw 'found t)))
-      nil)))
 
-(defun ergoemacs-theme-components (&optional theme)
-  "Get a list of components used for the current theme.
-This respects `ergoemacs-theme-options'."
-  (let* ((theme "standard")
-         (theme-plist (ergoemacs-gethash theme ergoemacs-theme-hash))
-         components opt first tmp required)
-    (if (not theme)
-        (error "Could not figure out the theme that you are trying to use...")
-      (setq components (plist-get theme-plist :components))
-      (while (and (< 1 (length components))
-                  (ergoemacs-theme-components--required-p (nth 0 components)))
-        (push (pop components) required))
-      (when (and (< 1 (length components))
-                 (symbolp (nth 1 components))
-                 (setq tmp (symbol-name (nth 1 components)))
-                 (< 5 (length tmp))
-                 (string= "theme" (substring tmp -5)))
-        (setq first (pop components)))
-      
-      (dolist (x (reverse (plist-get theme-plist :optional-off)))
-        (let ((a (assoc x ergoemacs-theme-options)))
-          (when a
-            (setq a (car (cdr a)))
-            (when (eq a 'on)
-              (push x opt)))))
-      (dolist (x (reverse (plist-get theme-plist :optional-on)))
-        (let ((a (assoc x ergoemacs-theme-options)))
-          (if (not a)
-              (push x opt)
-            (setq a (car (cdr a)))
-            (when (or (not a) (eq a 'on))
-              (push x opt)))))
-      (setq components (append (reverse required) (reverse opt) components))
-      (when first
-        (push first components)))
-    components))
-
-;;;###autoload
-(defun ergoemacs-theme-option-off (option &optional no-custom)
-  "Turns OPTION off.
-Uses `ergoemacs-theme-option-on'."
-  (ergoemacs-theme-option-on option no-custom 'off))
-
-;;;###autoload
-(defun ergoemacs-theme-option-on (option &optional no-custom off)
-  "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 (eq (type-of option) 'cons)
-      (dolist (new-option option)
-        (let (ergoemacs-mode)
-          (ergoemacs-theme-option-on new-option no-custom off)))
-    (let* (found
-           (tmp (mapcar
-                 (lambda(elt)
-                   (if (not (eq (nth 0 elt) option))
-                       elt
-                     (setq found t)
-                     (if off
-                         (list option 'off)
-                       (list option 'on))))
-                 ergoemacs-theme-options)))
-      (unless found
-        (push (if off (list option 'off) (list option 'on))
-              tmp))
-      (if no-custom
-          (setq ergoemacs-theme-options tmp)
-        (ergoemacs-save 'ergoemacs-theme-options tmp))))
-  (when ergoemacs-mode
-    (ergoemacs-mode-reset)))
-
-(defun ergoemacs-theme--custom-documentation (&optional themes ini)
-  "Get list of all known layouts and their documentation.
-
-THEMES is the list of themes for the customize documentation.
-
-INI is provided for initilazation, to shorten the descriptions."
-  (let ((themes (list "standard")))
-    (mapconcat
-     (lambda(theme)
-       (if ini
-           (concat theme "=" (plist-get (ergoemacs-gethash theme 
ergoemacs-theme-hash) :description))
-         (concat "\"" theme "\" - " (plist-get (ergoemacs-gethash theme 
ergoemacs-theme-hash) :description))))
-     themes "\n")))
-
-(defun ergoemacs-theme--customization-type ()
-  "Gets the customization types for `ergoemacs-theme'."
-  `(choice
-    (const :tag "Standard" :value nil)
-    ,@(mapcar
-       (lambda(elt)
-         `(const :tag ,elt :value ,elt))
-       (list "standard"))))
-
-(defun ergoemacs-theme--regexp (&optional at-end)
-  "Return a regexp of `ergoemacs-mode' themes.
-When AT-END is non-nil, append a $ to the regular expression."
-  (let (ret)
-    (setq ret (regexp-opt (list "standard") 'symbols))
-    (when at-end
-      (setq ret (concat ret "$")))
-    ret))
-
-(defun ergoemacs-theme-at-point ()
-  "Get the `ergoemacs-theme' defined at or before point.
-Return 0 if there is no such symbol.  Uses
-`ergoemacs-component-at-point'."
-  (ergoemacs-component-at-point t))
-
-(define-button-type 'ergoemacs-theme-help
-  :supertype 'help-xref
-  'help-function #'ergoemacs-theme-describe
-  'help-echo (purecopy "mouse-2, RET: describe ergoemacs keybindings"))
 
 (defvar ergoemacs-theme--svg-list nil)
 
-(defun ergoemacs-theme-describe ()
-  "Display the full documentation for Ergoemacs."
-  (interactive)
-  (let* (required-p
-         svg png tmp)
-    (setq svg (ergoemacs-theme--svg)
-         png (ergoemacs-theme--png))
-    (help-setup-xref (list #'ergoemacs-theme-describe)
-                     (called-interactively-p 'interactive))
-    (with-help-window (help-buffer)
-      (with-current-buffer standard-output
-        (insert "Ergoemacs Documentation:\n")
-        (insert "Diagram:\n")
-        (cond
-         ((and (image-type-available-p 'png)
-               (car png)
-               (file-exists-p (car png)))
-          
-          (insert-image (create-image (car png)))
-          (insert "\n"))
-         ((and (car svg)
-               (file-exists-p (car svg)) (image-type-available-p 'svg))
-          (insert-image (create-image (car svg)))
-          (insert "\n")))
-        (if (and (car png) (file-exists-p (car png)))
-            (insert "[svg] [png]")
-          (insert "[svg]"))
-        (beginning-of-line)
-        (if (looking-at "\\(\\[svg\\]\\) \\(\\[png\\]\\)")
-            (progn
-              (help-xref-button 1 'help-url (car svg))
-              (help-xref-button 2 'help-url (car png)))
-          (if (looking-at "\\(\\[svg\\]\\)")
-              (help-xref-button 1 'help-url (car svg))))
-        (goto-char (point-max))
-       (when ergoemacs-theme--svg-list
-         (insert "\n")
-         (dolist (elt ergoemacs-theme--svg-list)
-           (when (string= key (nth 0 elt))
-             (insert (ergoemacs-key-description (nth 1 elt)) ":\n")
-              (cond
-               ((and (image-type-available-p 'png)
-                     (nth 2 elt)
-                     (file-exists-p (replace-regexp-in-string "[.]svg\\'" 
".png" (nth 2 elt))))
-                (insert-image (create-image (replace-regexp-in-string 
"[.]svg\\'" ".png" (nth 2 elt))))
-                (insert "\n"))
-               ((and (image-type-available-p 'svg)
-                     (nth 2 elt)
-                     (file-exists-p (nth 2 elt)))
-                (insert-image (create-image (nth 2 elt)))
-                (insert "\n")))
-              (when (file-exists-p (nth 2 elt))
-                (insert "[svg]")
-                (when (looking-back "\\(\\[svg\\]\\)" nil)
-                  (help-xref-button 1 'help-url (nth 2 elt))))
-              (when (file-exists-p (replace-regexp-in-string "[.]svg\\'" 
".png" (nth 2 elt)))
-                (insert " [png]")
-                (when (looking-back "\\(\\[png\\]\\)" nil)
-                  (help-xref-button 1 'help-url (replace-regexp-in-string 
"[.]svg\\'" ".png" (nth 2 elt)))))
-              (insert "\n\n"))))
-        (insert "\n\n")
-
-        (setq required-p t)
-        
-        (insert "\n\n")
-        (ergoemacs-key-description--keymap ergoemacs-keymap t)
-        (buffer-string)
-        )
-      )
-    )
-  )
-
 (defvar ergoemacs-theme-create-bash-functions
   '((backward-char)
     (forward-char)
diff --git a/ergoemacs-themes.el b/ergoemacs-themes.el
index e57463b..5b93774 100644
--- a/ergoemacs-themes.el
+++ b/ergoemacs-themes.el
@@ -448,8 +448,8 @@ These keys do not depend on the layout."
 
 (defun ergoemacs-set-move-bracket-reduction (keymap)
   "Move bracket in the reduction theme for KEYMAP."
-  (ergoemacs-global-set-key (kbd "<M-left>") 'ergoemacs-backward-open-bracket)
-  (ergoemacs-global-set-key (kbd "<M-right>") 
'ergoemacs-forward-close-bracket))
+  (ergoemacs-define-key keymap (kbd "<M-left>") 
'ergoemacs-backward-open-bracket)
+  (ergoemacs-define-key keymap (kbd "<M-right>") 
'ergoemacs-forward-close-bracket))
 
 (defun ergoemacs-set-copy (keymap)
   "Copy, Cut, Paste, Redo and Undo for KEYMAP."
@@ -1339,7 +1339,7 @@ In a terminal, this can be either arrow keys (e.g. meta+O 
A == <up>) or regular
   (ergoemacs-set-menu-bar-edit)
   (ergoemacs-set-menu-bar-file))
 
-
+(defvar org-mode-map )
 (defun ergoemacs-install-org-bindings ()
   "Install the `org-mode' bindings."
   (define-key org-mode-map (kbd "<C-return>") 
'ergoemacs-org-insert-heading-respect-content)
@@ -1362,12 +1362,14 @@ In a terminal, this can be either arrow keys (e.g. 
meta+O A == <up>) or regular
 
 (add-hook 'org-load-hook #'ergoemacs-install-org-bindings)
 
+(defvar log-edit-mode-map)
 (defun ergoemacs-install-log-edit-bindings ()
   "Install `log-edit' key bindings."
   (define-key log-edit-mode-map [remap save-buffer] 'log-edit-done))
 
 (with-eval-after-load 'log-edit (ergoemacs-install-log-edit-bindings))
 
+(defvar eshell-mode-map)
 (defun ergoemacs-install-eshell-bindings ()
   "Install `eshell' bindings."
   (define-key eshell-mode-map [remap move-beginning-of-line] 'eshell-bol))
@@ -1385,6 +1387,7 @@ In a terminal, this can be either arrow keys (e.g. meta+O 
A == <up>) or regular
   (define-key dired-mode-map [remap query-replace-regexp] 
'dired-do-query-replace-regexp))
 (add-hook 'dired-load-hook #'ergoemacs-install-dired-bindings)
 
+(defvar calc-mode-map)
 (defun ergoemacs-install-calc-bindings ()
   "Install `calc-mode' bindings."
   (define-key calc-mode-map [remap ergoemacs-undo] 'calc-undo))
diff --git a/ergoemacs-translate.el b/ergoemacs-translate.el
index eef41eb..31e9231 100644
--- a/ergoemacs-translate.el
+++ b/ergoemacs-translate.el
@@ -777,8 +777,7 @@ When NAME is a symbol, setup the translation function for 
the symbol."
         -digit-argument
         -modal
         translation
-        (local-keymap (or (plist-get plist :keymap) (make-sparse-keymap)))
-       (trans-keymap (intern (concat "ergoemacs-translate--" (plist-get plist 
:name) "-map"))))
+        (local-keymap (or (plist-get plist :keymap) (make-sparse-keymap))))
     (let (tmp
           cur-trans
           ret)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]