Coder Social home page Coder Social logo

Comments (18)

tuxiano avatar tuxiano commented on June 8, 2024 1

Hi, I have the same issue with doom emacs. I tried:

  • deft-use-filter-string-for-filename nil/t
  • (set-file-template! 'org-mode :ignore t)

Thank you for providing zetteldeft.el

from zetteldeft.

rotlaus avatar rotlaus commented on June 8, 2024 1

Oh, i forgot to mention that. Stripping the ID from the title never worked for me. It's not intentional. But i don't know why. I always wanted to check if that is another doom anomaly. I just have the default setup otherwise.

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

Thanks for reporting this issue, but I can't reproduce it.

Do you mean C-c d n to call zetteldeft-new-file? Because C-c C-d calls a deft function to delete notes.

And could you elaborate on what you mean with "two title-tags"? Like the org-mode #+TITLE: ?

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

Could you also let me know whether deft-use-filter-string-for-filename is t? And whether setting it to nil makes a difference?

EDIT: Never mind, I should have known that this does something completely different.

from zetteldeft.

neildurant avatar neildurant commented on June 8, 2024

Running on Emacs Doom, I had something similar (as far as I understand the original post), whereby Zetteldeft was inserting its title text, but also I was getting the default new file template behaviour, with a standard Org or Markdown boilerplate title. I had to do: (set-file-template! 'org-mode :ignore t) to disable the default empty file template functionality for org files, although note that this is Doom-specific syntax. But it might be worth investigating if the extra title is coming from a similar mechanism.

from zetteldeft.

juh2 avatar juh2 commented on June 8, 2024

Yes, it is zetteldeft-new-file
deft-use-filter-string-for-filename is nil

from zetteldeft.

ThunderBulk avatar ThunderBulk commented on June 8, 2024

same issue here; if I type a search into the deft buffer (e.g. zetteldeft rules) I would end up with this:
zetteldeft rules

#+TITLE: normal-title-as-expected

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

Thanks for all the reports.

I don't use the deft search bar to create new files, but decided to look at the code. Haven't narrowed it down completely, but it seems related to the following deft features:

  • internal function deft-auto-populate-title-maybe is what's used to set the title
  • and deft-org-mode-title-prefix is what's used as a prefix (if new files are org)

Attempting to fix this will have to wait until I've got some more free time, but in the mean time, remember that you can set deft-use-filename-as-title to nil, and manually configure zetteldeft-title-prefix.

from zetteldeft.

ThunderBulk avatar ThunderBulk commented on June 8, 2024

@EFLS i figured it was being caused by a deft function, I’ll post a fix when I have one

from zetteldeft.

rotlaus avatar rotlaus commented on June 8, 2024

I assume the first #+TITLE is generated by deft as it should be and the second comes from the doom file-templates package which also populates new org files with a #+TITLE derivated from the filename.

As others mentioned the error only happens when using the zetteldeft-new-file function. Creating notes with the standard deft interface does not have that problem.

I deactivated the file-templates package in my doom config which works for me as a workaround.

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

Thanks for the suggestion. Can someone with doom (and file-templates active) check whether setting zetteldeft-title-prefix to nil solves the problem?

from zetteldeft.

rotlaus avatar rotlaus commented on June 8, 2024

zetteldeft-new-file with (zetteldeft-title-prefix nil) gives me a single title formatted like this:

#+TITLE: 2020 04 02 1453 Test3

e: with file-templates active as suggested.

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

Strange to see a time stamp included in the title. Is this normal for your setup?

from zetteldeft.

jahfer avatar jahfer commented on June 8, 2024

It's about 2am where I am and this issue was driving me mad…after looking at the Deft code, the problem seems to be this chunk, which was pointed out in #26 (comment):

https://github.com/glucas/deft/blob/18607d2d581d008c76726eee01c847ede4ba8c16/deft.el#L1136-L1148

Using this config made new files get written correctly:

  (setq deft-use-filename-as-title t)

This ensures we bypass all of the logic of deft-auto-populate-title-maybe due to this conditional. Zetteldeft seems to be setting the filenames manually anyhow so this doesn't cause any other funky side effects!

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

Ooh, good find, thanks @jahfer! I had been looking at that deft-auto-populate-title-maybe function as the culprit, but couldn't figure out why it only affected Doom users.

Now I see that the Doom Deft module sets ...-as-title to nil: https://github.com/hlissner/doom-emacs/blob/110d70bdff12c61fb4bfebf8e9f6b3a18684076d/modules/ui/deft/config.el#L8.

So I think the best way forward is to set it to t within the zetteldeft-new-file function.

I don't have Doom, so can you confirm that this new defun works as expected?

    (defun zetteldeft-new-file (str &optional id)
      "Create a new deft file.
    
    The filename is a Zetteldeft ID, appended by STR. The ID will be
    generated, unles ID is provided.
    A file title will be inserted in the newly created file wrapped in
    `zetteldeft-title-prefix' and `zetteldeft-title-suffix'. Filename
    (without extension) is added to the kill ring. When `evil' is loaded,
    change to insert state."
      (interactive (list (read-string "Note title: ")))
      (let* ((deft-use-filename-as-title t)
    	     (zdId (or id
    	              (zetteldeft-generate-id str)))
    	     (zdName (concat zdId zetteldeft-id-filename-separator str)))
      (deft-new-file-named zdName)
      (kill-new zdName)
      (zetteldeft--insert-title str)
      (save-buffer)
      (when (featurep 'evil) (evil-insert-state))))

from zetteldeft.

jahfer avatar jahfer commented on June 8, 2024

I actually don't have Doom installed either, I think this is an issue out-of-the-box with zetteldeft + deft. The default value of deft-use-filename-as-title is nil, so it seems this would impact a fresh install.

Removing my manual setting and using your function does indeed let zetteldeft-new-file do the right thing! 🎉 I also tested without your change and confirmed the original issue was still there (just to be sure!). Looks like you've got the fix. Thanks!

p.s. Zetteldeft is one of my favourite emacs packages, thanks for building it ❤️

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

Great! Thank you for pointing towards the fix. And glad to hear you like the package!

I'll double check and push the fix in a couple of days when I have more time.

from zetteldeft.

EFLS avatar EFLS commented on June 8, 2024

I've pushed a fix (simply add a let to the new file function that keeps deft-use-filename-as-title to nil). Please check it out and let me know whether it fixes the issue!

from zetteldeft.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.