emacs-eaf / eaf-pdf-viewer

Fastest PDF Viewer in Emacs
GNU General Public License v3.0
75 stars 25 forks source link

Using with Auctex #88

Open Sparsa opened 1 year ago

Sparsa commented 1 year ago

Describe alternatives you've considered I have configured it with Auctex, and it is working as expected. I come from a pdf-tools background, it works much better than pdf-tools in fact I love to use dark mode to view the pdf. The only thing that bothers me is the accuracy of "Double click the left button to edit backward" which is only showing the line but not the word, but in pdf-tools, it was accurate up to words in most cases. In fact, auctex supports this accuracy. It would be great if EAF could be configured to word-level accuracy for reverse searching.

Additional context My auctex setup is as follows `(load "auctex.el" nil t t); it loads auctex

(add-hook 'LaTeX-mode-hook ;this are the hooks I want to enable during LaTeX-mode (lambda() (turn-on-reftex) ;enable reftex (set (make-local-variable 'company-backends) '((separate: company-reftex-labels company-reftex-citations) (separate: company-auctex-symbols company-auctex-environments company-capf company-auctex-macros) company-math-symbols-latex company-latex-commands )) (rainbow-delimiters-mode) (setq TeX-auto-save t) ;enable autosave on during LaTeX-mode (setq TeX-parse-self t) ; enable autoparsing (setq TeX-save-query nil) ; (setq TeX-source-correlate-method 'synctex) ; enable synctex (setq TeX-source-correlate-mode t) ; enable text-source-correlate using synctex (add-to-list 'TeX-view-program-list '("eaf" eaf-pdf-synctex-forward-view )) (add-to-list 'TeX-view-program-selection '(output-pdf "eaf")) (setq predictive-latex-electric-environments 1) (TeX-fold-mode 1); enabling tex fold mode for better readability. (setq-default TeX-master nil) (global-set-key (kbd "C-c C-g") 'pdf-sync-forward-search) ;sync from text to pdf (add-hook 'TeX-after-compilation-finished-functions

'TeX-revert-document-buffer) ; reload pdf buffer

    (setq reftex-plug-into-AUCTeX t) ; enable auctex
    (setq reftex-bibliography-commands '("bibliography" "nobibliography" "addbibresource"))
    (local-set-key [C-tab] 'TeX-complete-symbol) ;tex complete symbol
    ; could be ispell as well, depending on your preferences
    (setq ispell-program-name "aspell") 

; this can obviously be set to any language your spell-checking program supports (setq ispell-dictionary "english") (flyspell-mode) ; flyspell mode enable (flyspell-buffer); flyspell buffer (turn-on-auto-fill) (visual-line-mode) (LaTeX-math-mode) ) ) `

luhuaei commented 1 year ago

pdf-view return (page-index, x, y) clicked page index, coordinates x and y are counted from the top left corner of the page.

Then using synctex edit get position in .tex file. For my testing, synctex output column field always -1. If synctex edit can return the correct column value, it will so simple to support jump to word (see eaf-pdf-synctex-backward-edit

Sparsa commented 1 year ago

I see you have kept the x and y co-ordinates in the functions, so some how it should work, and it is not working with synctex. I will try to see if I can find something.

I have also found another issue, (add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer) does not refresh the pdf buffer, can you check? or it is not needed when using with eaf?