scimax icon indicating copy to clipboard operation
scimax copied to clipboard

Simplify startup files?

Open uliw opened this issue 1 year ago • 5 comments

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

uliw avatar Nov 16 '24 20:11 uliw

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.

jkitchin avatar Nov 17 '24 17:11 jkitchin

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 ...

uliw avatar Nov 18 '24 14:11 uliw

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

jkitchin avatar Nov 18 '24 14:11 jkitchin

What do you think about an opt-out strategy? scimax was (at least originally) designed to be a batteries included approach, rather than a you choose the batteries kind of approach. A compromise might be an opt-out strategy where the default is the way it is, but you can define things you don't want in a preload file, maybe as extreme as 'no-defaults which would bypass packages completely perhaps, and leave you to load what you want as defined in the user files?

jkitchin avatar Oct 08 '25 15:10 jkitchin

Hi John,

I think the batteries included is the way to go, however as time proceeds one starts to fiddle. My initial idea was to find a way to modify the configuration without changing the files that are inside the revision control system, maybe by checking if scimax-preload & scimax-packages exits in the user directory, and if not, use the ones that come with scimax (that way there is always a clean fallback).

Some stuff is maybe more important than others. I.e., choosing the theme, etc. but I guess if you move into the direction of LLM support one would need user specific config files anyway?

uliw avatar Oct 08 '25 15:10 uliw