Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AtomicNess123 opened this issue Jul 28, 2021 · 4 comments

Comments

@AtomicNess123
Copy link

AtomicNess123 commented Jul 28, 2021

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.

@gklimowicz
Copy link

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).

@AtomicNess123
Copy link
Author

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\\}"

@EFLS EFLS changed the title #+STARTUP options at the beginning of note retrieved as title Deft doesn't strip #+STARTUP options at the beginning of note from title Jul 30, 2021
@EFLS
Copy link
Owner

EFLS commented Jul 30, 2021

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

@AtomicNess123
Copy link
Author

AtomicNess123 commented Jul 30, 2021

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants