mirror of
https://github.com/org-roam/org-roam
synced 2025-09-16 15:56:48 -05:00
(fix): fix org-roam-today date functionality overriding old files (#235)
This commit is contained in:
22
org-roam.el
22
org-roam.el
@@ -577,17 +577,14 @@ specified via the #+ROAM_ALIAS property."
|
|||||||
(s-downcase slug))))
|
(s-downcase slug))))
|
||||||
|
|
||||||
;;;; Org-roam capture
|
;;;; Org-roam capture
|
||||||
(defun org-roam--new-file-path (id)
|
(defun org-roam--file-path-from-id (id)
|
||||||
"The file path for a new Org-roam file, with identifier ID.
|
"The file path for an Org-roam file, with identifier ID."
|
||||||
If ABSOLUTE, return an absolute file-path. Else, return a
|
(file-truename
|
||||||
relative file-path."
|
|
||||||
(let ((absolute-file-path (file-truename
|
|
||||||
(expand-file-name
|
(expand-file-name
|
||||||
(if org-roam-encrypt-files
|
(if org-roam-encrypt-files
|
||||||
(concat id ".org.gpg")
|
(concat id ".org.gpg")
|
||||||
(concat id ".org"))
|
(concat id ".org"))
|
||||||
org-roam-directory))))
|
org-roam-directory)))
|
||||||
absolute-file-path))
|
|
||||||
|
|
||||||
(defvar org-roam--capture-file-name-default "%<%Y%m%d%H%M%S>"
|
(defvar org-roam--capture-file-name-default "%<%Y%m%d%H%M%S>"
|
||||||
"The default file name format for org-roam templates.")
|
"The default file name format for org-roam templates.")
|
||||||
@@ -661,7 +658,9 @@ currently active org-roam template. Returns the path to the new file."
|
|||||||
(new-id (s-trim (org-roam--fill-template
|
(new-id (s-trim (org-roam--fill-template
|
||||||
name-templ
|
name-templ
|
||||||
org-roam--capture-info)))
|
org-roam--capture-info)))
|
||||||
(file-path (org-roam--new-file-path new-id)))
|
(file-path (org-roam--file-path-from-id new-id)))
|
||||||
|
(when (file-exists-p file-path)
|
||||||
|
(error (format "File exists at %s, aborting." file-path)))
|
||||||
(org-roam--touch-file file-path)
|
(org-roam--touch-file file-path)
|
||||||
(write-region
|
(write-region
|
||||||
(org-roam--fill-template (or (org-capture-get :head)
|
(org-roam--fill-template (or (org-capture-get :head)
|
||||||
@@ -844,14 +843,17 @@ INFO is an alist containing additional information."
|
|||||||
(defun org-roam--file-for-time (time)
|
(defun org-roam--file-for-time (time)
|
||||||
"Create and find file for TIME."
|
"Create and find file for TIME."
|
||||||
(let* ((title (format-time-string "%Y-%m-%d" time))
|
(let* ((title (format-time-string "%Y-%m-%d" time))
|
||||||
(org-roam-capture-templates (list (list "d" "daily" 'plain (list 'function #'org-roam--capture-get-point)
|
(file-path (org-roam--file-path-from-id title)))
|
||||||
|
(if (file-exists-p file-path)
|
||||||
|
file-path
|
||||||
|
(let ((org-roam-capture-templates (list (list "d" "daily" 'plain (list 'function #'org-roam--capture-get-point)
|
||||||
""
|
""
|
||||||
:immediate-finish t
|
:immediate-finish t
|
||||||
:file-name "${title}"
|
:file-name "${title}"
|
||||||
:head "#+TITLE: ${title}")))
|
:head "#+TITLE: ${title}")))
|
||||||
(org-roam--capture-context 'title)
|
(org-roam--capture-context 'title)
|
||||||
(org-roam--capture-info (list (cons 'title title))))
|
(org-roam--capture-info (list (cons 'title title))))
|
||||||
(org-roam-capture)))
|
(org-roam-capture)))))
|
||||||
|
|
||||||
(defun org-roam-today ()
|
(defun org-roam-today ()
|
||||||
"Create and find file for today."
|
"Create and find file for today."
|
||||||
|
Reference in New Issue
Block a user