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

reference key as target-finder? #13

Open
bdarcus opened this issue Feb 28, 2023 · 11 comments
Open

reference key as target-finder? #13

bdarcus opened this issue Feb 28, 2023 · 11 comments
Assignees
Labels
enhancement New feature or request

Comments

@bdarcus
Copy link

bdarcus commented Feb 28, 2023

Was playing a bit with your package and denote, and noticed something that sometimes comes up in the org-roam world.

The reference property citekey: you may want to consider an embark "target-finder" (or similar for hydra/transient) for that, so that users can act on it at point.

If you conclude yes, you may want to consider a syntax with already-existing finder: @key?

Which actually raises another issue: by default, you don't put the properties in an org property drawer, so this function doesn't work with that change.

https://github.com/emacs-citar/citar/blob/d183ec20c407983c4ae22089ec481f1a6f5cbe69/citar-org.el#L312

I think you want to wrap them in :properties: and :end:?

@pprevos
Copy link
Owner

pprevos commented Feb 28, 2023

Hi Bruce,

In the version currently on my workbench I wrote citar-denote-dwim which calls the citar-dwm function for the citations keys in the reference line.

(defun citar-denote-dwim ()
  "Access attachments, notes and links associated with a bibliographic note."
  (interactive)
  ;; Any citation keys in the note?
  (if-let ((keys (citar-denote-retrieve-references (buffer-file-name))))
      ;; Check if citation keys are in the bibliography
      (if-let (keys? (not (seq-every-p 'null
                                       (mapcar (lambda (key)
                                                 (gethash key (citar-get-entries))) keys))))
          (citar-open keys)
        (user-error "Citation key(s) not in bibliography"))
    (if (denote-file-is-note-p (buffer-file-name))
        (when (yes-or-no-p "Current buffer does not reference a citation key.  Add a reference ?")
          (citar-denote-add-citekey)
          (citar-denote-dwim))
      (user-error "Buffer is not a Denote file"))))

Are these the sort of actions you seek?

Wold introducing the ampersand create backward compatibility issues?

Wrapping the references in properties is not in line with the Denote way of working.

@bdarcus
Copy link
Author

bdarcus commented Feb 28, 2023

Are these the sort of actions you seek?

I'm not really requesting it per se; more just noting what others have requested in related packages.

In citar, if you have point on a key in a property drawer, and you run embark-act, it will present you with a list of actions you can run on it. This transient menu does the same.

Would introducing the ampersand create backward compatibility issues?

IDK.

Wrapping the references in properties is not in line with the Denote way of working.

So rather than using standard org properties for metadata, the Denote "way" is to use non-standard equivalents (I see now they're actually not org properties because the syntax is slightly different), but not specific to org?

@pprevos
Copy link
Owner

pprevos commented Mar 1, 2023

I'll look into adding the ampersand as it is a nice indicator of a citation. I should be able to build it without having to change existing notes.

Denote does not only work with Org mode but also Markdown and plain text. Using a property line is normal practice in Org Mode so we are not deviating from standard Org Mode practice.

I'll keep it open until I have time to release the next version.

@bdarcus
Copy link
Author

bdarcus commented Mar 1, 2023

You mean ampersand (&) or asperand (@)?

Using a property line is normal practice in Org Mode so we are not deviating from standard Org Mode practice.

The properties that denote or citar-denote (I don't understand which) creates now aren't actually properties, so org doesn't see them. That's why that function returns nil, even if I add the asperand to the key.

https://orgmode.org/guide/Properties.html

@pprevos
Copy link
Owner

pprevos commented Mar 2, 2023

Denote works this way to create consistency with Markdown and text files. It does not aim to be Org Mode centric.

It seems that (org-element-parse-buffer 'greater-element) recognises the Denote in-buffer settings, i.e. identifier and reference.

Using (org-element-at-point) on the reference line gives the correct value.

This page has some good info: https://orgmode.org/worg/dev/org-element-api.html

I don't have any time to work on this until May, but I think we could make the Embark at point function work on the reference line.

@pprevos pprevos added the enhancement New feature or request label Mar 2, 2023
@pprevos pprevos modified the milestone: Review feasibility Mar 2, 2023
@bdarcus
Copy link
Author

bdarcus commented Mar 2, 2023

Notes for May, while fresh in my mind ...

Yeah, I may just be not understanding some details about denote etc.

In the end, it should ideally just be easy for the current citar at-point functionality to work well with both org and markdown (via the yaml or toml headers).

Right now, here's what I can conclusively say:

citar-key-at-point returns nil when on a citekey in the header of an org file created by denote/citar-denote, whether or not I add a @ prefix.

It correctly returns the citekey in the org and markdown files that citar and citar-org-roam create.

For example, this also works as expected when point is on citekey in the YAML header, and also therefore should in a TOML header.

---
title: test
reference: @testkey
---

And a body citation [@testkey].

We do not assume org-roam per se in this org code (the code doesn't look for the ROAM_REF key), but do assume a metadata citekey value of the form @citekey (which org-roam supports, but doesn't require).

That allows us to share code between markdown and org functions. And in markdown, it's the same syntax for the citekey in the body.

So am not sure why it doesn't work when I tried with this package and org. But as you say, we can look at that later.

One possibility is to write your own major-mode function(s) for this and include it in this package, though I think ideally files would be as compatible as possible across note-taking packages.

Another is to change the citar function somehow.

Aside: seems the new djot format is likely to adopt the same YAML-light metadata syntax as pandoc, and a very similar citation syntax. So at the inevitable point at which we see an Emacs note package that supports that format, citar already does!

@pprevos
Copy link
Owner

pprevos commented Mar 5, 2023

Thanks. I'll review all this in May (big trip to the US coming up). Ideally we get Citar to integrate with Denote using Org, Markdown and plain text.

@pprevos pprevos self-assigned this Mar 5, 2023
@pprevos
Copy link
Owner

pprevos commented Mar 7, 2023

Aside: seems the new djot format is likely to adopt the same YAML-light metadata syntax as pandoc, and a very similar citation syntax. So at the inevitable point at which we see an Emacs note package that supports that format, citar already does!

It is easy to configure Denote to accept djot by configuring denote-file-types. There does not seem to be a major mode for this format yet.

@pprevos
Copy link
Owner

pprevos commented Mar 9, 2023

Hi Bruce, I wrote that I don't have time to look at this issue till May (which is true), but than I got distracted by the other issue. Anyway, I should be doing other things, but the allure of Emacs hacking is strong.

@pprevos
Copy link
Owner

pprevos commented Mar 15, 2023

I thought a bit about this one. The current citar-denote-dwim function lets the user access resources related to references in a note by selecting a reference (if more than one) and umping to citar-open. This allows the user to get context on references without having to have point on it.

I could redirect this function to the Embark equivalent, in case citar-embark-mode is enabled. Would that be a acceptable solution to this issue?

@bdarcus
Copy link
Author

bdarcus commented Mar 15, 2023

IDK.

I can just say that from a user POV, in citar and citar-org-roam, at-point behavior is the same with citekey in the buffer, and in the metadata properties, regardless of what function one is using at-point (embark, a transient menu or hydra, etc.; the only exception is org-open-at-point won't recognize the reference in the property drawer).

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

No branches or pull requests

2 participants