Open org-roam-buffer after org-roam-find-file

Adds +org-roam-open-buffer-on-find-file option.
This commit is contained in:
Henrik Lissner 2020-04-24 16:03:46 -04:00
parent 169821b9eb
commit 635d070e94
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -1,6 +1,13 @@
;;; lang/org/contrib/roam.el -*- lexical-binding: t; -*- ;;; lang/org/contrib/roam.el -*- lexical-binding: t; -*-
;;;###if (featurep! +roam) ;;;###if (featurep! +roam)
(defvar +org-roam-open-buffer-on-find-file t
"If non-nil, open the org-roam buffer when opening an org roam file.")
;;
;;; Packages
(use-package! org-roam (use-package! org-roam
:hook (org-load . org-roam-mode) :hook (org-load . org-roam-mode)
:hook (org-roam-backlinks-mode . turn-on-visual-line-mode) :hook (org-roam-backlinks-mode . turn-on-visual-line-mode)
@ -46,6 +53,18 @@
(or (featurep! :completion helm +fuzzy) (or (featurep! :completion helm +fuzzy)
(featurep! :completion ivy +fuzzy))) (featurep! :completion ivy +fuzzy)))
;; Normally, the org-roam buffer doesn't open until you explicitly call
;; `org-roam'. If `+org-roam-open-buffer-on-find-file' is non-nil, the
;; org-roam buffer will be opened for you when you use `org-roam-find-file'
;; (but not `find-file', to limit the scope of this behavior).
(add-hook! 'find-file-hook
(defun +org-roam-open-buffer-maybe-h ()
(and +org-roam-open-buffer-on-find-file
(memq 'org-roam-buffer--update-maybe post-command-hook)
(not (eq 'visible (org-roam-buffer--visibility)))
(with-current-buffer (window-buffer)
(org-roam-buffer--get-create)))))
;; Hide the mode line in the org-roam buffer, since it serves no purpose. This ;; Hide the mode line in the org-roam buffer, since it serves no purpose. This
;; makes it easier to distinguish among other org buffers. ;; makes it easier to distinguish among other org buffers.
(add-hook 'org-roam-buffer-prepare-hook #'hide-mode-line-mode)) (add-hook 'org-roam-buffer-prepare-hook #'hide-mode-line-mode))