format config.el with auto-fmt, fix python install

python not found, but python3 was on system. exec-shell-from-path fixes that
This commit is contained in:
Willem van den Ende
2023-01-19 12:49:13 +00:00
parent cb76399847
commit 70783ee4db
2 changed files with 212 additions and 294 deletions
+106 -191
View File
@@ -6,7 +6,8 @@
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "Willem van den Ende"
(setq
user-full-name "Willem van den Ende"
user-mail-address "redacted@example.invalid")
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
@@ -25,12 +26,17 @@
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-solarized-light)
;; set python3 as python
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize))
(exec-path-from-shell-copy-env "PYTHONPATH")
;; general editor customizations
(setq display-line-numbers-type 'relative)
(setq linum-format "%3d \u2502'")
;; org-mode customizations
(setq org-superstar-headline-bullets-list
'("⁖" "◉" "○" "✸" "✿"))
(setq org-superstar-headline-bullets-list '("⁖" "◉" "○" "✸" "✿"))
(setq org-startup-with-inline-images t)
;; org-roam customizations
;; If you use `org' and don't want your org files in the default location below,
@@ -46,21 +52,18 @@
(apply #'append list-of-lists))
(setq org-agenda-files
(flatten
(seq-map
'car
(org-roam-db-query
[:select
[file]
:from files :where
(like file "%daily\/2023%" )
:order-by
(desc file)
:from files
:where (like file "%daily\/2023%")
:order-by (desc file)
:limit 10])))
;; fix pdflatex for pdf export
(setenv "PATH"
(concat
(getenv "PATH")
":/Library/TeX/texbin"))
(setenv "PATH" (concat (getenv "PATH") ":/Library/TeX/texbin"))
;; html export configuration, assuming use in a CMS or static site gerator that
;; takes care of the layout
;; https://stackoverflow.com/questions/47508315/emacs-org-mode-export-to-html-without-syntax-highlighting
@@ -73,11 +76,12 @@
(setq org-latex-compiler "xelatex")
(setq org-latex-pdf-process
(list
(concat "latexmk -"
(concat
"latexmk -"
org-latex-compiler
" -recorder -synctex=1 -bibtex-cond %b")))
;; syntax highlighting for source code
(setq org-latex-listings t)
(setq org-latex-src-block-backend t)
;; stuff taken care of by the classes that come in the next step can be set to nil.
(setq org-latex-default-packages-alist
'(("" "graphicx" t)
@@ -174,13 +178,15 @@
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
("report" "\\documentclass[11pt]{report}"
("report"
"\\documentclass[11pt]{report}"
("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
("book" "\\documentclass[11pt]{book}"
("book"
"\\documentclass[11pt]{book}"
("\\part{%s}" . "\\part*{%s}")
("\\chapter{%s}" . "\\chapter*{%s}")
("\\section{%s}" . "\\section*{%s}")
@@ -211,24 +217,18 @@
;; they are implemented.
;; configure git-delta
(after! magit
(magit-delta-mode +1))
(after! magit (magit-delta-mode +1))
;; HACK: disable diff-hl in magit - it appears to work ok inside files, but not in magit
;; Why? diff-hl-magit-post-refresh appears to be 'null' for some reason
;; When? after stage, unstage or commit an error appears in messages.
(after!
(magit)
(remove-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
(magit) (remove-hook 'magit-post-refresh-hook 'diff-hl-magit-post-refresh))
;; HACK show small snippets for backlinks preview in roam-buffer
;; there is currently a problem in org-mode that shows an error
;; org-element--cache: Unregistered buffer modifications detected. Resetting. but this also happens without this function, it appears to be an interaction between org-roam and changes in orgmode.
(defun qwan/brief-preview
()
(let*
((elem
(org-element-context))
(parent
(org-element-property :parent elem)))
(defun qwan/brief-preview ()
(let* ((elem (org-element-context))
(parent (org-element-property :parent elem)))
;; TODO: alt handling for non-paragraph elements
(string-trim-right
(buffer-substring-no-properties
@@ -242,239 +242,154 @@
(setq-default enable-local-variables t)
;; two functions from:
;; https://zzamboni.org/post/my-emacs-configuration-with-commentary/#reformatting-an-org-buffer
(defun zz/org-reformat-buffer
()
(defun zz/org-reformat-buffer ()
(interactive)
(when
(y-or-n-p "Really format current buffer? ")
(let
((document
(org-element-interpret-data
(org-element-parse-buffer))))
(when (y-or-n-p "Really format current buffer? ")
(let ((document (org-element-interpret-data (org-element-parse-buffer))))
(erase-buffer)
(insert document)
(goto-char
(point-min)))))
(defun afs/org-remove-link
()
(goto-char (point-min)))))
(defun afs/org-remove-link ()
"Replace an org link by its description or if empty its address"
(interactive)
(if
(org-in-regexp org-link-bracket-re 1)
(let
((remove
(list
(match-beginning 0)
(match-end 0)))
(if (org-in-regexp org-link-bracket-re 1)
(let ((remove (list (match-beginning 0) (match-end 0)))
(description
(if
(match-end 3)
(org-match-string-no-properties 3)
(org-match-string-no-properties 1))))
(if (match-end 3)
(match-string-no-properties 3)
(match-string-no-properties 1))))
(apply 'delete-region remove)
(insert description))))
(defun qwan/org-replace-link-by-link-description
()
(defun qwan/org-replace-link-by-link-description ()
"Remove the link part of an org-mode link at point and keep
only the description"
(interactive)
(let
((elem
(org-element-context)))
(if
(eq
(car elem)
'link)
(let*
((content-begin
(org-element-property :contents-begin elem))
(content-end
(org-element-property :contents-end elem))
(link-begin
(org-element-property :begin elem))
(link-end
(org-element-property :end elem)))
(if
(and content-begin content-end)
(let
((content
(buffer-substring-no-properties content-begin content-end)))
(delete-region link-begin
(- link-end 1))
(let ((elem (org-element-context)))
(if (eq (car elem) 'link)
(let* ((content-begin (org-element-property :contents-begin elem))
(content-end (org-element-property :contents-end elem))
(link-begin (org-element-property :begin elem))
(link-end (org-element-property :end elem)))
(if (and content-begin content-end)
(let ((content
(buffer-substring-no-properties
content-begin content-end)))
(delete-region link-begin (- link-end 1))
(insert content)))))))
(bind-key "C-c r" 'qwan/org-replace-link-by-link-description)
(defun org-roam-replace-file-link-by-website-or-description
()
(defun org-roam-replace-file-link-by-website-or-description ()
"If a linked org-roam file has a website as key, use that as the link target instead of the filename. Otherwise, remove the link, and leave just
the description. This may destroy existing links, or change their targets so use in a copy of buffers you hold dearly as notes"
(interactive)
(let
((elem
(org-element-context)))
(if
(eq
(car elem)
'link)
(let*
((content-begin
(org-element-property :contents-begin elem))
(content-end
(org-element-property :contents-end elem))
(target-type
(org-element-property :type elem))
(target-path
(org-element-property :path elem))
(link-begin
(org-element-property :begin elem))
(link-end
(org-element-property :end elem)))
(if
(and content-begin content-end
(let ((elem (org-element-context)))
(if (eq (car elem) 'link)
(let* ((content-begin (org-element-property :contents-begin elem))
(content-end (org-element-property :contents-end elem))
(target-type (org-element-property :type elem))
(target-path (org-element-property :path elem))
(link-begin (org-element-property :begin elem))
(link-end (org-element-property :end elem)))
(if (and content-begin
content-end
(string-equal target-type "file")
target-path link-begin link-end)
(let
((new-link
target-path
link-begin
link-end)
(let ((new-link
(org-roam-description-file-to-org-url
(buffer-substring-no-properties content-begin content-end)
target-path)))
(delete-region link-begin
(- link-end 1))
(insert new-link)
))))))
(defun qwan/string-as-markdown-image-link
(a-string)
(delete-region link-begin (- link-end 1))
(insert new-link)))))))
(defun qwan/string-as-markdown-image-link (a-string)
(concat "![alt-text goes here](" a-string ")"))
(defun qwan/image-mode-copy-filename-as-markdown-image-link
()
(defun qwan/image-mode-copy-filename-as-markdown-image-link ()
"Push a markdown link to the currently visited image onto the kill ring."
(interactive)
(unless buffer-file-name
(error "The current buffer doesn't visit an image file"))
(let
((markdown-link
(let ((markdown-link
(qwan/string-as-markdown-image-link
(qwan/relative-path-to-attachments buffer-file-name))))
(kill-new markdown-link)
(message "Copied %s" markdown-link)))
(defun qwan/relative-path-to-attachments
(full-path)
(substring full-path
(string-search "/attachments" full-path 0)
))
(defun qwan/relative-path-to-attachments (full-path)
(substring full-path (string-search "/attachments" full-path 0)))
(require 'ert)
(ert-deftest relative-path-to-attachments-removes-prefix
()
(ert-deftest relative-path-to-attachments-removes-prefix ()
(should
(equal
(qwan/attachments-remove-prefix-path "prefix/attachments")
"/attachments")))
(ert-deftest relative-path-to-attachments-does-not-remove-prefix-when-no-attachments
(qwan/attachments-remove-prefix-path "prefix/attachments") "/attachments")))
(ert-deftest
relative-path-to-attachments-does-not-remove-prefix-when-no-attachments
()
(should
(equal
(qwan/attachments-remove-prefix-path "prefix/somethingelse")
"prefix/somethingelse")))
(ert-deftest markdown-link-tokens-should-surround-string
()
(ert-deftest markdown-link-tokens-should-surround-string ()
(should
(equal
(qwan/string-as-markdown-image-link "prefix/image.png")
"![alt-text goes here](prefix/image.png)")))
(defun qwan-echo
(new-name)
(defun qwan-echo (new-name)
(interactive "SRename function to:")
(message "Will rename to %s" new-name)
)
(message "Will rename to %s" new-name))
;; from @tbf@functional.cafe
(defun movd
(from to)
(fset to
(symbol-function from))
(defun movd (from to)
(fset to (symbol-function from))
(fset from nil)
to)
;; from @tbf@functional.cafe
(defmacro frename
(from to)
(defmacro frename (from to)
`(movd ',from ',to))
(defun qrefactor/rename
(new-name)
(defun qrefactor/rename (new-name)
"Rename function at point. You must modify references yourself"
(interactive "MRename function to:")
(let
((bounds
(bounds-of-thing-at-point 'symbol)))
(let ((bounds (bounds-of-thing-at-point 'symbol)))
(if bounds
(progn
(let*
((begin
(car bounds))
(end
(cdr bounds))
(old-name
(buffer-substring-no-properties begin end))
(new-function-name
(as-function-name new-name)))
(let* ((begin (car bounds))
(end (cdr bounds))
(old-name (buffer-substring-no-properties begin end))
(new-function-name (as-function-name new-name)))
(message "Will rename to %s" new-function-name)
;; should use as-function-name here
(movd
(intern old-name)
(intern new-function-name))
(ert-make-test-unbound
(intern old-name))
(movd (intern old-name) (intern new-function-name))
(ert-make-test-unbound (intern old-name))
(delete-region begin end)
(insert new-function-name)
(message "Renamed %s to %s." old-name new-name)))
(message "No symbol under cursor."))))
(defun qrefactor/remove-test
()
(defun qrefactor/remove-test ()
"Renmove test at point from memory.
See also ert-delete-test if you want to delete from a list of existing tests."
(interactive)
(let
((bounds
(bounds-of-thing-at-point 'symbol)))
(let ((bounds (bounds-of-thing-at-point 'symbol)))
(if bounds
(progn
(let*
((begin
(car bounds))
(end
(cdr bounds))
(old-name
(buffer-substring-no-properties begin end)))
(ert-make-test-unbound
(intern old-name))
(let* ((begin (car bounds))
(end (cdr bounds))
(old-name (buffer-substring-no-properties begin end)))
(ert-make-test-unbound (intern old-name))
(message "Undefined %s." old-name))))
(message "No symbol under cursor.")))
;; tests are better than literate programming when you want to triangulate on the same function
;; org only shows the last return value by default, you can return a list of course, but still
(defun as-function-name
(candidate-name)
(defun as-function-name (candidate-name)
"Take the string and make it suitable to be a function name. Replaces space with dash and make string all lowercase."
(declare
(side-effect-free t))
(s-join "-"
(mapcar 'downcase
(split-string candidate-name " " t))))
(declare (side-effect-free t))
(s-join "-" (mapcar 'downcase (split-string candidate-name " " t))))
;; (s-join "-" (mapcar 'downcase (s-split-words s))))
(ert-deftest refactor-rename-should-leave-forward-slash ()
(should
(equal
(as-function-name "qwan/echo")
"qwan/echo")))
(should (equal (as-function-name "qwan/echo") "qwan/echo")))
(ert-deftest refactor-rename-should-replace-space-with-dash ()
(should
(equal
(as-function-name "qwan/echo chamber")
"qwan/echo-chamber")))
(should (equal (as-function-name "qwan/echo chamber") "qwan/echo-chamber")))
(ert-deftest refactor-rename-replaces-uppercase-with-lowercase ()
(should
(equal
(as-function-name "Echo-chamber")
"echo-chamber")))
(ert-deftest refactor-renamed-thrice
()
(should
(equal 1 1)))
(should (equal (as-function-name "Echo-chamber") "echo-chamber")))
(ert-deftest refactor-renamed-thrice ()
(should (equal 1 1)))
(ert-make-test-unbound 'refactor-rename-test-for-fun)
(ert "refactor.*")
;; (ert "refactor.*")
+3
View File
@@ -12,6 +12,9 @@
(package! diff-hl)
(package! puni)
(package! crux)
(package! exec-path-from-shell)
(package! elisp-autofmt)
;; To install a package directly from a remote git repo, you must specify a
;; `:recipe'. You'll find documentation on what `:recipe' accepts here:
;; https://github.com/raxod502/straight.el#the-recipe-format