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

customisation option for note display string in Citar UI #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

einsiedlerspiel
Copy link
Contributor

Introduces a new variable citar-org-roam-format-candidate-fn which defines the function used to format the display string for roam notes in the Citar UI. This allows users to easily define a new format for these.

Also changes the default format to include the note title. With possibly multiple notes attached to the same CiteRef the citekey is not necessarily a unique identifier.

I'm not entirely sure this is the best solution to allowing customisation. I played around with using org-roams own templating system but that would've been a much more involved change. I think the solution in this PR is flexible enough.

The API for the formatting function is easily expandable by exposing more node properties. This might be wise to do to discourage users from doing their own additional queries to the roam database in the formatting function.

Love the package btw. thanks for creating it! :)

Introduces a new variable `citar-org-roam-format-candidate-fn` which defines the
function used to format the display string for roam notes in the Citar UI.
@einsiedlerspiel
Copy link
Contributor Author

I just realized that the version of the formatting function I commited is a bit mangled. Sorry it's late. Before I spam more fixing commits here my suggestion for the new default:

(defun citar-org-roam-format-note-candidate (nodeid citekey title)
  (concat 
   " ["
   (propertize citekey 'face 'citar)
   (truncate-string-to-width "] " (- 20 (length citekey)) nil 32)
   (propertize title 'face 'citar-highlight)))

It's similar to the old default just flipped face between citekey and title and shortened the string a bit.

@bdarcus
Copy link
Contributor

bdarcus commented May 9, 2024

@einsiedlerspiel - sorry I've dropped the ball on this. I probably looked at this initially and forgot to come back to it.

Any update on your end?

@einsiedlerspiel
Copy link
Contributor Author

einsiedlerspiel commented May 14, 2024

@bdarcus Hi sorry I haven't really looked at this in a while. But the status on it is basically that I still think it would be nice to have the formatting exposed for customization, but what I proposed here is probably not that good and the current default formatting is fine actually, not sure what i was thinking there (the default format might also have changed at some point?).

I could rework this to just introduce the customization variable without changing the formatting function. That'd be fairly trivial.

Although as I said in the Initial PR, integrating with org-roams completing read formatting would probably be nicer but is iirc kind of awkward because citar doesn't use the same format for the candidates as org-roam, so that would require a deeper rework.

IIRC Org Roam expects node-structs to be passed around while citar works with its own db-queries.

@einsiedlerspiel
Copy link
Contributor Author

Re: Changing the default

I think why I went for that was that at some point, the node title wasn't included in the formatting making nodes that referred to the same citeref indistinguishable but that's not the case any more.

Although this comment is still in the code and should be removed in any case:
(

;; TODO include note title in the candidate string?
)

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

Successfully merging this pull request may close these issues.

2 participants