aboutsummaryrefslogtreecommitdiff
path: root/modules/dirvish-config.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-12 12:49:33 -0500
committerCraig Jennings <c@cjennings.net>2026-05-12 12:49:33 -0500
commita15c6b3e92b8d7be6be6dc4dd6802a18ccf52326 (patch)
tree1d1c1f01f006d571aecfa0786d248d1c411c99be /modules/dirvish-config.el
parent162d52dfc5a401c95dcbb6f5630d4373568a70e6 (diff)
downloaddotemacs-a15c6b3e92b8d7be6be6dc4dd6802a18ccf52326.tar.gz
dotemacs-a15c6b3e92b8d7be6be6dc4dd6802a18ccf52326.zip
feat(dirvish): start org-drill on the .org file at point with S
`S` ("study") in `dirvish-mode-map` opens the `.org` file at point and runs `cj/drill-this-file` on it, so I can drill any deck straight from the file list. It `user-error`s on no file, on a directory, or on a non-`.org` file. `D` and `O` were already taken (duplicate-file, open-with-command), so I went with `S`. It shadows dired's `dired-do-symlink`, which I never use from dirvish and which stays on `M-x` anyway. New `tests/test-dirvish-config-drill.el`: 6 ERT tests with `dired-get-filename`, `find-file`, and `cj/drill-this-file` mocked. I also fixed the stale `P` line in the module commentary — `P` is the print command now, not copy-path.
Diffstat (limited to 'modules/dirvish-config.el')
-rw-r--r--modules/dirvish-config.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el
index b25baca9..5f5ca7fc 100644
--- a/modules/dirvish-config.el
+++ b/modules/dirvish-config.el
@@ -16,7 +16,8 @@
;; - o/O: Open file with xdg-open/custom command
;; - l: Copy org-link with relative file path (project-relative or home-relative)
;; - p: Copy absolute file path
-;; - P: Copy relative file path (project-relative or home-relative)
+;; - P: Print the file at point via CUPS
+;; - S: Study — start an org-drill session on the .org file at point
;; - M-S-d (Meta-Shift-d): DWIM shell commands menu
;; - TAB: Toggle subtree expansion
;; - F11: Toggle sidebar view
@@ -29,6 +30,8 @@
(require 'system-lib)
(require 'external-open-lib)
+(declare-function cj/drill-this-file "org-drill-config")
+
;; mark files in dirvish, attach in mu4e
(add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode)
@@ -291,6 +294,18 @@ Shadows dired's `P' (`dired-do-print') with this type-aware version."
(user-error "Print failed (exit %d)%s" code
(if (string-empty-p out) "" (concat ": " out))))))))))
+;;; ------------------------------ Dirvish Drill File ---------------------------
+
+(defun cj/dirvish-drill-file ()
+ "Open the Org file at point and start an `org-drill' session on it.
+Bound to `S' (\"study\") in `dirvish-mode-map'; refuses anything but a `.org' file."
+ (interactive)
+ (let ((file (dired-get-filename nil t)))
+ (unless (and file (not (file-directory-p file)) (string-suffix-p ".org" file t))
+ (user-error "Not an Org file at point"))
+ (find-file file)
+ (cj/drill-this-file)))
+
;;; ----------------------- Dirvish Open File Manager Here ----------------------
(defun cj/dirvish-open-file-manager-here ()
@@ -469,6 +484,7 @@ Uses feh on X11, swww on Wayland."
("p" . (lambda () (interactive) (cj/dired-copy-path-as-kill nil t)))
("P" . cj/dirvish-print-file)
("r" . dirvish-rsync)
+ ("S" . cj/dirvish-drill-file) ; Study: org-drill the .org file at point
("s" . dirvish-quicksort)
("v" . dirvish-vc-menu)
("y" . dirvish-yank-menu)))