Comments (31)
But it also, and I think prefers, date
.
Can any of you test this PR and confirm it works as expected?
from citar-denote.
Yeah:
https://stackoverflow.com/questions/1911109/how-do-i-clone-a-specific-git-branch
from citar-denote.
Hi Bruce, your function is great. Thanks for adding this upstream. I have integrated it with my code.
Will commit when your branch goes into citar main.
from citar-denote.
I have just committed the updated Citar-Denote package 62169f5, including updated manual. Big thanks to Adrian and Kai for the suggestions and Bruce for updating Citar to enable this functionality.
The update should land in MELPA within the next 24 hours.
from citar-denote.
Hi Adrian,
Thanks for the feedback. I have fixed the documentation and the code and committed the new version to GitHub (with some other enhancements).
In the current version, if the actual number of authors/editors is less than citar-denote-title-format-authors
, then they will all be listed. I think that is a reasonable and logical behaviour. There are too many citation styles to add subtleties to this package.
from citar-denote.
Yes; sorry if that was unclear. I've opened an issue in citar to address it there.
from citar-denote.
Just a little update on the citar end.
I did merge a small change yesterday that allows one use citar-citeproc-format-reference
to use arbitrary CSL styles, and so to do as in org-bib
.
But I'm also thinking of just allowing, in both citar
and in citar-org-roam
, users to configure to use citeproc
in place of the citar templates.
In practice, then, they would be able to choose a CSL style, and that fully-formatted reference (as you would see in a bibliography) would become the title content.
But I still need to sort out details; not just whether to do it, but how.
Let me know over there if any feedback @adrianadermon?
from citar-denote.
Hi Adrian,
This can certainly be done with an option.
The only slightly complex issue is the author name.
Citar only gives the full name, e.g. Adermon, Adrian.
This means I need a cleaning function (which could be useful in Citar as well). I assume you need: "Adermon (2023)" (1 author) or "Adermon and Prevos (2023)" (2 authors) or "Adermon et al. (2023)" (3 or more authors).
Such a function could be useful for Citar as well, ping @bdarcus.
P:)
from citar-denote.
Citar only gives the full name, e.g. Adermon, Adrian.
Try this function:
(citar--shorten-names "Doe, Jane and Smith, Joan")
from citar-denote.
Thanks @bdarcus, that is a great. The word "and" could possibly be a variable as it is language-dependent.
@adrianadermon , can you please try this function on some of your citekeys?
(defun citar-denote-extract-author-year (citekey)
"Extract author (year) from CITEKEY."
(let* ((author-full (citar-get-value "author" citekey))
(author-full (if (not author-full)
(citar-get-value "editor" citekey)
author-full))
(author (citar--shorten-names author-full))
(year (citar-get-value "year" citekey)))
(concat author " (" year ")")))
from citar-denote.
Thanks for the quick reply @pprevos, @bdarcus! This is great, but there are two things that could make it even better.
First, I'd love to be able to shorten it when there are many coauthors (say, more than two) to "Adermon, pprevos et al. (2023)".
Second, for two or more authors, it gives me a comma-separated list: "Adermon, pprevos (2023)", but ideally it would be "Adermon & pprevos (2023)". For more than two authors (and assuming no et al.), it would be "Adermon, bdarcus & pprevos (2023)".
from citar-denote.
I just completed an improved version that either gives:
- Author (year)
- Author1 and Author2 (year)
- Author1 et al. (year)
(defun citar-denote-insert-author-year (citekey)
"Extract author (year) from CITEKEY."
(let* ((author-full (citar-get-value "author" citekey))
(author-full (if (not author-full)
(citar-get-value "editor" citekey)
author-full))
(names (citar--shorten-names author-full))
(idv-names (mapcar
(lambda (n) (replace-regexp-in-string "," "" n))
(split-string names)))
(num-authors (length idv-names))
(author (cond ((equal num-authors 1) names)
((equal num-authors 2)
(concat (car idv-names) " and "
(cadr idv-names)))
(t (concat (car idv-names) " et al."))))
(year (citar-get-value "year" citekey)))
(concat author " (" year ")")))
So far only works with BibTeX files, not quite yet with CSL files. Please give it a whirl.
from citar-denote.
Refactored version that works on BibTeX and CSL:
(defun citar-denote-insert-author-year (citekey)
"Extract author (year) from CITEKEY."
(let* ((author-full (or (citar-get-value "author" citekey)
(citar-get-value "editor" citekey)))
(names (citar--shorten-names author-full))
(idv-names (mapcar
(lambda (n) (replace-regexp-in-string "," "" n))
(split-string names)))
(num-authors (length idv-names))
(author (cond ((equal num-authors 1) names)
((equal num-authors 2)
(concat (car idv-names) " and "
(cadr idv-names)))
(t (concat (car idv-names) " et al."))))
(year (or (citar-get-value "year" citekey)
(citar-get-value "issued" citekey))))
(concat author " (" year ")")))
from citar-denote.
And finally, evaluating this should give you the requested functionality. If you successfully test it, then I will add it to the next version.
Configure the variable to set your default behaviour.
(defcustom citar-denote-note-title nil
"Title format for new bibliographic notes.
- \"title\": Extract title from entry
- \"author-year\": Author-year citation style
- nil: Full reference"
:group 'citar-denote
:type 'string)
;; Replacement function
(defun citar-denote-create-note (citekey &optional _entry)
"Create a bibliography note for CITEKEY with properties ENTRY.
The file type for the new note is determined by `citar-denote-file-type'. The title of the new note is set by `citar-denote-note-title'. When `citar-denote-subdir' is non-nil, prompt for a subdirectory."
(let ((title (citar-get-value "title" citekey))
(author-year (citar-denote-insert-author-year citekey)))
(denote
(read-string "Title: "
(cond ((equal citar-denote-note-title "title")
title)
((equal citar-denote-note-title "author-year")
author-year)
(t (concat author-year " " title))))
(citar-denote-keywords-prompt)
citar-denote-file-type
(when citar-denote-subdir (denote-subdirectory-prompt)))
(citar-denote-add-reference citekey citar-denote-file-type)))
from citar-denote.
Works perfectly!
Only one more thing - since users might have different preferences for the number of authors to be shown before switching to "et al.", it might be nice to make it possible to change that number?
Regardless, thanks for being so responsive, and for making this great package!
from citar-denote.
I thought we had modified the citar function (which, BTW, is really designed for the minibuffer display) to enable et al as an option.
Regardless, I think the way to do that right is probably just to have an optional parameter whose value is an integer.
from citar-denote.
Ah, it was unresolved, because I got stuck on how to integrate it with templates.
But I can at least add the function enhancement easy enough.
So in the end, I think the function should add two optional arguments: truncate
(an integer) and and
(a string; like "and").
from citar-denote.
(year (or (citar-get-value "year" citekey)
(citar-get-value "issued" citekey))))
You don't support biblatex here.
from citar-denote.
It would be great if the customization also allowed to choose the citekey itself as the title of the denote note. I'm already used to using the citekey in the filename for any associated pdfs and so on.
from citar-denote.
choose the citekey itself as the title
Sure @fintelkai, how about having that as the nil option and configure as such:
(defcustom citar-denote-note-title "title"
"Title for new bibliographic notes.
- \"author-year\": Author-year citation style
- \"title\": Extract title (or short title) from entry
- \"full\": Full citation
- nil: Citekey as-is"
:group 'citar-denote
:type 'string)
Not sure if this is the proper way to use defcustom
, but it works.
from citar-denote.
don't support biblatex
@bdarcus , BibLaTex also uses the year field.
from citar-denote.
Thanks, I'll check it out this later. I am not so good with GitHub. How do I access the code? Can I clone the branch?
from citar-denote.
I just need to figure out how to adjust the citar template language so I can add it to citar-org-roam
. One possibility, though there are some nuances noted farther down:
emacs-citar/citar#694 (comment)
from citar-denote.
Great work Bruce. I am doing the final testing for the new Citar-Denote, with a dependency on Citar 1.1.
from citar-denote.
I've had a chance to try out the new functionality now. It works great, with two small issues:
First, the default value of citar-denote-title-format-authors
is 1, although the documentation says it's 2.
Second, when citar-denote-title-format-authors
is set to 2, it gives titles like “Coppa & Hass et al. (2008)”. This is as documented, but I would prefer to have it give only the first author before "et al." in cases where there are more authors than the maximum, regardless of the value of citar-denote-title-format-authors
. This would give “Coppa et al. (2008)” instead. I understand if this is not prioritized though.
from citar-denote.
Preface: I created CSL, so am painfully aware of the complexities of all this. And @pprevos is right this is intended to be a lightweight solution.
Anyway, on the details, here's an example from such a CSL style:
<bibliography et-al-min="4" et-al-use-first="1" entry-spacing="0" second-field-align="flush">
So already it has two parameters while this function only one.
You can read the documentation of et-al handling here, which actually shows more than two parameters.
https://docs.citationstyles.org/en/stable/specification.html#name
If you can come up with a reasonable way to extend the citar function (e.g. without too much complexity), we can consider that over there (in which case you can put in a feature request there).
Note, however: one wrinkle that CSL processors handle, but this likely won't: disambiguation. What do you do with these if you want only the first name?
Doe, J and Smith, K
Doe, J and Jones M
The current function would only print the first name, but that could be ambiguous, particularly if the same publication year. But adding support for that is too complicated for this purpose.
EDIT: I wonder if it's possible to use the new variable modifier feature (documented here) I just merged to have citeproc do name formatting somehow? Do you know if that's practical @andras-simonyi; to use citeproc only to format, for example, a list of author names?
from citar-denote.
Do you know if that's practical @andras-simonyi; to use citeproc only to format, for example, a list of author names?
Without being familiar with the context, I'd say it should be possible, IIRC Nicolas P. Rougier's Literate & annotated bibliography mode uses citeproc to render authors' names in previews.
from citar-denote.
Oh, perfect; thanks!
from citar-denote.
Actually, we already have citar-citeproc-format-reference
, which can do this. It would just need to allow an optional style
argument, I think, so that one can use arbitrary styles, like the one that Nicolas uses for name formatting.
from citar-denote.
I prefer to keep citation styling issues out of my package as much as possible and rather lean on a specialised package.
The current version will stay as-is until a more configurable solution is available from another package.
from citar-denote.
Thanks for all the help Bruce - and thanks for developing CSL.
from citar-denote.
Related Issues (11)
- Using specific directory for citar notes HOT 3
- Include subdirectory? HOT 7
- Feature request: Add support for citations in the backlinks buffer ? HOT 4
- reference key as target-finder? HOT 11
- Running citar-create-note doesn't add a "#+reference" HOT 5
- Add additional information from bibliographic entry into note, with pre-defined formatting? HOT 4
- Create a denote note including the citekey and bib keyword in one step. HOT 6
- Miss candidate with citar-denote-find-citation HOT 6
- Obsolete symbols, some further integration HOT 5
- add an easy way to insert a link to the note of a given reference? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from citar-denote.