lang/org: reorganize autoload/org.el. Pedantry intensifies.
Library is now separated into alphabetically sorted sections. So nice and neat!
This commit is contained in:
parent
d84af58f77
commit
7b70aa9b7d
1 changed files with 92 additions and 78 deletions
|
@ -1,5 +1,18 @@
|
|||
;;; org/org/autoload/org.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-get-property (name &optional _file) ; TODO Add FILE
|
||||
"Get a propery from an org file."
|
||||
(save-excursion
|
||||
(goto-char 1)
|
||||
(re-search-forward (format "^#\\+%s:[ \t]*\\([^\n]+\\)" (upcase name)) nil t)
|
||||
(buffer-substring-no-properties (match-beginning 1) (match-end 1))))
|
||||
|
||||
|
||||
;;
|
||||
;; Modes
|
||||
;;
|
||||
|
||||
;;;###autoload
|
||||
(define-minor-mode +org-pretty-mode
|
||||
"TODO"
|
||||
|
@ -12,18 +25,10 @@
|
|||
;; In case the above un-align tables
|
||||
(org-table-map-tables 'org-table-align t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|realign-table-maybe ()
|
||||
"Auto-align table under cursor and re-calculate formulas."
|
||||
(when (org-at-table-p)
|
||||
(save-excursion
|
||||
(quiet! (org-table-recalculate)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|update-cookies ()
|
||||
"Update counts in headlines (aka \"cookies\")."
|
||||
(when (and buffer-file-name (file-exists-p buffer-file-name))
|
||||
(org-update-statistics-cookies t)))
|
||||
;;
|
||||
;; Commands
|
||||
;;
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/dwim-at-point ()
|
||||
|
@ -111,54 +116,6 @@ If on a:
|
|||
(_ (+org/refresh-inline-images)))
|
||||
(set-window-start nil scroll-pt)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|indent-maybe ()
|
||||
"Indent the current item (header or item), if possible. Made for
|
||||
`org-tab-first-hook'."
|
||||
(interactive)
|
||||
(cond ((org-at-item-p)
|
||||
(org-indent-item-tree)
|
||||
t)
|
||||
((org-at-heading-p)
|
||||
(ignore-errors (org-demote))
|
||||
t)
|
||||
((org-in-src-block-p t)
|
||||
(doom/dumb-indent)
|
||||
t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|yas-expand-maybe ()
|
||||
"Tries to expand a yasnippet snippet, if one is available. Made for
|
||||
`org-tab-first-hook'."
|
||||
(when (and (if (bound-and-true-p evil-mode)
|
||||
(eq evil-state 'insert)
|
||||
t)
|
||||
(bound-and-true-p yas-minor-mode)
|
||||
(yas--templates-for-key-at-point))
|
||||
(call-interactively #'yas-expand)
|
||||
t))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/shifttab (&optional arg)
|
||||
"An alternative to `org-shifttab' which performs smart indentation if in
|
||||
insert mode (evil). Otherwise, forwards to the original `org-shifttab'."
|
||||
(interactive)
|
||||
(cond ((org-at-table-p)
|
||||
(call-interactively #'org-table-previous-field))
|
||||
((and (bound-and-true-p evil-mode)
|
||||
(evil-insert-state-p))
|
||||
(cond ((org-at-item-p)
|
||||
(org-list-indent-item-generic
|
||||
-1 nil
|
||||
(save-excursion
|
||||
(when (org-region-active-p)
|
||||
(goto-char (region-beginning)))
|
||||
(org-list-struct))))
|
||||
((org-at-heading-p)
|
||||
(ignore-errors (org-promote)))
|
||||
(t (call-interactively #'self-insert-command))))
|
||||
(t (org-shifttab arg))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/insert-item (direction)
|
||||
"Inserts a new heading, table cell or item, depending on the context.
|
||||
|
@ -245,12 +202,25 @@ wrong places)."
|
|||
(evil-insert 1))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org-get-property (name &optional _file) ; TODO Add FILE
|
||||
"Get a propery from an org file."
|
||||
(defun +org/shifttab (&optional arg)
|
||||
"An alternative to `org-shifttab' which performs smart indentation if in
|
||||
insert mode (evil). Otherwise, forwards to the original `org-shifttab'."
|
||||
(interactive)
|
||||
(cond ((org-at-table-p)
|
||||
(call-interactively #'org-table-previous-field))
|
||||
((and (bound-and-true-p evil-mode)
|
||||
(evil-insert-state-p))
|
||||
(cond ((org-at-item-p)
|
||||
(org-list-indent-item-generic
|
||||
-1 nil
|
||||
(save-excursion
|
||||
(goto-char 1)
|
||||
(re-search-forward (format "^#\\+%s:[ \t]*\\([^\n]+\\)" (upcase name)) nil t)
|
||||
(buffer-substring-no-properties (match-beginning 1) (match-end 1))))
|
||||
(when (org-region-active-p)
|
||||
(goto-char (region-beginning)))
|
||||
(org-list-struct))))
|
||||
((org-at-heading-p)
|
||||
(ignore-errors (org-promote)))
|
||||
(t (call-interactively #'self-insert-command))))
|
||||
(t (org-shifttab arg))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/refresh-inline-images ()
|
||||
|
@ -267,6 +237,20 @@ wrong places)."
|
|||
(line-end-position)
|
||||
(save-excursion (org-end-of-subtree) (point))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/remove-link ()
|
||||
"Unlink the text at point."
|
||||
(interactive)
|
||||
(unless (org-in-regexp org-bracket-link-regexp 1)
|
||||
(user-error "No link at point"))
|
||||
(save-excursion
|
||||
(let ((remove (list (match-beginning 0) (match-end 0)))
|
||||
(description (if (match-end 3)
|
||||
(match-string-no-properties 3)
|
||||
(match-string-no-properties 1))))
|
||||
(apply #'delete-region remove)
|
||||
(insert description))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/toggle-checkbox ()
|
||||
"Toggle the presence of a checkbox in the current item."
|
||||
|
@ -294,17 +278,47 @@ with `org-cycle'). Also:
|
|||
(org-cycle)
|
||||
(set-window-start nil window-beg))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org/remove-link ()
|
||||
"Unlink the text at point."
|
||||
(interactive)
|
||||
(unless (org-in-regexp org-bracket-link-regexp 1)
|
||||
(user-error "No link at point"))
|
||||
(save-excursion
|
||||
(let ((remove (list (match-beginning 0) (match-end 0)))
|
||||
(description (if (match-end 3)
|
||||
(match-string-no-properties 3)
|
||||
(match-string-no-properties 1))))
|
||||
(apply #'delete-region remove)
|
||||
(insert description))))
|
||||
|
||||
;;
|
||||
;; Hooks
|
||||
;;
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|indent-maybe ()
|
||||
"Indent the current item (header or item), if possible. Made for
|
||||
`org-tab-first-hook'."
|
||||
(interactive)
|
||||
(cond ((org-at-item-p)
|
||||
(org-indent-item-tree)
|
||||
t)
|
||||
((org-at-heading-p)
|
||||
(ignore-errors (org-demote))
|
||||
t)
|
||||
((org-in-src-block-p t)
|
||||
(doom/dumb-indent)
|
||||
t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|realign-table-maybe ()
|
||||
"Auto-align table under cursor and re-calculate formulas."
|
||||
(when (org-at-table-p)
|
||||
(save-excursion
|
||||
(quiet! (org-table-recalculate)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|update-cookies ()
|
||||
"Update counts in headlines (aka \"cookies\")."
|
||||
(when (and buffer-file-name (file-exists-p buffer-file-name))
|
||||
(org-update-statistics-cookies t)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +org|yas-expand-maybe ()
|
||||
"Tries to expand a yasnippet snippet, if one is available. Made for
|
||||
`org-tab-first-hook'."
|
||||
(when (and (if (bound-and-true-p evil-mode)
|
||||
(eq evil-state 'insert)
|
||||
t)
|
||||
(bound-and-true-p yas-minor-mode)
|
||||
(yas--templates-for-key-at-point))
|
||||
(call-interactively #'yas-expand)
|
||||
t))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue