[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.
- [elpa] externals/ergoemacs-mode f2caedb 032/325: Remove dead code, (continued)
- [elpa] externals/ergoemacs-mode f2caedb 032/325: Remove dead code, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 149c900 037/325: Remove ergoemacs-command-loop--modal-pop, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 8e17210 044/325: Remove ergoemacs-modal-ignored-keymap, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 3e25eac 043/325: Remove unused modal customizations, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 34daf02 062/325: Do not autoload ergoemacs-debug, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode de74f45 002/325: Remove some Control key bindings, so nano works, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 72a812c 025/325: Remove dead code, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 30ed202 012/325: Remove cttl-x-c 'both' option, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode b0c649d 052/325: Cleanup, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 1203d93 059/325: Remove dead code, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 4996d2c 066/325: Remove the apply-inits function,
Stefan Monnier <=
- [elpa] externals/ergoemacs-mode 37d642e 092/325: Remove the optional off stuff and lots of helm stuff., Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode d6926f0 095/325: Simplify menus, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode d3a7657 116/325: Make 306 work and clean up lots of tests., Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 5a1ec10 111/325: Fix some warnings, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode bb77fa2 131/325: Replace ergoemacs-print-buffer-confirm with pr-interface everywhere, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 4f43e90 001/325: Add a whole bunch of keybindings, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode f58f7d8 008/325: Replace all cl with cl-lib, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 89b618b 004/325: Merge branch 'master' into ergoterm, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 21cab2a 006/325: Merge branch 'master' into ergoterm, Stefan Monnier, 2021/10/23
- [elpa] externals/ergoemacs-mode 57bbe7d 005/325: Revert "Remove shift translation, instead directly binding those keys", Stefan Monnier, 2021/10/23