Compare commits
2 Commits
3c2423fc40
...
73e8aa6fb7
| Author | SHA1 | Date | |
|---|---|---|---|
| 73e8aa6fb7 | |||
| 9429eb7036 |
226
lisp/org-fragtog.el
Normal file
226
lisp/org-fragtog.el
Normal file
@@ -0,0 +1,226 @@
|
||||
;;; org-fragtog.el --- Auto-toggle Org LaTeX fragments -*- lexical-binding: t; -*-
|
||||
|
||||
;; Copyright (C) 2020 Benjamin Levy - MIT/X11 License
|
||||
;; Author: Benjamin Levy <blevy@protonmail.com>
|
||||
;; Version: 0.4.0
|
||||
;; Package-Version: 20220106.758
|
||||
;; Package-Commit: 5b346068c346c4164f5e48e81d1e1bb285da8fd5
|
||||
;; Description: Automatically toggle Org mode LaTeX fragment previews as the cursor enters and exits them
|
||||
;; Homepage: https://github.com/io12/org-fragtog
|
||||
;; Package-Requires: ((emacs "27.1"))
|
||||
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
;; of this software and associated documentation files (the "Software"), to deal
|
||||
;; in the Software without restriction, including without limitation the rights
|
||||
;; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
;; copies of the Software, and to permit persons to whom the Software is
|
||||
;; furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in all
|
||||
;; copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
;; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
;; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; This package automates toggling Org mode LaTeX fragment
|
||||
;; previews. Fragment previews are disabled for editing when
|
||||
;; your cursor steps onto them, and re-enabled when the cursor
|
||||
;; leaves.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'org)
|
||||
|
||||
(defgroup org-fragtog nil
|
||||
"Auto-toggle Org LaTeX fragments"
|
||||
:group 'org-latex)
|
||||
|
||||
(defcustom org-fragtog-ignore-predicates nil
|
||||
"List of predicates to determine whether to ignore a fragment.
|
||||
For example, adding `org-at-table-p' will ignore fragments inside tables."
|
||||
:group 'org-fragtog
|
||||
:type 'hook
|
||||
:options '(org-at-table-p
|
||||
org-at-table.el-p
|
||||
org-at-block-p
|
||||
org-at-heading-p))
|
||||
|
||||
(defcustom org-fragtog-preview-delay 0.0
|
||||
"Seconds of delay before LaTeX preview."
|
||||
:group 'org-fragtog
|
||||
:type 'number)
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode org-fragtog-mode
|
||||
"A minor mode that automatically toggles Org mode LaTeX fragment previews.
|
||||
Fragment previews are disabled for editing when your cursor steps onto them,
|
||||
and re-enabled when the cursor leaves."
|
||||
nil nil nil
|
||||
|
||||
;; Fix nil error in `org-element-context'
|
||||
;; when using `org-fragtog' without Org mode.
|
||||
(setq org-complex-heading-regexp (or org-complex-heading-regexp ""))
|
||||
|
||||
(if org-fragtog-mode
|
||||
(add-hook 'post-command-hook #'org-fragtog--post-cmd nil t)
|
||||
(remove-hook 'post-command-hook #'org-fragtog--post-cmd t)))
|
||||
|
||||
(defvar-local org-fragtog--prev-frag nil
|
||||
"Previous fragment that surrounded the cursor, or nil if the cursor was not
|
||||
on a fragment. This is used to track when the cursor leaves a fragment.")
|
||||
|
||||
(defvar-local org-fragtog--prev-point nil
|
||||
"Value of point from before the most recent command.")
|
||||
|
||||
(defvar-local org-fragtog--timer nil
|
||||
"Current active timer.")
|
||||
|
||||
(defun org-fragtog--post-cmd ()
|
||||
"This function is executed by `post-command-hook' in `org-fragtog-mode'.
|
||||
It handles toggling fragments depending on whether the cursor entered or exited them."
|
||||
(let*
|
||||
;; Previous fragment
|
||||
((prev-frag (or org-fragtog--prev-frag
|
||||
;; If there is no previous fragment,
|
||||
;; try to use a fragment at the previous cursor position.
|
||||
;; This case matters when the cursor constructs a fragment
|
||||
;; without ever being inside of it while it's constructed.
|
||||
;; For example, if the user types "$foo$" in sequential order,
|
||||
;; entering the final "$" creates a fragment without
|
||||
;; the cursor ever being inside of it.
|
||||
(if org-fragtog--prev-point
|
||||
(save-excursion
|
||||
(goto-char org-fragtog--prev-point)
|
||||
(org-fragtog--cursor-frag)))))
|
||||
;; Previous fragment's start position
|
||||
(prev-frag-start-pos (car (org-fragtog--frag-pos prev-frag)))
|
||||
;; Current fragment
|
||||
(cursor-frag (org-fragtog--cursor-frag))
|
||||
;; The current fragment didn't change
|
||||
(frag-same (equal
|
||||
;; Fragments are considered the same if they have the same
|
||||
;; start position
|
||||
(car (org-fragtog--frag-pos cursor-frag))
|
||||
prev-frag-start-pos))
|
||||
;; The current fragment changed
|
||||
(frag-changed (not frag-same))
|
||||
;; The fragment at position of previous fragment.
|
||||
;; This can be nil when for example $foo$ is edited to become $foo $.
|
||||
(frag-at-prev-pos (and prev-frag-start-pos
|
||||
(save-excursion
|
||||
(goto-char prev-frag-start-pos)
|
||||
(org-fragtog--cursor-frag)))))
|
||||
|
||||
;; Only do anything if the current fragment changed
|
||||
(when frag-changed
|
||||
;; Current fragment is the new previous
|
||||
(setq org-fragtog--prev-frag cursor-frag)
|
||||
;; Enable fragment if cursor left it after a timed disable
|
||||
;; and the fragment still exists
|
||||
(when (and frag-at-prev-pos
|
||||
(not (org-fragtog--overlay-in-p
|
||||
(org-fragtog--frag-pos frag-at-prev-pos))))
|
||||
(org-fragtog--enable-frag frag-at-prev-pos))
|
||||
;; Cancel and expire timer
|
||||
(when org-fragtog--timer
|
||||
(cancel-timer org-fragtog--timer)
|
||||
(setq org-fragtog--timer nil))
|
||||
;; Disable fragment if cursor entered it
|
||||
(when cursor-frag
|
||||
(if (> org-fragtog-preview-delay 0)
|
||||
(setq org-fragtog--timer (run-with-idle-timer org-fragtog-preview-delay
|
||||
nil
|
||||
#'org-fragtog--disable-frag
|
||||
cursor-frag
|
||||
t))
|
||||
(org-fragtog--disable-frag cursor-frag))))
|
||||
|
||||
(setq org-fragtog--prev-point (point))))
|
||||
|
||||
|
||||
|
||||
(defun org-fragtog--overlay-in-p (range)
|
||||
"Return whether there is a fragment overlay in RANGE.
|
||||
The RANGE parameter is a cons of start and end positions."
|
||||
(seq-find (lambda (overlay)
|
||||
(equal (overlay-get overlay 'org-overlay-type)
|
||||
'org-latex-overlay))
|
||||
(overlays-in (car range) (cdr range))))
|
||||
|
||||
(defun org-fragtog--cursor-frag ()
|
||||
"Return the fragment currently surrounding the cursor.
|
||||
If there is none, return nil.
|
||||
If the fragment is ignored from rules in `org-fragtog-ignore-predicates',
|
||||
return nil."
|
||||
(let*
|
||||
;; Element surrounding the cursor
|
||||
((elem (org-element-context))
|
||||
;; Type of element surrounding the cursor
|
||||
(elem-type (nth 0 elem))
|
||||
;; List of fragment's properties
|
||||
(elem-plist (nth 1 elem))
|
||||
;; A LaTeX fragment or environment is surrounding the cursor
|
||||
(elem-is-latex (and (member elem-type '(latex-fragment latex-environment))
|
||||
;; Normally org-mode considers whitespace after an
|
||||
;; element as part of the element.
|
||||
;; Avoid this behavior and consider trailing
|
||||
;; whitespace as outside the fragment.
|
||||
(< (point) (- (plist-get elem-plist :end)
|
||||
(plist-get elem-plist :post-blank)))))
|
||||
;; Whether the fragment should be ignored
|
||||
(should-ignore (run-hook-with-args-until-success
|
||||
'org-fragtog-ignore-predicates)))
|
||||
|
||||
(if (and elem-is-latex (not should-ignore))
|
||||
elem
|
||||
nil)))
|
||||
|
||||
(defun org-fragtog--enable-frag (frag)
|
||||
"Enable the Org LaTeX fragment preview for the fragment FRAG."
|
||||
|
||||
;; The fragment must be disabled before `org-latex-preview', since
|
||||
;; `org-latex-preview' only toggles, leaving no guarantee that it's enabled
|
||||
;; afterwards.
|
||||
(org-fragtog--disable-frag frag)
|
||||
|
||||
;; Move to fragment and enable
|
||||
(save-excursion
|
||||
(goto-char (car
|
||||
(org-fragtog--frag-pos frag)))
|
||||
(ignore-errors (org-latex-preview))))
|
||||
|
||||
(defun org-fragtog--disable-frag (frag &optional renew)
|
||||
"Disable the Org LaTeX fragment preview for the fragment FRAG.
|
||||
If RENEW is non-nil, renew the fragment at point."
|
||||
|
||||
;; Renew frag at point in case point was adjusted
|
||||
;; See Emacs Lisp manual, 21.6 Adjusting Point After Commands
|
||||
(when renew
|
||||
(setq frag (org-fragtog--cursor-frag))
|
||||
(setq org-fragtog--prev-frag frag)
|
||||
(setq org-fragtog--timer nil))
|
||||
|
||||
;; There may be nothing at the adjusted point
|
||||
(when frag
|
||||
(let
|
||||
((pos (org-fragtog--frag-pos frag)))
|
||||
(org-clear-latex-preview (car pos)
|
||||
(cdr pos)))))
|
||||
|
||||
(defun org-fragtog--frag-pos (frag)
|
||||
"Get the position of the fragment FRAG.
|
||||
Return a cons of the begin and end positions."
|
||||
(cons
|
||||
(org-element-property :begin frag)
|
||||
(org-element-property :end frag)))
|
||||
|
||||
(provide 'org-fragtog)
|
||||
|
||||
;;; org-fragtog.el ends here
|
||||
@@ -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,15 @@ 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-startup-with-latex-preview t) ;; #+STARTUP: latexpreview|nolatexpreview
|
||||
(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 +316,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 +330,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 +397,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 <s to a src block, ...
|
||||
:after (org))
|
||||
(use-package org-drill ;; requires persist https://elpa.gnu.org/packages/persist.html
|
||||
:commands org-drill)
|
||||
|
||||
(use-package org-num ;; numbering of headings
|
||||
:after (org)
|
||||
:delight (org-num-mode "#") ;; o#
|
||||
(use-package org-faces
|
||||
:defer t
|
||||
:config
|
||||
(setq org-num-skip-tags '("ignore"))
|
||||
(setq org-num-skip-unnumbered t))
|
||||
|
||||
(use-package org-collector ;; collect properties into tables, using #+BEGIN: propview
|
||||
:after (org))
|
||||
|
||||
(use-package org-superstar
|
||||
;; formerly
|
||||
;;(require 'org-bullets)
|
||||
;;(add-hook 'org-mode-hook 'org-bullets-mode)
|
||||
:hook (org-mode . org-superstar-mode) ;; defers the loading.
|
||||
:config
|
||||
(setq org-superstar-leading-bullet " ·") ;; " ․" " ·" " ⚫" or to hide: ?\s
|
||||
(setq org-superstar-prettify-item-bullets t) ;; can cause slowdown when using a lot of lists (thousands), run command org-superstar-toggle-lightweight-list or set this variable to nil or see hack on the source web page
|
||||
(setq org-superstar-remove-leading-stars nil) ;; to remove the indentation
|
||||
(setq org-superstar-special-todo-items t) ;; using symbols defined in org-superstar-todo-bullet-alist
|
||||
;; (setq org-superstar-todo-bullet-alist
|
||||
;; '(("TODO" . 9744)
|
||||
;; ("WAIT" . 9744)
|
||||
;; ("DONE" . 9745)
|
||||
;; ("CANC" . 9745)))
|
||||
(setq org-superstar-todo-bullet-alist
|
||||
'(("TODO" . 9744)
|
||||
("WAIT" . 9744)
|
||||
("DONE" . 9744)
|
||||
("CANC" . 9744)))
|
||||
(set-face-attribute 'org-superstar-leading nil :foreground "#42444a")) ;; "#42444a"
|
||||
|
||||
(use-package org-table-sticky-header
|
||||
:after (org)
|
||||
:delight (org-table-sticky-header-mode "Ⓣ") ;; Ⓞt OTSH
|
||||
:hook (org-mode . org-table-sticky-header-mode)) ;; must be set before org-sticky-header-mode, maybe orgtbl-show-header can also be used
|
||||
|
||||
(use-package org-sticky-header
|
||||
:after (org)
|
||||
:hook (org-mode . org-sticky-header-mode)
|
||||
:config
|
||||
;;(setq org-sticky-header-always-show-header nil)
|
||||
(setq org-sticky-header-full-path 'reversed))
|
||||
(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)))))
|
||||
|
||||
(use-package org-fancy-priorities
|
||||
:after (org)
|
||||
@@ -442,35 +491,67 @@ Example defines
|
||||
(list ?4 :foreground "green1")
|
||||
(list ?I :foreground "#df5f5f" :weight 'bold))))
|
||||
|
||||
(use-package org-cliplink
|
||||
(use-package org-fragtog
|
||||
:after (org)
|
||||
:load-path (lambda() (concat config-dir "lisp/org-cliplink"))
|
||||
:hook (org-mode . org-fragtog-mode))
|
||||
|
||||
(use-package org-id ;; used by org-brain
|
||||
:defer t
|
||||
: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))))
|
||||
;; (setq org-id-track-globally t) ;; default is t
|
||||
(setq org-id-locations-file (concat user-cache-directory ".org-id-locations")))
|
||||
|
||||
(use-package org-mouse ;; to load mouse features, like clicking on the bullet of a heading
|
||||
:after (org))
|
||||
|
||||
(use-package org-num ;; numbering of headings
|
||||
:after (org)
|
||||
:delight (org-num-mode "#") ;; o#
|
||||
:config
|
||||
(setq org-num-skip-tags '("ignore"))
|
||||
(setq org-num-skip-unnumbered t))
|
||||
|
||||
(use-package org-sticky-header
|
||||
:after (org org-table-sticky-header) ;; org-table-sticky-header-mode must be set before
|
||||
:hook (org-mode . org-sticky-header-mode)
|
||||
:config
|
||||
;;(setq org-sticky-header-always-show-header nil)
|
||||
(setq org-sticky-header-full-path 'reversed))
|
||||
|
||||
(use-package org-superstar
|
||||
;; formerly
|
||||
;;(require 'org-bullets)
|
||||
;;(add-hook 'org-mode-hook 'org-bullets-mode)
|
||||
:hook (org-mode . org-superstar-mode) ;; defers the loading.
|
||||
:config
|
||||
(setq org-superstar-leading-bullet " ·") ;; " ․" " ·" " ⚫" or to hide: ?\s
|
||||
(setq org-superstar-prettify-item-bullets t) ;; can cause slowdown when using a lot of lists (thousands), run command org-superstar-toggle-lightweight-list or set this variable to nil or see hack on the source web page
|
||||
(setq org-superstar-remove-leading-stars nil) ;; to remove the indentation
|
||||
(setq org-superstar-special-todo-items t) ;; using symbols defined in org-superstar-todo-bullet-alist
|
||||
;; (setq org-superstar-todo-bullet-alist
|
||||
;; '(("TODO" . 9744)
|
||||
;; ("WAIT" . 9744)
|
||||
;; ("DONE" . 9745)
|
||||
;; ("CANC" . 9745)))
|
||||
(setq org-superstar-todo-bullet-alist
|
||||
'(("TODO" . 9744)
|
||||
("WAIT" . 9744)
|
||||
("DONE" . 9744)
|
||||
("CANC" . 9744)))
|
||||
(set-face-attribute 'org-superstar-leading nil :foreground "#42444a")) ;; "#42444a"
|
||||
|
||||
(use-package org-table
|
||||
:defer t
|
||||
:config
|
||||
(setq org-table-convert-region-max-lines 9999))
|
||||
|
||||
(use-package org-table-sticky-header
|
||||
:after (org)
|
||||
:delight (org-table-sticky-header-mode "Ⓣ") ;; Ⓞt OTSH
|
||||
:hook (org-mode . org-table-sticky-header-mode)) ;; must be set before org-sticky-header-mode, maybe orgtbl-show-header can also be used
|
||||
|
||||
(use-package org-tempo ;; expand <s to a src block, ...
|
||||
:after (org))
|
||||
|
||||
(use-package ob-core
|
||||
:defer t
|
||||
@@ -507,6 +588,26 @@ Updating an old preamble.org should remove this warning."))
|
||||
(t "_dark"))
|
||||
".svg")))
|
||||
|
||||
(use-package ob-async ;; https://melpa.org/#/ob-async execute src blocks async, insert in block header (without argument) :async
|
||||
:after (org))
|
||||
|
||||
(use-package ob-csharp
|
||||
:after (org))
|
||||
|
||||
(use-package ob-ditaa
|
||||
:defer t
|
||||
:config
|
||||
;; org-ditaa-jar-path (car (directory-files "/usr/share/java/ditaa" 'full "[.]*.jar" #'file-newer-than-file-p))
|
||||
;; config to change from a ditaa.jar file to a ditaa executable file
|
||||
;; org-babel-ditaa-java-cmd "" ; default is "java". set to "" because system ditaa executable includes java
|
||||
;; org-babel-default-header-args:ditaa ; default is ((:results . "file") (:exports . "results") (:java . "-Dfile.encoding=UTF-8"))
|
||||
;; '((:results . "file")
|
||||
;; (:exports . "results"))
|
||||
;; org-ditaa-jar-option "" ; default is "-jar". set to "" because system ditaa executable includes -jar
|
||||
;; org-ditaa-jar-path (concat "" (executable-find "ditaa"))
|
||||
;; TODO: find file e.g. (shell-command "cat `which ditaa`") or (shell-command "ls /usr/share/java/ditaa")
|
||||
(setq org-ditaa-jar-path "/usr/share/java/ditaa/ditaa-0.11.jar"))
|
||||
|
||||
(use-package ob-gnuplot
|
||||
:defer t
|
||||
:config
|
||||
@@ -643,26 +744,6 @@ usage: #+HEADER: :prologue (mpl-prologue)
|
||||
(article-latex "")
|
||||
(t "import matplotlib.pyplot as plt;plt.style.use('dark_background');"))))
|
||||
|
||||
(use-package ob-ditaa
|
||||
:defer t
|
||||
:config
|
||||
;; org-ditaa-jar-path (car (directory-files "/usr/share/java/ditaa" 'full "[.]*.jar" #'file-newer-than-file-p))
|
||||
;; config to change from a ditaa.jar file to a ditaa executable file
|
||||
;; org-babel-ditaa-java-cmd "" ; default is "java". set to "" because system ditaa executable includes java
|
||||
;; org-babel-default-header-args:ditaa ; default is ((:results . "file") (:exports . "results") (:java . "-Dfile.encoding=UTF-8"))
|
||||
;; '((:results . "file")
|
||||
;; (:exports . "results"))
|
||||
;; org-ditaa-jar-option "" ; default is "-jar". set to "" because system ditaa executable includes -jar
|
||||
;; org-ditaa-jar-path (concat "" (executable-find "ditaa"))
|
||||
;; TODO: find file e.g. (shell-command "cat `which ditaa`") or (shell-command "ls /usr/share/java/ditaa")
|
||||
(setq org-ditaa-jar-path "/usr/share/java/ditaa/ditaa-0.11.jar"))
|
||||
|
||||
(use-package ob-csharp
|
||||
:after (org))
|
||||
|
||||
(use-package ob-async ;; https://melpa.org/#/ob-async execute src blocks async, insert in block header (without argument) :async
|
||||
:after (org))
|
||||
|
||||
(use-package ol-notmuch
|
||||
:after (org))
|
||||
|
||||
@@ -804,87 +885,6 @@ usage: #+HEADER: :prologue (mpl-prologue)
|
||||
src=\"%PATH\"></script>")
|
||||
)
|
||||
|
||||
(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
|
||||
"<!-- %s --><!-- %s -->")))
|
||||
(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 <b>done</b>."
|
||||
: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 "<pre class=\"example\"%s>\n%s</pre>" label code)
|
||||
(format "<div class=\"org-src-container\">\n%s%s\n</div>"
|
||||
;; Build caption.
|
||||
(let ((caption (org-export-get-caption src-block)))
|
||||
(if (not caption) ""
|
||||
(let ((listing-number
|
||||
(format
|
||||
"<span class=\"listing-number\">%s </span>"
|
||||
(format
|
||||
(org-html--translate "Listing %d:" info)
|
||||
(org-export-get-ordinal
|
||||
src-block info nil #'org-html--has-caption-p)))))
|
||||
(format "<label class=\"org-src-name\">%s%s</label>"
|
||||
listing-number
|
||||
(org-trim (org-export-data caption info))))))
|
||||
;; Contents.
|
||||
(if klipsify
|
||||
(format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>"
|
||||
lang
|
||||
label
|
||||
(if (string= lang "html")
|
||||
" data-editor-type=\"html\""
|
||||
"")
|
||||
code)
|
||||
(format "<pre class=\"src src-%s\"%s>%s</pre>"
|
||||
lang label code))))))))
|
||||
|
||||
(use-package ox-latex
|
||||
:defer t ;; will be loaded via `org-export-backends' see above inside `org'
|
||||
:config
|
||||
@@ -1207,64 +1207,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
|
||||
"<!-- %s --><!-- %s -->")))
|
||||
(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 <b>done</b>."
|
||||
: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 "<pre class=\"example\"%s>\n%s</pre>" label code)
|
||||
(format "<div class=\"org-src-container\">\n%s%s\n</div>"
|
||||
;; Build caption.
|
||||
(let ((caption (org-export-get-caption src-block)))
|
||||
(if (not caption) ""
|
||||
(let ((listing-number
|
||||
(format
|
||||
"<span class=\"listing-number\">%s </span>"
|
||||
(format
|
||||
(org-html--translate "Listing %d:" info)
|
||||
(org-export-get-ordinal
|
||||
src-block info nil #'org-html--has-caption-p)))))
|
||||
(format "<label class=\"org-src-name\">%s%s</label>"
|
||||
listing-number
|
||||
(org-trim (org-export-data caption info))))))
|
||||
;; Contents.
|
||||
(if klipsify
|
||||
(format "<pre><code class=\"src src-%s\"%s%s>%s</code></pre>"
|
||||
lang
|
||||
label
|
||||
(if (string= lang "html")
|
||||
" data-editor-type=\"html\""
|
||||
"")
|
||||
code)
|
||||
(format "<pre class=\"src src-%s\"%s>%s</pre>"
|
||||
lang label code))))))))
|
||||
|
||||
;; Allows you to edit entries directly from org-brain-visualize
|
||||
(use-package polymode
|
||||
|
||||
Reference in New Issue
Block a user