Fix: open-today-log failed when opening from root of project
simplified locate-dominating-file call, by using the version from the documentation
This commit is contained in:
@@ -36,13 +36,13 @@
|
|||||||
"Open today's log file in log/YYYY-MM-DD.md format.
|
"Open today's log file in log/YYYY-MM-DD.md format.
|
||||||
Creates the log directory if it doesn't exist."
|
Creates the log directory if it doesn't exist."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((git-root (locate-dominating-file (or buffer-file-name default-directory) ".git"))
|
(let* ((git-root (locate-dominating-file "." ".git"))
|
||||||
(log-dir (concat (if git-root (file-name-directory git-root) default-directory) "log"))
|
(log-dir (concat git-root "log"))
|
||||||
(date-str (format-time-string "%Y-%m-%d"))
|
(date-str (format-time-string "%Y-%m-%d")))
|
||||||
(unless (file-directory-p log-dir)
|
(unless (file-directory-p log-dir)
|
||||||
(make-directory log-dir t))
|
(make-directory log-dir t))
|
||||||
(let ((file-name (concat log-dir "/" date-str ".md")))
|
(let ((file-name (concat log-dir "/" date-str ".md")))
|
||||||
(if (file-exists-p file-name)
|
(if (file-exists-p file-name)
|
||||||
(find-file file-name)
|
(find-file file-name)
|
||||||
(progn (find-file file-name)
|
(progn (find-file file-name)
|
||||||
(insert (format "# %s\n\n" date-str))))))))
|
(insert (format "# %s\n\n" date-str)))))))
|
||||||
|
|||||||
Reference in New Issue
Block a user