fix(pdf-misc): do not signal from the size indication mode-line - #365
Open
alberti42 wants to merge 1 commit into
Open
fix(pdf-misc): do not signal from the size indication mode-line#365alberti42 wants to merge 1 commit into
alberti42 wants to merge 1 commit into
Conversation
`pdf-misc-size-indication' runs from a mode-line construct, so it may not
signal: redisplay reports the error and drops the rest of the line.
Error during redisplay: (eval (pdf-misc-size-indication) t) signaled
(wrong-type-argument overlayp nil)
It calls `pdf-view-image-size', which has nothing to measure whenever the
page carries no image. With `pdf-view-roll-minor-mode' that function
reads the overlay holding the page:
(overlay-get (pdf-roll-page-overlay page window) 'display)
so it signals rather than returning nothing, and a `revert-buffer' that
collapses the overlays leaves a window in which every redisplay reports
the error until they are rebuilt. Reverting a PDF while it is on screen
-- what AUCTeX does when a recompile finishes -- reproduced it two to six
times per revert.
Return an empty indication instead. Guarding `pdf-view-image-size'
itself is not an option: some thirty callers do arithmetic on its result,
so it cannot start returning nil.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What happens
pdf-misc-size-indicationis put intomode-line-positionas an:evalconstruct, so it runs on every redisplay. When it signals, redisplay reports the error and drops the rest of the line:Reverting a PDF while it is on screen — what AUCTeX does through
TeX-revert-document-bufferwhen a recompile finishes — produced this two to six times per revert on a document withpdf-view-roll-minor-modeenabled.Why
It calls
pdf-view-image-size, which has nothing to measure whenever the page carries no image. Withpdf-view-roll-minor-modethat function reads the overlay holding the page:so it signals rather than returning nothing.
revert-bufferreplaces the buffer text, and a page overlay carriesevaporate, so the overlays collapse; until they are rebuilt every redisplay in that window reports the error.The fix
Return an empty indication when the size is not available.
Guarding the read in
pdf-view-image-sizeinstead is not an option: some thirty-five callers acrosspdf-view.el,pdf-util.el,pdf-annot.el,pdf-links.el,pdf-sync.elandpdf-isearch.eldo arithmetic on its result, so it cannot start returning nil. What that function should report when a page has no image yet is a separate question, and not one a mode-line construct needs answered — it just needs to not signal.Normal reporting is unchanged:
" Top"at the top of a page," Bot"and the percentage below it.Reproducing it
A one-shot advice that makes a revert land inside a page render. The
lexical-bindingcookie matters — without it the timer's lambda does not capturebufandwin, and nothing happens. The revert also has to fire with a window other than the PDF's selected, which is what a revert from the TeX process sentinel does.Open a PDF in a frame that has a second window, then
M-x pdf-roll-goto-pageto a page that has not been rendered yet, and read*Messages*. On a 16 page document the error appeared in two of two runs before this change and none of two after.Priority
Lower than #361, #362 and #364. This is a cosmetic failure — noise in
*Messages*and a briefly blank size indication — rather than a crash, and it corrects itself on the next redisplay.It is also independent of all three: it touches only
lisp/pdf-misc.el, andgit merge-treereports no conflict against any of them.