zetteldeft icon indicating copy to clipboard operation
zetteldeft copied to clipboard

Deft doesn't strip #+STARTUP options at the beginning of note from title

Open AtomicNess123 opened this issue 2 years ago • 4 comments

My format for new notes has some #+STARTUP: options lines at the start of the buffer, the first one being "+STARTUP: overview".

When I use functions like zetteldeft-insert-list-links and zetteldeft-file-rename, the list of links I get retrieves the first line of the note as the title:

zetteldeft-insert-list-links :

- §2021-07-05-1648-11 +STARTUP: overview
- §2021-07-05-1643-01 +STARTUP: overview

zetteldeft-file-rename:

Change +STARTUP: overview to : +STARTUP: overview

I am not sure if I am doing something wrong or should tweak my configuration. Any help provided welcome, thanks!

On a side note, the format of the links shows like this on my Emacs (tried many themes invariably):

image

This is, the last two digits of the ID are not fontified like the rest.

AtomicNess123 avatar Jul 28 '21 08:07 AtomicNess123

The first line of an org file is customarily the #+TITLE line. I don't know whether that is a requirement, or just a custom. (I've not seen an example where the #+TITLE was not first, but I haven't searched the entire Internet.)

Note that zetteldeft-title-prefix starts with it.

Regarding the link highlighting, how have you set zetteldeft-id-regex? That might be related, as I believe you need to set it in such a way that zetteldeft--id-font-lock-setup will be called (like via :custom in use-package).

gklimowicz avatar Jul 28 '21 17:07 gklimowicz

First, thanks for your help.

I actually learned from other users and set my orgfiles to be of the form:

#+startup: overview
#+startup: indent
#+options: toc:nil num:nil
#+todo: TODO FANCY OPTIONS | DONE
# ...etc.
#+title: My title

I like this approach because I don't have the title and then lots of setting in between the main text and the title, it's just a preamble with settings.

My zetteldeft-title-prefix’s value is:

"#+STARTUP: overview
#+STARTUP: indent
#+TITLE: "
Original value was "#+TITLE: "

I modified to suit my needs.

As for my setteldeft-id-regex, I modified it also:

"[0-9]\\{4\\}\\(-[0-9]\\{2,\\}\\)\\{3\\}-[0-9]\\{2\\}"
Original value was 
"[0-9]\\{4\\}\\(-[0-9]\\{2,\\}\\)\\{3\\}"

AtomicNess123 avatar Jul 28 '21 19:07 AtomicNess123

So these are actually two separate issues.

First the titles: Zetteldeft relies on Deft to figure out the title of a note, so the challenge here is to figure Deft correctly. Take a look at deft-strip-title-regexp. I seem to recall a discussion about this topic in Deft's Github repository, perhaps start there? EDIT: It's this issue

Second the link highlighting: this is indeed something Zetteldeft should take care of. How did you customize the zetteldeft-id-regex in your setup? I think two approaches should work: either via setq before requiring Zetteldeft, or via the customize interface. This way, the font-lock is applied correctly, as explained by @gklimowicz

EFLS avatar Jul 30 '21 16:07 EFLS

Thanks!

(1) deft-strip-title-regexp: "\\(?:^%+\\|^#\\+TITLE: *\\|^[#* ]+\\|-\\*-[[:alpha:]]+-\\*-\\|^Title:[ ]*\\|#+$\\)" This is a regex issue, and I don't know much regex, so I guess I will be stuck here. I read the thread but couldn't figure it out yet. Will keep trying.

(2) zetteldeft-id-regex should be correct: Its value is "[0-9]\\{4\\}\\(-[0-9]\\{2,\\}\\)\\{3\\}-[0-9]\\{2\\}" Original value was "[0-9]\{4\}\(-[0-9]\{2,\}\)\{3\}"

edit: I forgot to answer your question on how I set up this variable:

(setq zetteldeft-id-regex "[0-9]\\{4\\}\\(-[0-9]\\{2,\\}\\)\\{3\\}-[0-9]\\{2\\}")

and I call it on my init AFTER requiring zetteldeft.

edit:

calling it before fixes the issue (2), thanks!

AtomicNess123 avatar Jul 30 '21 17:07 AtomicNess123