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)) (setq buffer-file-name (plist-get confpkg :file))
(insert-file-contents buffer-file-name) (insert-file-contents buffer-file-name)
(goto-char (point-min)) (goto-char (point-min))
(while (re-search-forward "^;;; Code:\n[[:space:]\n]*(\\(package!\\|unpin!\\)[[:space:]\n]+\\([^[:space:]]+\\)\\b" nil t) (re-search-forward "^;;; Code:\n")
(plist-put confpkg :package-statements (let (prepared)
(nconc (plist-get confpkg :package-statements) (while (re-search-forward "(\\(package!\\|unpin!\\)" nil t)
(list (match-string 2)))) (let* ((start (copy-marker (match-beginning 0)))
(let* ((start (progn (beginning-of-line) (point))) (end (progn (goto-char start)
(end (progn (forward-sexp 1) (forward-sexp 1)
(if (looking-at "[\t ]*;.*") (if (looking-at "[\t ]*;.*")
(line-end-position) (line-end-position)
(point)))) (point))))
@ -216,15 +216,23 @@ If you're reading the raw org file instead of the published version, the code fo
(comment-start ";") (comment-start ";")
(comment-padding " ") (comment-padding " ")
(comment-end "")) (comment-end ""))
(plist-put confpkg :package-statements
(nconc (plist-get confpkg :package-statements)
(list contents)))
(delete-region start (1+ end)) (delete-region start (1+ end))
(re-search-backward "^;;; Code:") (re-search-backward "^;;; Code:")
(beginning-of-line) (beginning-of-line)
(unless prepared
(insert ";; Package statement:\n") (insert ";; Package statement:\n")
(setq prepared t))
(setq paste-start (point)) (setq paste-start (point))
(insert contents) (insert contents)
(setq paste-end (point)) (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) (when (buffer-modified-p)
(write-region nil nil buffer-file-name) (write-region nil nil buffer-file-name)
(set-buffer-modified-p nil))))) (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 (insert
(format ";;; config.el -*- lexical-binding: t; -*- (format ";;; config.el -*- lexical-binding: t; -*-
;; SPDX-FileCopyrightText: © 2020-%s %s <%s> ;; SPDX-FileCopyrightText: © 2023-%s %s <%s>
;; SPDX-License-Identifier: MIT ;; SPDX-License-Identifier: MIT
;; Generated at %s from the literate configuration. ;; 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: 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! flycheck :disable t)
(package! flyspell :disable t) (package! flyspell :disable t)
#+end_src #+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~: 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) (package! org-super-agenda)
#+end_src #+end_src