-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Copy cite command should respect preferences #10615
Comments
I confirm this bug, making version 5.1.1 not usable. Revert to 5.10 and hoping, that it is corrected soon |
Hello koppor, hope everything's well. This is my first time taking a issue and I wonder if I can take this one? Thanks |
Hello koppor, I hope you're doing well. This is my first time addressing an issue, and I'm wondering if I can handle this one. Thanks! |
Sorry for the late reply. I will assign @OvercloudX, because of first come first serve. @keshav2025 Please choose another issue. We usually only assign one issue per student to avoid trouble further down the road. I am sorry. |
Thanks u so much, im gonna start up in it |
Indeed. Maybe your browser has issues? Could you try with another one? I use Mozilla Firefox and I can see the image. What happens, if you click on that image link? |
I use edge, and I tried Firefox but it had the same problem. When I click the image link it shows 404 not found. |
Ok, I think I fixed it. Apparently the links to those images were copied from a private protected GitHub repository. I uploaded new images, which you now should be able to see. Could you please confirm, if you can see them now? |
yes, it works, thank you for your help |
Can you now reproduce the issue? You can open the example BibTeX file https://github.com/JabRef/jabref/blob/main/src/test/resources/testbib/jabref-authors.bib. And then you can go to an entry and try to do "Copy \cite{citationkey}". I think, even this context menu item text needs to be adapted based on the preferences. |
Yes, I've succeeded reproduce the issue I think. I saw that it was different when I imported to TEX Studio using two methods. Thank you for the help. |
@koppor @ThiloteE Hello I have a question about the step3. It is said that the default prefix should be "{" but when I check the defaultCiteCommand in the java/org/jabref/preferences/ExternalApplicationsPreferences.java, I found it was "\cite{key1,key2}" so I wonder if the default prefix is "\cite{" or "{" ? |
Please forgive me if I made any silly mistake because I'm new in code. |
You can reproduce by
Now, you should see See https://github.com/JabRef/jabref/pull/10303/files#diff-42a07fbc47ff359873a26e31184338ddf82ddcecf188dac16da1ef103eae3833R703 for the change introduced in the PR Please note that I linked the PR in the first words of the issue description You need to click on "Files changed" Then scroll down to Is it now more clear? |
@OvercloudX Did you do step 2 - and modify org.jabref.preferences.ExternalApplicationsPreferences#getCiteCommand? Can we see it a draft pull request? |
Yes, I think I may successfully finished the part 2 and I'd like to make a draft PR to you. I changed the method and created a record(CitationCommandStringPreferences). |
@OvercloudX You probably have to mock the preferences with prefs = mock(ExternalApplicationsPreferences.class) and then using when(prefs.getCiteCommand).thenReturn... |
Thank you for the help, gonna that right now |
Thanks, that's more clear, but I still confused with these things:
Thank you again for taking the time and effort to help me |
Software Engineering is also about clear requirements. It is good that you try to understand them. I would ask you to read and try to understand existing material. Please take the time to read. No rush. I assume you worked with Microsoft Word and not with LaTeX and JabRef. Then, it takes even more time to understand the whole setting. In the statements you gave me, I can just write "yes" as answer. Do you ask about the why? From #10303, there is #10133 linked. I try to copy and paste from that.
Yes. JabRef 5.10.
Yes. JabRef 5.10 to 5.11. Quoting: #10133
Quoting #10303 with a highlight. Screenshot of today's JabRef: Did you click on the question mark? It leads to https://docs.jabref.org/cite/pushtoapplications I highlight the important part. It is still worth to read the complete page. Now click on "Copy \cite{citaton key}" Result is:
Which is wrong. The issue is about to fix THAT behavior. |
@koppor Thanks for your advice, I'll read them again. |
@OvercloudX We did not see any activity on your side. Do you intend to continue? |
Hi there, recently I don't have much time to do it. But I still have strong willing to continue after several days. But if there's anyone who want to take this issue now, I don't mind if you give it to someone else, because I don't want to take up public resources either. |
Take your time, we will be happy, if you come back to this :-) |
* Fix Copy cite command should respect preferences Fixes #10615 * add changelog fix checsktyle * Fix CHANGELOG.md * Add missing "citation" to "key" * Add debug message at error in logic in CopyMoreAction * Add fallback if preference could not be parsed * Fix key binding setting * More relaxed parsing * Streamline code in AbstractPushToApplication * Add more test cases for configured citation command * Streamline code for copy action * Update src/main/java/org/jabref/gui/preferences/external/ExternalTabViewModel.java * Fix test --------- Co-authored-by: Oliver Kopp <[email protected]>
#10303 introduced a new cite command:
It is parsed at
org.jabref.gui.push.AbstractPushToApplication#dissectCiteCommand
.However, in
org.jabref.gui.edit.CopyMoreAction#copyCiteKey
, this pattern is not used.This leads to
\cite{key1,key2}{Khalaf2007}
for keyKhalaf2007
.Implementation
org.jabref.logic.citationkeypattern.CitationKeyPatternPreferences
toCitationKeyGenerationPreferences
.org.jabref.preferences.ExternalApplicationsPreferences#getCiteCommand
to return arecord
havingprefix, delimiter, suffix
as string. There, the value is constructed based on the code at org.jabref.gui.push.AbstractPushToApplication#dissectCiteCommand. - No need to introduce caching there. That could be done as next step. (This code does not run for a long time, so no performance issues expected). Name therecord
CitationCommandStringPreferences
.\cite
. It should work nevertheless. It should use,
as delimiter and{
as prefix, and}
as suffix (as fallback if nothing was provided). Adapt the code ofCitationKeyGenerationPreferences
accordingly. If this is successfully done, The command "Push entries to external application" adds a "null" prefix and suffix to an existing Citationkey in LaTeX. #10568 is fixed.getCitePrefix()
,getDelimiter()
, andgetCiteSuffix()
to use the introducedCitationStringPreferences
.org.jabref.gui.push.AbstractPushToApplication#dissectCiteCommand
.Removeorg.jabref.gui.push.PushToApplication#getDelimiter
Change parameter at org.jabref.gui.push.PushToApplicationCommand#pushEntries to useThis is wrong; since application's delimiter has higher precedence than the one of the citaton command.CitationCommandStringPreferences
s delimiterorg.jabref.gui.edit.CopyMoreAction#copyCiteKey
to use the new preferenceThe text was updated successfully, but these errors were encountered: