org-noter icon indicating copy to clipboard operation
org-noter copied to clipboard

Customizable variable for note template?

Open yanghaoxie opened this issue 5 years ago • 14 comments

I use helm-bibtex, I sometime create new notes from helm-bibtex interface. helm-bibtex has a variable bibtex-completion-notes-template-one-file which customize the note entries of new notes.

It will be consistent and smooth, if we can customize the org-noter note-template, such that it is consistent with helm-bibtex.

I know a little elisp, and I read some source code of org-noter, however, I did not find some similar options.

yanghaoxie avatar Oct 17 '18 02:10 yanghaoxie

Hello! What should be the template in order to be compatible? Do you want to create the note from the bibtex interface?

weirdNox avatar Oct 17 '18 10:10 weirdNox

Hi! Thanks for your contributions, the package helps a lot!

  1. About question one.
  • When I say compatible I mean the note entry created by helm-bibtex or org-noter should be the same. Because, I sometimes create note entry from helm-bibtex when I search bibtex, and sometimes I create note entry when I read a PDF attached to a bibtex entry.
  • About compatible, since you can customize how helm-bibtex create note entries, you can make the note entries the same as org-noter, however it would be nice if we can customize the note entries created by org-noter as helm-bibtex.
  • Why I prefer helm-bibtex note entry? Because it is more powerful, I can use any bibtex field to create my note entry.
  • It seems like that org-noter creates note entries use information of current file, and helm-bibtex use information of the current bibtex entry. Maybe there is no easy way to make org-noter create note entry like helm-bibtex.
  • Maby org-noter can detect if current file is one of the bibtex entries, if so, org-noter can use helm-bibtex-like template to create note entries. This may be a stupid idea, just a quick thought.
  1. About question two.
  • I does not want create very entry from bibtex interface. Because in my workflow, I use helm-bibtex to search, and read the pdf in pdf-tools, when I want to take notes in some papers, I call org-noter. This situation make the note entry less powerful. But if I use helm-bibtex to create note entry, I have to find the bibtex entry again!

Just some thoughts, maybe they are stupid or wrong. I would like to hear your comments.

yanghaoxie avatar Oct 17 '18 12:10 yanghaoxie

Thanks for the comment :)

About your request, what should a note have in order to be compatible?

Like you said, as the other way is more flexible and knows about your articles organization, it is trivial to do. I have this in my config:

