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

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

[elpa] externals/ergoemacs-mode d0004ec 241/325: Remove more -map functi


From: Stefan Monnier
Subject: [elpa] externals/ergoemacs-mode d0004ec 241/325: Remove more -map functions
Date: Sat, 23 Oct 2021 18:49:02 -0400 (EDT)

branch: externals/ergoemacs-mode
commit d0004ec9ce417ee42ed7c05f4db4d936b580006c
Author: Walter Landry <wlandry@caltech.edu>
Commit: Walter Landry <wlandry@caltech.edu>

    Remove more -map functions
---
 ergoemacs-map.el | 309 -------------------------------------------------------
 1 file changed, 309 deletions(-)

diff --git a/ergoemacs-map.el b/ergoemacs-map.el
index cd817bc..bc7b283 100644
--- a/ergoemacs-map.el
+++ b/ergoemacs-map.el
@@ -301,14 +301,8 @@ done in `ergoemacs-map--alist'."
 (defvar ergoemacs-map--undefined-keys nil
   "List of undefined keys for the global map.")
 
-
 (defvar ergoemacs-map--cache--last-breadcrumb "")
 
-(defun ergoemacs-map-cache--exists-p (what)
-  "Does the hashkey WHAT exist?"
-  (let ((key (ergoemacs-map--hashkey what)))
-    (ergoemacs-gethash key ergoemacs-map--hash)))
-
 (defun ergoemacs-map--cache-- (what &optional save)
   "Get WHAT cache.  If SAVE is non-nil, save cache to WHAT."
   (or (and (not what) save
@@ -333,26 +327,6 @@ done in `ergoemacs-map--alist'."
           (puthash key (copy-tree val t) ergoemacs-map--hash))
         val)))
 
-(defvar ergoemacs-map--lookup-keymap-key-volitile-maps
-  '()
-  "Keymaps that are always calculated when they are the `current-local-map'.")
-
-(defun ergoemacs-map--lookup-keymap-key (lookup-keymap)
-  "Calculates the cache key based on LOOKUP-KEYMAP."
-  (let ((lookup-key (or (and (not (string= "" ergoemacs-map--breadcrumb)) 
ergoemacs-map--breadcrumb)
-                        (ergoemacs lookup-keymap :map-list)))
-        mode-hook)
-    (setq lookup-key (or (and (stringp lookup-key) (intern lookup-key))
-                         (and (consp lookup-key) (car lookup-key))))
-    (when (and lookup-key (eq (current-local-map) lookup-keymap))
-      (if (memq lookup-key ergoemacs-map--lookup-keymap-key-volitile-maps)
-          (setq lookup-key nil)
-        (if (minibufferp)
-            (setq lookup-key (intern (format "%s-%s" lookup-key (md5 (format 
"%s" minibuffer-setup-hook)))))
-          (when (and (setq mode-hook (intern (format "%s-hook" major-mode))) 
(boundp mode-hook))
-            (setq lookup-key (intern (format "%s-%s" lookup-key (md5 (format 
"%s" (symbol-value mode-hook))))))))))
-    lookup-key))
-
 (defvar ergoemacs-map--unbound-keys nil
   "Unbound keys.")
 
