aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaúl Benencia <id@rbenencia.name>2024-05-16 08:33:58 -0700
committerRaúl Benencia <id@rbenencia.name>2024-05-16 08:34:33 -0700
commit9c6bbe78d116a1ffd24245621853d6ff6f2ac1f7 (patch)
treef5989450305e1e0d91a2eefbf5ebaae04b865e66
parent1126674db3382ce0323a5e4081a79d2c6137ae60 (diff)
emacs: delete-frame-after-capture
-rw-r--r--.emacs.d/rul-lisp/packages/rul-org.el29
1 files changed, 25 insertions, 4 deletions
diff --git a/.emacs.d/rul-lisp/packages/rul-org.el b/.emacs.d/rul-lisp/packages/rul-org.el
index bced45c..3e796e3 100644
--- a/.emacs.d/rul-lisp/packages/rul-org.el
+++ b/.emacs.d/rul-lisp/packages/rul-org.el
@@ -84,16 +84,37 @@
("L" "Web Link" entry
(file+headline org-refile-path "Read later")
- "* %?[[%:link][%:description]]\n %:initial\n")
+ "* %?[[%:link][%:description]] %(progn (setq rul/delete-frame-after-capture 1) \"\")\n %:initial\n \nCaptured On: %U")
("l" "Web Link with Selection" entry
(file+headline org-refile-path "Read later")
- "* [[%:link][%:description]]%?\n %:initial\n")
+ "* [[%:link][%:description]] %(progn (setq rul/delete-frame-after-capture 1) \"\")\n %:initial\n \nCaptured On: %U")
)))
-(add-hook 'org-capture-mode-hook 'delete-other-windows)
-
+(defvar rul/delete-frame-after-capture 0 "Whether to delete the last frame after the current capture")
+
+(defun rul/delete-frame-if-necessary ()
+ "Delete the last frame if necessary."
+ (cond
+ ((= rul/delete-frame-after-capture 0) nil)
+ ((> rul/delete-frame-after-capture 1)
+ (setq rul/delete-frame-after-capture (- rul/delete-frame-after-capture 1)))
+ (t
+ (setq rul/delete-frame-after-capture 0)
+ (delete-frame))))
+
+(defun rul/org-capture-before ()
+ "Function to run before org capture."
+ (setq rul/delete-frame-after-capture (1+ rul/delete-frame-after-capture)))
+
+(defun rul/org-capture-after ()
+ "Function to run after org capture."
+ (rul/delete-frame-if-necessary))
+
+(advice-add 'org-capture-finalize :after 'rul/delete-frame-if-necessary)
+(advice-add 'org-capture-kill :after 'rul/delete-frame-if-necessary)
+(advice-add 'org-capture-refile :after 'rul/delete-frame-if-necessary)
;; REFILE ;;
nihil fit ex nihilo