aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanketsu <hanketsu@egregore.fun>2024-12-19 23:55:08 +0100
committerHanketsu <hanketsu@egregore.fun>2025-06-13 00:04:16 +0200
commit0dd48876903e6176a08d04efe36565b3082915ac (patch)
tree952a41947f9e37a53d3264a4f8e893262ef04b32
parent9682e18ba3b5a24207440978ada0f7234181de14 (diff)
Add .dir-locals.el and related snippets
-rw-r--r--.dir-locals.el188
-rw-r--r--snippets/tempel/scheme-mode.eld87
-rw-r--r--snippets/tempel/text-mode.eld156
3 files changed, 431 insertions, 0 deletions
diff --git a/.dir-locals.el b/.dir-locals.el
new file mode 100644
index 0000000..49039f2
--- /dev/null
+++ b/.dir-locals.el
@@ -0,0 +1,188 @@
+;; Per-directory local variables for GNU Emacs 23 and later.
+
+((nil
+ . ((fill-column . 78)
+ (tab-width . 8)
+ (sentence-end-double-space . f)
+
+ ;; For use with 'bug-reference-prog-mode'. Extra bug-reference
+ ;; configuration should be done in your Emacs user configuration file;
+ ;; refer to (info (guix) The Perfect Setup).
+ ;; (bug-reference-bug-regexp
+ ;; . "\\(<https?://\\bugs\\.gnu\\.org/\\([0-9]+\\)>\\)")
+ ;; (bug-reference-url-format . "https://issues.guix.gnu.org/%s")
+
+ (eval . (add-to-list 'completion-ignored-extensions ".go"))
+
+ ;; Emacs-Guix
+ (eval . (setq-local guix-directory
+ (locate-dominating-file default-directory
+ ".dir-locals.el")))
+
+ ;; TempEl
+ (eval . (with-eval-after-load
+ 'tempel
+ (if (stringp tempel-path)
+ (setq tempel-path (list tempel-path)))
+ (let ((guix-tempel-snippets
+ (concat
+ (expand-file-name
+ "snippets/tempel"
+ (locate-dominating-file default-directory
+ ".dir-locals.el"))
+ "/*.eld")))
+ (unless (member guix-tempel-snippets tempel-path)
+ (add-to-list 'tempel-path guix-tempel-snippets)))))
+
+ ;; Geiser
+ ;; This allows automatically setting the `geiser-guile-load-path'
+ ;; variable when using various Guix checkouts (e.g., via git worktrees).
+ (geiser-repl-per-project-p . t)))
+
+ (c-mode . ((c-file-style . "gnu")))
+ (scheme-mode
+ .
+ ((indent-tabs-mode . nil)
+ (eval . (put 'eval-when 'scheme-indent-function 1))
+ (eval . (put 'call-with-prompt 'scheme-indent-function 1))
+ (eval . (put 'test-assert 'scheme-indent-function 1))
+ (eval . (put 'test-assertm 'scheme-indent-function 1))
+ (eval . (put 'test-equalm 'scheme-indent-function 1))
+ (eval . (put 'test-equal 'scheme-indent-function 1))
+ (eval . (put 'test-eq 'scheme-indent-function 1))
+ (eval . (put 'call-with-input-string 'scheme-indent-function 1))
+ (eval . (put 'call-with-port 'scheme-indent-function 1))
+ (eval . (put 'guard 'scheme-indent-function 1))
+ (eval . (put 'lambda* 'scheme-indent-function 1))
+ (eval . (put 'substitute* 'scheme-indent-function 1))
+ (eval . (put 'match-record 'scheme-indent-function 3))
+ (eval . (put 'match-record-lambda 'scheme-indent-function 2))
+
+ ;; TODO: Contribute these to Emacs' scheme-mode.
+ (eval . (put 'let-keywords 'scheme-indent-function 3))
+
+ ;; 'modify-inputs' and its keywords.
+ (eval . (put 'modify-inputs 'scheme-indent-function 1))
+ (eval . (put 'replace 'scheme-indent-function 1))
+
+ ;; 'modify-phases' and its keywords.
+ (eval . (put 'modify-phases 'scheme-indent-function 1))
+ (eval . (put 'replace 'scheme-indent-function 1))
+ (eval . (put 'add-before 'scheme-indent-function 2))
+ (eval . (put 'add-after 'scheme-indent-function 2))
+
+ (eval . (put 'modify-services 'scheme-indent-function 1))
+ (eval . (put 'with-directory-excursion 'scheme-indent-function 1))
+ (eval . (put 'with-file-lock 'scheme-indent-function 1))
+ (eval . (put 'with-file-lock/no-wait 'scheme-indent-function 1))
+ (eval . (put 'with-profile-lock 'scheme-indent-function 1))
+ (eval . (put 'with-writable-file 'scheme-indent-function 2))
+
+ (eval . (put 'package 'scheme-indent-function 0))
+ (eval . (put 'package/inherit 'scheme-indent-function 1))
+ (eval . (put 'origin 'scheme-indent-function 0))
+ (eval . (put 'build-system 'scheme-indent-function 0))
+ (eval . (put 'bag 'scheme-indent-function 0))
+ (eval . (put 'graft 'scheme-indent-function 0))
+ (eval . (put 'operating-system 'scheme-indent-function 0))
+ (eval . (put 'file-system 'scheme-indent-function 0))
+ (eval . (put 'swap-space 'scheme-indent-function 0))
+ (eval . (put 'manifest-entry 'scheme-indent-function 0))
+ (eval . (put 'manifest-pattern 'scheme-indent-function 0))
+ (eval . (put 'substitute-keyword-arguments 'scheme-indent-function 1))
+ (eval . (put 'with-store 'scheme-indent-function 1))
+ (eval . (put 'with-store/non-blocking 'scheme-indent-function 1))
+ (eval . (put 'with-external-store 'scheme-indent-function 1))
+ (eval . (put 'with-error-handling 'scheme-indent-function 0))
+ (eval . (put 'with-mutex 'scheme-indent-function 1))
+ (eval . (put 'with-atomic-file-output 'scheme-indent-function 1))
+ (eval . (put 'call-with-compressed-output-port 'scheme-indent-function 2))
+ (eval . (put 'call-with-decompressed-port 'scheme-indent-function 2))
+ (eval . (put 'call-with-gzip-input-port 'scheme-indent-function 1))
+ (eval . (put 'call-with-gzip-output-port 'scheme-indent-function 1))
+ (eval . (put 'call-with-lzip-input-port 'scheme-indent-function 1))
+ (eval . (put 'call-with-lzip-output-port 'scheme-indent-function 1))
+ (eval . (put 'signature-case 'scheme-indent-function 1))
+ (eval . (put 'emacs-batch-eval 'scheme-indent-function 0))
+ (eval . (put 'emacs-batch-edit-file 'scheme-indent-function 1))
+ (eval . (put 'emacs-substitute-sexps 'scheme-indent-function 1))
+ (eval . (put 'emacs-substitute-variables 'scheme-indent-function 1))
+ (eval . (put 'with-derivation-narinfo 'scheme-indent-function 1))
+ (eval . (put 'with-derivation-substitute 'scheme-indent-function 2))
+ (eval . (put 'with-status-report 'scheme-indent-function 1))
+ (eval . (put 'with-status-verbosity 'scheme-indent-function 1))
+ (eval . (put 'with-build-handler 'scheme-indent-function 1))
+
+ (eval . (put 'mlambda 'scheme-indent-function 1))
+ (eval . (put 'mlambdaq 'scheme-indent-function 1))
+ (eval . (put 'syntax-parameterize 'scheme-indent-function 1))
+ (eval . (put 'with-monad 'scheme-indent-function 1))
+ (eval . (put 'mbegin 'scheme-indent-function 1))
+ (eval . (put 'mwhen 'scheme-indent-function 1))
+ (eval . (put 'munless 'scheme-indent-function 1))
+ (eval . (put 'mlet* 'scheme-indent-function 2))
+ (eval . (put 'mlet 'scheme-indent-function 2))
+ (eval . (put 'mparameterize 'scheme-indent-function 2))
+ (eval . (put 'run-with-store 'scheme-indent-function 1))
+ (eval . (put 'run-with-state 'scheme-indent-function 1))
+ (eval . (put 'wrap-program 'scheme-indent-function 1))
+ (eval . (put 'wrap-script 'scheme-indent-function 1))
+ (eval . (put 'with-imported-modules 'scheme-indent-function 1))
+ (eval . (put 'with-extensions 'scheme-indent-function 1))
+ (eval . (put 'with-parameters 'scheme-indent-function 1))
+ (eval . (put 'let-system 'scheme-indent-function 1))
+ (eval . (put 'with-build-variables 'scheme-indent-function 2))
+
+ (eval . (put 'with-database 'scheme-indent-function 2))
+ (eval . (put 'call-with-database 'scheme-indent-function 1))
+ (eval . (put 'call-with-transaction 'scheme-indent-function 1))
+ (eval . (put 'call-with-retrying-transaction 'scheme-indent-function 1))
+
+ (eval . (put 'call-with-container 'scheme-indent-function 1))
+ (eval . (put 'container-excursion 'scheme-indent-function 1))
+ (eval . (put 'eventually 'scheme-indent-function 1))
+
+ (eval . (put 'call-with-progress-reporter 'scheme-indent-function 1))
+ (eval . (put 'with-repository 'scheme-indent-function 2))
+ (eval . (put 'with-temporary-git-repository 'scheme-indent-function 2))
+ (eval . (put 'with-environment-variables 'scheme-indent-function 1))
+ (eval . (put 'with-fresh-gnupg-setup 'scheme-indent-function 1))
+
+ (eval . (put 'with-paginated-output-port 'scheme-indent-function 1))
+
+ (eval . (put 'with-shepherd-action 'scheme-indent-function 3))
+
+ (eval . (put 'with-http-server 'scheme-indent-function 1))
+
+ ;; This notably allows '(' in Paredit to not insert a space when the
+ ;; preceding symbol is one of these.
+ (eval . (modify-syntax-entry ?~ "'"))
+ (eval . (modify-syntax-entry ?$ "'"))
+ (eval . (modify-syntax-entry ?+ "'"))
+
+ ;; Emacs 28 changed the behavior of 'lisp-fill-paragraph', which causes the
+ ;; first line of package descriptions to extrude past 'fill-column', and
+ ;; somehow that is deemed more correct upstream (see:
+ ;; https://issues.guix.gnu.org/56197).
+ (eval . (progn
+ (require 'lisp-mode)
+ (defun emacs27-lisp-fill-paragraph (&optional justify)
+ (interactive "P")
+ (or (fill-comment-paragraph justify)
+ (let ((paragraph-start
+ (concat paragraph-start
+ "\\|\\s-*\\([(;\"]\\|\\s-:\\|`(\\|#'(\\)"))
+ (paragraph-separate
+ (concat paragraph-separate "\\|\\s-*\".*[,\\.]$"))
+ (fill-column (if (and (integerp emacs-lisp-docstring-fill-column)
+ (derived-mode-p 'emacs-lisp-mode))
+ emacs-lisp-docstring-fill-column
+ fill-column)))
+ (fill-paragraph justify))
+ ;; Never return nil.
+ t))
+ (setq-local fill-paragraph-function #'emacs27-lisp-fill-paragraph)))))
+
+ (emacs-lisp-mode . ((indent-tabs-mode . nil)))
+ (texinfo-mode . ((indent-tabs-mode . nil)
+ (fill-column . 72))))
diff --git a/snippets/tempel/scheme-mode.eld b/snippets/tempel/scheme-mode.eld
new file mode 100644
index 0000000..21a5dd6
--- /dev/null
+++ b/snippets/tempel/scheme-mode.eld
@@ -0,0 +1,87 @@
+scheme-mode
+
+(package...
+ "(define-public " (s name)
+ n> "(package"
+ n > "(name \"" (s name) "\")"
+ n > "(version \"" p "\")"
+ n > "(source origin...)"
+ n > "(build-system " (p "gnu") "-build-system)"
+ n > "(home-page \"" p "\")"
+ n > "(synopsis \"" p "\")"
+ n > "(description \"" p "\")"
+ n > "(license license:" (p "unknown") ")))" n)
+
+(origin...
+ "(origin"
+ n> "(method " (p "url-fetch" method) ")"
+ n> "(uri " (cl-case (and method (intern method))
+ (git-fetch "git-reference...")
+ (svn-fetch "svn-reference...")
+ (hg-fetch "hg-reference...")
+ (cvs-fetch "cvs-reference...")
+ (bzr-fetch "bzr-reference...")
+ (otherwise "\"https://...\""))
+ ")"
+ n>
+ (cl-case (and method (intern method))
+ (git-fetch
+ (insert "(file-name (git-file-name name version))")
+ (newline)
+ (indent-according-to-mode))
+ (hg-fetch
+ (insert "(file-name (hg-file-name name version))")
+ (newline)
+ (indent-according-to-mode))
+ (svn-fetch
+ (insert "(file-name (string-append name \"-\" version \"-checkout\"))")
+ (newline)
+ (indent-according-to-mode))
+ (cvs-fetch
+ (insert "(file-name (string-append name \"-\" version \"-checkout\"))")
+ (newline)
+ (indent-according-to-mode))
+ (bzr-fetch
+ (insert "(file-name (string-append name \"-\" version \"-checkout\"))")
+ (newline)
+ (indent-according-to-mode))
+ (t ""))
+ > "(sha256"
+ n > "(base32 \""
+ ;; hash of an empty directory
+ (p "0sjjj9z1dhilhpc8pq4154czrb79z9cm044jvn75kxcjv6v5l2m5") "\")))")
+
+(git-reference...
+ "(git-reference"
+ n> "(url \"" p "\")"
+ n> "(commit " (p "commit") "))")
+
+(svn-reference...
+ "(svn-reference"
+ n> "(url \"" p "\")"
+ n> "(revision " (p "revision") "))")
+
+(cvs-reference...
+ "(cvs-reference"
+ n> "(root-directory \"" p "\")"
+ n> "(module \"" p "\")"
+ n> "(revision \"" p "\"))")
+
+(hg-reference...
+ "(hg-reference"
+ n> "(url \"" p "\")"
+ n> "(changeset " (p "changeset") "))")
+
+(bzr-reference...
+ "(bzr-reference"
+ n> "(url \"" p "\")"
+ n> "(revision " (p "revision") "))")
+
+(:phases\ "#:phases (modify-phases %standard-phases"
+ n> p ")")
+
+(add-before\ "(add-before '" p " '" p
+ n > p ")")
+(add-after\ "(add-after '" p " '" p
+ n > p ")")
+(replace\ "(replace '" p " " p")")
diff --git a/snippets/tempel/text-mode.eld b/snippets/tempel/text-mode.eld
new file mode 100644
index 0000000..daa0061
--- /dev/null
+++ b/snippets/tempel/text-mode.eld
@@ -0,0 +1,156 @@
+text-mode :when (bound-and-true-p git-commit-mode)
+
+(add\ "battering: Add "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (when (re-search-forward "\\+(define-public \\(\\S-+\\)"
+ nil 'noerror)
+ (match-string-no-properties 1)))
+ var)
+ "." n n
+ "* " (p (or (car (magit-staged-files)) ""))
+ " (" (s var ) "): New variable.")
+
+(remove\ "battering: Remove "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (when (re-search-forward "\\-(define-public \\(\\S-+\\)"
+ nil 'noerror)
+ (match-string-no-properties 1)))
+ var)
+ "." n n
+ "* " (p (or (car (magit-staged-files)) ""))
+ " (" (s var) "): Delete variable.")
+
+(rename\ "battering: "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (beginning-of-buffer)
+ (when (search-forward "-(define-public " nil 'noerror)
+ (thing-at-point 'sexp 'no-properties)))
+ prev-var)
+ ": Rename package to "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (beginning-of-buffer)
+ (when (search-forward "+(define-public " nil 'noerror)
+ (thing-at-point 'sexp 'no-properties)))
+ new-var)
+ "." n n
+ "* " (p (or (car (magit-staged-files)) "")) " (" (s prev-var) "): "
+ "Define in terms of" n
+ "'deprecated-package'." n
+ "(" (s new-var) "): New variable, formerly known as \""
+ (s prev-var) "\".")
+
+(update\ "battering: "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)"
+ nil 'noerror)
+ (match-string-no-properties 1)))
+ var)
+ ": Update to "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (search-forward "name" nil 'noerror)
+ (search-forward "+" nil 'noerror) ; first change
+ (when (and (search-forward "version " nil 'noerror)
+ (looking-at-p "\""))
+ (let ((end (save-excursion (search-forward "\")"
+ nil 'noerror))))
+ (when end
+ (forward-char)
+ (buffer-substring-no-properties (point) (- end 2))))))
+ version)
+ "." n n
+ "* " (p (or (car (magit-staged-files)) "")) " (" (s var) "): "
+ "Update to " (s version) "." n
+ (mapconcat (lambda (file) (concat "* " file))
+ (cdr (magit-staged-files))
+ "\n"))
+
+(addcl\ "battering: Add cl-"
+ (p (replace-regexp-in-string
+ "^cl-" "" (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (beginning-of-buffer)
+ (when (search-forward "+(define-public " nil 'noerror)
+ (replace-regexp-in-string
+ "^sbcl-" ""
+ (thing-at-point 'sexp 'no-properties)))))
+ var)
+ "." n n
+ "* " (p (or (car (magit-staged-files)) ""))
+ " (cl-" (s var)
+ ", ecl-" (s var)
+ ", sbcl-" (s var) "): New variables.")
+
+(https\ "battering: "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (when (re-search-forward "^[ ]*(define-public \\(\\S-+\\)"
+ nil 'noerror)
+ (match-string-no-properties 1)))
+ var)
+ ": Use HTTPS home page." n n
+ "* " (p (or (car (magit-staged-files)) ""))
+ " (" (s var) ")[home-page]: Use HTTPS."
+ n
+ (mapconcat (lambda (file) (concat "* " file))
+ (cdr (magit-staged-files))
+ "\n"))
+
+(move\ "battering: "
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (when (re-search-forward "\\-(define-public \\(\\S-+\\)"
+ nil 'noerror)
+ (match-string-no-properties 1)))
+ var)
+ ": Move to ("
+ (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (when (and
+ (re-search-forward "\\+(define-public \\(\\S-+\\)"
+ nil 'noerror)
+ (re-search-backward "modified[ ]*\\(\\S-+\\)"
+ nil 'noerror))
+ (string-replace
+ "\.scm" ""
+ (string-replace "/" " "
+ (match-string-no-properties 1)))))
+ new-module)
+ ")." n
+ n
+ "* " (p (with-temp-buffer
+ (magit-git-wash #'magit-diff-wash-diffs
+ "diff" "--staged")
+ (goto-char (point-min))
+ (when (and
+ (re-search-forward "\\-(define-public \\(\\S-+\\)"
+ nil 'noerror)
+ (re-search-backward "modified[ ]*\\(\\S-+\\)"
+ nil 'noerror))
+ (match-string-no-properties 1))
+ source))
+ " (" (s var) "): Move from here…" n
+ "* " (concat (string-replace " " "/" new-module) ".scm")
+ " (" (s var) "): …to here.")