@@ -366,289 +340,6 @@ done in `ergoemacs-map--alist'."
 (defvar ergoemacs-map-- (make-hash-table :test 'equal))
 (defvar ergoemacs-map--lookup-hash (make-hash-table :test 'equal))
 
-(defun ergoemacs-map--composed-list (lookup-keymap only-modify-p 
use-local-unbind-list-p)
-  "Calculate majority of keys for LOOKUP-KEYMAP.
-
-It takes the following arguments:
-
-- LOOKUP-KEY - key for the caching of keymaps.
-
-- LOOKUP-KEYMP -- keymap for any ergoemacs-mode equivalent
-  binding lookups.
-
-- ONLY-MODIFY-P -- When the keymap should only be modified,
-  lookups should not be performed.
-
-- USE-LOCAL-UNBIND-LIST-P -- When `ergoemacs-mode' equivalent
-  keys should be locally unbound.  This is useful for
-  `isearch-mode-map' keymap in Emacs 24.4+."
-  (when (ergoemacs-keymapp lookup-keymap)
-    (unless (ergoemacs lookup-keymap :installed-p)
-      (let ((ret (make-sparse-keymap))
-            tmp composed-list local-unbind-list bound-keys i key2)
-        ;; This used to have caching.  It causes infinite loops in
-        ;; mu4e for reasons that are hard to figure out.
-        (unless only-modify-p
-          (ergoemacs-timing lookup-keymap
-            (ergoemacs-map-keymap
-             (lambda(key item)
-               (unless (or (eq item 'ergoemacs-prefix)
-                           (consp key)
-                           (memq item ergoemacs-remap-ignore))
-                 (let ((key (vconcat key)))
-                   ;; What are the keys that are changed.
-                   (when (setq tmp (ergoemacs-gethash key 
ergoemacs-map--lookup-hash))
-                     (dolist (new-key tmp)
-                       ;; (if (and (boundp 'isearch-mode-map) (eq 
lookup-keymap isearch-mode-map))
-                       ;;     (message "Define %s->%s" (key-description 
new-key) item))
-                       ;; Don't use (ergoemacs :define-key), since list 
contains all variants.
-                       (ergoemacs :define-key ret new-key item)
-                       (push new-key bound-keys)))
-                   ;; Keys where `ergoemacs-mode' dominates
-                   (setq i (length key))
-                   (when (and (catch 'found-key
-                                (while (> i 0)
-                                  (when (setq tmp (ergoemacs-gethash (setq 
key2 (substring key 0 i)) ergoemacs-map--))
-                                    (throw 'found-key t))
-                                  (setq i (- i 1))) nil)
-                              (not (member key2 bound-keys))
-                              (not (member key2 ergoemacs-map--unbound-keys)))
-                     (if (not use-local-unbind-list-p)
-                         (ergoemacs :define-key ret key2 tmp)
-                       (ergoemacs :apply-key key2
-                                  (lambda (trans-key)
-                                    (unless (member trans-key 
local-unbind-list)
-                                      (push trans-key local-unbind-list))))))
-                   ;; Define ergoemacs-mode remapping
-                   ;; lookups.
-                   (when (setq tmp (ergoemacs-gethash key (ergoemacs 
global-map :lookup)))
-                     (ergoemacs :define-key ret (vector 'ergoemacs-remap tmp) 
item)))))
-             lookup-keymap))
-          (ergoemacs ret :label (list (ergoemacs lookup-keymap :key-hash) 
'ergoemacs-mode (intern ergoemacs-keyboard-layout))))
-        (setq tmp (ergoemacs-component-struct--lookup-list lookup-keymap) 
composed-list (or (and ret (or (and tmp (append tmp (list ret))) (list ret))) 
tmp))
-        (list composed-list local-unbind-list ret)))))
-
-(defun ergoemacs-map--puthash (key new &optional table)
-  "Associate KEY with a list including NEW in TABLE."
-  (let* ((hash (or table ergoemacs-map--lookup-hash))
-         (lst (ergoemacs-gethash key hash)))
-    (if lst
-        (unless (member new lst)
-          (push new lst))
-      (setq lst (list new)))
-    (puthash key lst hash)))
-
-(defun ergoemacs-map--remhash (key new &optional table)
-  "For the KEY containing NEW, remove that NEW and update TABLE.
-
-If NEW is the only item in the list, remove it from the hash
-TABLE."
-  (let* ((hash (or table ergoemacs-map--lookup-hash))
-         (lst (ergoemacs-gethash key hash))
-         new-lst)
-    (when lst
-      (dolist (elt (reverse new-lst))
-        (unless (equal new elt)
-          (push elt new-lst)))
-      (if new-lst
-          (puthash key lst hash)
-        (remhash key hash)))))
-
-(defun ergoemacs-map--get-struct-map (struct-map cur-layout &optional 
lookup-keymap)
-  "For component STRUCT-MAP, get the ergoemacs keymap.
-
-When STRUCT-MAP is not a `ergoemacs-component-struct' object,
-return nil.  Otherwise, return the keymap based on the STRUCT-MAP
-component.
-
-The keyboard layout that is being calculated is CUR-LAYOUT.
-
-When LOOKUP-KEYMAP is nil, the returned map is relative to the
-global keymap.  Otherwise, it is relative to LOOKUP-KEYMAP."
-  (if (not (ergoemacs-component-struct-p struct-map)) nil
-    (let (ret
-         (cur-layout (or cur-layout ergoemacs-keyboard-layout)))
-      (cond
-       ((and (not lookup-keymap)
-             (string= cur-layout (ergoemacs-component-struct-layout 
struct-map)))
-        (setq ret (ergoemacs-component-struct-map struct-map)))
-       ((and (not lookup-keymap)
-             (setq ret (ergoemacs-gethash
-                        (list nil (intern cur-layout))
-                        (ergoemacs-component-struct-calculated-layouts 
struct-map))))
-        ret)
-       ((not lookup-keymap)
-        ;; Overall layout hasn't been calculated.
-        (setq ret (ergoemacs-component-struct--get struct-map cur-layout nil)))
-       (t
-        (error "Cant calculate/lookup keymap")))
-      ret)))
-
-(defun ergoemacs-map--get-undefined-map (component-list)
-  "Get a keymap of the ergoemacs-mode unbound keys based on COMPONENT-LIST.
-
-COMPONENT-LIST is a list of `ergoemacs-component-struct' items
-that will be applied.
-
-This updates the variable `ergoemacs-map--undefined-keys', and
-then defines each key in the `ergoemacs-map--undefined-keys'
-vector on the new keymap to be `ergoemacs-map-undefind'."
-  (let ((ret (make-sparse-keymap)))
-    (dolist (cur-map component-list)
-      (dolist (undefined-key (ergoemacs-component-struct-undefined cur-map))
-        (unless (member undefined-key ergoemacs-map--undefined-keys)
-          (push undefined-key ergoemacs-map--undefined-keys))))
-    (dolist (i ergoemacs-map--undefined-keys)
-      (define-key ret i #'ergoemacs-map-undefined))
-    (ergoemacs ret :label (list (ergoemacs (ergoemacs :global-map) :key-hash) 
'ergoemacs-undefined (intern ergoemacs-keyboard-layout)))
-    ret))
-
-(defun ergoemacs-map--global-component-keys-lists (component-list 
menu-bar-list composed-keymap-list &optional layout)
-  "Get ergoemacs keys from COMPONENT-LIST.
-
-This puts menu bar components in MENU-BAR-LIST, and other keymaps
-in COMPOSED-KEYMAP-LIST.
-
-The LAYOUT represents the keybaord layout that will be translated."
-  (let (tmp tmp2)
-    (push (lookup-key (ergoemacs :global-map) [menu-bar]) menu-bar-list)
-    (dolist (cur-map (reverse component-list))
-      (when cur-map
-       (setq tmp (ergoemacs-map--get-struct-map cur-map layout))
-       (unless (ergoemacs tmp :empty-p)
-          (cond
-           ((setq tmp2 (lookup-key tmp [menu-bar-list]))
-            (push (copy-keymap tmp2) menu-bar-list)
-            (setq tmp2 (make-sparse-keymap))
-            (map-keymap
-             (lambda (event item)
-               (unless (eq event 'menu-bar-list)
-                 (define-key tmp2 (vector event) item)))
-             tmp)
-            (unless (ergoemacs tmp2 :empty-p)
-              (push tmp2 composed-keymap-list)))
-           (t (push tmp composed-keymap-list))))))
-    (vector menu-bar-list composed-keymap-list)))
-
-(defun ergoemacs-map--setup-global-ergoemacs-hash (keymap-list unbind-list)
-  "Setup `ergoemacs-map--' cache based on KEYMAP-LIST, repsecting UNBIND-LIST."
-  (let (tmp)
-    (ergoemacs-timing setup-ergoemacs-hash
-      (dolist (ret keymap-list)
-       (ergoemacs-map-keymap
-        (lambda(key item)
-          (unless (or (eq item 'ergoemacs-prefix)
-                      (ignore-errors (eq (aref key 0) 'ergoemacs-labeled))
-                      (gethash key ergoemacs-map--)
-                      (member key unbind-list))
-            (when (setq tmp (ergoemacs-gethash item (ergoemacs global-map 
:where-is)))
-              (dolist (old-key tmp)
-                (ergoemacs :apply-key old-key
-                           (lambda(trans-old-key)
-                             (ergoemacs :apply-key key
-                                        (lambda(trans-new-key)
-                                          (unless (or (gethash trans-new-key 
ergoemacs-map--)
-                                                      (member trans-new-key 
unbind-list))
-                                            (puthash trans-new-key item 
ergoemacs-map--)
-                                            (ergoemacs-map--puthash 
trans-old-key trans-new-key))))))))
-            (ergoemacs :apply-key key #'puthash item ergoemacs-map--)))
-        ret)))))
-
-(defun ergoemacs-map--get-global-menu-map (menu-bar-list)
-  "Get the global menu-bar from MENU-BAR-LIST."
-  (let ((tmp (make-composed-keymap menu-bar-list))
-       (i 0)
-       alst)
-    (dolist (menu ergoemacs-menu-order)
-      (push (list menu i) alst)
-      (setq i (+ i 1)))
-    (setq tmp (sort tmp (lambda(elt1 elt2)
-                          (let ((i1 (or (and (eq elt1 'keymap) -1) (assq (car 
elt1) alst)))
-                                (i2 (or (and (eq elt2 'keymap) -1) (assq (car 
elt2) alst))))
-                            (if i1
-                                (setq i1 (or (and (integerp i1) i1) (nth 1 
i1)))
-                              (setq i1 (length ergoemacs-menu-order)))
-                            (if i2
-                                (setq i2 (or (and (integerp i2) i2) (nth 1 
i2)) )
-                              (setq i2 (length ergoemacs-menu-order)))
-                            (< i1 i2)))))
-    tmp))
-
-(defun ergoemacs-map--adjust-remaps-for-overrides (hook-overrides 
composed-list keymap &optional deferred-p)
-  "Use HOOK-OVERRIDES to adjust COMPOSED-LIST and KEYMAP.
-
-A new list of keymaps will be returned with any [ergoemacs-remap]
-keys calculated.
-
-When DEFERRED-P is non-nil, the returned keymap list will have
-new overriding keymaps are appended, otherwise the overriding
-keymaps are prepended"
-  (if (not hook-overrides) composed-list
-    ;; Need to fix 'ergoemacs-remaps as well.
-    ;; This is done here because hooks can change, and the
-    ;; cached map would be invalid.
-    (let ((tmp (ergoemacs global-map :keys))
-          (tmp2 (make-sparse-keymap))
-          (tmp3 (make-composed-keymap hook-overrides)))
-      (ergoemacs tmp2 :label '(fix-hook-remaps))
-      (ergoemacs-timing calculate-ergoemacs-remap
-       (ergoemacs-map-keymap
-        (lambda(key item)
-          (unless (or (eq item 'ergoemacs-prefix)
-                      (consp key))
-            (let ((key (vconcat key)))
-              (when (member key tmp)
-                (define-key keymap (vector 'ergoemacs-remap (ergoemacs-gethash 
key (ergoemacs global-map :lookup))) nil)))))
-        tmp3))
-      (unless (ergoemacs tmp2 :empty-p)
-       (push tmp2 hook-overrides))
-      (if deferred-p
-         (append composed-list hook-overrides)
-       (append hook-overrides composed-list)))))
-
-(defun ergoemacs-map--set-maps (lookup-keymap final-keymap)
-  "Set maps.
-
-LOOKUP-KEYMAP is the lookup-keymap where the keymaps may be set.
-
-FINAL-KEYMAP is the `ergoemacs-mode' modified keymap."
-  (let (tmp)
-    (when (ergoemacs lookup-keymap :set-map-p)
-      (dolist (map (ergoemacs lookup-keymap :map-list))
-       (when (eq lookup-keymap overriding-local-map)
-         (setq overriding-local-map final-keymap))
-       (when (eq lookup-keymap overriding-terminal-local-map)
-         (setq overriding-terminal-local-map final-keymap))
-       (when (eq (default-value map) lookup-keymap)
-         (ergoemacs :spinner '("⌨→%s (default)" "ergoemacs→%s (default)" 
"ergoemacs->%s (default)") map)
-         (set-default map final-keymap))
-       (when (eq (symbol-value map) lookup-keymap)
-         (ergoemacs :spinner '("⌨→%s (local)" "ergoemacs→%s (local)" 
"ergoemacs->%s (local)") map)
-         (set map final-keymap))
-       (when (setq tmp (assoc map ergoemacs-map--mirrored-maps))
-         (dolist (mirror (cdr tmp))
-           (when (and mirror (boundp mirror))
-             (ergoemacs :spinner '("⌨→%s (mirror %s)" "ergoemacs→%s (mirror 
%s)" "ergoemacs->%s (mirror %s)") map mirror)
-             (set mirror final-keymap)
-             (push mirror ergoemacs-map--modified-maps))))
-       (push map ergoemacs-map--modified-maps)))))
-
-(defun ergoemacs-map--temporary-map-properties (map)
-  "Test if MAP is a transient map that `ergoemacs-mode' does not touch.
-
-This occurs when the keymap is not known to `ergoemacs-mode' and
-it is not a composed keymap.
-
-If it is a tranisent map, assign the :dont-modify-p property to t."
-  (setq ergoemacs-map--breadcrumb "transient-maps")
-  (ergoemacs map :label)
-  ;;ergoemacs-modify-transient-maps
-  (if (eq (ergoemacs-gethash 'transient-maps ergoemacs-breadcrumb-hash)
-         (ergoemacs (ergoemacs :original map) :key))
-      (ergoemacs map :dont-modify-p t)
-    (ergoemacs-setcdr (cdr map) (cdr (ergoemacs (ergoemacs :original map))))))
-
-
 (defvar ergoemacs-map--saved-global-map nil)
 (defvar ergoemacs-map--last-global-map nil)
 (defvar ergoemacs-read-from-minibuffer-map nil



reply via email to

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