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

Coding style for org-roam-bibtex #13

Open
myshevchuk opened this issue Apr 20, 2020 · 17 comments
Open

Coding style for org-roam-bibtex #13

myshevchuk opened this issue Apr 20, 2020 · 17 comments
Labels
1. enhancement New feature or request

Comments

@myshevchuk
Copy link
Member

@zaeph
There are a couple of general emacs-lisp style guides, most notably the official one:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Coding-Conventions.html
and another one here:
https://github.com/bbatsov/emacs-lisp-style-guide

I would suggest we adhere to the guidelines outlined in the above resources. Which we seem to have been doing so far anyway.

I have started this issue, however, with subtler matters in mind, which it seems did not make it into the guides, and which will likely arise in the development process.

In the recent commit 715083d I have introduced .dir-locals.el and also a file-local variables section at the bottom of org-roam-bibtex.el.

So far, sentence-end-double-space is set to t as a top-directory variable (Emacs default). It seems my Emacs installation has it set to nil and I have constantly been messing up the spaces in the doc-strings - I would like to apologise for that.

I also set fill-column to 70 , which is Emacs default, as a file-local variable.

If you have other preferences, please feel free to change these and other relevant variables to your liking. I care as much as to keep the things coherent, the actual values being of lesser importance.

@zaeph
Copy link
Member

zaeph commented Apr 20, 2020

So far, sentence-end-double-space is set to t as a top-directory variable (Emacs default). It seems my Emacs installation has it set to nil and I have constantly been messing up the spaces in the doc-strings - I would like to apologise for that.

No problem whatsoever, don't sweat it.

So far, sentence-end-double-space is set to t as a top-directory variable (Emacs default). It seems my Emacs installation has it set to nil and I have constantly been messing up the spaces in the doc-strings - I would like to apologise for that.

I also set fill-column to 70 , which is Emacs default, as a file-local variable.

Sounds good. I'm ironing it the kinks as I see them, but I'm learning as I'm going, just like you I assume. On top of the links you've mentioned, there's also @alphapapa's excellent Emacs Package Developer's Handbook.

Now that the README.md is a little more furnished, I'm focussing on testing. I'm learning the ropes of emacs-buttercup. It's finals week for me, though, so there probably won't much work done on the project on my end this week.

And thanks again for your help maintaining the package. I think we've done pretty good so far! 🚀

@zaeph zaeph added the 1. enhancement New feature or request label Apr 20, 2020
@myshevchuk
Copy link
Member Author

Yes, thank you very much for you collaboration! Indeed, everything is developing very nicely.

@myshevchuk
Copy link
Member Author

myshevchuk commented May 3, 2020

Here I would suggest that we do not require our feature libraries in org-roam-bibtex.el, except for orb-compat.el of course. Currently, we have only orb-note-actions.el, which has only one user function orb-note-actions, which has the autoload magic comment. Normally, when a package is installed through a package manger such as package.el, use-package or straight.el, the autoloads file is generated automatically.

There are potentially two problems with this paradigm.

  1. user variables (customize definitions) are not discoverable until the package is loaded, that is until the autoloaded function is called.
  2. autoloads, of course, are not generated automatically if the main file org-roam-bibtex.el is loaded with load-file rather than a package manager.

The latter problem can be addressed easily by providing instructions in README on how to generate autoloads file.
The former surely can also be solved but I need to research how to do this correctly.

We may also have in future some auxiliary library or libraries that would contain purely utility functions akin to orb--unformat-citekey, which could be potentially used across several "functionality" or feature libraries. Those, of course, should be required in org-roam-bibtex.el. Currently, there is only one such file, org-compat.el mentioned earlier.

So the structure would be like this:

utility libraries -> org-roam-bibtex.el -> feature libraries

The arrows show how the features are provided. Utility libraries provide features to org-roam-bibtex.el, which requires them. Feature libraries require only org-roam-bibtex.el, which will also provide the features provided to it by the utility libraries.

@zaeph
Copy link
Member

zaeph commented May 4, 2020

So the structure would be like this:

utility libraries -> org-roam-bibtex.el -> feature libraries

Sounds good.

I think I got confused because I couldn't get my Emacs to load the library at some point, but that might have been due to an unrelated error. I might have been using the wrong session to run my tests, one which hadn't loaded orb-note-actions.el, or maybe I screwed up and didn't reload the file upon checkout. At any rate, sorry for that.

