diff options
| author | BardofSprites <[email protected]> | 2026-01-30 07:48:40 -0500 |
|---|---|---|
| committer | BardofSprites <[email protected]> | 2026-01-30 07:48:40 -0500 |
| commit | 02b05dcfd540f1de76fda833fe18d50e9e76a74a (patch) | |
| tree | dc00ec1cf103db994fd943c3259249de920451ed /bard-elisp | |
| parent | 5bd1310456d6bee510c431882a625c27fba5db2e (diff) | |
optionally open class-dir in dired
Diffstat (limited to 'bard-elisp')
| -rw-r--r-- | bard-elisp/bard-writing.el | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/bard-elisp/bard-writing.el b/bard-elisp/bard-writing.el index fcf2762..cf66650 100644 --- a/bard-elisp/bard-writing.el +++ b/bard-elisp/bard-writing.el @@ -50,44 +50,44 @@ (defvar bard/uni-notes-file "~/Notes/denote/uni.org" "Path to the main university org file.") -(defun bard/jump-to-class (class) - "Jump to CLASS heading in `bard/uni-notes-file` and open its dir in dired." +(defun bard/jump-to-class (class &optional with-dired) + "Jump to CLASS heading in bard/uni-notes-file, can open its dir in Dired". (interactive - (list (completing-read "Class: " (mapcar #'car bard/class-dirs)))) - (let* ((dir (cdr (assoc class bard/class-dirs)))) - ;; split windows + (list + (completing-read "Class: " (mapcar #'car bard/class-dirs)) + current-prefix-arg)) + (let ((dir (cdr (assoc class bard/class-dirs)))) (delete-other-windows) - (let ((notes-window (selected-window)) - (dired-window (split-window-right))) - ;; open notes file and jump to heading - (with-selected-window notes-window - (find-file bard/uni-notes-file) - (widen) - (goto-char (point-min)) - (message class) - (search-forward class nil nil)) - ;; open dired in right window - (with-selected-window dired-window - (dired dir))))) - -(defun bard/jump-to-class-new-frame (class) - "Open CLASS notes and dir in a new frame titled after CLASS, even with beframe." + (find-file bard/uni-notes-file) + (widen) + (goto-char (point-min)) + (search-forward class nil nil) + + (when with-dired + (let ((dired-window (split-window-right))) + (with-selected-window dired-window + (dired dir)))))) + +(defun bard/jump-to-class-new-frame (class &optional with-dired) + "Open CLASS notes and dir in a new frame titled after CLASS, optionally WITH-DIRED." (interactive - (list (completing-read "Class: " (mapcar #'car bard/class-dirs)))) + (list + (completing-read "Class: " (mapcar #'car bard/class-dirs)) + current-prefix-arg)) (let* ((dir (cdr (assoc class bard/class-dirs))) (frame (make-frame `((frame-title-format . ,class))))) (select-frame-set-input-focus frame) (delete-other-windows) - (let ((notes-window (selected-window)) - (dired-window (split-window-right))) - (with-selected-window notes-window - (find-file bard/uni-notes-file) - (widen) - (goto-char (point-min)) - (search-forward class nil nil)) - (with-selected-window dired-window - (dired dir) - (beframe-rename-current-frame))))) + (find-file bard/uni-notes-file) + (widen) + (goto-char (point-min)) + (search-forward class nil nil) + + (when with-dired + (let ((dired-window (split-window-right))) + (with-selected-window dired-window + (dired dir) + (beframe-rename-current-frame)))))) ;; Optional: bind to a key (global-set-key (kbd "C-c u") #'bard/jump-to-class) |
