Install org-pomodoro, includes fix to reduce org-agenda
if you don't reduce the number of files, org-clock-in does not work.
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
;; clients, file templates and snippets.
|
;; 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")
|
user-mail-address "redacted@example.invalid")
|
||||||
|
|
||||||
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
|
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
|
||||||
;; are the three important ones:
|
;; are the three important ones:
|
||||||
;;
|
;;
|
||||||
@@ -26,15 +25,13 @@
|
|||||||
;; available. You can either set `doom-theme' or manually load a theme with the
|
;; available. You can either set `doom-theme' or manually load a theme with the
|
||||||
;; `load-theme' function. This is the default:
|
;; `load-theme' function. This is the default:
|
||||||
(setq doom-theme 'doom-solarized-light)
|
(setq doom-theme 'doom-solarized-light)
|
||||||
|
|
||||||
;; general editor customizations
|
;; general editor customizations
|
||||||
(setq display-line-numbers-type 'relative)
|
(setq display-line-numbers-type 'relative)
|
||||||
(setq linum-format "%3d \u2502'")
|
(setq linum-format "%3d \u2502'")
|
||||||
|
|
||||||
;; org-mode customizations
|
;; org-mode customizations
|
||||||
(setq org-superstar-headline-bullets-list '("⁖" "◉" "○" "✸" "✿"))
|
(setq org-superstar-headline-bullets-list
|
||||||
|
'("⁖" "◉" "○" "✸" "✿"))
|
||||||
(setq org-startup-with-inline-images t)
|
(setq org-startup-with-inline-images t)
|
||||||
|
|
||||||
;; org-roam customizations
|
;; org-roam customizations
|
||||||
;; If you use `org' and don't want your org files in the default location below,
|
;; If you use `org' and don't want your org files in the default location below,
|
||||||
;; change `org-directory'. It must be set before org loads!
|
;; change `org-directory'. It must be set before org loads!
|
||||||
@@ -42,43 +39,57 @@
|
|||||||
(setq org-roam-directory "~/MyDocuments/qwan/essays/willem")
|
(setq org-roam-directory "~/MyDocuments/qwan/essays/willem")
|
||||||
; (define-key org-roam-mode-map [mouse-1] #'org-roam-visit-thing)
|
; (define-key org-roam-mode-map [mouse-1] #'org-roam-visit-thing)
|
||||||
|
|
||||||
|
;; make sure that org-timer works and org-pomodoro therefore. Limit the number of agenda files searched
|
||||||
|
;; plus a utility function for flattening, since that is not part of the standard library of emacs
|
||||||
|
(defun flatten (list-of-lists)
|
||||||
|
(apply #'append list-of-lists))
|
||||||
|
|
||||||
|
(setq org-agenda-files
|
||||||
|
(flatten
|
||||||
|
(org-roam-db-query
|
||||||
|
[:select
|
||||||
|
[file]
|
||||||
|
:from files :where
|
||||||
|
(like file "%daily\/2023%" )
|
||||||
|
:order-by
|
||||||
|
(desc file)
|
||||||
|
:limit 10])))
|
||||||
|
|
||||||
;; fix pdflatex for pdf export
|
;; 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
|
;; html export configuration, assuming use in a CMS or static site gerator that
|
||||||
;; takes care of the layout
|
;; takes care of the layout
|
||||||
;; https://stackoverflow.com/questions/47508315/emacs-org-mode-export-to-html-without-syntax-highlighting
|
;; https://stackoverflow.com/questions/47508315/emacs-org-mode-export-to-html-without-syntax-highlighting
|
||||||
(setq org-html-htmlize-output-type `nil)
|
(setq org-html-htmlize-output-type `nil)
|
||||||
(setq org-html-preamble `nil)
|
(setq org-html-preamble `nil)
|
||||||
(setq org-html-postamble `nil)
|
(setq org-html-postamble `nil)
|
||||||
|
|
||||||
;; LaTEX export that does not look like an academic paper
|
;; LaTEX export that does not look like an academic paper
|
||||||
;; source: https://so.nwalsh.com/2020/01/05-latex
|
;; source: https://so.nwalsh.com/2020/01/05-latex
|
||||||
;; utf-8 supported by the following lines
|
;; utf-8 supported by the following lines
|
||||||
(setq org-latex-compiler "xelatex")
|
(setq org-latex-compiler "xelatex")
|
||||||
(setq org-latex-pdf-process
|
(setq org-latex-pdf-process
|
||||||
(list (concat "latexmk -"
|
(list
|
||||||
|
(concat "latexmk -"
|
||||||
org-latex-compiler
|
org-latex-compiler
|
||||||
" -recorder -synctex=1 -bibtex-cond %b")))
|
" -recorder -synctex=1 -bibtex-cond %b")))
|
||||||
|
|
||||||
;; syntax highlighting for source code
|
;; syntax highlighting for source code
|
||||||
(setq org-latex-listings t)
|
(setq org-latex-listings t)
|
||||||
|
|
||||||
;; stuff taken care of by the classes that come in the next step can be set to nil.
|
;; stuff taken care of by the classes that come in the next step can be set to nil.
|
||||||
(setq org-latex-default-packages-alist
|
(setq org-latex-default-packages-alist
|
||||||
'(("" "graphicx" t)
|
'(("" "graphicx" t)
|
||||||
("" "grffile" t)
|
("" "grffile" t)
|
||||||
("" "longtable" nil)
|
("" "longtable" nil)
|
||||||
("" "wrapfig" nil)
|
("" "wrapfig" nil)
|
||||||
("" "rotating" nil)
|
("" "rotating" nil)
|
||||||
("normalem" "ulem" t)
|
("normalem" "ulem" t)
|
||||||
("" "amsmath" t)
|
("" "amsmath" t)
|
||||||
("" "textcomp" t)
|
("" "textcomp" t)
|
||||||
("" "amssymb" t)
|
("" "amssymb" t)
|
||||||
("" "capt-of" nil)
|
("" "capt-of" nil)
|
||||||
("" "hyperref" nil)))
|
("" "hyperref" nil)))
|
||||||
|
|
||||||
;; lots of latex
|
;; lots of latex
|
||||||
(setq org-latex-classes
|
(setq org-latex-classes
|
||||||
'(("article"
|
'(("article"
|
||||||
@@ -162,21 +173,18 @@
|
|||||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
|
||||||
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
("\\paragraph{%s}" . "\\paragraph*{%s}")
|
||||||
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
|
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
|
||||||
|
|
||||||
("report" "\\documentclass[11pt]{report}"
|
("report" "\\documentclass[11pt]{report}"
|
||||||
("\\part{%s}" . "\\part*{%s}")
|
("\\part{%s}" . "\\part*{%s}")
|
||||||
("\\chapter{%s}" . "\\chapter*{%s}")
|
("\\chapter{%s}" . "\\chapter*{%s}")
|
||||||
("\\section{%s}" . "\\section*{%s}")
|
("\\section{%s}" . "\\section*{%s}")
|
||||||
("\\subsection{%s}" . "\\subsection*{%s}")
|
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
|
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))
|
||||||
|
|
||||||
("book" "\\documentclass[11pt]{book}"
|
("book" "\\documentclass[11pt]{book}"
|
||||||
("\\part{%s}" . "\\part*{%s}")
|
("\\part{%s}" . "\\part*{%s}")
|
||||||
("\\chapter{%s}" . "\\chapter*{%s}")
|
("\\chapter{%s}" . "\\chapter*{%s}")
|
||||||
("\\section{%s}" . "\\section*{%s}")
|
("\\section{%s}" . "\\section*{%s}")
|
||||||
("\\subsection{%s}" . "\\subsection*{%s}")
|
("\\subsection{%s}" . "\\subsection*{%s}")
|
||||||
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
|
("\\subsubsection{%s}" . "\\subsubsection*{%s}"))))
|
||||||
|
|
||||||
;; make screenshot and paste
|
;; make screenshot and paste
|
||||||
;; https://zzamboni.org/post/how-to-insert-screenshots-in-org-documents-on-macos/
|
;; https://zzamboni.org/post/how-to-insert-screenshots-in-org-documents-on-macos/
|
||||||
|
|
||||||
@@ -184,7 +192,6 @@
|
|||||||
;; This determines the style of line numbers in effect. If set to `nil', line
|
;; This determines the style of line numbers in effect. If set to `nil', line
|
||||||
;; numbers are disabled. For relative line numbers, set this to `relative'.
|
;; numbers are disabled. For relative line numbers, set this to `relative'.
|
||||||
(setq display-line-numbers-type `relative)
|
(setq display-line-numbers-type `relative)
|
||||||
|
|
||||||
;; Here are some additional functions/macros that could help you configure Doom:
|
;; Here are some additional functions/macros that could help you configure Doom:
|
||||||
;;
|
;;
|
||||||
;; - `load!' for loading external *.el files relative to this one
|
;; - `load!' for loading external *.el files relative to this one
|
||||||
@@ -203,207 +210,270 @@
|
|||||||
;; they are implemented.
|
;; they are implemented.
|
||||||
|
|
||||||
;; configure git-delta
|
;; 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
|
;; 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
|
;; Why? diff-hl-magit-post-refresh appears to be 'null' for some reason
|
||||||
;; When? after stage, unstage or commit an error appears in messages.
|
;; When? after stage, unstage or commit an error appears in messages.
|
||||||
(after! (magit)
|
(after!
|
||||||
(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
|
;; HACK show small snippets for backlinks preview in roam-buffer
|
||||||
;; there is currently a problem in org-mode that shows an error
|
;; 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.
|
;; 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 ()
|
(defun qwan/brief-preview
|
||||||
(let* ((elem (org-element-context))
|
()
|
||||||
(parent (org-element-property :parent elem)))
|
(let*
|
||||||
;; TODO: alt handling for non-paragraph elements
|
((elem
|
||||||
(string-trim-right (buffer-substring-no-properties
|
(org-element-context))
|
||||||
(org-element-property :begin parent)
|
(parent
|
||||||
(org-element-property :end parent)))))
|
(org-element-property :parent elem)))
|
||||||
|
;; TODO: alt handling for non-paragraph elements
|
||||||
|
(string-trim-right
|
||||||
|
(buffer-substring-no-properties
|
||||||
|
(org-element-property :begin parent)
|
||||||
|
(org-element-property :end parent)))))
|
||||||
(setq org-roam-preview-function #'qwan/brief-preview)
|
(setq org-roam-preview-function #'qwan/brief-preview)
|
||||||
|
|
||||||
;; cursor moved back to ?beginning of line? too often
|
;; cursor moved back to ?beginning of line? too often
|
||||||
(setq evil-move-cursor-back nil)
|
(setq evil-move-cursor-back nil)
|
||||||
|
|
||||||
|
|
||||||
;; to enable multiple org-roam dirs
|
;; to enable multiple org-roam dirs
|
||||||
;; https://github.com/org-roam/org-roam/issues/1527
|
;; https://github.com/org-roam/org-roam/issues/1527
|
||||||
(setq-default enable-local-variables t)
|
(setq-default enable-local-variables t)
|
||||||
|
|
||||||
;; two functions from:
|
;; two functions from:
|
||||||
;; https://zzamboni.org/post/my-emacs-configuration-with-commentary/#reformatting-an-org-buffer
|
;; 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? ")
|
(interactive)
|
||||||
(let ((document (org-element-interpret-data (org-element-parse-buffer))))
|
(when
|
||||||
(erase-buffer)
|
(y-or-n-p "Really format current buffer? ")
|
||||||
(insert document)
|
(let
|
||||||
(goto-char (point-min)))))
|
((document
|
||||||
|
(org-element-interpret-data
|
||||||
(defun afs/org-remove-link ()
|
(org-element-parse-buffer))))
|
||||||
"Replace an org link by its description or if empty its address"
|
(erase-buffer)
|
||||||
(interactive)
|
(insert document)
|
||||||
(if (org-in-regexp org-link-bracket-re 1)
|
(goto-char
|
||||||
(let ((remove (list (match-beginning 0) (match-end 0)))
|
(point-min)))))
|
||||||
(description (if (match-end 3)
|
(defun afs/org-remove-link
|
||||||
(org-match-string-no-properties 3)
|
()
|
||||||
(org-match-string-no-properties 1))))
|
"Replace an org link by its description or if empty its address"
|
||||||
(apply 'delete-region remove)
|
(interactive)
|
||||||
(insert description))))
|
(if
|
||||||
|
(org-in-regexp org-link-bracket-re 1)
|
||||||
(defun qwan/org-replace-link-by-link-description ()
|
(let
|
||||||
"Remove the link part of an org-mode link at point and keep
|
((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))))
|
||||||
|
(apply 'delete-region remove)
|
||||||
|
(insert 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"
|
only the description"
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((elem (org-element-context)))
|
(let
|
||||||
(if (eq (car elem) 'link)
|
((elem
|
||||||
(let* ((content-begin (org-element-property :contents-begin elem))
|
(org-element-context)))
|
||||||
(content-end (org-element-property :contents-end elem))
|
(if
|
||||||
(link-begin (org-element-property :begin elem))
|
(eq
|
||||||
(link-end (org-element-property :end elem)))
|
(car elem)
|
||||||
(if (and content-begin content-end)
|
'link)
|
||||||
(let ((content (buffer-substring-no-properties content-begin content-end)))
|
(let*
|
||||||
(delete-region link-begin (- link-end 1))
|
((content-begin
|
||||||
(insert content)))))))
|
(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)
|
(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
|
"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"
|
the description. This may destroy existing links, or change their targets so use in a copy of buffers you hold dearly as notes"
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((elem (org-element-context)))
|
(let
|
||||||
(if (eq (car elem) 'link)
|
((elem
|
||||||
(let* ((content-begin (org-element-property :contents-begin elem))
|
(org-element-context)))
|
||||||
(content-end (org-element-property :contents-end elem))
|
(if
|
||||||
(target-type (org-element-property :type elem))
|
(eq
|
||||||
(target-path (org-element-property :path elem))
|
(car elem)
|
||||||
(link-begin (org-element-property :begin elem))
|
'link)
|
||||||
(link-end (org-element-property :end elem)))
|
(let*
|
||||||
(if (and content-begin content-end (string-equal target-type "file") target-path link-begin link-end)
|
((content-begin
|
||||||
(let ((new-link (org-roam-description-file-to-org-url
|
(org-element-property :contents-begin elem))
|
||||||
(buffer-substring-no-properties content-begin content-end)
|
(content-end
|
||||||
target-path)))
|
(org-element-property :contents-end elem))
|
||||||
(delete-region link-begin (- link-end 1))
|
(target-type
|
||||||
(insert new-link)
|
(org-element-property :type elem))
|
||||||
))))))
|
(target-path
|
||||||
(defun qwan/string-as-markdown-image-link (a-string)
|
(org-element-property :path elem))
|
||||||
(concat ""))
|
(link-begin
|
||||||
|
(org-element-property :begin elem))
|
||||||
(defun qwan/image-mode-copy-filename-as-markdown-image-link ()
|
(link-end
|
||||||
"Push a markdown link to the currently visited image onto the kill ring."
|
(org-element-property :end elem)))
|
||||||
(interactive)
|
(if
|
||||||
(unless buffer-file-name
|
(and content-begin content-end
|
||||||
(error "The current buffer doesn't visit an image file"))
|
(string-equal target-type "file")
|
||||||
(let ((markdown-link (qwan/string-as-markdown-image-link
|
target-path link-begin link-end)
|
||||||
(qwan/relative-path-to-attachments buffer-file-name))))
|
(let
|
||||||
|
((new-link
|
||||||
(kill-new markdown-link)
|
(org-roam-description-file-to-org-url
|
||||||
(message "Copied %s" markdown-link)))
|
(buffer-substring-no-properties content-begin content-end)
|
||||||
|
target-path)))
|
||||||
|
(delete-region link-begin
|
||||||
|
(- link-end 1))
|
||||||
(defun qwan/relative-path-to-attachments (full-path)
|
(insert new-link)
|
||||||
(substring full-path (string-search "/attachments" full-path 0) ))
|
))))))
|
||||||
|
(defun qwan/string-as-markdown-image-link
|
||||||
|
(a-string)
|
||||||
|
(concat ""))
|
||||||
|
(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
|
||||||
|
(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)
|
||||||
|
))
|
||||||
(require 'ert)
|
(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")))
|
()
|
||||||
|
(should
|
||||||
(ert-deftest relative-path-to-attachments-does-not-remove-prefix-when-no-attachments ()
|
(equal
|
||||||
(should (equal (qwan/attachments-remove-prefix-path "prefix/somethingelse") "prefix/somethingelse")))
|
(qwan/attachments-remove-prefix-path "prefix/attachments")
|
||||||
|
"/attachments")))
|
||||||
(ert-deftest markdown-link-tokens-should-surround-string ()
|
(ert-deftest relative-path-to-attachments-does-not-remove-prefix-when-no-attachments
|
||||||
(should (equal (qwan/string-as-markdown-image-link "prefix/image.png")
|
()
|
||||||
"")))
|
(should
|
||||||
|
(equal
|
||||||
|
(qwan/attachments-remove-prefix-path "prefix/somethingelse")
|
||||||
(defun qwan-echo (new-name)
|
"prefix/somethingelse")))
|
||||||
(interactive "SRename function to:")
|
(ert-deftest markdown-link-tokens-should-surround-string
|
||||||
(message "Will rename to %s" new-name)
|
()
|
||||||
)
|
(should
|
||||||
|
(equal
|
||||||
|
(qwan/string-as-markdown-image-link "prefix/image.png")
|
||||||
|
"")))
|
||||||
|
(defun qwan-echo
|
||||||
|
(new-name)
|
||||||
|
(interactive "SRename function to:")
|
||||||
|
(message "Will rename to %s" new-name)
|
||||||
|
)
|
||||||
;; from @tbf@functional.cafe
|
;; from @tbf@functional.cafe
|
||||||
(defun movd (from to)
|
(defun movd
|
||||||
(fset to (symbol-function from))
|
(from to)
|
||||||
(fset from nil)
|
(fset to
|
||||||
to)
|
(symbol-function from))
|
||||||
|
(fset from nil)
|
||||||
|
to)
|
||||||
;; from @tbf@functional.cafe
|
;; from @tbf@functional.cafe
|
||||||
(defmacro frename (from to)
|
(defmacro frename
|
||||||
`(movd ',from ',to))
|
(from to)
|
||||||
|
`(movd ',from ',to))
|
||||||
|
|
||||||
(defun qrefactor/rename
|
(defun qrefactor/rename
|
||||||
(new-name)
|
(new-name)
|
||||||
"Rename function at point. You must modify references yourself"
|
"Rename function at point. You must modify references yourself"
|
||||||
(interactive "MRename function to:")
|
(interactive "MRename function to:")
|
||||||
(let
|
(let
|
||||||
((bounds
|
((bounds
|
||||||
(bounds-of-thing-at-point 'symbol)))
|
(bounds-of-thing-at-point 'symbol)))
|
||||||
(if bounds
|
(if bounds
|
||||||
(progn
|
(progn
|
||||||
(let*
|
(let*
|
||||||
((begin
|
((begin
|
||||||
(car bounds))
|
(car bounds))
|
||||||
(end
|
(end
|
||||||
(cdr bounds))
|
(cdr bounds))
|
||||||
(old-name
|
(old-name
|
||||||
(buffer-substring-no-properties begin end))
|
(buffer-substring-no-properties begin end))
|
||||||
(new-function-name (as-function-name new-name)))
|
(new-function-name
|
||||||
(message "Will rename to %s" new-function-name) ;; should use as-function-name here
|
(as-function-name new-name)))
|
||||||
(movd (intern old-name) (intern new-function-name))
|
(message "Will rename to %s" new-function-name)
|
||||||
(ert-make-test-unbound (intern old-name))
|
;; should use as-function-name here
|
||||||
(delete-region begin end)
|
(movd
|
||||||
(insert new-function-name)
|
(intern old-name)
|
||||||
(message "Renamed %s to %s." old-name new-name)))
|
(intern new-function-name))
|
||||||
(message "No symbol under cursor."))))
|
(ert-make-test-unbound
|
||||||
|
(intern old-name))
|
||||||
(defun qrefactor/remove-test ()
|
(delete-region begin end)
|
||||||
"Renmove test at point from memory.
|
(insert new-function-name)
|
||||||
|
(message "Renamed %s to %s." old-name new-name)))
|
||||||
|
(message "No symbol under cursor."))))
|
||||||
|
(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."
|
See also ert-delete-test if you want to delete from a list of existing tests."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let
|
(let
|
||||||
((bounds
|
((bounds
|
||||||
(bounds-of-thing-at-point 'symbol)))
|
(bounds-of-thing-at-point 'symbol)))
|
||||||
(if bounds
|
(if bounds
|
||||||
(progn
|
(progn
|
||||||
(let*
|
(let*
|
||||||
((begin
|
((begin
|
||||||
(car bounds))
|
(car bounds))
|
||||||
(end
|
(end
|
||||||
(cdr bounds))
|
(cdr bounds))
|
||||||
(old-name
|
(old-name
|
||||||
(buffer-substring-no-properties begin end)))
|
(buffer-substring-no-properties begin end)))
|
||||||
(ert-make-test-unbound (intern old-name))
|
(ert-make-test-unbound
|
||||||
(message "Undefined %s." old-name ))))
|
(intern old-name))
|
||||||
(message "No symbol under cursor.")))
|
(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
|
;; 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
|
;; 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
|
||||||
"Take the string and make it suitable to be a function name. Replaces space with dash and make string all lowercase."
|
(candidate-name)
|
||||||
(declare (side-effect-free t))
|
"Take the string and make it suitable to be a function name. Replaces space with dash and make string all lowercase."
|
||||||
(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))))
|
;; (s-join "-" (mapcar 'downcase (s-split-words s))))
|
||||||
(ert-deftest refactor-rename-should-leave-forward-slash()
|
(ert-deftest refactor-rename-should-leave-forward-slash()
|
||||||
(should (equal (as-function-name "qwan/echo")
|
(should
|
||||||
"qwan/echo")))
|
(equal
|
||||||
|
(as-function-name "qwan/echo")
|
||||||
|
"qwan/echo")))
|
||||||
(ert-deftest refactor-rename-should-replace-space-with-dash()
|
(ert-deftest refactor-rename-should-replace-space-with-dash()
|
||||||
(should (equal (as-function-name "qwan/echo chamber")
|
(should
|
||||||
"qwan/echo-chamber")))
|
(equal
|
||||||
|
(as-function-name "qwan/echo chamber")
|
||||||
|
"qwan/echo-chamber")))
|
||||||
(ert-deftest refactor-rename-replaces-uppercase-with-lowercase()
|
(ert-deftest refactor-rename-replaces-uppercase-with-lowercase()
|
||||||
(should (equal (as-function-name "Echo-chamber")
|
(should
|
||||||
"echo-chamber")))
|
(equal
|
||||||
|
(as-function-name "Echo-chamber")
|
||||||
(ert-deftest refactor-renamed-thrice ()
|
"echo-chamber")))
|
||||||
(should (equal 1 1)))
|
(ert-deftest refactor-renamed-thrice
|
||||||
|
()
|
||||||
|
(should
|
||||||
|
(equal 1 1)))
|
||||||
(ert-make-test-unbound 'refactor-rename-test-for-fun)
|
(ert-make-test-unbound 'refactor-rename-test-for-fun)
|
||||||
(ert "refactor.*")
|
(ert "refactor.*")
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
'(jdee-db-requested-breakpoint-face-colors (cons "#1B2229" "#98be65"))
|
'(jdee-db-requested-breakpoint-face-colors (cons "#1B2229" "#98be65"))
|
||||||
'(jdee-db-spec-breakpoint-face-colors (cons "#1B2229" "#3f444a"))
|
'(jdee-db-spec-breakpoint-face-colors (cons "#1B2229" "#3f444a"))
|
||||||
'(objed-cursor-color "#ff6c6b")
|
'(objed-cursor-color "#ff6c6b")
|
||||||
|
'(org-agenda-files '("~/MyDocuments/qwan/essays/willem/daily/2023-01-16.org"))
|
||||||
'(package-selected-packages '(magit-delta))
|
'(package-selected-packages '(magit-delta))
|
||||||
'(pdf-view-midnight-colors (cons "#bbc2cf" "#282c34"))
|
'(pdf-view-midnight-colors (cons "#bbc2cf" "#282c34"))
|
||||||
'(rustic-ansi-faces
|
'(rustic-ansi-faces
|
||||||
|
|||||||
@@ -149,7 +149,7 @@
|
|||||||
;;nim ; python + lisp at the speed of c
|
;;nim ; python + lisp at the speed of c
|
||||||
;;nix ; I hereby declare "nix geht mehr!"
|
;;nix ; I hereby declare "nix geht mehr!"
|
||||||
;;ocaml ; an objective camel
|
;;ocaml ; an objective camel
|
||||||
(org +gnuplot +pretty +roam2 +download-dnd) ; organize your plain life in plain text
|
(org +pomodoro +gnuplot +pretty +roam2 +download-dnd) ; organize your plain life in plain text
|
||||||
;;php ; perl's insecure younger brother
|
;;php ; perl's insecure younger brother
|
||||||
plantuml ; diagrams for confusing people more
|
plantuml ; diagrams for confusing people more
|
||||||
purescript ; javascript, but functional
|
purescript ; javascript, but functional
|
||||||
|
|||||||
Reference in New Issue
Block a user