Closed alperenkose closed 3 months ago
From: Alp Eren Kose @.***> Date: Wed, 31 Jul 2024 04:13:39 -0700
[... 33 lines elided]
Please see the backtrace for the error below. I also get a similar error when I run
denote-rename-file
as well.
Thank you for taking the time to report this! Which version of Denote are you using? This will help me track things down.
-- Protesilaos Stavrou https://protesilaos.com
I'm currently on 3.0.8 from elpa but I also had the same issue on 2.x - upgraded to latest version but didn't help.
From: Alp Eren Kose @.***> Date: Wed, 31 Jul 2024 05:13:13 -0700
I'm currently on 3.0.8 from elpa but I also had the same issue on 2.x
- upgraded to latest version but didn't help.
This is strange. I cannot reproduce the issue. Please send me the configuration you are using and I will try again.
-- Protesilaos Stavrou https://protesilaos.com
Following is my configuration, I'm using Spacemacs btw.
One thing I noticed now is, it is working if I mark the file in dired
and then run denote-dired-rename-marked-files-using-front-matter
however denote-rename-file-using-front-matter
is still not working when my cursor is on the file in dired.
(require 'denote)
(setq denote-file-type "markdown-yaml")
(setq denote-prompts '(title keywords subdirectory))
(setq denote-dired-directories
(list denote-directory
(expand-file-name "~/Documents/notes")))
(add-hook 'dired-mode-hook #'denote-dired-mode-in-directories)
(setq denote-dired-directories-include-subdirectories t)
(denote-rename-buffer-mode 1)
From: Alp Eren Kose @.***> Date: Wed, 31 Jul 2024 07:37:01 -0700
Following is my configuration, I'm using Spacemacs btw.
Everything looks okay here.
One thing I noticed now is, it is working if I mark the file in
dired
and then rundenote-dired-rename-marked-files-using-front-matter
howeverdenote-rename-file-using-front-matter
is still not working when my cursor is on the file in dired.
Oh, I think I understand what is happening:
The command 'denote-rename-file-using-front-matter' is only meant to be used inside the file. You in the buffer, make the edits to the front matter, and then call the command to rename the file accordingly.
The 'denote-dired-rename-marked-files-using-front-matter' is for a different workflow. You edit a bunch of files' front matter, then you go to Dired to mark them, and then run the command to apply the renames across all of them.
The command 'denote-rename-file' can be used both inside a file's buffer and in Dired.
Does this make sense? I think we may be able to make the command 'denote-dired-rename-marked-files-using-front-matter' also work from Dired, to recognise the file at point.
-- Protesilaos Stavrou https://protesilaos.com
Ohhh I'm sorry for not reading the documentation carefully 😞 Since the denote-rename-file
works in dired I thought all the other rename commands work as well.. 🙂
I'm really sorry for wasting your time, denote-rename-file-using-front-matter
works from within the buffer.
I wish I knew elisp and implement this to work in dired though :)
From: Alp Eren Kose @.***> Date: Wed, 31 Jul 2024 08:11:02 -0700
Ohhh I'm sorry for not reading the documentation carefully 😞 Since the
denote-rename-file
works in dired I thought all the other rename commands work as well.. 🙂 I'm really sorry for wasting your time,denote-rename-file-using-front-matter
works from within the buffer.
That's fine, no worries!
I wish I knew elisp and implement this to work in dired though :)
I will review the code. Maybe it is easy to do. Will keep you posted.
-- Protesilaos Stavrou https://protesilaos.com
I just pushed the change. Thank you!
If you want to test this before the new version is out, evaluate the following:
(defun denote-rename-file-using-front-matter (file)
"Rename FILE using its front matter as input.
When called interactively, FILE is the variable `buffer-file-name' or
the Dired file at point, which is subsequently inspected for the
requisite front matter. It is thus implied that the FILE has a file
type that is supported by Denote, per `denote-file-type'.
The values of `denote-rename-confirmations' and `denote-save-buffers'
are respected. Though there is no prompt to confirm the rewrite of the
front matter, since this is already done by the user.
The identifier of the file, if any, is never modified even if it
is edited in the front matter: Denote considers the file name to
be the source of truth in this case, to avoid potential breakage
with typos and the like.
Construct the file name in accordance with the user option
`denote-file-name-components-order'."
(interactive (list (or (dired-get-filename nil t) buffer-file-name)))
(unless (denote-file-is-writable-and-supported-p file)
(user-error "The file is not writable or does not have a supported file extension"))
(if-let ((file-type (denote-filetype-heuristics file))
(front-matter-title (denote-retrieve-front-matter-title-value file file-type))
(id (denote-retrieve-filename-identifier file)))
(let ((denote-rename-confirmations (delq 'rewrite-front-matter denote-rename-confirmations)))
(pcase-let* ((denote-prompts '())
(front-matter-keywords (denote-retrieve-front-matter-keywords-value file file-type))
(`(_title _keywords ,signature ,date)
(denote--rename-get-file-info-from-prompts-or-existing file)))
(denote--rename-file file front-matter-title front-matter-keywords signature date)
(denote-update-dired-buffers)))
(user-error "No identifier or front matter for title")))
Hi,
I'm trying to rename files using
denote-rename-file-using-front-matter
in order to import them from plain markdown files which have frontmatters in the compatible format with denote. I'm using themarkdown-yaml
format for frontmatter.At first I thought there could be something wrong with how I generated frontmatters for my markdown files but I have the same issue when I try
denote-rename-file-using-front-matter
even on denote generated markdown files.Consider the following frontmatter:
I remove one of the tags and run
denote-rename-file-using-front-matter
but I receive a(wrong-type-argument stringp nil)
error.Please see the backtrace for the error below. I also get a similar error when I run
denote-rename-file
as well.Could you please help what might be wrong?
Thanks!