Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify startup files? #511

Open
uliw opened this issue Nov 16, 2024 · 3 comments
Open

Simplify startup files? #511

uliw opened this issue Nov 16, 2024 · 3 comments

Comments

@uliw
Copy link

uliw commented Nov 16, 2024

The current startup involves calling several nested init files

.emacs.d/init.el
  .emacs.d/scimax/init.el
       .emacs.d/scimax/preload.el
       .emacs.d/scimax/bootstrap
               .emacs.d/scimax/several packages
       .emacs.d/scimax/packages
               .emacs.d/scimax/several packages
 .emacs.d/scimax/user.el
      .emacs.d/scimax/settings.el (or org, or user.el)

This results in variables being declared and packages being loaded, multiple times in different locations.

This hierarchy can be flattened into a single init file (see the working example below).

.emacs.d/scimax/init_new.el
    .emacs.d/scimax/init_new.el
    .emacs.d/scimax/boostrap.el
    .emacs.d/scimax/packages.el
    .emacs.d/scimax/settings.el

Further, packages.el specifies many packages, and not all are required for everyone. I can easily modify packages.el myself, but that means I am changing the scimax structure. Could this be into essentials.el, use-helm.el or use-avy.el, writing.el, coding.el, extras.el? This would allow loading them from a user-startup file. A suitable init file could be provided as a template so that this would not interfere with the current setup.

;; this makes garbage collection less frequent, which speeds up init by about 2 seconds.
(set-language-environment "UTF-8")
(setq gc-cons-threshold 80000000)
(when (version< emacs-version "25.0")
  (warn "You probably need at least Emacs 25. You should upgrade. You may need to install leuven-theme manually."))

;; remember this directory
;; defconst scimax-dir (file-name-directory (or load-file-name (buffer-file-name)))
;;  "Directory where the scimax is installed.")
;; this depends onm where the init file is located. Hard coding for now
(defconst scimax-dir "~/.emacs.d/scimax/")
(add-to-list 'load-path scimax-dir)

;; Define here any variables that might affect package loading

;;; Load the package manager, I removed the ssl part since https is now standard
(require 'package)
(add-to-list 'package-archives '("elpa" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
;; (add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))

;; Load scimax standard packages, Are all of these needed, or can this be split into
;; several files, like helm, ivy, writing, coding?
(require 'bootstrap)
(require 'packages)

;; check for user defined settings
(defun scimax-customize-user ()
  "Open scimax/user/user.el. If it does not exist, copy the example
one and open it."
  (interactive)
  (let ((user-file (expand-file-name
		    "user/settings.org"
		    scimax-dir)))
    (unless (file-exists-p user-file)
      (copy-file (expand-file-name
		  "user/user.example"
		  scimax-dir)
		 user-file))
    (find-file user-file)))

;; (require 'org) already loaded in packages el.
(org-babel-load-file
 (expand-file-name "settings.org"
                   user-emacs-directory))

;; END
@jkitchin
Copy link
Owner

I will give this some thought. I don't currently have time for any significant restructuring though. It is certainly not necessary to use the files in scimax as provided, you can simply add the directory to a load-path and use what you want, as you describe above. In that sense, I don't see an urgency to change it; it is hard to say where the line between what someone needs or doesn't, and to maintain the experience I set up scimax to provide.

Thanks for sharing your outline of a simplified load procedure. If I get time, I will take a look at it more closely.

@uliw
Copy link
Author

uliw commented Nov 18, 2024

no worries. The above init file works well for me. I just had that kind of weekend where I thought I had to clean my init files from historical ballast ...

@jkitchin
Copy link
Owner

I am due for one of those, but no ETA on when it might be!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants