diff --git a/config.org b/config.org index 4b79340..8de0644 100644 --- a/config.org +++ b/config.org @@ -2849,7 +2849,9 @@ Org uses many popup windows for various things, and we can use Doom to make them While Org-mode provides a very comprehensive set of tools and systems, there are a few small things that are missing or that would make the overall UX smoother. Luckily, Org-mode being implemented as an Emacs package gives us more than enough control over its function to crowbar in a few new features! -*** Archive Restore +*** Archiving + +**** Archive Restore Org offers a wonderfully useful trash system called archiving, which lets you move subtrees into a file where they can be saved without permanently deleting them. However, there's no system for automatically restoring these subtrees once they're archived! @@ -2903,6 +2905,32 @@ the attachment cannot be restored!" (message "Restored \"%s\" to file %s" title file))) #+end_src +**** File Archive + +Currently, there only exists capabilities to archive a subtree, not an entire file. This matters for me because I often want to remove Org Roam files so that they don't clutter up the database and bog down my agenda. As a quick hacky way to implement this, we can just rename the file to make it look like an archive file. + +#+begin_src emacs-lisp +(defun org-archive-file (file) + "Archive the entire Org file FILE by renaming it to an org_archive file. + +Interactively, this operates on the current buffer. With a prefix arg, +prompt for a file instead." + (interactive (list (if current-prefix-arg + (read-file-name "Archive file: " nil nil t) + (buffer-file-name (buffer-base-buffer))))) + (find-file file) + (widen) + (let ((archive (car (org-archive--compute-location org-archive-location)))) + (if (file-exists-p archive) + (progn + (goto-char (point-min)) + (insert "\n# Final contents:\n\n") + (append-to-file (point-min) (point-max) archive)) + (add-file-local-variable-prop-line 'mode 'org) + (write-file archive)) + (doom/delete-this-file nil t))) +#+end_src + *** Todo Date Overriding My attention span being what it is, I often forget to update TODO entries in my Org files until long after the task has been completed. I rely heavily on tracking TODOs through timestamps, so it would be nice to have a command to specify the time to log the task as being completed at. To do this, we can create a new variable ~org-todo-time~ that will override the time when set.