From 7ff3b9b69fe7cb726acadfa81f6a076be8b2af78 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Tue, 25 Jul 2023 10:17:11 +1000 Subject: some minor fixes --- emacs/.emacs.d/lisp/my/my-org.el | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'emacs/.emacs.d/lisp/my/my-org.el') diff --git a/emacs/.emacs.d/lisp/my/my-org.el b/emacs/.emacs.d/lisp/my/my-org.el index e03a91d..0fb7d9e 100644 --- a/emacs/.emacs.d/lisp/my/my-org.el +++ b/emacs/.emacs.d/lisp/my/my-org.el @@ -1182,5 +1182,23 @@ When BLOCK-REGEXP is non-nil, use this regexp to find blocks." (when (derived-mode-p 'prog-mode) (number-to-string (org-current-line)))) +;; override `org-capture-set-plist' +(defun my-org-capture-set-plist (entry) + "Initialize the property list for ENTRY from the template definition." + (setq org-capture-plist (copy-sequence (nthcdr 5 entry))) + (org-capture-put :key (car entry) :description (nth 1 entry) + :target (nth 3 entry)) + (let ((txt (nth 4 entry)) (type (or (nth 2 entry) 'entry))) + (when (or (not txt) (and (stringp txt) (not (string-match "\\S-" txt)))) + ;; The template may be empty or omitted for special types. + ;; Here we insert the default templates for such cases. + (cond + ((eq type 'item) (setq txt "- %?")) + ((eq type 'checkitem) (setq txt "- [ ] %?")) + ((eq type 'table-line) (setq txt "| %? |")) + ;; >>> the overriding difference + ((member type '(nil entry)) (setq txt "* %?")))) + (org-capture-put :template txt :type type))) + (provide 'my-org) ;;; my-org.el ends here -- cgit v1.2.3