And so, this understanding led to #25, which led to a recursion error spotted by #27, and fixed in 8cc2d95.

I think that the bulk of the confusion came from #26: where to define the key-binding? In the org-roam's use-package? In a separate, parallel use-package just for orb-note-actions? Or one nested in org-roam's?

  1. autoloads, of course, are not generated automatically if the main file org-roam-bibtex.el is loaded with load-file rather than a package manager.

That is such an edge-case that I'm not even sure if it bears mentioning

@zaeph
Copy link
Member

zaeph commented May 4, 2020

#30 reverts f0a65ae. I'll let you merge once you've confirmed this is what you wanted.

@zaeph
Copy link
Member

zaeph commented May 4, 2020

Also, I'm crunching for my MA thesis right now, so I'm going to take the week off to focus on it. I'll try to keep an eye out on the repo, but I won't be doing anything substantial.

@myshevchuk
Copy link
Member Author

myshevchuk commented May 4, 2020

There is nothing principally wrong in requiring orb-note-actions in the main file. Autoloading it is a tiny optimization - tiny considering the current size of the library - that is inline with the current trend to autoload everything. I'm using doom-emacs, which takes care of installing the packages and autoloading them (via straight), so the previous version worked fine for me. I haven't tested it with a bare minimum though. I think at some point we'd need to set an automated test environment, but that is a long-standing goal I guess. I'm currently busy with my PhD thesis and am not currently predisposed to engage in this type of work.

If you install org-roam-bibtex with MELPA and use use-package, the setup should be as simple as this, essentially as described in the README but without the extra parentheses around ("C-c n a" . orb-note-actions) (maybe this was the cause of the problems?)

(use-package org-roam-bibtex
:after org-roam
:bind (:map org-mode-map
         ("C-c n a" . orb-note-actions))
:hook (org-roam-mode . org-roam-bibtex-mode)
:config
(setq ...))

Could you please test the latest commit of this branch with the setup above? No need to hurry though, this can wait.

@zaeph
Copy link
Member

zaeph commented May 4, 2020

Could you please test the latest commit of this branch with the setup above? [emphasis added]

Do you mean #30 or master?

@myshevchuk
Copy link
Member Author

#30 with my commit.

@zaeph
Copy link
Member

zaeph commented May 4, 2020

#30 with my commit.

It's working. I'm merging.

@myshevchuk
Copy link
Member Author

Ok, good.

@zaeph
Copy link
Member

zaeph commented May 4, 2020

Also, I've disabled the option to merge all commits from a PR, and instead, we're going to squash-then-merge them. That'll prevent a lot of small commits from crowding up the history.

@myshevchuk
Copy link
Member Author

YES!

@myshevchuk
Copy link
Member Author

Now, enough procrastinating. It's working, it's doing its job. And there is real work ahead to be done.

@zaeph
Copy link
Member

zaeph commented May 4, 2020

Righto. Glad to know you're in the spot as I am, although a bit further down the line.

Let's reconvene once we've done enough progress to convince our supervisors that we're doing decent work. 🤡

@myshevchuk
Copy link
Member Author

myshevchuk commented Jun 5, 2020

I've created a development branch develop, which is not for merging with master but for testing purposes. All the new branches should first go into it and then into master. It would also make it more convenient to test different features together, since different feature branches can be developed independently and are not always supposed to be merged one into another. They instead should be merged into this branch.

New features should start on master and then merged back into it after being tested on develop.

@zaeph
Copy link
Member

zaeph commented Jun 9, 2020

Sounds good. I did it in a next branch on my own fork, but develop works just as well.

myshevchuk added a commit that referenced this issue Jul 29, 2020
* feature: reference scrapper

* interactive orb-reference-scrapper process

* create special orb-temp-dir

* fix orb-reference-scrapper--cleanup

* another fix for buffer cleanup

* prevent multiple orb-reference-scrapper processes

* s/orb-reference-scrapper/orb-pdf-scrapper

* isolate orb-pdf-scrapper--sanitize-txt

* major reformatting

* orb-with message macro

* orb-pdf-scrapper-anystyle with plist options

* polishing orb-anystyle, documentation

* minor adjustments to orb-anystyle

* use orb-anystyle in orb-pdf-scrapper