(use-package org-ref :ensure
  :after bibtex
  :demand
  :config
  (setq! org-ref-default-bibliography '("~/Documents/Bibliography/References.bib")
         org-ref-bibliography-notes "~/Documents/Bibliography/Notes.org"
         org-ref-pdf-directory "~/Documents/Bibliography/PDFs/"
         reftex-default-bibliography org-ref-default-bibliography
         bibtex-completion-bibliography (car org-ref-default-bibliography)
         bibtex-completion-notes-path org-ref-bibliography-notes
         bibtex-completion-library-path org-ref-pdf-directory

         ;; NOTE(nox): Key generation
         bibtex-autokey-names 2
         bibtex-autokey-names-stretch 1
         bibtex-autokey-name-separator "-"
         bibtex-autokey-additional-names "-et_al"
         bibtex-autokey-year-length 4
         bibtex-autokey-year-title-separator "_")

  (require 'org-ref-ivy))

(use-package ivy-bibtex :ensure
  :config
  (setq! bibtex-completion-notes-template-one-file (format "* ${title} - ${year}
:PROPERTIES:
:Custom_ID: ${=key=}
:NOTER_DOCUMENT: %s${=key=}.pdf
:END:
"
                                                           org-ref-pdf-directory)
         bibtex-completion-display-formats
         '((t . "${=type=:7} | ${title:*} ${author:20} ${year:4} ${=has-pdf=:1}${=has-note=:1}  ${keywords:80}")))

  (defun nox*disable-completion-notes-mode (&optional _) (widen))
  (advice-add #'bibtex-completion-notes-mode :override #'nox*disable-completion-notes-mode))

When you say note, are you talking about a note in a page or the collection of notes annotating a document. Like, each note, or the parent heading with NOTER_DOCUMENT?

weirdNox avatar Oct 17 '18 21:10 weirdNox

Sorry for wait so long to reply. I am going to give examples of what I mean.

Example 1. Create notes when there is not an heading for current file.

my ivy-bibtex configuration is like this

(use-package ivy-bibtex
  :ensure t
  :defer t
  :init
  (my/leader-keys
    "ib" 'ivy-bibtex)
  (setq bibtex-completion-pdf-field "file"
	bibtex-completion-find-additional-pdfs t
	bibtex-completion-bibliography "~/Dropbox/software/Zotero/bibtex/main.bib"
	bibtex-completion-notes-path "~/Dropbox/document/org/references/ref-notes.org"
	bibtex-completion-notes-template-one-file
	"\n* ${title} cite:${=key=}\n  :PROPERTIES:\n  :Custom_ID:  :${=key=}\n  :NOTER_DOCUMENT: ${file}\n  :END:\n\n"))

If I execute ivy-bibtex, all I browse all my bibtex items, if I hit M-o, I can choose to edit notes for the bibtex entry, and ivy-bibtex will create the heading for this bibtex item (following the value of bibtex-completion-notes-template-one-file). An example is here,

* Mobile Edge Computing: A Survey cite:AbbasMobile2018
  :PROPERTIES:
  :Custom_ID:  :AbbasMobile2018
  :NOTER_DOCUMENT: /home/yhxie/Zotero/storage/9ZQFTBDD/AbbasMobile2018.pdf
  :END:

However, if I execute org-noter when the focus is in AbbasMobile2018.pdf, org-noter will creat a heading like this (If there is not a heading in my ref-notes.org for this file)

* AbbasMobile2018
  :PROPERTIES:
  :NOTER_DOCUMENT: ../../../../Zotero/storage/9ZQFTBDD/AbbasMobile2018.pdf
  :NOTER_PAGE: 1
  :END:

You see, ivy-bibtex and org-noter create different heading for the same bibtex entry.

Example 2. Create notes when I first create note heading using org-noter, then I choose Edit notes in ivy-bibtex.

* AbbasMobile2018
  :PROPERTIES:
  :NOTER_DOCUMENT: ../../../../Zotero/storage/9ZQFTBDD/AbbasMobile2018.pdf
  :NOTER_PAGE: 1
  :END:

* Mobile Edge Computing: A Survey cite:AbbasMobile2018
  :PROPERTIES:
  :Custom_ID:  :AbbasMobile2018
  :NOTER_DOCUMENT: /home/yhxie/Zotero/storage/9ZQFTBDD/AbbasMobile2018.pdf
  :END:

It seems like that ivy-bibtex does not recognize heading created by org-noter

Example 3.

Create notes using ivy-bibtex, and execute org-noter in corresponding files.

* Mobile Edge Computing: A Survey cite:AbbasMobile2018
  :PROPERTIES:
  :Custom_ID:  :AbbasMobile2018
  :NOTER_DOCUMENT: /home/yhxie/Zotero/storage/9ZQFTBDD/AbbasMobile2018.pdf
  :NOTER_PAGE: 1
  :END:

It seems like that org-noter can recognize heading created by ivy-bibtex.

Discussion

  1. In Example 1, can we make the two heads be the same.
  2. In Example 2, this seems a unwanted feature(bug).
  3. In Example 3, this works fine.
  4. Therefore, it would be nice if no matter how I create the notes, the headings are the same, and no duplicated headings.

yanghaoxie avatar Oct 24 '18 10:10 yanghaoxie

Ohhh, I see! Thanks for the examples, this helps a lot!

The PDF name is "KEY.pdf" right? That may be a way to get the Custom_ID you need, which would be enough for ivy-bibtex to find the heading. Now, the title itself I don't know how to generate, we probably would have to query ivy-bibtex itself in order fetch it from the .bib file. I'll see if that's possible!

Sidenote: I noticed you are using Zotero with ivy-bibtex, do you have that documented somewhere? I tried to do that, but didn't find that much information about it...

weirdNox avatar Oct 24 '18 10:10 weirdNox

You are welcome! And thanks your such fast reply!

  1. The name of PDF indeed is "KEY.pdf"

  2. The Custom_ID just my setting, maybe someone else like other properties. Anyway, best way is fetch filed from bibtex entry. In this way, we could generate any heading using any information that the pdf has (if the pdf associated to a bibtex entry).

  3. About Zotero.

a. It seems like I use this guide http://iflysib14.iflysib.unlp.edu.ar/tomas/en/blog/reference-management.html.

b. In addition, I use another very useful function (my/org-ref-open-pdf-at-point). I use org-ref to manage references when I take notes in org-mode, my/org-ref-open-pdf-at-point can open pdf if your cursor is at one org-ref cite key(e.g., cite:ShiEdge2016) (of cause, this bibtex entry should have a file filed which shows the absolute path of the file, and this can be exported by zotero).

(defun my/org-ref-open-pdf-at-point ( )
  "Open the pdf for bibtex key under point if it exists."
  (interactive)
  (let* ((results (org-ref-get-bibtex-key-and-file))
         (key (car results))
         (pdf-file (car (bibtex-completion-find-pdf key))))
    (if (file-exists-p pdf-file)
        (org-open-file pdf-file)
      (message "No PDF found for %s" key))))

yanghaoxie avatar Oct 24 '18 11:10 yanghaoxie

Thanks!

Also, I just skimmed through bibtex-completion.el and found bibtex-completion-get-entry, which seems to return the key, type, title, etc. It seems to be it! I'm thinking of a way to integrate this to my package.

weirdNox avatar Oct 26 '18 08:10 weirdNox

You are welcome!

That is cool. Hope it will make org-noter nicer.

yanghaoxie avatar Oct 26 '18 08:10 yanghaoxie

Hello,

Thanks for org-noter, a very nice package. An integration with ivy/helm-bibtex would be very useful. It could simplify a lot my note taking process.

Someone already have done something that can help (https://github.com/hitswint/.emacs.d/blob/c77907cefc6e0003bbee08801c55a9e41ce0c39c/lisp/setup_org_mode.el#L508)

For me, the perfect solution would be that we only need the Custom_ID to open the pdf file. No need of the ":NOTER_DOCUMENT:" property. --> Thanks to the custom_id and the .bib file used by ivy/helm-bibtex (or org-ref) we could open the document

Concerning zotero integration (this suppose that the bibtex file has been exported), see here: https://github.com/tmalsburg/helm-bibtex

If the BibTeX entries have a field that specifies the full path to the PDFs, that field can also be used. For example, JabRef and Zotero store the location of PDFs in a field called File: (setq bibtex-completion-pdf-field "File")

There is also a direct integration between zotero and org noter here (but don't know if it works): https://gitlab.com/egh/zotxt-emacs/blob/master/org-zotxt.el#L230

samspo avatar Oct 31 '18 04:10 samspo

Yes, that's a great idea, @samspo, thanks!

weirdNox avatar Oct 31 '18 10:10 weirdNox

This might be of use for someone: to synchronize org-ref and org-noter, you may change org-ref template, so that org-noter will find it.

  ;; Add NOTER_DOCUMENT to org-ref template
  (setq org-ref-note-title-format
        "** TODO %y - %t
 :PROPERTIES:
  :Custom_ID: %k
  :AUTHOR: %9a
  :NOTER_DOCUMENT: %F
  :JOURNAL: %j
  :YEAR: %y
  :VOLUME: %v
  :PAGES: %p
  :DOI: %D
  :URL: %U
 :END:
")

Make sure you have / ending in org-ref-pdf-directory, so that org-ref concatenates the correct path.

yiufung avatar Mar 15 '19 09:03 yiufung

It would be great if org-noter could read the (setq bibtex-completion-pdf-field "File") entry as Zotero and better bib(la)tex export the file field as a jabref link Full Text PDF:files/982/Zimmerman - 2017 - The Youth of Things Life and Death in the Age of .pdf:application/pdf

ghost avatar Oct 01 '20 17:10 ghost

Very interesting thread! I am using a combo of helm-bibtex+org-ref+pdf-tools+org-noter having migrated originally from Zotero. Because of that, my pdfs are partly in zotero-made directories (ZD) and partly in the org-ref-pdf-directory (ORD). As a consequence, when taking notes at a pdf in the ZD it creates a new * header from org-noter, and otherwise it creates/updates an org-ref header (which I prefer). Although it has already been pointed out that the pdf is the ID used to find notes, I just wanted to report that when using org-noter, if migrating from Zotero, it is possible to see this bipolar behavior. Any updates regarding a fix for this issue? Thanks!

averter avatar Oct 11 '20 11:10 averter

Hi, I am completely new to emacs, having recently discovered it can do all the things I am looking for in terms of note-taking and text-production for my PhD. I'm in awe of the tool that has been collectively crafted by so many people - thanks for this package.

I am having a hard time figuring out how to get org-noter and helm-bibtex (and perhaps org-ref?) to work together and I think my use-case is the same as those described in this thread, but I'm not sure if there is a solution yet:

  • I want to keep all my notes in one large file.
  • I use helm-bibtex to create a note entry (the .bib file is exported from Zotero with Betterbibtex). it finds the file with bibtex-completion-pdf-field "File".
  • I would like to find a way for org-noter notes to appear under that same heading, however, when I call org-noter from there, it prompts me for a filepath and inserts a second set of PROPERTIES under my heading. Calling it from the pdf would be fine too, if it recognised the heading to add notes to.

I came across this configuration which seems to have achieved that by adding this to the bibtex-completion file template (though multiple files in this case) : ":NOTER_DOCUMENT: %(orb-process-file-field \"${=key=}\")\n" Unfortunately I am completely illiterate when it comes to code but I hoped that replacing orb-process-file-fieldwith bibtex-completion-find-pdfwould produce the desired outcome, but I got an Error in NOTER_DOCUMENT (I'll be using org-roam too, but separately from this notes file. )

Can this be done?

jlteekiste avatar Jan 26 '21 01:01 jlteekiste