Function: pdf-view-midnight-minor-mode
pdf-view-midnight-minor-mode is an interactive and natively compiled
function defined in pdf-view.el.
Signature
(pdf-view-midnight-minor-mode &optional ARG)
Documentation
Apply a color-filter appropriate for past midnight reading.
The colors are determined by the variable
pdf-view-midnight-colors, which see.
This is a minor mode. If called interactively, toggle the
Pdf-View-Midnight minor mode mode. If the prefix argument is
positive, enable the mode, and if it is zero or negative, disable the
mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable the
mode if ARG is nil, omitted, or is a positive number. Disable the mode
if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate the variable pdf-view-midnight-minor-mode(var)/pdf-view-midnight-minor-mode(fun).
The mode's hook is called both when the mode is enabled and when it is disabled.
Key Bindings
pdf-view-mode-map C-c C-r m
Source Code
;; Defined in /nix/store/63h5z2vmzn0mfavcxi2idi23g5xcgkbl-emacs-packages-deps/share/emacs/site-lisp/elpa/pdf-tools-20260102.1101/pdf-view.el
(define-minor-mode pdf-view-midnight-minor-mode
"Apply a color-filter appropriate for past midnight reading.
The colors are determined by the variable
`pdf-view-midnight-colors', which see. "
:group 'pdf-view
:lighter " Mid"
(pdf-util-assert-pdf-buffer)
;; FIXME: Maybe these options should be passed stateless to pdf-info-renderpage ?
(let ((enable (lambda ()
(pdf-info-setoptions
:render/foreground (or (car pdf-view-midnight-colors) "black")
:render/background (or (cdr pdf-view-midnight-colors) "white")
:render/gamma pdf-view-midnight-gamma
:render/gammabeforeinvert pdf-view-midnight-gamma-before-invert
:render/usecolors
(if pdf-view-midnight-invert
;; If midnight invert is enabled, pass "2" indicating
;; that :render/foreground and :render/background should
;; be ignored and to instead invert the PDF (preserving
;; hue)
2
;; If invert is not enabled, pass "1" indictating that
;; :render/foreground and :render/background should be used
1)))))
(cond
(pdf-view-midnight-minor-mode
(add-hook 'after-save-hook enable nil t)
(add-hook 'after-revert-hook enable nil t)
(funcall enable))
(t
(remove-hook 'after-save-hook enable t)
(remove-hook 'after-revert-hook enable t)
(pdf-info-setoptions
;; Value "0" indicates that colors should remain unchanged
:render/usecolors 0))))
(pdf-cache-clear-images)
(pdf-view-redisplay t))