diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-25 14:37:40 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-25 14:37:40 -0500 |
| commit | a5555afaf09be4c023f49661d48de803b2586927 (patch) | |
| tree | 78625656fea7df312ed9a4467e2e899433e16998 /modules/org-refile-config.el | |
| parent | 80de20b443c7a3cbc9283bb64380539d80c61cf8 (diff) | |
re-organized org modules using use-package + maintenance work
- updated packages
- removed :after org-contrib references
- added ob-awk, sed, scheme, and shell backends
- make v play with mpv in elfeed search mode map
- added abbrevs
Diffstat (limited to 'modules/org-refile-config.el')
| -rw-r--r-- | modules/org-refile-config.el | 118 |
1 files changed, 57 insertions, 61 deletions
diff --git a/modules/org-refile-config.el b/modules/org-refile-config.el index 3f71d91d..f36af000 100644 --- a/modules/org-refile-config.el +++ b/modules/org-refile-config.el @@ -1,81 +1,77 @@ ;;; org-refile-config.el --- Org Refile Customizations -*- lexical-binding: t; -*- ;;; Commentary: -;; +;; Configuration and custom functions for org-mode refiling. ;;; Code: -(use-package org-refile - :ensure nil ;; built-in - :defer .5 - :bind - (:map org-mode-map - ("C-c C-w" . cj/org-refile) - ("C-c w" . cj/org-refile-in-file)) - :config - - ;; ----------------------------- Org Refile Targets ---------------------------- - ;; sets refile targets - ;; - adds project files in org-roam to the refile targets - ;; - adds todo.org files in subdirectories of the code and project directories - - (defun cj/build-org-refile-targets() - "Build org-refile-targets." - (interactive) - (let (new-files) - ;; Start with the inbox and the schedule files. - (setq new-files `((,inbox-file . (:maxlevel . 1)) (,schedule-file . (:maxlevel . 1)))) - - ;; Extend new-files with the project and topic files. - (let ((project-and-topic-files (append (cj/org-roam-list-notes-by-tag "Project") - (cj/org-roam-list-notes-by-tag "Topic")))) +;; ----------------------------- Org Refile Targets ---------------------------- +;; sets refile targets +;; - adds project files in org-roam to the refile targets +;; - adds todo.org files in subdirectories of the code and project directories + +(defun cj/build-org-refile-targets() + "Build org-refile-targets." + (interactive) + (let (new-files) + ;; Start with the inbox and the schedule files. + (setq new-files `((,inbox-file . (:maxlevel . 1)) (,schedule-file . (:maxlevel . 1)))) + + ;; Extend new-files with the project and topic files. + (let ((project-and-topic-files (append (cj/org-roam-list-notes-by-tag "Project") + (cj/org-roam-list-notes-by-tag "Topic")))) + (let ((file-rule `(:level . 1))) + (dolist (file project-and-topic-files) + (unless (assoc file new-files) + (push `(,file . ,file-rule) new-files))))) + + ;; Extend new-files with todo.org files in the specified directories. + (dolist (dir (list user-emacs-directory code-dir projects-dir)) + (let ((todo-files (directory-files-recursively dir "^[Tt][Oo][Dd][Oo]\\.[Oo][Rr][Gg]$"))) (let ((file-rule `(:level . 1))) - (dolist (file project-and-topic-files) + (dolist (file todo-files) (unless (assoc file new-files) - (push `(,file . ,file-rule) new-files))))) - - ;; Extend new-files with todo.org files in the specified directories. - (dolist (dir (list user-emacs-directory code-dir projects-dir)) - (let ((todo-files (directory-files-recursively dir "^[Tt][Oo][Dd][Oo]\\.[Oo][Rr][Gg]$"))) - (let ((file-rule `(:level . 1))) - (dolist (file todo-files) - (unless (assoc file new-files) - (push `(,file . ,file-rule) new-files)))))) + (push `(,file . ,file-rule) new-files)))))) - ;; Set org-refile-targets. - (setq org-refile-targets (nreverse new-files)))) + ;; Set org-refile-targets. + (setq org-refile-targets (nreverse new-files)))) - ;; -------------------------------- Org-Refile ------------------------------- - ;; used in place of org-refile to ensure the refile targets are rebuilt. +;; -------------------------------- Org-Refile ------------------------------- +;; used in place of org-refile to ensure the refile targets are rebuilt. - (defun cj/org-refile (&optional ARG DEFAULT-BUFFER RFLOC MSG) - "Simply rebuilds the refile targets before calling org-refile. +(defun cj/org-refile (&optional ARG DEFAULT-BUFFER RFLOC MSG) + "Simply rebuilds the refile targets before calling org-refile. ARG DEFAULT-BUFFER RFLOC and MSG parameters passed to org-refile." - (interactive "P") - (cj/build-org-refile-targets) - (org-refile ARG DEFAULT-BUFFER RFLOC MSG)) + (interactive "P") + (cj/build-org-refile-targets) + (org-refile ARG DEFAULT-BUFFER RFLOC MSG)) - ;; ----------------------------- Org Refile In File ---------------------------- - ;; convenience function for scoping the refile candidates to the current buffer. +;; ----------------------------- Org Refile In File ---------------------------- +;; convenience function for scoping the refile candidates to the current buffer. - (defun cj/org-refile-in-file () - "Refile to a target within the current file and save the buffer." - (interactive) - (let ((org-refile-targets `(((,(buffer-file-name)) :maxlevel . 6)))) - (call-interactively 'org-refile) - (save-buffer))) +(defun cj/org-refile-in-file () + "Refile to a target within the current file and save the buffer." + (interactive) + (let ((org-refile-targets `(((,(buffer-file-name)) :maxlevel . 6)))) + (call-interactively 'org-refile) + (save-buffer))) - ) ; end use-package statement - - -;; ----------------------- Save Org Files After Refile ----------------------- -;; advice that saves all open org buffers after a refile is complete - -(advice-add 'org-refile :after - (lambda (&rest _) - (org-save-all-org-buffers))) +;; --------------------------------- Org Refile -------------------------------- +;; +(use-package org-refile + :ensure nil ;; built-in + :defer .5 + :bind + (:map org-mode-map + ("C-c C-w" . cj/org-refile) + ("C-c w" . cj/org-refile-in-file)) + :config + ;; save all open org buffers after a refile is complete + (advice-add 'org-refile :after + (lambda (&rest _) + (org-save-all-org-buffers)))) (provide 'org-refile-config) ;;; org-refile-config.el ends here. |
