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,29 +202,37 @@ 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))))
(contents (buffer-substring start end)) (contents (buffer-substring start end))
paste-start paste-end paste-start paste-end
(comment-start ";") (comment-start ";")
(comment-padding " ") (comment-padding " ")
(comment-end "")) (comment-end ""))
(delete-region start (1+ 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))
(comment-region paste-start paste-end 2)
(goto-char start)))
(when prepared
(re-search-backward "^;;; Code:") (re-search-backward "^;;; Code:")
(beginning-of-line) (insert ";;\n")))
(insert ";; Package statement:\n")
(setq paste-start (point))
(insert contents)
(setq paste-end (point))
(insert "\n;;\n")
(comment-region paste-start paste-end 2)))
(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.
@ -354,7 +362,7 @@ If you're reading the raw org file instead of the published version, the code fo
(org-fold-core-ignore-fragility-checks (org-fold-core-ignore-fragility-checks
(org-babel-map-executables nil (org-babel-map-executables nil
(when (and (eq (org-element-type (org-element-context)) 'babel-call) (when (and (eq (org-element-type (org-element-context)) 'babel-call)
(equal (org-element-property :call (org-element-context)) "confpkg")) (equal (org-element-property :call (org-element-context)) "confpkg"))
(org-babel-remove-result) (org-babel-remove-result)
(org-entry-delete nil "header-args:emacs-lisp"))))) (org-entry-delete nil "header-args:emacs-lisp")))))
@ -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