Mark +org-dir obsolete (use org-directory instead)

I prefer not to invent new variables when they aren't strictly
necessary. org-directory is one such variable (although the other path
variables are still necessary).
This commit is contained in:
Henrik Lissner 2018-06-15 00:45:26 +02:00
parent db8b4091dd
commit 6693db48af
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
8 changed files with 30 additions and 33 deletions

View file

@ -13,7 +13,7 @@
(elfeed-db-compact)
(doom-kill-matching-buffers "^\\*elfeed")
(dolist (file +rss-elfeed-files)
(when-let* ((buf (get-file-buffer (expand-file-name file +org-dir))))
(when-let* ((buf (get-file-buffer (expand-file-name file org-directory))))
(kill-buffer buf))))
;;;###autoload

View file

@ -5,8 +5,8 @@
;; don't care for the UI you can invoke elfeed directly with `elfeed'.
(defvar +rss-elfeed-files (list "elfeed.org")
"Where to look for elfeed.org files, relative to `+org-dir'. Can be absolute
paths.")
"Where to look for elfeed.org files, relative to `org-directory'. Can be
absolute paths.")
(defvar +rss-split-direction 'below
"What direction to pop up the entry buffer in elfeed.")
@ -65,6 +65,6 @@ paths.")
:after elfeed
:config
(setq rmh-elfeed-org-files
(let ((default-directory +org-dir))
(let ((default-directory org-directory))
(mapcar #'expand-file-name +rss-elfeed-files)))
(elfeed-org))

View file

@ -29,10 +29,10 @@
;;;###autoload
(defun +default/browse-notes ()
(interactive) (doom-project-browse +org-dir))
(interactive) (doom-project-browse org-directory))
;;;###autoload
(defun +default/find-in-notes ()
(interactive) (doom-project-find-file +org-dir))
(interactive) (doom-project-find-file org-directory))
;;;###autoload
(defun +default/browse-snippets ()

View file

@ -6,9 +6,9 @@
;; files with metadata I don't want. So I wrote my own, which:
;;
;; + Places attachments in a centralized location (`+org-attach-dir' in
;; `+org-dir'), using an attach:* link abbreviation.
;; + Use `+org-attach/sync' to index all attachments in `+org-dir' that use the
;; attach:* abbreviation and delete orphaned ones that are no longer
;; `org-directory'), using an attach:* link abbreviation.
;; + Use `+org-attach/sync' to index all attachments in `org-directory' that use
;; the attach:* abbreviation and delete orphaned ones that are no longer
;; referenced.
;; + Adds drag-and-drop support for images (with inline image preview)
;; + Adds drag-and-drop support for media files (pdfs, zips, etc) with a
@ -21,7 +21,7 @@
;; + `+org-attach/sync'
(defvar +org-attach-dir ".attach/"
"Where to store attachments relative to `+org-dir'.")
"Where to store attachments relative to `org-directory'.")
;;
@ -55,14 +55,14 @@
(advice-add #'org-download-insert-link :override #'+org-attach*insert-link)
(defun +org-attach*download-subdir ()
(when (file-in-directory-p buffer-file-name +org-dir)
(file-relative-name buffer-file-name +org-dir)))
(when (file-in-directory-p buffer-file-name org-directory)
(file-relative-name buffer-file-name org-directory)))
(defun +org-attach*download-fullname (path)
"Write PATH relative to current file."
(let ((dir (or (if buffer-file-name (file-name-directory buffer-file-name))
default-directory)))
(if (file-in-directory-p dir +org-dir)
(if (file-in-directory-p dir org-directory)
(file-relative-name path dir)
path)))
(advice-add #'org-download--dir-2 :override #'ignore)
@ -75,7 +75,7 @@
;;
(defun +org|init-attach ()
(setq org-attach-directory (expand-file-name +org-attach-dir +org-dir))
(setq org-attach-directory (expand-file-name +org-attach-dir org-directory))
;; A shorter link to attachments
(push (cons "attach" (abbreviate-file-name org-attach-directory)) org-link-abbrev-alist)

View file

@ -29,10 +29,8 @@
(defun +org|init-capture ()
(defvaralias 'org-default-notes-file '+org-default-notes-file)
(setq org-default-notes-file (expand-file-name +org-default-notes-file +org-dir)
+org-default-todo-file (expand-file-name +org-default-todo-file +org-dir))
(setq org-default-notes-file (expand-file-name +org-default-notes-file org-directory)
+org-default-todo-file (expand-file-name +org-default-todo-file org-directory))
(add-hook 'org-capture-after-finalize-hook #'+org-capture|cleanup-frame)

View file

@ -23,17 +23,17 @@
(when (executable-find "pandoc")
(require 'ox-pandoc))
;; Export to a central location by default or if target isn't in `+org-dir'.
(setq org-export-directory (expand-file-name ".export" +org-dir))
;; Export to a central location by default or if target isn't in `org-directory'.
(setq org-export-directory (expand-file-name ".export" org-directory))
(unless (file-directory-p org-export-directory)
(make-directory org-export-directory t))
(defun +org*export-output-file-name (args)
"Return a centralized export location unless one is provided or the current
file isn't in `+org-dir'."
file isn't in `org-directory'."
(when (and (not (nth 2 args))
buffer-file-name
(file-in-directory-p (file-truename buffer-file-name) (file-truename +org-dir)))
(file-in-directory-p (file-truename buffer-file-name) (file-truename org-directory)))
(setq args (append args (list org-export-directory))))
args)
(advice-add #'org-export-output-file-name :filter-args #'+org*export-output-file-name))

View file

@ -17,7 +17,7 @@
;;
(defvar +org-attachments nil
"A list of all indexed attachments in `+org-dir'.")
"A list of all indexed attachments in `org-directory'.")
(defvar +org-attachments-files nil
"A list of all attachments in `org-attach-directory'.")
@ -42,7 +42,7 @@ and END (defaults to `point-min' and `point-max')."
;;;###autoload
(defun +org-attach/sync (arg)
"Reindex all attachments in `+org-dir' and delete orphaned attachments in
"Reindex all attachments in `org-directory' and delete orphaned attachments in
`org-attach-directory'. If ARG (universal arg), conduct a dry run."
(declare (interactive-only t))
(interactive "P")
@ -50,7 +50,7 @@ and END (defaults to `point-min' and `point-max')."
(setq +org-attachments-files (directory-files org-attach-directory nil "^[^.]" t))
(with-temp-buffer
(delay-mode-hooks (org-mode))
(dolist (org-file (directory-files-recursively +org-dir "\\.org$"))
(dolist (org-file (directory-files-recursively org-directory "\\.org$"))
(insert-file-contents-literally org-file))
(setq +org-attachments (+org-attachments--list)))
;; clean up
@ -132,8 +132,8 @@ an file icon produced by `+org-attach--icon')."
(format "#+attr_latex: :width %dcm\n" org-download-image-latex-width))
(cond ((file-in-directory-p filename org-attach-directory)
(format "[[attach:%s]]" (file-relative-name filename org-attach-directory)))
((file-in-directory-p filename +org-dir)
(format org-download-link-format (file-relative-name filename +org-dir)))
((file-in-directory-p filename org-directory)
(format org-download-link-format (file-relative-name filename org-directory)))
(t
(format org-download-link-format filename)))))
(org-display-inline-images))

View file

@ -1,7 +1,9 @@
;;; lang/org/config.el -*- lexical-binding: t; -*-
(defvar +org-dir (expand-file-name "~/org/")
"The directory where org files are kept.")
;; FIXME deprecated
(define-obsolete-variable-alias '+org-dir 'org-directory "2.1.0")
(defvar org-directory "~/org/")
;; Sub-modules
(if (featurep! +attach) (load! "+attach"))
@ -61,9 +63,6 @@
+org|unfold-to-2nd-level-or-point
+org|show-paren-mode-compatibility))
(after! org
(defvaralias 'org-directory '+org-dir))
;;
;; `org-mode' hooks
@ -240,7 +239,7 @@ unfold to point on startup."
'org-link
'error)))))
(def-org-file-link! "org" +org-dir)
(def-org-file-link! "org" org-directory)
(def-org-file-link! "doom" doom-emacs-dir)
(def-org-file-link! "doom-docs" doom-docs-dir)
(def-org-file-link! "doom-modules" doom-modules-dir)