refactor: Code tidying
This commit is contained in:
@@ -30,7 +30,7 @@
|
||||
"Lookup IDENTIFIER with `describe-symbol'"
|
||||
;; HACK: Much to my frustration, `describe-symbol' has no defined return
|
||||
;; value. To test if the call was successful or not, we check if any window
|
||||
;; is displaying the help buffer. This probably breaks if
|
||||
;; is displaying the help buffer. This breaks if
|
||||
;; `syd-emacs-lisp-lookup-documentation' is called while the help buffer is
|
||||
;; already open.
|
||||
(describe-symbol (intern identifier))
|
||||
|
||||
@@ -17,17 +17,16 @@
|
||||
org-agenda-new-buffers))
|
||||
(run-hooks 'find-file-hook))
|
||||
|
||||
(defun syd-org-exclude-agenda-buffers-from-workspace-h ()
|
||||
"Don't associate temporary agenda buffers with current workspace."
|
||||
(when (and org-agenda-new-buffers
|
||||
(bound-and-true-p persp-mode)
|
||||
(not org-agenda-sticky))
|
||||
(let (persp-autokill-buffer-on-remove)
|
||||
(persp-remove-buffer org-agenda-new-buffers
|
||||
(get-current-persp)
|
||||
nil))))
|
||||
(add-hook 'org-agenda-finalize-hook
|
||||
#'syd-org-exclude-agenda-buffers-from-workspace-h)
|
||||
(syd-add-hook 'org-agenda-finalize-hook
|
||||
(defun syd-org-exclude-agenda-buffers-from-workspace-h ()
|
||||
"Don't associate temporary agenda buffers with current workspace."
|
||||
(when (and org-agenda-new-buffers
|
||||
(bound-and-true-p persp-mode)
|
||||
(not org-agenda-sticky))
|
||||
(let (persp-autokill-buffer-on-remove)
|
||||
(persp-remove-buffer org-agenda-new-buffers
|
||||
(get-current-persp)
|
||||
nil)))))
|
||||
|
||||
(defun syd-org--restart-mode-before-indirect-buffer-a (&optional buffer _)
|
||||
"Restart `org-mode' in buffers in which the mode has been deferred (see
|
||||
@@ -42,13 +41,15 @@ via an indirect buffer."
|
||||
:before #'syd-org--restart-mode-before-indirect-buffer-a)
|
||||
|
||||
(defvar recentf-exclude)
|
||||
(defun syd-org--optimize-backgrounded-agenda-buffers-a (fn file)
|
||||
|
||||
(syd-defadvice syd-org--optimize-backgrounded-agenda-buffers-a (fn file)
|
||||
"Disable `org-mode's startup processes for temporary agenda buffers.
|
||||
|
||||
Prevents recentf pollution as well. However, if the user tries to visit one of
|
||||
these buffers they'll see a gimped, half-broken org buffer, so to avoid that,
|
||||
install a hook to restart `org-mode' when they're switched to so they can grow
|
||||
up to be fully-fledged org-mode buffers."
|
||||
:around #'org-get-agenda-file-buffer
|
||||
(if-let* ((buf (org-find-base-buffer-visiting file)))
|
||||
buf
|
||||
(let ((recentf-exclude '(always))
|
||||
@@ -63,18 +64,14 @@ up to be fully-fledged org-mode buffers."
|
||||
(add-hook 'on-switch-buffer-hook #'syd-org--restart-mode-h
|
||||
nil 'local))
|
||||
buf))))
|
||||
(advice-add #'org-get-agenda-file-buffer
|
||||
:around #'syd-org--optimize-backgrounded-agenda-buffers-a)
|
||||
|
||||
(defun syd-org--fix-inconsistent-uuidgen-case-a (uuid)
|
||||
(syd-defadvice syd-org--fix-inconsistent-uuidgen-case-a (uuid)
|
||||
"Ensure uuidgen is always lowercase (consistent) regardless of system.
|
||||
See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
|
||||
:filter-return #'org-id-new
|
||||
(if (eq org-id-method 'uuid)
|
||||
(downcase uuid)
|
||||
uuid))
|
||||
(advice-add #'org-id-new
|
||||
:filter-return #'syd-org--fix-inconsistent-uuidgen-case-a))
|
||||
uuid)))
|
||||
|
||||
(defun syd-org-init-faces ()
|
||||
(let ((headline `(:weight bold)))
|
||||
@@ -123,6 +120,7 @@ See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
|
||||
:custom ((org-startup-folded 'content)
|
||||
(org-directory "~/org"))
|
||||
:preface
|
||||
;; Speed up initialisation by disabling modules we don't need.
|
||||
(defvar org-modules
|
||||
'(;; ol-w3m
|
||||
;; ol-bbdb
|
||||
@@ -164,18 +162,20 @@ See https://lists.gnu.org/archive/html/emacs-orgmode/2019-07/msg00081.html."
|
||||
(org-roam-completion-everywhere t))
|
||||
:config
|
||||
(defun syd-org-init-roam-h ()
|
||||
"Setup `org-roam' but don't immediately initialize its database.
|
||||
Instead, initialize it when it will be actually needed."
|
||||
"Setup `org-roam' but don't immediately initialize its database. Instead,
|
||||
initialize it when it will be actually needed."
|
||||
(cl-letf (((symbol-function #'org-roam-db-sync) #'ignore))
|
||||
(org-roam-db-autosync-enable)))
|
||||
(defun syd-org-roam-try-init-db-a (&rest _)
|
||||
|
||||
(syd-org--init-roam-keybinds)
|
||||
|
||||
(syd-defadvice syd-org-roam-try-init-db-a (&rest _)
|
||||
"Try to initialize org-roam database at the last possible safe moment.
|
||||
In case of failure, fail gracefully."
|
||||
:before #'org-roam-db-query
|
||||
(message "Initializing org-roam database...")
|
||||
(advice-remove 'org-roam-db-query #'syd-org-roam-try-init-db-a)
|
||||
(org-roam-db-sync))
|
||||
(advice-add #'org-roam-db-query
|
||||
:before #'syd-org-roam-try-init-db-a))
|
||||
(org-roam-db-sync)))
|
||||
|
||||
(provide 'syd-org)
|
||||
;;; syd-org.el ends here
|
||||
|
||||
Reference in New Issue
Block a user