aboutsummaryrefslogtreecommitdiff
path: root/emacs/.emacs.d/lisp/my
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-09-02 13:45:55 +1000
committerYuchen Pei <id@ypei.org>2023-09-02 13:45:55 +1000
commit7e6e98e5683f2b0d8d335f53100b6b3623823df3 (patch)
treecc84f2590da859003ebec0562eee42cd1122b847 /emacs/.emacs.d/lisp/my
parente07a2aee70031e7d4b1c43208867e1e716209a53 (diff)
A few more org utilities, and small fixes in editing / goto places
added my-org-swap-referral-with-headline added my-org-clean-up-entry fixed avy binding org capture todo: contain initial content (if any) in an example block
Diffstat (limited to 'emacs/.emacs.d/lisp/my')
-rw-r--r--emacs/.emacs.d/lisp/my/my-org.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/emacs/.emacs.d/lisp/my/my-org.el b/emacs/.emacs.d/lisp/my/my-org.el
index 334f708..1a44a10 100644
--- a/emacs/.emacs.d/lisp/my/my-org.el
+++ b/emacs/.emacs.d/lisp/my/my-org.el
@@ -1120,6 +1120,39 @@ When BLOCK-REGEXP is non-nil, use this regexp to find blocks."
(list "ITEM" "Referral" "Wikipedia-link" "IMDB-link")))
"\t"))
+(defun my-org-swap-referral-with-headline ()
+ "Swap Referral property with headline of org node at point.
+
+Remove the Referral property if empty."
+ (interactive)
+ (let ((ref (or (org-entry-get (point) "Referral") ""))
+ (headline (org-entry-get (point) "ITEM")))
+ (if (string-empty-p headline)
+ (org-delete-property "Referral")
+ (org-entry-put (point) "Referral" headline))
+ (org-edit-headline ref)))
+
+(defun my-org-clean-up-entry ()
+ "Clean up an org entry.
+
+Delete empty standard properties.
+Sync attachment.
+Remove trailing whitespaces.
+Flush lines with only some common symbols."
+ (interactive)
+ (my-org-delete-empty-properties)
+ (org-attach-sync)
+ (save-restriction
+ (org-narrow-to-subtree)
+ (flush-lines "^[ \t-]*$")
+ (delete-trailing-whitespace)))
+
+(defun my-org-delete-empty-properties ()
+ "Delete empty (standard) properties at point."
+ (interactive)
+ (pcase-dolist (`(,name . ,value) (org-entry-properties (point) 'standard))
+ (when (string-empty-p value) (org-entry-delete (point) name))))
+
(defvar org-entries-tsv-buffer "*org-entries-tsv*")
(defun my-org-entries-at-point-to-tsv (beg end)
(interactive "r")