diff --git a/.config/doom/config.el b/.config/doom/config.el index 932622e..a2291a5 100644 --- a/.config/doom/config.el +++ b/.config/doom/config.el @@ -282,6 +282,8 @@ Version 2019-11-04 2021-02-16" :config + (defun xf/slugify (string) (downcase (s-replace-regexp "[^[:alnum:][:digit:]]\+" "-" string))) + ; the value does not matter, see https://emacs.stackexchange.com/questions/71774/pass-default-value-to-org-set-property/71777#71777 ;(add-to-list 'org-global-properties-fixed '("ID_ALL" . "id")) (map! :map org-mode-map @@ -305,9 +307,11 @@ Version 2019-11-04 2021-02-16" :desc "Low Priority" "pc" (lambda () (interactive) (org-priority "C")) :desc "Medium Priority" "pb" (lambda () (interactive) (org-priority "B")) :desc "High Priority" "pa" (lambda () (interactive) (org-priority "A")) - :desc "Set ID property" "lI" (lambda () (interactive) (org-set-property "ID" + :desc "Set ID property" "lI" (lambda () (interactive) + (org-set-property "ID" (let ((heading (org-get-heading t t t t))) - (if heading (org-read-property-value "ID" nil (downcase (s-replace-regexp "[^[:alnum:][:digit:]]\+" "-" heading))) (file-name-sans-extension (file-name-nondirectory buffer-file-name)))))) + (if heading (org-read-property-value "ID" nil (xf/slugify heading)) (file-name-sans-extension (file-name-nondirectory buffer-file-name))) + ))) :desc "Set Roam Aliases" "la" (lambda () (interactive) (org-set-property "ROAM_ALIASES" nil)) :desc "Add tag" "mt" 'org-roam-tag-add :desc "Remove tag" "mT" 'org-roam-tag-remove @@ -331,8 +335,10 @@ Version 2019-11-04 2021-02-16" ;; Org startup - https://orgmode.org/manual/In_002dbuffer-Settings.html (setq org-startup-folded 'show2levels - org-display-remote-inline-images 'cache - ) + org-display-remote-inline-images 'cache) + + (add-variable-watcher 'org-display-custom-times (lambda (symbol val op wh) (cl-flet ((wrapper (if val (-cut concat "<" <> ">") 'identity))) (setq org-time-stamp-custom-formats `(,(wrapper "%d.%m.%Y %a") . ,(wrapper "%d.%m.%Y %a %H:%M")))))) + (setq org-display-custom-times 't) ; TODO customize org-log-note-headings @@ -572,11 +578,10 @@ Version 2019-11-04 2021-02-16" :config (map! :map org-mode-map :leader - "e" 'org-export-dispatch-custom-date + "e" 'org-export-dispatch-without-time "E" 'org-export-repeat :desc "Save and Export" "be" (lambda () (interactive) (basic-save-buffer) (org-export-repeat)) :localleader - "e" 'org-export-dispatch-custom-date "E" 'org-export-repeat ) @@ -590,11 +595,12 @@ Version 2019-11-04 2021-02-16" ) ;; TODO name file according to subtree headline - (defun org-export-dispatch-custom-date () + (defun org-export-dispatch-without-time () (interactive) (let ((org-time-stamp-custom-formats - '("<%d.%m.%Y>" . "<%d.%m.%Y>")) + '("%d.%m.%Y" . "%d.%m.%Y")) (org-display-custom-times 't)) + (org-set-property "EXPORT_FILE_NAME" (xf/slugify (org-get-heading t t t t))) (org-export-dispatch)) ) @@ -828,6 +834,13 @@ Version 2019-11-04 2021-02-16" ;;; File modes +(use-package! adoc-mode ; Asciidoc, a md alternative + :mode "\\.adoc\\'" + ) +(use-package! nov + :mode ("\\.epub\\'" . nov-mode) + ) + (use-package! plantuml-mode ; Diagrams :mode "\\.puml\\'" :config @@ -844,17 +857,11 @@ Version 2019-11-04 2021-02-16" (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))) ) ) -(use-package! adoc-mode ; Asciidoc, a md alternative - :mode "\\.adoc\\'" - ) -(use-package! nov - :mode ("\\.epub\\'" . nov-mode) - ) (use-package! chordpro-mode :mode "\\.cho" :config - ;; TODO template + (set-file-template! 'chordpro-mode :mode 'chordpro-mode) ; TODO broken (define-key chordpro-mode-map (kbd "C-c C-c") 'chordpro-insert-chord) ) (use-package! lilypond-mode diff --git a/.config/doom/snippets/LilyPond-mode/__ b/.config/doom/snippets/LilyPond-mode/__ index 7fb1402..811a090 100644 --- a/.config/doom/snippets/LilyPond-mode/__ +++ b/.config/doom/snippets/LilyPond-mode/__ @@ -1,5 +1,5 @@ # -*- mode: snippet -*- -# name: LilyPond Foundation +# name: LilyPond Scaffold # -- \header { title = "${1:`(upcase-initials (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`}" diff --git a/.config/doom/snippets/chordpro-mode/__ b/.config/doom/snippets/chordpro-mode/__ new file mode 100644 index 0000000..9481a59 --- /dev/null +++ b/.config/doom/snippets/chordpro-mode/__ @@ -0,0 +1,21 @@ +# -*- mode: snippet -*- +# name: ChordPro Scaffold +# -- +{title: ${1:`(upcase-initials (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))`}} +{artist: Janek Fischer} + +{sov: Vers 1} + +{eov} + +{sov: Vers 2} + +{eov} + +{soc} + +{eoc} + +{sob} + +{eob} \ No newline at end of file diff --git a/.config/doom/snippets/org-mode/__ b/.config/doom/snippets/org-mode/__ index f30ff41..00b96f5 100644 --- a/.config/doom/snippets/org-mode/__ +++ b/.config/doom/snippets/org-mode/__ @@ -1,5 +1,5 @@ # -*- mode: snippet -*- -# name: Org template +# name: Org Scaffold # -- #+title: ${1:` (string-join