General refactors & reformatting across the board
This commit is contained in:
parent
4e28b48a3a
commit
ea18c83c0a
19 changed files with 123 additions and 110 deletions
|
@ -46,11 +46,15 @@ exist, and `org-link' otherwise."
|
|||
"Intepret LINK as an image file path and return its data."
|
||||
(setq
|
||||
link (expand-file-name
|
||||
link
|
||||
(pcase protocol
|
||||
("download" (or org-download-image-dir org-attach-id-dir default-directory))
|
||||
("attachment" org-attach-id-dir)
|
||||
(_ default-directory))))
|
||||
link (pcase protocol
|
||||
("download"
|
||||
(or (if (require 'org-download nil t) org-download-image-dir)
|
||||
(if (require 'org-attach) org-attach-id-dir)
|
||||
default-directory))
|
||||
("attachment"
|
||||
(require 'org-attach)
|
||||
org-attach-id-dir)
|
||||
(_ default-directory))))
|
||||
(when (and (file-exists-p link)
|
||||
(image-type-from-file-name link))
|
||||
(with-temp-buffer
|
||||
|
|
|
@ -141,7 +141,7 @@ current file). Only scans first 2048 bytes of the document."
|
|||
;;; Commands
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/dwim-at-point ()
|
||||
(defun +org/dwim-at-point (&optional arg)
|
||||
"Do-what-I-mean at point.
|
||||
|
||||
If on a:
|
||||
|
@ -158,7 +158,7 @@ If on a:
|
|||
- latex fragment: toggle it.
|
||||
- link: follow it
|
||||
- otherwise, refresh all inline images in current tree."
|
||||
(interactive)
|
||||
(interactive "P")
|
||||
(let* ((context (org-element-context))
|
||||
(type (org-element-type context)))
|
||||
;; skip over unimportant contexts
|
||||
|
@ -206,7 +206,7 @@ If on a:
|
|||
|
||||
(`table-cell
|
||||
(org-table-blank-field)
|
||||
(org-table-recalculate)
|
||||
(org-table-recalculate arg)
|
||||
(when (and (string-empty-p (string-trim (org-table-get-field)))
|
||||
(bound-and-true-p evil-local-mode))
|
||||
(evil-change-state 'insert)))
|
||||
|
@ -215,13 +215,13 @@ If on a:
|
|||
(org-babel-lob-execute-maybe))
|
||||
|
||||
(`statistics-cookie
|
||||
(save-excursion (org-update-statistics-cookies nil)))
|
||||
(save-excursion (org-update-statistics-cookies arg)))
|
||||
|
||||
((or `src-block `inline-src-block)
|
||||
(org-babel-execute-src-block))
|
||||
(org-babel-execute-src-block arg))
|
||||
|
||||
((or `latex-fragment `latex-environment)
|
||||
(org-latex-preview))
|
||||
(org-latex-preview arg))
|
||||
|
||||
(`link
|
||||
(let* ((lineage (org-element-lineage context '(link) t))
|
||||
|
@ -229,7 +229,7 @@ If on a:
|
|||
(if (or (equal (org-element-property :type lineage) "img")
|
||||
(and path (image-type-from-file-name path)))
|
||||
(+org--refresh-inline-images-in-subtree)
|
||||
(org-open-at-point))))
|
||||
(org-open-at-point arg))))
|
||||
|
||||
((guard (org-element-property :checkbox (org-element-lineage context '(item) t)))
|
||||
(let ((match (and (org-at-item-checkbox-p) (match-string 1))))
|
||||
|
@ -238,7 +238,7 @@ If on a:
|
|||
(_
|
||||
(if (or (org-in-regexp org-ts-regexp-both nil t)
|
||||
(org-in-regexp org-tsr-regexp-both nil t)
|
||||
(org-in-regexp org-any-link-re nil t))
|
||||
(org-in-regexp org-link-any-re nil t))
|
||||
(call-interactively #'org-open-at-point)
|
||||
(+org--refresh-inline-images-in-subtree))))))
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ This forces it to read the background before rendering."
|
|||
("HOLD" . +org-todo-onhold)
|
||||
("PROJ" . +org-todo-project)))
|
||||
|
||||
(defadvice! +org-display-link-in-eldoc-a (&rest args)
|
||||
(defadvice! +org-display-link-in-eldoc-a (&rest _)
|
||||
"Display full link in minibuffer when cursor/mouse is over it."
|
||||
:before-until #'org-eldoc-documentation-function
|
||||
(when-let (link (org-element-property :raw-link (org-element-context)))
|
||||
|
@ -196,10 +196,10 @@ This forces it to read the background before rendering."
|
|||
;; I prefer C-c C-c over C-c ' (more consistent)
|
||||
(define-key org-src-mode-map (kbd "C-c C-c") #'org-edit-src-exit)
|
||||
|
||||
(defadvice! +org-fix-newline-and-indent-in-src-blocks-a ()
|
||||
(defadvice! +org-fix-newline-and-indent-in-src-blocks-a (&optional indent _arg _interactive)
|
||||
"Mimic `newline-and-indent' in src blocks w/ lang-appropriate indentation."
|
||||
:after #'org-return-indent
|
||||
(when (org-in-src-block-p t)
|
||||
:after #'org-return
|
||||
(when (and indent (org-in-src-block-p t))
|
||||
(org-babel-do-in-edit-buffer
|
||||
(call-interactively #'indent-for-tab-command))))
|
||||
|
||||
|
@ -916,8 +916,8 @@ compelling reason, so..."
|
|||
:ni "C-S-k" #'org-shiftup
|
||||
:ni "C-S-j" #'org-shiftdown
|
||||
;; more intuitive RET keybinds
|
||||
:i [return] #'org-return-indent
|
||||
:i "RET" #'org-return-indent
|
||||
:i [return] (λ! (org-return t))
|
||||
:i "RET" (λ! (org-return t))
|
||||
:n [return] #'+org/dwim-at-point
|
||||
:n "RET" #'+org/dwim-at-point
|
||||
;; more vim-esque org motion keys (not covered by evil-org-mode)
|
||||
|
|
|
@ -41,19 +41,19 @@
|
|||
(defadvice! +org-present--narrow-to-subtree-a (orig-fn &rest args)
|
||||
"Narrow to the target subtree when you start the presentation."
|
||||
:around #'org-tree-slide--display-tree-with-narrow
|
||||
(letf! ((defun org-narrow-to-subtree ()
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(org-with-limited-levels
|
||||
(narrow-to-region
|
||||
(progn
|
||||
(when (org-before-first-heading-p)
|
||||
(org-next-visible-heading 1))
|
||||
(ignore-errors (org-up-heading-all 99))
|
||||
(forward-line 1)
|
||||
(point))
|
||||
(progn (org-end-of-subtree t t)
|
||||
(when (and (org-at-heading-p) (not (eobp)))
|
||||
(backward-char 1))
|
||||
(point))))))))
|
||||
(letf! (defun org-narrow-to-subtree ()
|
||||
(save-excursion
|
||||
(save-match-data
|
||||
(org-with-limited-levels
|
||||
(narrow-to-region
|
||||
(progn
|
||||
(when (org-before-first-heading-p)
|
||||
(org-next-visible-heading 1))
|
||||
(ignore-errors (org-up-heading-all 99))
|
||||
(forward-line 1)
|
||||
(point))
|
||||
(progn (org-end-of-subtree t t)
|
||||
(when (and (org-at-heading-p) (not (eobp)))
|
||||
(backward-char 1))
|
||||
(point)))))))
|
||||
(apply orig-fn args))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue