dalanicolai / pymupdf-mode.el

Extend pdf-tools annotation capabilities via pymupdf
20 stars 0 forks source link

Don’t do spacemacs things when people don’t use spacemacs. #1

Closed c1-g closed 3 years ago

c1-g commented 3 years ago

Emacs won?t stop screaming about ?Symbol?s function definition is void? so this will fix my personal annoyance.

I'm sure there's probably a more elegant way to check for spacemacs but this will do.

Also, do you think that I can incorporate this into EAF's pdf-viewer? It also uses pymupdf so that might be pretty easy.

dalanicolai commented 3 years ago

Thanks, these functions indeed should get wrapped in some when. I am not sure how I can modify your PR, so I will send my suggestion as feedback. Maybe you'd like to extend the PR (you can simply press c e in magit after incorporating the changes) before I will merge it.

Incorporating into EAF is possible for sure. However, pymupdf was written to run as a comint process so that users could directly modify/apply pymupdf commands to the pdf from within the comint buffer. The mode is more or less just an experiment to see what was possible and how it would work. But using the comint is really slow. In EAF the pdf-reader is already just running as a python program. I would suggest you add these function directly to the python program which would make it very fast. There really is no need to make it slow and hacky like pymupdf for doing this in EAF.

So in EAF I think you can just add another annotation function to the app/pdf-viewer/buffer.py file. The only thing you would have to find out is how to get the information (coordinates) of the mouse click events, I see that the other annots use some buffer_widget.annot_select_char_area method for this. Maybe this is described in the pyqt docs, or you can ask the EAF maintainers. Having that, I guess it should further be pretty straightforward...