diff options
Diffstat (limited to 'config.org')
| -rw-r--r-- | config.org | 62 |
1 files changed, 31 insertions, 31 deletions
@@ -4335,44 +4335,44 @@ This is what the tabs look like with ~doom-gruvbox~ theme: (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) |
