-
Notifications
You must be signed in to change notification settings - Fork 74
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
Use org-capture to create new notes #263
Conversation
Loading Org here makes helm-bibtex load slower with recent versions of Org.
Thank you for making this PR. A lot of things going on here. I will need to make some time to study this. Is this change going to introduce breaking chances for users of one or multiple notes files? What's the role of |
Is this change going to introduce breaking chances for users of one or multiple notes files?
I don't think so. There should be no difference for multiple files users. For one file users, a few things changed. First, they should notice org-capture when creating new notes. Second, they should see the point after the properties drawer and not at the beginning of the heading. Third, they might have to change the bibtex-completion-capture-template variable if they want something different as far as org-capture goes.
I'm also hashing the notes file so that if the file hasn't changed since the last time it was parsed, bibtex-completion-candidates reuses the notes keys which should make helm-bibtex load faster.
What's the role of bibtex-completion-notes-template-one-file in this new implementation? Is is redundant? If I understand correctly it should serves the same purpose as the capture template no? Sorry if I misunderstood something.
bibtex-completion-notes-template-one-file is what org-capture uses to create the notes template. The user could still do everything from the capture template but it would look something like this:
(setq bibtex-completion-capture-template
'("bibtex" "helm-bibtex" entry (file+headline bibtex-completion-notes-path "New Notes")
"%(bibtex-completion-clean-notes-string (s-format \"\n** ${author} (${year}) ${title}\n:PROPERTIES:\n:Custom_ID: ${=key=}\n:END:\n\n\"
'bibtex-completion-apa-get-value (bibtex-completion-get-entry entry)))"))
I think it may be easier for the user if we separate notes template from the capture template, WDYT? (cc @leezu)
|
(progn | ||
(require 'org-capture) | ||
(unless (assoc-default "bibtex" org-capture-templates) | ||
(cl-pushnew bibtex-completion-capture-template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sese to remove "bibtex" from org-capture-templates
after completion of bibtex-completion-edit-notes-one-file
? My concern is, that running org-capture
separately from bibtex-completion-edit-notes-one-file
should not show the "bibtex" action. (I haven't tested if this is the case with your code, but it seems to be the case?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even better, could we just let-bind org-capture-templates
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use let binding since opening #260 and didn't observe any interference with "normal" org-capture use.
Would it make sese to remove "bibtex" from `org-capture-templates` after completion of `bibtex-completion-edit-notes-one-file`? My concern is, that running `org-capture` separately from `bibtex-completion-edit-notes-one-file` should not show the "bibtex" action. (I haven't tested if this is the case with your code, but it seems to be the case?)
It's definitely not the case. At least I don't see the "bibtex" template show up, which I think is expected when we use a string and not a key as part of the template.
|
@jarg, I haven't tested it but how is it possible that we permanently push a new template and then it doesn't show up? I must be missing something. |
On 17 Apr 2019, Titus von der Malsburg ***@***.***> wrote:
@jarg, I haven't tested it but how is it possible that we permanently push a new template and then
it doesn't show up? I must be missing something.
Try this:
(add-to-list 'org-capture-templates
`("bibtex" "Bibtex" entry (file ,(car org-agenda-files))
"* %?\n"))
Do you see anything different when you call org-capture interactively?
Now eval this:
(org-capture nil "bibtex")
|
Ah, I see what you mean. But I think "bibtex" as the key of the template is actually not allowed. See here: https://orgmode.org/manual/Template-elements.html#Template-elements p.s: The template is still in |
Are you sure? The docstring says:
ELisp programs can set KEYS to a string associated with a template
in `org-capture-templates'. In this case, interactive selection
will be bypassed.
|
I think by "string" they mean the data type string:
Multiple characters are possible as well but there are constraints:
|
Either way, I think we should perhaps not change the user's configuration in a way that may not be transparent to them. |
Sorry for letting this slide. Life is too busy and I don't find the time to study this PR more in depth. Hopefully I will get to it soonish. For now just one question: A solution relying on existing infrastructure (org-capture) would ideally involve fewer lines of code than something home-grown and would therefore be easier to maintain. However, the present PR overall adds 52 lines. Is there a way to make this feature more compact? No need to write any code. Just looking for ideas. In general maintainability has become an issue with this software and it has prevented me from merging some other features as well. If I had time, I'd heavily refactor the whole package. |
I should've made smaller PRs. Sorry about that. Anyway, the idea is to use org-capture when creating new notes, so in theory we would need a new variable for defining the template, and a way to call org-capture programmatically when the Edit notes command is run. Also, I made the bibtex-completion-edit-notes smaller, in the hope of making it easier to maintain, by creating a separate function for the one file case and another one for the multiple files case. That's probably why the PR got so bloated. Anyway if you want it shouldn't be difficult to implement this feature from scratch.
|
Sorry for not getting back to you earlier. A solution using org-capture is the goal for the future. Do you think #309 might be a good stepping stone? |
Looks good AFAICT. It uses org-capture-fill-template to expand the
template which is nice. We should also consider replacing
bibtex-completion-notes-mode with org-capture-mode eventually.
|
See #260