From 9429eb7036f379c2a3c5ad6ec73bace56b10ba8e Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Thu, 6 Jan 2022 19:00:23 +0100 Subject: [PATCH] rearrange org settings --- settings/org-settings.el | 519 ++++++++++++++++++++------------------- 1 file changed, 268 insertions(+), 251 deletions(-) diff --git a/settings/org-settings.el b/settings/org-settings.el index 3ed68f33..311a4032 100644 --- a/settings/org-settings.el +++ b/settings/org-settings.el @@ -14,6 +14,16 @@ ;; * Overview of modes and commands ;; -------------------------------- +;; +;; ** `org-appear' +;; --------------- +;; auto toogle entities, emphasis markers, links, subscripts and superscripts, +;; keywords +;; `org-appear-autoentities', `org-appear-autoemphasis', `org-appear-autolinks' +;; `org-appear-autosubmarkers', `org-appear-autokeywords' +;; and from `org': `org-pretty-entries', `org-hide-emphasis-markers', +;; `org-link-descriptive', `org-hidden-keywords' +;; ;; ** Export `ox-reveal' ;; --------------------- ;; (org-export-get-all-options 'reveal) @@ -250,6 +260,14 @@ Example defines (setq org-pretty-entities t) ;; see also `org-appear' and [C-c C-x \] (`org-toggle-pretty-entities') (setq org-pretty-entities-include-sub-superscripts t) ;; if `org-pretty-entities' is active include also sub-superscripts. (setq org-image-actual-width '(600)) ;; image width displayed in org + (setq org-format-latex-options + '(:foreground default + :background default + :scale 1.75 + :html-foreground "Black" + :html-background "Transparent" + :html-scale 1.0 + :matchers ("begin" "$1" "$" "$$" "\\(" "\\["))) (setq org-tag-persistent-alist '(("ignore" . ?i) ("noexport" . ?n))) ;; todo see also org-todo-keyword-faces and org-superstar-todo-bullet-alist (setq org-todo-keywords ;; (x!) record a time stamp, (x@) add a note (with time), (y/z) entering the state / leaving the state @@ -297,6 +315,9 @@ Example defines (add-to-list 'image-file-name-extensions "eps" t)) ;; TODO: eps not needed? +(use-package org-contrib + :load-path (lambda () (list (concat config-dir "lisp/org-contrib")))) + ;; Make invisible parts of Org elements appear visible. (use-package org-appear :after (org) @@ -308,30 +329,61 @@ Example defines (setq org-appear-autosubmarkers t) ;; toogle subscripts and superscripts: ^3 -> ³, needs `org-pretty-entries' active (setq org-appear-autokeywords t)) ;; toogle keywords: #+TITLE: foo -> foo, needs `org-hidden-keywords' active -(use-package org-contrib - :load-path (lambda () (list (concat config-dir "lisp/org-contrib")))) - -(use-package org-id ;; used by org-brain - :defer t +(use-package org-brain ;; uses org-id If you find that org-brain is missing entries, or list entries which doesn’t exist, try using M-x org-brain-update-id-locations, which syncs the org-brain entries with the org-id caching system. + :commands (org-brain-visualize) + :init + (setq org-brain-path my-org-brain-path) :config - ;; (setq org-id-track-globally t) ;; default is t - (setq org-id-locations-file (concat user-cache-directory ".org-id-locations"))) + (require 'org-capture) + ;; make org-brain commands more accessable if you edit entries from org-mode + (bind-key "C-c B" 'org-brain-prefix-map org-mode-map) + ;; org-brain use org-id in order to speed things up. Because of + ;; this, the variable org-id-track-globally should be t (which it + ;; already is by default). You may want to modify + ;; org-id-locations-file too. If you add entries to org-brain + ;; directly from org-mode you must assign headliens an ID. A + ;; comfortable way to do this is with the command + ;; org-brain-ensure-ids-in-buffer. Even more comfortable is to add + ;; that to before-save-hook, so that it runs when saving. + (add-hook 'before-save-hook #'org-brain-ensure-ids-in-buffer) + ;; to add information at the end of an entry, without visiting the file. + (push '("b" "Brain" plain (function org-brain-goto-end) + "* %i%?" :empty-lines 1) + org-capture-templates) + ;; (setq org-brain-visualize-default-choices 'all) + ;; (setq org-brain-show-resources t) + ;; (setq org-brain-show-text t) + ;; (setq org-brain-title-max-length 12) + ;; Some users find it confusing having both headline entries and + ;; file entries (see below). It may be preferable to only use + ;; headline entries, by setting org-brain-include-file-entries to + ;; nil. If doing this, you should probably also set + ;; org-brain-file-entries-use-title to nil. Another possibility is + ;; if you’re only using file entries, in which case you can set + ;; org-brain-scan-for-header-entries to nil. + ;; (setq org-brain-include-file-entries nil) + ;; (setq org-brain-file-entries-use-title nil) -(use-package org-faces - :defer t - :config - (setq org-todo-keyword-faces ;; TODO keywords - '(("TODO" . "LightSkyBlue4") ;; org-warning (bold red), DeepSkyBlue3 - ("WAIT" . "LightSkyBlue4") ;; - ("DONE" . "#5e5079") ;; DarkSlateGray4 PaleTurquoise4, CadetBlue4, LightSkyBlue4 - ("CANC" . "#5e5079") ;; - ("STARTED" . "yellow") - ("CANCELED" . (:foreground "blue" :weight bold))))) + (require 'deft) + (defun org-brain-deft () + "Use `deft' for files in `org-brain-path'." + (interactive) + (let ((deft-directory org-brain-path) + (deft-recursive t) + (deft-extensions '("org"))) + (deft))) -(use-package org-table - :defer t - :config - (setq org-table-convert-region-max-lines 9999)) + (require 'org-cliplink) + (defun org-brain-cliplink-resource () + "Add a URL from the clipboard as an org-brain resource. +Suggest the URL title as a description for resource." + (interactive) + (let ((url (org-cliplink-clipboard-content))) + (org-brain-add-resource + url + (org-cliplink-retrieve-title-synchronously url) + t))) + (define-key org-brain-visualize-mode-map (kbd "L") #'org-brain-cliplink-resource)) (use-package org-capture :defer t @@ -344,59 +396,55 @@ Example defines (add-to-list 'org-capture-templates '(;; put entries under a date tree (year - month - day - entry) in the default file ("j" "Journal" entry (file+olp+datetree "") ;; empty string is the file, e.g. "~/org/journal.org" - "* %?\nEntered on %U\n %i\n %a"))) + "* %?\nEntered on %U\n %i\n %a")))) ;; see also org-cliplink K, org-brain b - ) -(use-package org-mouse ;; to load mouse features, like clicking on the bullet of a heading +(use-package org-cliplink + :after (org) + :load-path (lambda() (concat config-dir "lisp/org-cliplink")) + :config + (defun my-org-link-description-update () + "." + ;; content is the link 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)) + (raw-link (org-element-property :raw-link elem))) + (save-excursion + ;; if content-begin (and content-end) is not nil (will be nil if there is no description) + (if (and content-begin content-end) + (progn + (delete-region content-begin content-end) + (insert (org-cliplink-retrieve-title-synchronously raw-link))) + (delete-region link-begin link-end) + (insert (org-cliplink-org-mode-link-transformer + raw-link (org-cliplink-retrieve-title-synchronously raw-link))))))))) + + (with-eval-after-load 'org-capture + (add-to-list 'org-capture-templates + '("K" "Cliplink capture task" entry (file "") + "* TODO %(org-cliplink-capture) \n SCHEDULED: %t\n" :empty-lines 0)))) + +(use-package org-collector ;; collect properties into tables, using #+BEGIN: propview :after (org)) -(use-package org-tempo ;; expand ") ) -(use-package ox-tufte ;; https://melpa.org/#/ox-tufte - :defer t ;; will be loaded via `org-export-backends' see above inside `org' - :config - (defun my-org-tufte-export-to-file (&optional async subtreep visible-only) - "Like `org-tufte-export-to-file' but with additional notification." - (interactive) - (let ((outfile (org-export-output-file-name ".html" subtreep)) - ;; need to bind this because tufte treats footnotes specially, so we - ;; don't want to display them at the bottom - (org-html-footnotes-section (if org-tufte-include-footnotes-at-bottom - org-html-footnotes-section - ""))) - (org-export-to-file 'tufte-html outfile - async subtreep visible-only nil nil - (lambda (file) ;; is called with FILE and has to return a file name. - (progn - (when my-dbusp - (use-package notifications) - (notifications-notify - :title "Emacs Org Tufte (HTML) Export to File" - :body "Export done." - :timeout 60000 - :urgency 'normal - :category "transfer")) - file))))) ;; is needed for the asynchronous task - - (defun my-org-export-html (&optional async) - (interactive) - (save-buffer) - (when (get-buffer "*gnuplot*") - (kill-buffer "*gnuplot*")) ;; to get a new session - (my-org-tufte-export-to-file async)) - - (defun my-org-export-html-async () - (interactive) - (my-org-export-html t)) - - (org-defkey org-mode-map [f5] 'my-org-export-html) - (org-defkey org-mode-map [C-f5] 'my-org-export-html-async) - - (defun org-tufte-src-block (src-block _contents info) - "Transcode a SRC-BLOCK element from Org to HTML. -CONTENTS holds the contents of the item. INFO is a plist holding -contextual information." - (if (org-export-read-attribute :attr_html src-block :textarea) - (org-html--textarea-block src-block) - (let* ((lang (org-element-property :language src-block)) - (code (org-html-format-code src-block info)) - (label (let ((lbl (and (org-element-property :name src-block) - (org-export-get-reference src-block info)))) - (if lbl (format " id=\"%s\"" lbl) ""))) - (klipsify (and (plist-get info :html-klipsify-src) - (member lang '("javascript" "js" - "ruby" "scheme" "clojure" "php" "html"))))) - (if (not lang) (format "
\n%s
" label code) - (format "
\n%s%s\n
" - ;; Build caption. - (let ((caption (org-export-get-caption src-block))) - (if (not caption) "" - (let ((listing-number - (format - "%s " - (format - (org-html--translate "Listing %d:" info) - (org-export-get-ordinal - src-block info nil #'org-html--has-caption-p))))) - (format "" - listing-number - (org-trim (org-export-data caption info)))))) - ;; Contents. - (if klipsify - (format "
%s
" - lang - label - (if (string= lang "html") - " data-editor-type=\"html\"" - "") - code) - (format "
%s
" - lang label code)))))))) - (use-package ox-latex :defer t ;; will be loaded via `org-export-backends' see above inside `org' :config @@ -1207,64 +1202,86 @@ used as a communication channel." ;; No plugins, return empty string (cons nil nil))))) -(use-package org-drill ;; requires persist https://elpa.gnu.org/packages/persist.html - :commands org-drill) - -(use-package org-brain ;; uses org-id If you find that org-brain is missing entries, or list entries which doesn’t exist, try using M-x org-brain-update-id-locations, which syncs the org-brain entries with the org-id caching system. - :commands (org-brain-visualize) - :init - (setq org-brain-path my-org-brain-path) +(use-package ox-tufte ;; https://melpa.org/#/ox-tufte + :defer t ;; will be loaded via `org-export-backends' see above inside `org' :config - (require 'org-capture) - ;; make org-brain commands more accessable if you edit entries from org-mode - (bind-key "C-c B" 'org-brain-prefix-map org-mode-map) - ;; org-brain use org-id in order to speed things up. Because of - ;; this, the variable org-id-track-globally should be t (which it - ;; already is by default). You may want to modify - ;; org-id-locations-file too. If you add entries to org-brain - ;; directly from org-mode you must assign headliens an ID. A - ;; comfortable way to do this is with the command - ;; org-brain-ensure-ids-in-buffer. Even more comfortable is to add - ;; that to before-save-hook, so that it runs when saving. - (add-hook 'before-save-hook #'org-brain-ensure-ids-in-buffer) - ;; to add information at the end of an entry, without visiting the file. - (push '("b" "Brain" plain (function org-brain-goto-end) - "* %i%?" :empty-lines 1) - org-capture-templates) - ;; (setq org-brain-visualize-default-choices 'all) - ;; (setq org-brain-show-resources t) - ;; (setq org-brain-show-text t) - ;; (setq org-brain-title-max-length 12) - ;; Some users find it confusing having both headline entries and - ;; file entries (see below). It may be preferable to only use - ;; headline entries, by setting org-brain-include-file-entries to - ;; nil. If doing this, you should probably also set - ;; org-brain-file-entries-use-title to nil. Another possibility is - ;; if you’re only using file entries, in which case you can set - ;; org-brain-scan-for-header-entries to nil. - ;; (setq org-brain-include-file-entries nil) - ;; (setq org-brain-file-entries-use-title nil) - - (require 'deft) - (defun org-brain-deft () - "Use `deft' for files in `org-brain-path'." + (defun my-org-tufte-export-to-file (&optional async subtreep visible-only) + "Like `org-tufte-export-to-file' but with additional notification." (interactive) - (let ((deft-directory org-brain-path) - (deft-recursive t) - (deft-extensions '("org"))) - (deft))) + (let ((outfile (org-export-output-file-name ".html" subtreep)) + ;; need to bind this because tufte treats footnotes specially, so we + ;; don't want to display them at the bottom + (org-html-footnotes-section (if org-tufte-include-footnotes-at-bottom + org-html-footnotes-section + ""))) + (org-export-to-file 'tufte-html outfile + async subtreep visible-only nil nil + (lambda (file) ;; is called with FILE and has to return a file name. + (progn + (when my-dbusp + (use-package notifications) + (notifications-notify + :title "Emacs Org Tufte (HTML) Export to File" + :body "Export done." + :timeout 60000 + :urgency 'normal + :category "transfer")) + file))))) ;; is needed for the asynchronous task - (require 'org-cliplink) - (defun org-brain-cliplink-resource () - "Add a URL from the clipboard as an org-brain resource. -Suggest the URL title as a description for resource." + (defun my-org-export-html (&optional async) (interactive) - (let ((url (org-cliplink-clipboard-content))) - (org-brain-add-resource - url - (org-cliplink-retrieve-title-synchronously url) - t))) - (define-key org-brain-visualize-mode-map (kbd "L") #'org-brain-cliplink-resource)) + (save-buffer) + (when (get-buffer "*gnuplot*") + (kill-buffer "*gnuplot*")) ;; to get a new session + (my-org-tufte-export-to-file async)) + + (defun my-org-export-html-async () + (interactive) + (my-org-export-html t)) + + (org-defkey org-mode-map [f5] 'my-org-export-html) + (org-defkey org-mode-map [C-f5] 'my-org-export-html-async) + + (defun org-tufte-src-block (src-block _contents info) + "Transcode a SRC-BLOCK element from Org to HTML. +CONTENTS holds the contents of the item. INFO is a plist holding +contextual information." + (if (org-export-read-attribute :attr_html src-block :textarea) + (org-html--textarea-block src-block) + (let* ((lang (org-element-property :language src-block)) + (code (org-html-format-code src-block info)) + (label (let ((lbl (and (org-element-property :name src-block) + (org-export-get-reference src-block info)))) + (if lbl (format " id=\"%s\"" lbl) ""))) + (klipsify (and (plist-get info :html-klipsify-src) + (member lang '("javascript" "js" + "ruby" "scheme" "clojure" "php" "html"))))) + (if (not lang) (format "
\n%s
" label code) + (format "
\n%s%s\n
" + ;; Build caption. + (let ((caption (org-export-get-caption src-block))) + (if (not caption) "" + (let ((listing-number + (format + "%s " + (format + (org-html--translate "Listing %d:" info) + (org-export-get-ordinal + src-block info nil #'org-html--has-caption-p))))) + (format "" + listing-number + (org-trim (org-export-data caption info)))))) + ;; Contents. + (if klipsify + (format "
%s
" + lang + label + (if (string= lang "html") + " data-editor-type=\"html\"" + "") + code) + (format "
%s
" + lang label code)))))))) ;; Allows you to edit entries directly from org-brain-visualize (use-package polymode