Update confpkg to comment all package statements

The original code only commented package statements at the beginning,
which I thought was a bit restrictive.
This commit is contained in:
Kiana Sheibani 2024-03-30 17:28:29 -04:00
parent 8f610083a6
commit 48bee50fe6
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -202,12 +202,12 @@ If you're reading the raw org file instead of the published version, the code fo
(setq buffer-file-name (plist-get confpkg :file))
(insert-file-contents buffer-file-name)
(goto-char (point-min))
(while (re-search-forward "^;;; Code:\n[[:space:]\n]*(\\(package!\\|unpin!\\)[[:space:]\n]+\\([^[:space:]]+\\)\\b" nil t)
(plist-put confpkg :package-statements
(nconc (plist-get confpkg :package-statements)
(list (match-string 2))))
(let* ((start (progn (beginning-of-line) (point)))
(end (progn (forward-sexp 1)
(re-search-forward "^;;; Code:\n")
(let (prepared)
(while (re-search-forward "(\\(package!\\|unpin!\\)" nil t)
(let* ((start (copy-marker (match-beginning 0)))
(end (progn (goto-char start)
(forward-sexp 1)
(if (looking-at "[\t ]*;.*")
(line-end-position)
(point))))
@ -216,15 +216,23 @@ If you're reading the raw org file instead of the published version, the code fo
(comment-start ";")
(comment-padding " ")
(comment-end ""))
(plist-put confpkg :package-statements
(nconc (plist-get confpkg :package-statements)
(list contents)))
(delete-region start (1+ end))
(re-search-backward "^;;; Code:")
(beginning-of-line)
(unless prepared
(insert ";; Package statement:\n")
(setq prepared t))
(setq paste-start (point))
(insert contents)
(setq paste-end (point))
(insert "\n;;\n")
(comment-region paste-start paste-end 2)))
(comment-region paste-start paste-end 2)
(goto-char start)))
(when prepared
(re-search-backward "^;;; Code:")
(insert ";;\n")))
(when (buffer-modified-p)
(write-region nil nil buffer-file-name)
(set-buffer-modified-p nil)))))
@ -237,7 +245,7 @@ If you're reading the raw org file instead of the published version, the code fo
(insert
(format ";;; config.el -*- lexical-binding: t; -*-
;; SPDX-FileCopyrightText: © 2020-%s %s <%s>
;; SPDX-FileCopyrightText: © 2023-%s %s <%s>
;; SPDX-License-Identifier: MIT
;; Generated at %s from the literate configuration.
@ -1967,7 +1975,7 @@ Flymake normally uses italics for warnings, but my italics font being cursive ma
And just to make sure nothing else accidentally starts running:
#+begin_src emacs-lisp :tangle packages.el :noweb-ref none
#+begin_src emacs-lisp :tangle packages.el
(package! flycheck :disable t)
(package! flyspell :disable t)
#+end_src
@ -3329,7 +3337,7 @@ A full week-long agenda is usually too cluttered for me to read, so I'll narrow
The Org agenda is a very nice feature, but by default it doesn't really provide enough customization to fit my needs. I like to have nice categories to make parsing my todos easier, so we'll use ~org-super-agenda~:
#+begin_src emacs-lisp :tangle packages.el :noweb-ref none
#+begin_src emacs-lisp :tangle packages.el
(package! org-super-agenda)
#+end_src