8000 GitHub - vale981/overleaf.el: Sync and track changes live with overleaf and emacs!
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

vale981/overleaf.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overleaf.el

https://melpa.org/packages/overleaf-badge.svg

This packages provides overleaf-mode that allows to live-edit $\LaTeX$ files on overleaf.

Simultaneous edits from multiple sources are now supported but probably not entirely bug free. However, the worst thing that can happen is that people on overleaf might get an “out of sync” message and have to reload the page.

Note that active development happens on the ~dev~ branch. Changes are rebased into main if they’re unlikely to break things too badly. If you want to use the most “stable” version, the tagged versions (c.f. MELPA stable) are the place to go.

Demo

assets/demo.gif

Installation

To use this package, you can clone the repo, make it available in you load path and (require 'overleaf). You can also use use-package:

(use-package overleaf
  :custom
  (overleaf-use-nerdfont t "Use nerfont icons for the modeline.")
  :config
  ;; Example: load/save cookies from GPG encrypted file.
  ;;          (remove the .gpg extension to save unencrypted)
  (let ((cookie-file "~/.overleaf-cookies.gpg"))
    (setq overleaf-save-cookies
          (overleaf-save-cookies-to-file cookie-file))
    (setq overleaf-cookies
          (overleaf-read-cookies-from-file cookie-file)))

  ;; Example: load cookies from firefox
  (setq overleaf-cookies
        (overleaf-read-cookies-from-firefox "~/.mozilla/firefox/[YOUR PROFILE].default/cookies.sqlite")))

Setting Up

Getting the Session Cookies

First, there are the session cookies which can be obtained either through executing the command M-x overleaf-authenticate, reading the Firefox cookie database or through the developer tools in your favorite browser.

overleaf-authenticate

For the former option the Mozilla gecko driver must be installed and the variable overleaf-save-cookies must be set to a function that receives a string containing the cookies and saving it either directly into overleaf-cookies via setq (that’s the default) or stores it by some other means. In the latter case the variable overleaf-cookies must be assigned a function that returns the cookie string. For example, the cookies can be stored and loaded from a gpg encrypted file:

(let ((cookie-file "~/.overleaf-cookies.gpg"))
    (setq overleaf-save-cookies
          (overleaf-save-cookies-to-file cookie-file))
    (setq overleaf-cookies
          (overleaf-read-cookies-from-file cookie-file)))

Firefox

Locate you Firefox profile folder and set:

(setq overleaf-cookies
          (overleaf-read-cookies-from-firefox [optional: :profile "<profile>"]  ))

This assumes that you’re logged into overleaf in this Firefox profile.

It is recommended that no Firefox instance using this profile is running while =overleaf.el= is accessing the cookie database. The cookies usually tend to be evicted from the database while Firefox is running and will only be put back upon closure.

Manual

If the above doesn’t work for you, simply open the overleaf document you want to edit and enable network monitoring. Select any request made to the overleaf domain and get the contents of the Cookie request header. It should have contents like:

overleaf_session2=[redacted]

Then set overleaf-cookies to the cookies string

(setq overleaf-cookies
      (("[overleaf domain (ovelerleaf.com)]" "overleaf_session2=[session]" [expiry unix time])))

or store the cookies by any means you’d like (see above) and set overleaf-cookies to a function that returns the cookie string. The cookie domain should only contain the part just before the TLD and the TLD. For example www.overleaf.com becomes overleaf.com (I don’t make the rules…).

Usage

If the cookies are set, calling overleaf-connect will prompt you for a project and file to connect to if the buffer has never been connected to overleaf. If you want to reconnect the same buffer forcibly to another overleaf document, use overleaf-find-file.

If this buffer hasn’t been associated with an overleaf connection before (i.e. the document-id and project-id aren’t set), use M-x overleaf-find-file to select a project and file.

The default overleaf instance can be customized by changing the overleaf-default-url variable.

Calling overleaf-toggle-track-changes toggles whether the edits made in emacs will tracked (highlighted) by overleaf.

Calling overleaf-disconnect disconnects the current buffer from overleaf.

The modeline will indicate the connection status, as well as the number of changes that have yet to be synced to overleaf and whether the track-changes feature is enabled: (O: <connection status>, <number of changes>, <track changes status>).

Calling overleaf-toggle-auto-save toggles auto-saving the buffer whenever a consistent state with overleaf is reached.

With overleaf-goto-cursor one can jump to the cursor of another user.

Calling overleaf-browse opens a browser window with the current project.

Nicer modeline icons

If you have a font with nerd-font symbol support you can set:

(setopt overleaf-use-nerdfont t)

Keybindings

To make Overleaf keybindings available in LaTeX buffers, bind a key to overleaf-command-map, like so:

  • For the built-in tex-mode:
(with-eval-after-load 'tex-mode
  (keymap-set latex-mode-map "C-c o" overleaf-command-map))
(with-eval-after-load 'latex
  (keymap-set LaTeX-mode-map "C-c o" overleaf-command-map))
  • For bibtex-mode:
(with-eval-after-load 'bibtex
    (keymap-set bibtex-mode-map "C-c o" overleaf-command-map))

The available keybindings are then:

  • [prefix] c - (re)-connect
  • [prefix] d - disconnect
  • [prefix] t - toggle track-changes
  • [prefix] s - toggle auto-save
  • [prefix] b - browse project
  • [prefix] f - find file
  • [prefix] g - go to the cursor of another user
  • [prefix] l - list users’ cursor positions in an xref buffer

Troubleshooting

Rather verbose logging may be enabled by setting overleaf-debug to t. The log message will be collected in a buffer *overleaf-[document-id]*.

Feel free to open an issue providing this log.

Alternatives

  • GhostText works pretty well in conjunction with Atomic Chrome

    Had I realized this solution existed, I probably wouln’t have started this project. However, the solution here is still useful and provides some functionality on top (like jumping to other peoples cursors).

To-do

work out edge case: receiving changes while still decoding doc

store project and document names in buffer-locals

About

Sync and track changes live with overleaf and emacs!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  
0