8000 GitHub - dangom/vellum: pdfs in emacs on macos · GitHub
[go: up one dir, main page]

Skip to content
dangomPublic

About

pdfs in emacs on macos

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vellum

A native PDF view for Emacs on macOS, made for writing LaTeX.

A PDF opens in an ordinary Emacs window, but what you see there is a WebKit view laid over it. Scrolling and pinch-zoom are the system's own, with momentum. The keyboard never leaves Emacs, so the PDF buffer has ordinary Emacs keys and C-M-v scrolls it from the source window.

  • SyncTeX both ways. vellum-forward-search shows where point's line was set, with a band that fades. A double click or a command-click in the PDF goes to the source, down to the word.
  • Recompiles without a flicker. When the compiler rewrites the PDF, the new one is prepared out of sight and swapped in at the same place and zoom.
  • Links. A click follows a link: a reference, a citation, an entry in the table of contents. Resting the pointer on one shows where it leads, so a figure or a reference can be checked without going there. F labels the links in view, to follow one from the keyboard. l goes back to where you were; a web address op 7F0A ens with browse-url, even one that is only plain text in the PDF.
  • Search, outline, copy. C-s, imenu (the PDF's table of contents), and M-w on a mouse selection. M-s o lists the lines matching a regexp, as occur does; M-g n and M-g p go through them in the PDF.
  • Trimmed margins. c cuts the margins away so the text fills the window; odd and even pages are each cut to their own text block.
  • Two pages side by side. 2 pairs the pages; C-u 2 sets the first alone, as a book opens.
  • Thumbnails. t opens a column of the pages beside the document, at once however long it is; a click on one goes there.
  • Dark pages. i turns the page's white into the theme's background and its black into the theme's foreground, keeping the hue of what is coloured. Under a light theme the pages go dark grey. Set vellum-dark-pages to auto to have them dark whenever the theme is.
  • Splits like any buffer. Each window showing a PDF has its own view, with its own place and zoom; keys go to the selected window's.
  • A caret, moved as point is. A click puts a caret in the text (or v does, at the top of the view), and Emacs's own motions move it: M-f, M-e, C-n, C-x ], isearch, expand-region. C-SPC starts a region, and a stroke of the mouse makes one; M-w copies it with its lines joined, and S sends it to vellum-send-function (an agent's prompt, say) saying the page it is from. Escape takes the caret away. A faint band marks the caret's line, to read by as with a ruler.
  • Highlights and notes. With a region, h highlights it and a gives it a note; A lists them all, to go to, take away (d) or note again (e). C-x C-s writes them into the PDF, where any reader shows them. They are for reading: a PDF rebuilt by its compiler loses those saved.
  • Places to come back to. C-x r m bookmarks the place, m keeps it in a register for ' (or C-x r j) to go back to, and org-store-link makes a vellum: link to the page.
  • It remembers where you were in each file.

Requirements

macOS, a graphical Emacs 29 or later built with dynamic modules (no xwidgets needed), the Xcode Command Line Tools, and synctex from TeX Live.

Install

Clone it, put it on the load-path, and:

(autoload 'vellum-mode "vellum" nil t)
(add-to-list 'auto-mode-alist '("\\.pdf\\'" . vellum-mode))
(with-eval-after-load 'tex (vellum-auctex-setup))

The module is built the first time a PDF is opened; make builds it by hand.

With straight.el (or Doom's package!), the recipe needs nothing beyond the repository: the module and the viewer are found in the checkout.

(package! vellum :recipe (:host github :repo "dangom/vellum"))

vellum-auctex-setup makes Vellum AUCTeX's PDF viewer, so C-c C-v is a forward search.

Keys

Key
C-n C-p j k a line down, up
SPC DEL C-v M-v a screen down, up
n p next, previous page
M-< M-> start, end
M-g g go to a page
+ - w f 1 zoom in, out; fit width; fit page; actual size
c trim the margins, or show them again
t a column of thumbnails beside the document
i dark pages, or pages as printed
2 two pages side by side, or one again; C-u 2 as a book
C-s C-r search, and again; C-g clears the marks
M-s o list the lines matching a regexp
o outline
F follow a link by its label
l B N back after a link or a jump; back; forward again
v a caret in the text, moved with Emacs's motions; Escape ends it
S with a caret: send the region, saying where it is from
h a with a region: highlight it; highlight it with a note
A list the highlights and notes; C-x C-s saves them into the PDF
m ' keep the place in a register; go to a register
M-w copy the selection
g reload

How it is put together

  • src/vellum-module.m: the dynamic module. It owns WKWebViews, places them over rectangles of an Emacs frame, runs JavaScript in them, and passes their messages back through a pipe. It knows nothing about PDFs.
  • web/: the viewer, which is pdf.js (vendored in web/pdfjs, version in web/pdfjs/VERSION) and vellum.js.
  • vellum.el: the mode. It keeps each view over the window showing its buffer, talks to the viewer, and runs the synctex command-line tool.

Limits

  • WebKit does not paint a window that is entirely hidden behind others, so a PDF loaded in a covered frame appears when the frame is next seen.
  • Pages are drawn on white whatever the theme; the space around them takes the theme's background.
  • Very large documents are pdf.js's weak spot; PDFKit would be faster there.

Licence

GPL-3.0-or-later. pdf.js is Apache-2.0; see web/pdfjs/LICENSE.

About

pdfs in emacs on macos

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0