fix(org-noter): smart launcher -- auto-select PDF window on SPC o n
This commit is contained in:
28
config.el
28
config.el
@@ -1234,18 +1234,38 @@ Otherwise: runs interactive ement-connect, then opens rooms after sync."
|
||||
:after (:any org pdf-view)
|
||||
:config
|
||||
(setq org-noter-notes-window-location 'horizontal-split
|
||||
;; Where to search for and create notes files (same dir as org notes)
|
||||
;; Directories to search for and create notes files
|
||||
org-noter-notes-search-path (list (expand-file-name "notes/" org-directory))
|
||||
;; Default note file name when creating a new session
|
||||
org-noter-default-notes-file-names '("notes.org")
|
||||
;; Remember last position in PDF across sessions
|
||||
org-noter-auto-save-last-location t
|
||||
;; Insert note at precise location (not just page level)
|
||||
;; Insert note at precise location, not just page level
|
||||
org-noter-insert-note-no-questions nil
|
||||
;; Always use separate notes file per PDF (cleaner than one big file)
|
||||
org-noter-use-indirect-buffer nil))
|
||||
|
||||
;; Smart launcher: always start org-noter from the PDF window,
|
||||
;; regardless of which window is currently selected.
|
||||
;; Fixes: calling SPC o n from an org buffer while PDF is visible in split.
|
||||
(defun my/org-noter-smart ()
|
||||
"Start org-noter, auto-selecting the PDF window in the current frame.
|
||||
If current buffer is pdf-view-mode: start normally.
|
||||
If another visible window shows a PDF: switch to it first, then start.
|
||||
Otherwise: run standard org-noter (interactive, prompts for document)."
|
||||
(interactive)
|
||||
(let ((pdf-win (cl-find-if
|
||||
(lambda (w)
|
||||
(with-current-buffer (window-buffer w)
|
||||
(derived-mode-p 'pdf-view-mode)))
|
||||
(window-list (selected-frame)))))
|
||||
(if pdf-win
|
||||
(with-selected-window pdf-win
|
||||
(org-noter))
|
||||
(org-noter))))
|
||||
|
||||
(map! :leader
|
||||
(:prefix ("o" . "open")
|
||||
:desc "org-noter" "n" #'org-noter
|
||||
:desc "org-noter (smart)" "n" #'my/org-noter-smart
|
||||
:desc "org-noter insert note" "N" #'org-noter-insert-note))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user