[ Added the other recipients, as they were missing. ]
> From: Peter Prevos <peter@prevos.net>> Date: Sat, 23 Jul 2022 07:08:34 +1000>> Hi Prot and Saša,
Hello Peter,
> Thanks for the information. I think we now have a working prototype to > create Denote files from within Citar. Working my way towards the > denote-citar package; or is this something we should include in your > code as denote-citar.el?
A standalone package should be the norm here because it introduces a
dependency on something not built into Emacs. I will, of course, cover
this in the Denote manual.
> The code below lets you create a new bibliographic note from within > Citar. The note will have a default keyword (denote-citar-keyword) and > uses the citation key as filename (underscores transformed to dashes).
I suppose the 'denote-citar-keyword' is a user option, right? By "user
option" I mean (1) a variable that the user is expected to customise and
(2) it is customisable via the custom UI.
If so, try to declare it with 'defcustom'. It should be the same type
as 'denote-known-keywords'.
Also, its doc string could state that this is a list of keywords.
Not a problem though. Just for you to consider.
> Next step is to let Citar find bibliography notes. The citation key in > BibTeX has no fixed format and users choose to use either dashes, > underscores or whatever else (only few characters are illegal). Using > the filename is thus not an option, so it has to be an identifier in the > front matter.
About adding custom front matter, it is possible to do it with the
function that generates the new note. I write an annotated interactive
command which you can adapt to you your needs. Please let me know if
you have any questions with it:
(defun denote-with-extra-front-matter ()
"Create a bibliography note through Citar."
(interactive) ; I make this interactive so you can try it
(let ((denote-file-type nil)) ; make sure it is Org
(denote
"Just a demo title"
(denote-citar--keywords-prompt))
;; From here on we add the custom front matter "#+reference"
;; The `denote-last-buffer' is the one we just created with
;; `denote'.
(with-current-buffer (get-buffer denote-last-buffer)
;; Ask the user for a string, which will be used as the citation
;; key.
(let ((key (read-string "Key for this citation: ")))
;; With the `save-excursion' we do not move the point away from
;; where it would have been originally.
(save-excursion
;; These motions do:
;; 1. to the top
;; 2. search for the identifier's line
;; 3. go to the end of that line
;; 4. insert a newline
;; 5. insert the #+reference
(goto-char (point-min))
(re-search-forward denote-retrieve--id-front-matter-key-regexp)
(goto-char (point-at-eol))
(newline)
(insert (format "#+reference: %s" key)))))))
> Using the Denote identifier as citation key is not an option because> that creates havoc upstream as these citation keys are used in LaTeX.
What would be a good pattern for not creating havoc upstream? Maybe we
can come up with an efficient convention.
> Having a default keyword creates some efficiencies for Citar to search > for linked notes.
Agreed! It also is a good practice in general, as it is easier for the
user to filter entries.
> I shall reverse-engineer the citar-file--get-notes function next.
Please keep us posted.
All the best,
Prot
> regards>> P:)>>> ;; Denote keyword to indicate bibliographic notes> (defvar denote-citar-keyword '("bib")> "Denote keyword to indicate bibliographical notes")>> ;; Helper function for selecting keywords> (defun denote-citar--keywords-prompt ()> "Prompt for one or more keywords and include > `denote-citar-keyword'."> (let ((choice (append denote-citar-keyword> (denote--keywords-crm (denote-keywords)))))> (setq denote-last-keywords> (if denote-sort-keywords> (sort choice #'string-lessp)> choice))))>> ;; Helper function to create a new note from within Citar> (defun denote-citar-file--create-note (key &optional entry)> "Create a bibliography note through Citar."> (denote> (replace-regexp-in-string "_" "-" key)> (denote-citar--keywords-prompt)))>> ;; Modify the way Citar links notes to bibliographies> (setq citar-notes-sources> `((citar-file .> ,(list :name "Notes"> :category 'file> :items #'citar-file--get-notes> :hasitems #'citar-file--has-notes> :open #'find-file> :create #'denote-citar-file--create-note> :transform #'file-name-nondirectory))))>>
--
Protesilaos Stavrou
https://protesilaos.com
Hi Prot,
That is brilliant.
It is now easy to select an entry in Citar and create a note with
#+reference: as identifier.
I have moved this project to GitHub:
https://github.com/pprevos/denote-citar
It will take a while for this to reach maturity as I need to complete
another project first.
Thanks for the great help Prot.
regards
---
Dr Peter Prevos
---------------
peterprevos.com
On 23-07-2022 12:07, Protesilaos Stavrou wrote:
> [ Added the other recipients, as they were missing. ]> >> From: Peter Prevos <peter@prevos.net>>> Date: Sat, 23 Jul 2022 07:08:34 +1000>> >> Hi Prot and Saša,> > Hello Peter,> >> Thanks for the information. I think we now have a working prototype to>> create Denote files from within Citar. Working my way towards the>> denote-citar package; or is this something we should include in your>> code as denote-citar.el?> > A standalone package should be the norm here because it introduces a> dependency on something not built into Emacs. I will, of course, cover> this in the Denote manual.> >> The code below lets you create a new bibliographic note from within>> Citar. The note will have a default keyword (denote-citar-keyword) and>> uses the citation key as filename (underscores transformed to dashes).> > I suppose the 'denote-citar-keyword' is a user option, right? By "user> option" I mean (1) a variable that the user is expected to customise > and> (2) it is customisable via the custom UI.> > If so, try to declare it with 'defcustom'. It should be the same type> as 'denote-known-keywords'.> > Also, its doc string could state that this is a list of keywords.> > Not a problem though. Just for you to consider.> >> Next step is to let Citar find bibliography notes. The citation key in>> BibTeX has no fixed format and users choose to use either dashes,>> underscores or whatever else (only few characters are illegal). Using>> the filename is thus not an option, so it has to be an identifier in >> the>> front matter.> > About adding custom front matter, it is possible to do it with the> function that generates the new note. I write an annotated interactive> command which you can adapt to you your needs. Please let me know if> you have any questions with it:> > (defun denote-with-extra-front-matter ()> "Create a bibliography note through Citar."> (interactive) ; I make this interactive so you can try it> (let ((denote-file-type nil)) ; make sure it is Org> (denote> "Just a demo title"> (denote-citar--keywords-prompt))> ;; From here on we add the custom front matter "#+reference"> > ;; The `denote-last-buffer' is the one we just created with> ;; `denote'.> (with-current-buffer (get-buffer denote-last-buffer)> ;; Ask the user for a string, which will be used as the > citation> ;; key.> (let ((key (read-string "Key for this citation: ")))> ;; With the `save-excursion' we do not move the point away > from> ;; where it would have been originally.> (save-excursion> ;; These motions do:> ;; 1. to the top> ;; 2. search for the identifier's line> ;; 3. go to the end of that line> ;; 4. insert a newline> ;; 5. insert the #+reference> (goto-char (point-min))> (re-search-forward > denote-retrieve--id-front-matter-key-regexp)> (goto-char (point-at-eol))> (newline)> (insert (format "#+reference: %s" key)))))))> >> Using the Denote identifier as citation key is not an option because>> that creates havoc upstream as these citation keys are used in LaTeX.> > What would be a good pattern for not creating havoc upstream? Maybe we> can come up with an efficient convention.> >> Having a default keyword creates some efficiencies for Citar to search>> for linked notes.> > Agreed! It also is a good practice in general, as it is easier for the> user to filter entries.> >> I shall reverse-engineer the citar-file--get-notes function next.> > Please keep us posted.> > All the best,> Prot> >> regards>> >> P:)>> >> >> ;; Denote keyword to indicate bibliographic notes>> (defvar denote-citar-keyword '("bib")>> "Denote keyword to indicate bibliographical notes")>> >> ;; Helper function for selecting keywords>> (defun denote-citar--keywords-prompt ()>> "Prompt for one or more keywords and include>> `denote-citar-keyword'.">> (let ((choice (append denote-citar-keyword>> (denote--keywords-crm (denote-keywords)))))>> (setq denote-last-keywords>> (if denote-sort-keywords>> (sort choice #'string-lessp)>> choice))))>> >> ;; Helper function to create a new note from within Citar>> (defun denote-citar-file--create-note (key &optional entry)>> "Create a bibliography note through Citar.">> (denote>> (replace-regexp-in-string "_" "-" key)>> (denote-citar--keywords-prompt)))>> >> ;; Modify the way Citar links notes to bibliographies>> (setq citar-notes-sources>> `((citar-file .>> ,(list :name "Notes">> :category 'file>> :items #'citar-file--get-notes>> :hasitems #'citar-file--has-notes>> :open #'find-file>> :create #'denote-citar-file--create-note>> :transform #'file-name-nondirectory))))>> >>
> From: Peter Prevos <peter@prevos.net>> Date: Sat, 23 Jul 2022 16:52:27 +1000>> Hi Prot,
Hello Peter,
> That is brilliant.
I think there are lots of cases like this one where a few tweaks give us
what we want. The code is designed to be easy to hack on.
> It is now easy to select an entry in Citar and create a note with > #+reference: as identifier.
I guess you will need a helper function to search the file's contents?
Check 'denote-retrieve--value-title'. You would basically just need to
create a copy of it and 'denote-retrieve--title-front-matter-key-regexp'
with "reference" instead of "title".
> I have moved this project to GitHub: > https://github.com/pprevos/denote-citar>> It will take a while for this to reach maturity as I need to complete > another project first.
Very well! If you need help or have any questions, please let me know.
> Thanks for the great help Prot.
You are welcome!
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
Peter Prevos <peter@prevos.net> writes:
Hello Peter,
> I have moved this project to GitHub: > https://github.com/pprevos/denote-citar
+1
> It will take a while for this to reach maturity as I need to > complete > another project first.>> Thanks for the great help Prot.
Please forgive my ignorance, but only now I realized that you're
the
author of LucidManager web site which I discovered few days ago
and it
is very inspiring!!
However, now we'd need a new video about. org-roam vs. denote :-)
Sincerely,
Saša
--
In the material world, one who is unaffected by whatever good
or evil he may obtain, neither praising it nor despising it,
is firmly fixed in perfect knowledge.
Hi Saša,
I am glad my website is useful for you.
Regarding drawing networks - I am not planning to write anything as
impressive as the Org Roam UI. In my view, graphical representations are
mostly distractions - very rewarding and endorfine-producing though :)
If you like to combine the best of two worlds, it would not be so hard
to have Denote and Roam share the same identifier. You just need to hack
Denote to add a properties drawer at the start of the file and then you
can use both packages in parallel.
Something like:
:PROPERTIES:
:ID: 20220723T210612
:END:
Org Roam will then treat the note as one of its own.
This function does the trick partially:
(defun denote-add-org-roam-id ()
"Add the denote identifier in a drawer to register the note in Org
Roam"
(interactive)
(save-excursion
(goto-char (point-min))
(insert ":PROPERTIES:\n"
":ID: " (substring (buffer-name) 0 15) "\n"
":END:\n")))
It does not replace an existing drawer and it gets wiped when you rename
a file with the Denote function. Perhaps there is a more elegant method
with an Org mode function. I tested this crude method and it works so I
can use Org Roam and Denote in parallel.
Regards
P:)
---
Dr Peter Prevos
---------------
peterprevos.com
On 23-07-2022 20:14, Saša Janiška wrote:
> Peter Prevos <peter@prevos.net> writes:> > Hello Peter,> >> I have moved this project to GitHub: >> https://github.com/pprevos/denote-citar> > +1> >> It will take a while for this to reach maturity as I need to complete >> another project first.>> >> Thanks for the great help Prot.> > Please forgive my ignorance, but only now I realized that you're the> author of LucidManager web site which I discovered few days ago and it> is very inspiring!!> > However, now we'd need a new video about. org-roam vs. denote :-)> > > Sincerely,> Saša
> From: Peter Prevos <peter@prevos.net>> Date: Sat, 23 Jul 2022 21:33:07 +1000>> Regarding drawing networks - I am not planning to write anything as > impressive as the Org Roam UI. In my view, graphical representations are > mostly distractions - very rewarding and endorfine-producing though :)
I never felt the need for such a utility and can understand why you
state this. Though I also get why people may need such a feature.
> If you like to combine the best of two worlds, it would not be so hard > to have Denote and Roam share the same identifier. You just need to hack > Denote to add a properties drawer at the start of the file and then you > can use both packages in parallel.>> [... 19 lines elided]>> It does not replace an existing drawer and it gets wiped when you rename > a file with the Denote function. Perhaps there is a more elegant method > with an Org mode function. I tested this crude method and it works so I > can use Org Roam and Denote in parallel.
We provide an "advanced feature" where the user can modify what front
matter gets inserted. Please note that this is do-it-yourself stuff
and not your average customisation option.
Try this (WITHOUT the indentation):
;; Read the doc string of `denote-org-front-matter'
(setq denote-org-front-matter
":PROPERTIES:
:ID: %4$s
:END:
#+title: %1$s
#+date: %2$s
#+filetags: %3$s
\n")
It creates a new note like:
:PROPERTIES:
:ID: 20220723T150301
:END:
#+title: This is a test
#+date: [2022-07-23 Sat 15:03]
#+filetags: testing
The renaming mechanism uses those variables that hold the front matter,
so any renaming and subsequent rewritting of front matter applies this
template as well.
You can expand it with other keywords, assuming those are constant, and
they will be added to new notes as well as any rewritten front matter.
For example:
(setq denote-org-front-matter
":PROPERTIES:
:ID: %4$s
:END:
#+title: %1$s
#+date: %2$s
#+filetags: %3$s
#+author: Protesilaos
\n")
:PROPERTIES:
:ID: 20220723T150512
:END:
#+title: This is a test
#+date: [2022-07-23 Sat 15:05]
#+filetags: testing
#+author: Protesilaos
I am happy to adjust this facility, depending on what users need. So
consider this just a point of entry. The guiding principle is that
Denote's code should be easy to hack or tweak/adapt to specific needs.
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com
Hi Prot,
I have shown that in principle, Denote can be linked to any
graph-generating package.
However, my workaround and your more elegant method, is only a partial
solution as Org Roam can only register its own link types. You could
build a hybrid Denote Roam system by using Denote file-naming and
tagging and Roam linking,
Somebody could write a package that creates a database from Denote in
the same structure as the Org Roam database so you can use the
downstream benefits of that approach.
Another option would be to build a list in Emacs Memory en the fly every
time a new file is saved in denote-directory. This is what my R code
does.
P:)
---
Dr Peter Prevos
---------------
peterprevos.com
On 23-07-2022 22:11, Protesilaos Stavrou wrote:
>> From: Peter Prevos <peter@prevos.net>>> Date: Sat, 23 Jul 2022 21:33:07 +1000>> >> Regarding drawing networks - I am not planning to write anything as>> impressive as the Org Roam UI. In my view, graphical representations >> are>> mostly distractions - very rewarding and endorfine-producing though :)> > I never felt the need for such a utility and can understand why you> state this. Though I also get why people may need such a feature.> >> If you like to combine the best of two worlds, it would not be so hard>> to have Denote and Roam share the same identifier. You just need to >> hack>> Denote to add a properties drawer at the start of the file and then >> you>> can use both packages in parallel.>> >> [... 19 lines elided]>> >> It does not replace an existing drawer and it gets wiped when you >> rename>> a file with the Denote function. Perhaps there is a more elegant >> method>> with an Org mode function. I tested this crude method and it works so >> I>> can use Org Roam and Denote in parallel.> > We provide an "advanced feature" where the user can modify what front> matter gets inserted. Please note that this is do-it-yourself stuff> and not your average customisation option.> > Try this (WITHOUT the indentation):> > ;; Read the doc string of `denote-org-front-matter'> (setq denote-org-front-matter> ":PROPERTIES:> :ID: %4$s> :END:> #+title: %1$s> #+date: %2$s> #+filetags: %3$s> \n")> > It creates a new note like:> > :PROPERTIES:> :ID: 20220723T150301> :END:> #+title: This is a test> #+date: [2022-07-23 Sat 15:03]> #+filetags: testing> > The renaming mechanism uses those variables that hold the front matter,> so any renaming and subsequent rewritting of front matter applies this> template as well.> > You can expand it with other keywords, assuming those are constant, and> they will be added to new notes as well as any rewritten front matter.> For example:> > (setq denote-org-front-matter> ":PROPERTIES:> :ID: %4$s> :END:> #+title: %1$s> #+date: %2$s> #+filetags: %3$s> #+author: Protesilaos> \n")> > :PROPERTIES:> :ID: 20220723T150512> :END:> #+title: This is a test> #+date: [2022-07-23 Sat 15:05]> #+filetags: testing> #+author: Protesilaos> > I am happy to adjust this facility, depending on what users need. So> consider this just a point of entry. The guiding principle is that> Denote's code should be easy to hack or tweak/adapt to specific needs.> > All the best,> Prot
> From: Peter Prevos <peter@prevos.net>> Date: Sun, 24 Jul 2022 05:38:13 +1000>> Hi Prot,
Hello Peter,
> I have shown that in principle, Denote can be linked to any > graph-generating package.
Indeed! As I noted before, I personally have no use for such a feature
though I wouldn't be against it. It would have to be separate package,
anyway.
> However, my workaround and your more elegant method, is only a partial > solution as Org Roam can only register its own link types. You could > build a hybrid Denote Roam system by using Denote file-naming and > tagging and Roam linking,>> Somebody could write a package that creates a database from Denote in > the same structure as the Org Roam database so you can use the > downstream benefits of that approach.
I see. This may need a lot of tinkering and might not be robust to
changes in either project.
> Another option would be to build a list in Emacs Memory en the fly every > time a new file is saved in denote-directory. This is what my R code > does.
My approach thus far is to be conservative with what we add to the
package. I think it is better to see what the concrete needs are and
act based on those. Not due to an opposition to adding code, but simply
because I know it is difficult to remove something after the fact.
My feeling right now---and time may prove me wrong---is that the feature
set of Denote is largely complete. We can streamline stuff, refine the
code, etc., but from an end-user perspective I think we are "mostly
done".
All the best,
Prot
--
Protesilaos Stavrou
https://protesilaos.com