* switch between txt and bib, interactively

* fix orb-pdf-scrapper-mode-map

* better regexp for orb-pdf-scrapper-sanitize-text

* replace switch-to-buffer with pop-to-buffer

* better regexp for sanitize text

- also library dependencies

* rename: to `orb-pdf-scrapper-keygen-function`

* isolate journal regexp function

- /s/orb--tsv-to-list /orb-pdf-scrapper--tsv-to-list
- improve pages regexp

* fix anystyle check

- check command does not require a valid format option
- additionally, renamings in orb-pdf-scrapper

* add variables, fix regression in keygen function

- orb-data-dir
- orb-anystyle-parser-model
- orb-anystyle-finder-model

* fix anystyle model keys, scrapper sanitize

* fix library requires

* orb--buffer-string; rename util. funcs.

* refactor and document orb-pdf-scrapper

* set file local fill-column to 79

relevant to #13

* autokey functionality: format field

* fix typos, new journal abbreviations

* it works; added docstrings

* fix type mismatch in orb-autokey-generate-key

* fix orb-autokey-generate-key elisp evaluation

- save match data before evaluation

* eval-when-compile rx; autoload orb-autokey..

* rewrite pdf-scrapper citekey generation

* fix edge cases in orb--autokey-format-field

* add edit-org interactive context

* defvar orb-anystyle crop

* right order for org-roam-capture-templates

* refactor orb-anystyle

* refactor orb-pdf-scrapper.el

* separate undo history for different modes

+ refactor orb-pdf-scrapper.el

* refactor autokey functions

* remove journal_titles.tsv and related code

- this was too much tailored to my discipline; it was here for
development and testing purposes and now goes back to my personal config

* remove orb-data-dir

* orb-autokey-invalid-field-marker

* rename orb-autokey-invalid-field- s/marker/token

* extract orb-pdf-scrapper--generate-key-at-point-1

- parsing a single record was extracted into a separate function
- this function is used in commands `orb-pdf-scrapper-generate-keys`
and `orb-pdf-scrapper-generate-key-at-point`
- use parsebib instead of bibtex-completion-get-entry to avoid
setting buffer-local bibliography
- references are stored unsorted until they are passed to
`orb-pdf-scrapper--edit-org`

* C-u prefix for orb-pdf-scrapper-generate-keys

- remove `orb-pdf-scrapper-generate-key-at-point`, move its
functionality into `orb-pdf-scrapper-generate-keys` making it accessible
with the universal argument

* remove option `orb-pdf-scrapper-keygen-function`

- customization of key generation can be achieved
with `orb-autokey-generate-key`.
- customization of how to validate keys, which fields
to set and which to export can be achieved with corresponding
user variables

* docs: :after org-roam in use-package examples

- leaving it out may potentially lead to loading problems #66

* fix a few minor regressions after refactoring

* insert as org list or table, minor fixes

* add parser training session, refactoring

* set orb-autokey-titlewords-ignore directly

* optimize lazy loading

* orb-autokey-invalid-characters

- filter characters not allowed in BibTeX/LaTeX
- `orb-autokey-invalid-characters` is a user variable for such
  characters
- " and " ("and" surrounded with spaces) as the name field delimiter
- orb-autokey-titlewords-ignore is not copied from
  `bibtex-autokey-titleword-ignore`. This was really a bad idea.
- rename `orb-autokey-invalid-field-token` > `orb-autokey-empty-field-token`

* orb-autokey latest commit follow-up

* fix year expansion edge cases

* set fields per entry type; customize definitions

- in `orb-pdf-scrapper-set-fields` list, entry types can be specified in
the tail of element's list. The field will be set only if its record's
type is a member of those types
- `defcustom` definitions for user variables
- minor refactoring

* refactor orb-pdf-scrapper--insert-org-as-table

also defcustom for orb-pdf-scrapper-mode-hook

* fix training session bug; backup master xml file

* anystyle defcustoms

* Add note actions documentation

- also make `orb-note-actions-default` a user variable

* Update README.md and docstrings

* Fix missing quote

* Require pdf-scraper in relevant action

* Clarify language

The filling might have been messed up, so it’ll probably require a clean-up
later down the line.

* use biblatex dialect in BibTeX mode

* fix invalidate-range regexp

Co-authored-by: Leo Vivier <leo.vivier+dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants