Guard against loading invalid config files

Ensure that config org-mode files don't contain "#" in the filename
when looping to call org-babel-load-file. These files only exist if a
file has unsaved changes, but directory-files will still find them as
.org files and attempt to load

Move package-archive definition and priorities into start of init.el,
since everything else actually depends on that (somewhat)
This commit is contained in:
Evie Litherland-Smith 2024-04-05 15:22:48 +01:00
parent 2eb76021bf
commit 74bbe0578f
2 changed files with 16 additions and 14 deletions

View file

@ -80,17 +80,6 @@
(recentf-max-saved-items 2048)) (recentf-max-saved-items 2048))
#+end_src #+end_src
* package-archive with priorities
#+begin_src emacs-lisp :results output silent
(when (require 'package nil :noerror)
(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(setq package-archive-priorities '(("gnu" . 99)
("nongnu" . 80)
("stable" . 70)
("melpa" . 0))))
#+end_src
* diminish modes * diminish modes
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package diminish :ensure t) (use-package diminish :ensure t)

19
init.el
View file

@ -8,11 +8,24 @@
;; Stop popups for warning messages, keep in log buffer ;; Stop popups for warning messages, keep in log buffer
(setopt warning-minimum-level :error) (setopt warning-minimum-level :error)
(defvar my/config-files () "List of literate config files to load.") ;; Configure packages archives with priority
(when (require 'package nil :noerror)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/"))
(setq my/config-files (directory-files (locate-user-emacs-file "config") t ".org")) (setopt package-archive-priorities '(("melpa" . 10)
("stable" . 5)
("nongnu" . 5)
("gnu" . 0)))
(package-initialize))
(dolist (fname my/config-files) (org-babel-load-file fname)) (defvar my/config-files
(directory-files (locate-user-emacs-file "config") t ".org")
"List of literate config files to load.")
(dolist (fname my/config-files)
(unless (string-match-p (regexp-quote "#") fname)
(org-babel-load-file fname)))
(provide 'init) (provide 'init)
;;; init.el ends here ;;; init.el ends here