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

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

[elpa] externals/ergoemacs-mode 4996d2c 066/325: Remove the apply-inits


From: Stefan Monnier
Subject: [elpa] externals/ergoemacs-mode 4996d2c 066/325: Remove the apply-inits function
Date: Sat, 23 Oct 2021 18:48:23 -0400 (EDT)

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

    Remove the apply-inits function
    
    It does not appear to do anything useful and was causing weird timing bugs.
---
 ergoemacs-component.el | 212 -------------------------------------------------
 1 file changed, 212 deletions(-)

diff --git a/ergoemacs-component.el b/ergoemacs-component.el
index 6519dfd..583c3a8 100644
--- a/ergoemacs-component.el
+++ b/ergoemacs-component.el
@@ -985,218 +985,6 @@ OBJECT is the `ergoemacs-component-struct' object being 
changed."
      (t (ergoemacs-component-struct--variables 
(ergoemacs-component-struct--lookup-hash obj))))))
 
 (defvar ergoemacs-component-struct--refresh-variables nil)
-(defvar ergoemacs-component-struct--applied-inits '())
-(defvar ergoemacs-component-struct--deferred-functions '())
-
-(defvar ergoemacs-component-struct--apply-inits-first-p t)
-(defvar ergoemacs-component-struct--applied-plists nil)
-
-(defvar ergoemacs-component-echo-loaded-file-p nil)
-
-(defvar ergoemacs-component-struct--apply-inits nil)
-(defun ergoemacs-component-struct--apply-inits (&optional file obj)
-  "Apply the initializations after loading FILE from the object OBJ.
-
-This is a wrapper for `ergoemacs-component-struct--apply-inits--'
-to prevent infinite recursion."
-  (unless ergoemacs-component-struct--apply-inits
-    (setq ergoemacs-component-struct--apply-inits t)
-    (unwind-protect
-       (ergoemacs-component-struct--apply-inits-- file obj))
-    (setq ergoemacs-component-struct--apply-inits nil)))
-
-(defun ergoemacs-component-struct--apply-inits-- (&optional file obj)
-  "Apply the initializations after loading FILE from the object OBJ."
-  (ergoemacs-map-properties--label-known)
-  (when (and ergoemacs-component-echo-loaded-file-p file)
-    (message "`ergoemacs-mode' Loaded %s" file))
-  (when (eq ergoemacs-component-struct--refresh-variables t)
-    (setq ergoemacs-component-struct--refresh-variables 
ergoemacs-component-struct--applied-inits))
-  (let* ((obj (or obj (ergoemacs-theme-components)))
-         tmp)
-    (when ergoemacs-component-struct--apply-inits-first-p
-      (setq ergoemacs-component-struct--apply-inits-first-p nil)
-      (if (not ergoemacs-mode--fast-p)
-          (setq ergoemacs--start-emacs-state-2 (ergoemacs--emacs-state))
-        ;; Check to see if emacs state has changed.
-        (setq ergoemacs--start-emacs-state-2 (ergoemacs--emacs-state))
-        (ergoemacs-mode--setup-hash-tables--setq
-         nil
-         'ergoemacs--last-start-emacs-state-2 nil)
-        (unless (equal ergoemacs--last-start-emacs-state-2 
ergoemacs--start-emacs-state-2)
-          (if (not ergoemacs--last-start-emacs-state-2)
-              (progn
-                (message "Saving fast startup state.")
-                (setq ergoemacs--last-start-emacs-state-2 
ergoemacs--start-emacs-state-2)
-                (ergoemacs-mode--setup-hash-tables--setq
-                 t
-                 'ergoemacs--last-start-emacs-state-2 
ergoemacs--last-start-emacs-state-2))
-            (ergoemacs-mode-clear-cache t)
-            (ergoemacs-warn "ergoemacs-mode cache reset AFTER loading; Keys 
may be slightly inconsistent until emacs restart.")))))
-    ;; Turn on plist options (like :diminish)
-    (dolist (elt obj)
-      (unless (memq elt ergoemacs-component-struct--applied-plists)
-        (let* ((comp (ergoemacs-component-struct--lookup-hash elt))
-               (plist (ergoemacs-component-struct-plist comp))
-               fn)
-          (dolist (elt plist)
-            (when (and (symbolp elt)
-                       (setq fn (intern (format "ergoemacs-component--%s-on"
-                                                (substring (symbol-name elt) 
1))))
-                       (fboundp fn))
-              (funcall fn plist)))
-          (push elt ergoemacs-component-struct--applied-plists))))
-    
-    ;; Turn off plist options
-    (setq tmp nil)
-    (dolist (elt ergoemacs-component-struct--applied-plists)
-      (if (memq elt obj)
-          (push elt tmp)
-        (let* ((comp (ergoemacs-component-struct--lookup-hash elt))
-               (plist (ergoemacs-component-struct-plist comp))
-               fn)
-          (dolist (elt plist)
-            (when (and (symbolp elt)
-                       (setq fn (intern (format "ergoemacs-component--%s-off"
-                                                (substring (symbol-name elt) 
1))))
-                       (fboundp fn))
-              (funcall fn plist))))))
-    (setq ergoemacs-component-struct--applied-plists tmp)
-    (dolist (cur-obj obj)
-      (ergoemacs-timing (intern (format "initialize-%s" cur-obj))
-        (dolist (init (ergoemacs-component-struct--variables cur-obj))
-          (if (and (consp (nth 0 init)) (not (nth 1 init)) (not (nth 2 init)))
-              (unless (member (nth 0 init) 
ergoemacs-component-struct--deferred-functions)
-                (cond
-                 ((eq (car (nth 0 init)) 'add-to-list)
-                  (when (ignore-errors (boundp (nth 1 (nth 0 init))))
-                    (ignore-errors
-                      (apply (car (nth 0 init)) (cdr (nth 0 init)))
-                      (push (nth 0 init) 
ergoemacs-component-struct--deferred-functions)))
-                  (when (ignore-errors (eq 'quote (nth 0 (nth 1 (nth 0 
init)))))
-                    (if (ignore-errors (eq 'quote (nth 0 (nth 2 (nth 0 
init)))))
-                        (when (ignore-errors (boundp (nth 1 (nth 1 (nth 0 
init)))))
-                          (apply 'add-to-list  (nth 1 (nth 2 (nth 0 init))) 
(cdr (cdr (cdr (nth 0 init)))))
-                          (push (nth 0 init) 
ergoemacs-component-struct--deferred-functions))
-                      (when (ignore-errors (boundp (nth 1 (nth 1 (nth 0 
init)))))
-                        (apply 'add-to-list (nth 1 (nth 1 (nth 0 init))) (cdr 
(cdr (nth 0 init))))
-                        (push (nth 0 init) 
ergoemacs-component-struct--deferred-functions)))))
-                 ((memq (car (nth 0 init)) '(push cl-pushnew))
-                  (when (ignore-errors (boundp (nth 2 (nth 0 init))))
-                    (if (ignore-errors (eq 'quote (nth 1 (nth 1 (nth 0 
init)))))
-                        (ignore-errors
-                          (apply (car (nth 0 init)) (nth 1 (nth 1 (nth 0 
init))) (cdr (cdr (nth 0 init))))
-                          (push (nth 0 init) 
ergoemacs-component-struct--deferred-functions))
-                      (ignore-errors
-                        (apply (car (nth 0 init)) (cdr (nth 0 init)))
-                        (push (nth 0 init) 
ergoemacs-component-struct--deferred-functions)))
-                    (ignore-errors
-                      (apply (car (nth 0 init)) (cdr (nth 0 init)))
-                      (push (nth 0 init) 
ergoemacs-component-struct--deferred-functions))))
-                 ((eq (car (nth 0 init)) 'require)
-                  (require (nth 1 (nth 1 (nth 0 init))) nil t)
-                  (when (not (featurep (nth 1 (nth 1 (nth 0 init)))))
-                    ;; Attempt to ensure the feature, if specified.
-                    (ergoemacs-warn "Could not load %s; %s" (nth 1 (nth 1 (nth 
0 init)))
-                          (nth 3 init))))
-                 (t
-                  (condition-case err
-                      (eval (nth 0 init))
-                    (error (progn
-                            (ergoemacs-warn "%s while evaluating %s" err (nth 
0 init))
-                            (debug err))))
-                  (push (nth 0 init) 
ergoemacs-component-struct--deferred-functions))
-                 ;; (t (ergoemacs-warn "Theme did not handle: %s" (nth 0 
init)))
-                 ))
-            (let ((x (and ergoemacs-component-struct--refresh-variables 
(boundp (nth 0 init))
-                          (assq (nth 0 init) 
ergoemacs-component-struct--refresh-variables)))
-                  add-hook-p append-p local-p)
-              (cond
-               ((and x
-                     (not (nth 2 init))
-                     (not
-                      (equal (ergoemacs-sv (nth 0 init))
-                             (funcall (nth 1 init)))))
-                ;; Values have changed, so reapply.
-                (setq ergoemacs-component-struct--refresh-variables (delq x 
ergoemacs-component-struct--refresh-variables)
-                      x nil))
-               ((and x (nth 2 init))
-                ;; Reapply hooks
-                (setq ergoemacs-component-struct--refresh-variables (delq x 
ergoemacs-component-struct--refresh-variables)
-                      x nil)))
-              (cond
-               (x ;; Values have not changed
-                (setq ergoemacs-component-struct--refresh-variables (delq x 
ergoemacs-component-struct--refresh-variables)))
-               ((not (boundp (nth 0 init))) ;; Do nothing, not bound yet.
-                )
-               ((and (nth 2 init) ;; Already applied hook?
-                     (setq add-hook-p (nth 0 (nth 2 init))
-                           append-p (nth 1 (nth 2 init))
-                           local-p (nth 2 (nth 2 init)))
-                     (member (list (nth 0 init) (nth 1 init)
-                                   (list (not add-hook-p) append-p local-p))
-                             ergoemacs-component-struct--applied-inits)))
-               ((nth 2 init)
-                ;; Hook
-                (if add-hook-p
-                    (progn
-                      (funcall 'add-hook (nth 0 init) (nth 1 init) append-p 
local-p)
-                      ;; (message "%s: (add-hook %s %s %s %s)"
-                      ;;          cur-obj (nth 0 init) (nth 1 init)
-                      ;;          append-p local-p)
-                      )
-                  (funcall 'remove-hook (nth 0 init) (nth 1 init) local-p)
-                  ;; (message "%s: (remove-hook %s %s %s %s)"
-                  ;;          cur-obj (nth 0 init) (nth 1 init)
-                  ;;          append-p local-p)
-                  )
-                (push (list (nth 0 init) (nth 1 init)
-                            (list (not add-hook-p) append-p local-p))
-                      ergoemacs-component-struct--applied-inits))
-               ((and (not (nth 2 init)) (assq (nth 0 init) 
ergoemacs-component-struct--applied-inits))
-                ;; Already applied, Do nothing for now.
-                )
-               (t
-                ;; (Nth 0 Init)iable state change
-                (when (ergoemacs-set (nth 0 init) (funcall (nth 1 init))
-                                     (ergoemacs-component-struct-defer 
(ergoemacs-component-struct--lookup-hash cur-obj)))
-                  (push (list (nth 0 init) (ergoemacs-sv (nth 0 init)))
-                        ergoemacs-component-struct--applied-inits)
-                  )))))))))
-  ;; Now remove things that were not set
-  (when ergoemacs-component-struct--refresh-variables
-    (let ((tmp ergoemacs-component-struct--applied-inits))
-      (setq ergoemacs-component-struct--applied-inits 
ergoemacs-component-struct--refresh-variables)
-      (setq ergoemacs-component-struct--refresh-variables nil)
-      (unwind-protect
-          (ergoemacs-component-struct--remove-inits)
-        (setq ergoemacs-component-struct--applied-inits tmp)))))
-
-(add-hook 'ergoemacs-mode-startup-hook 
#'ergoemacs-component-struct--apply-inits)
-(add-hook 'ergoemacs-after-load-functions 
#'ergoemacs-component-struct--apply-inits)
-
-(defun ergoemacs-component-struct--remove-inits ()
-  "Remove the applied initializations of modes and variables.
-This assumes the variables are stored in 
`ergoemacs-component-struct--applied-inits'"
-  (if ergoemacs-component-struct--refresh-variables
-      (setq ergoemacs-component-struct--refresh-variables 
ergoemacs-component-struct--applied-inits)
-    (dolist (init ergoemacs-component-struct--applied-inits)
-      (let ((var (nth 0 init))
-            ;; (val (nth 1 init))
-            (hook (nth 2 init)))
-        (cond
-         (hook
-          (let ((add-hook-p (nth 0 hook))
-                (append-p (nth 1 hook))
-                (local-p (nth 2 hook)))
-            (if add-hook-p
-                (funcall 'add-hook (nth 0 init) (nth 1 init) append-p local-p)
-              (funcall 'remove-hook (nth 0 init) (nth 1 init) local-p))))
-         (t
-          (ergoemacs-reset var))))))
-  (setq ergoemacs-component-struct--applied-inits '()))
-
-(add-hook 'ergoemacs-mode-shutdown-hook 
#'ergoemacs-component-struct--remove-inits)
 
 (defun ergoemacs-component-struct--versions (&optional obj)
   "Get Versions available for OBJ.



reply via email to

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