tmalsburg / helm-bibtex

Search and manage bibliographies in Emacs
GNU General Public License v2.0
465 stars 74 forks source link

Addition of journal or journaltitle to filename template in helm-bibtex #403

Open Phil2740 opened 2 years ago

Phil2740 commented 2 years ago

Hi, I'm not sure that this is the correct forum to raise this issue, but here goes.

I have many entries in my Bibtex files that are references to newspaper articles, which typically don't have either an author or an editor. If I try to create a note from such an entry I get an error message and the note doesn't get a title.

My question is: How could I add in the option of a journal or a journaltitle field in the the variable bibtex-completion-notes-template-multiple-files?

I have only a dim understanding of Emacs Lisp; I tried:

(setq bibtex-completion-notes-template-multiple-files     
    '("#+TITLE: Notes on: ${author-or-editor-or-journaltitle} (${year}): ${title}

      ")) 

in my init file, but that did not work.

I suppose I could add an author field to the newspaper entries, but I'd rather not do that; I've got thousands of entries.

Thanks for writing helm-bibtex, it's a great package, and thanks in advance for any help you can give me on this issue.

tmalsburg commented 2 years ago

Hi. What you'd like to do is unfortunately not possible. But you could try this:

(setq bibtex-completion-notes-template-multiple-files     
    '("#+TITLE: Notes on: ${author-or-editor} ${journaltitle} (${year}): ${title}

      "))

This didn't work previously due to a bug that I discovered thanks to your request. The solution above is not super pretty but perhaps good enough?

Phil2740 commented 2 years ago

Hi Dr von der Malsburg,

Thanks for your quick response to my query, but your suggested fix did not work.

I note that you have discovered a bug, does this mean that I need to download a new version of bibtex-completion.el? My directory where bibtex-completion.el is stored also has bibtex-completion-autoloads.el and bibtex-completion-pkg.el. Do I need these file too, and if I do, where do I get them?

I would normally use the package system for updating Emacs packages, but the package system doesn’t seem to be working at the moment.

Regards,

Phil

On 5 Apr 2022, at 2:13 am, Titus von der Malsburg @.***> wrote:

Hi. What you'd like to do is unfortunately not possible. But you could try this:

(setq bibtex-completion-notes-template-multiple-files
'("#+TITLE: Notes on: ${author-or-editor} ${journaltitle} (${year}): ${title}

  "))

This didn't work previously due to a bug that I discovered thanks to your request. The solution above is not super pretty but perhaps good enough?

— Reply to this email directly, view it on GitHub https://github.com/tmalsburg/helm-bibtex/issues/403#issuecomment-1087750510, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARHQK33BJMKTHGUHQBNKYXDVDMIKDANCNFSM5SPNPZTA. You are receiving this because you authored the thread.

tmalsburg commented 2 years ago

Yes, in order to make the proposed template work, you need the latest version. For install instructions, please see the documentation here.

Phil2740 commented 2 years ago

Hi again,

I’d really like to make this work. I upgraded packages as you suggested, but when I attempt to create a note I still get this message:

Wrong type argument: stringp, ("#+TITLE: Notes on: ${author-or-editor} ${journaltitle} (${year}): ${title}

  “) 

Here are some random thoughts that occurred to me. The field name”journaltitle” doesn’t appear anywhere in bibtex-completion.el. I use string abbreviations for the journal titles, such as: journaltitle = DCN. Has the absence of braces around this field got any bearing on the problem?

I don’t know whether it is relevant, but I am running Emacs 28.1 under macOS 12.3.1 on an M1 Mac Mini.

Where could I find documentation on the string definition, #+TITLE: Notes on:…. I assume it is an Emacs Lisp expression, but I couldn’t find anything in the Elisp manual.

Thanks again for your assistance.

Phil

On 5 Apr 2022, at 5:39 pm, Titus von der Malsburg @.***> wrote:

Yes, in order to make the proposed template work, you need the latest version. For install instructions, please see the documentation here https://github.com/tmalsburg/helm-bibtex#installation.

— Reply to this email directly, view it on GitHub https://github.com/tmalsburg/helm-bibtex/issues/403#issuecomment-1088366974, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARHQK3ZFTF6W3V346KTM2D3VDPU4FANCNFSM5SPNPZTA. You are receiving this because you authored the thread.

tmalsburg commented 2 years ago

journaltitle isn't read by default because it's not a standard bibtex field. You need to add it to bibtex-completion-addition-search-fields (see here). I think there is also a mistake in the code that I provided above. It should be this (I think):

(setq bibtex-completion-notes-template-multiple-files     
    "#+TITLE: Notes on: ${author-or-editor} ${journaltitle} (${year}): ${title}

      ")