update of packages

This commit is contained in:
2023-11-04 19:26:41 +01:00
parent e162a12b58
commit 3b54a3236d
726 changed files with 297673 additions and 34585 deletions

View File

@@ -118,6 +118,20 @@ This should be a cons \(FOREGROUND . BACKGROUND\) of colors."
:type '(cons (color :tag "Foreground")
(color :tag "Background")))
(defcustom pdf-view-midnight-invert t
"In midnight mode invert the image color lightness maintaining hue.
This is particularly useful if you are viewing documents with
color coded data in plots. This will maintain the colors such
that blue and red will remain these colors in the inverted
rendering. This inversion is non-trivial. This makes use of the
OKLab color space which is well calibrated to have equal
perceptual brightness across hue, but not all colors are within
the RGB gamut after inversion, causing some colors to saturate.
Nevertheless, this seems to work well in most cases."
:group 'pdf-view
:type 'boolean)
(defcustom pdf-view-change-page-hook nil
"Hook run after changing to another page, but before displaying it.
@@ -181,13 +195,23 @@ loaded."
(defcustom pdf-view-incompatible-modes
'(linum-mode linum-relative-mode helm-linum-relative-mode
nlinum-mode nlinum-hl-mode nlinum-relative-mode yalinum-mode)
nlinum-mode nlinum-hl-mode nlinum-relative-mode yalinum-mode
display-line-numbers-mode)
"A list of modes incompatible with `pdf-view-mode'.
Issue a warning, if one of them is active in a PDF buffer."
:group 'pdf-view
:type '(repeat symbol))
(defcustom pdf-view-selection-style 'word
"The current default selection style.
Must be one of `glyph', `word', or `line'."
:group 'pdf-view
:type '(choice (const glyph)
(const word)
(const line)))
;; * ================================================================== *
;; * Internal variables and macros
@@ -217,6 +241,9 @@ regarding display of the region in the later function.")
(defvar-local pdf-view--hotspot-functions nil
"Alist of hotspot functions.")
(defvar-local pdf-view--current-rotation nil
"Current rotation of the page.")
(defvar-local pdf-view-register-alist nil
"Local, dedicated register for PDF positions.")
@@ -281,6 +308,8 @@ regarding display of the region in the later function.")
(define-key map (kbd "s m") 'pdf-view-set-slice-using-mouse)
(define-key map (kbd "s b") 'pdf-view-set-slice-from-bounding-box)
(define-key map (kbd "s r") 'pdf-view-reset-slice)
;; Rotation.
(define-key map (kbd "R") #'pdf-view-rotate)
;; Reconvert
(define-key map (kbd "C-c C-c") 'doc-view-mode)
(define-key map (kbd "g") 'revert-buffer)
@@ -304,6 +333,7 @@ regarding display of the region in the later function.")
map)
"Keymap used by `pdf-view-mode' when displaying a doc as a set of images.")
(defvar pdf-tools-enabled-modes)
(define-derived-mode pdf-view-mode special-mode "PDFView"
"Major mode in PDF buffers.
@@ -337,6 +367,17 @@ PNG images in Emacs buffers."
;; Disable pixel-scroll-precision-mode locally if enabled
(if (bound-and-true-p pixel-scroll-precision-mode)
(set (make-local-variable 'pixel-scroll-precision-mode) nil))
(if (boundp 'mwheel-coalesce-scroll-events)
(setq-local mwheel-coalesce-scroll-events t))
;; If the Emacs theme is dark, add `pdf-view-dark-minor-mode' to the
;; list of `pdf-tools-enabled-modes'. See an interesting discussion
;; at: https://github.com/vedang/pdf-tools/issues/166 about how this
;; avoids a segfault crash in MacOS Ventura. IF you know why this
;; happens, please get in touch via the linked issue.
(when (eq 'dark (frame-parameter nil 'background-mode))
(add-to-list 'pdf-tools-enabled-modes 'pdf-view-dark-minor-mode))
;; Clearing overlays
(add-hook 'change-major-mode-hook
@@ -461,7 +502,10 @@ operating on a local copy of a remote file."
;; in the process), it may be immediately reopened due to
;; redisplay happening inside the pdf-info-close function
;; (while waiting for a response from the process.).
(copy-file tempfile (buffer-file-name) t)
(copy-file tempfile (or (buffer-file-name)
(read-file-name
"File name to save PDF to: "))
t)
(pdf-info-close pdf-view--server-file-name)
(when pdf-view--buffer-file-name
@@ -574,6 +618,21 @@ For example, (pdf-view-shrink 1.25) decreases size by 20%."
(setq pdf-view-display-size 1.0)
(pdf-view-redisplay t))
;; * ================================================================== *
;; * Rotation
;; * ================================================================== *
(defun pdf-view-rotate (angle)
"Rotate the current page by ANGLE degrees clockwise.
When called interactively, angle defaults to 90. Moreover, if
called interactively with a prefix argument, then rotate
anti-clockwise."
(interactive (list (if current-prefix-arg -90 90)))
(setq-local pdf-view--current-rotation
(mod (+ (or pdf-view--current-rotation 0)
angle)
360))
(pdf-view-redisplay t))
;; * ================================================================== *
@@ -962,6 +1021,7 @@ See also `pdf-view-use-imagemagick'."
window page size)))
(pdf-view-create-image data
:width (car size)
:rotation (or pdf-view--current-rotation 0)
:map hotspots
:pointer 'arrow)))
@@ -1210,7 +1270,16 @@ The colors are determined by the variable
(pdf-info-setoptions
:render/foreground (or (car pdf-view-midnight-colors) "black")
:render/background (or (cdr pdf-view-midnight-colors) "white")
:render/usecolors t))))
: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)
@@ -1219,10 +1288,20 @@ The colors are determined by the variable
(t
(remove-hook 'after-save-hook enable t)
(remove-hook 'after-revert-hook enable t)
(pdf-info-setoptions :render/usecolors nil))))
(pdf-info-setoptions
;; Value "0" indicates that colors should remain unchanged
:render/usecolors 0))))
(pdf-cache-clear-images)
(pdf-view-redisplay t))
(defun pdf-view-set-theme-background ()
"Set the buffer's color filter to correspond to the current Emacs theme."
(pdf-util-assert-pdf-buffer)
(pdf-info-setoptions
:render/foreground (face-foreground 'default nil)
:render/background (face-background 'default nil)
:render/usecolors 1))
(defun pdf-view-refresh-themed-buffer (&optional get-theme)
"Refresh the current buffer to activate applied colors.
@@ -1234,14 +1313,6 @@ current theme's colors."
(pdf-view-set-theme-background))
(pdf-view-redisplay t))
(defun pdf-view-set-theme-background ()
"Set the buffer's color filter to correspond to the current Emacs theme."
(pdf-util-assert-pdf-buffer)
(pdf-info-setoptions
:render/foreground (face-foreground 'default nil)
:render/background (face-background 'default nil)
:render/usecolors t))
(define-minor-mode pdf-view-themed-minor-mode
"Synchronize color filter with the present Emacs theme.
@@ -1257,7 +1328,7 @@ The colors are determined by the `face-foreground' and
(t
(remove-hook 'after-save-hook #'pdf-view-set-theme-background t)
(remove-hook 'after-revert-hook #'pdf-view-set-theme-background t)
(pdf-info-setoptions :render/usecolors nil)))
(pdf-info-setoptions :render/usecolors 0)))
(pdf-view-refresh-themed-buffer pdf-view-themed-minor-mode))
(when pdf-view-use-unicode-ligther
@@ -1338,13 +1409,17 @@ Deactivate the region if DEACTIVATE-P is non-nil."
(pdf-view-redisplay t)))
(defun pdf-view-mouse-set-region (event &optional allow-extend-p
rectangle-p)
rectangle-p
selection-style)
"Select a region of text using the mouse with mouse event EVENT.
Allow for stacking of regions, if ALLOW-EXTEND-P is non-nil.
Create a rectangular region, if RECTANGLE-P is non-nil.
Overwrite `pdf-view-selection-style' with SELECTION-STYLE,
which is one of `glyph', `word', or `line'.
Stores the region in `pdf-view-active-region'."
(interactive "@e")
(setq pdf-view--have-rectangle-region rectangle-p)
@@ -1366,6 +1441,7 @@ Stores the region in `pdf-view-active-region'."
(setq begin-inside-image-p nil)
(posn-x-y pos)))
(abs-begin (posn-x-y pos))
(selection-style (or selection-style pdf-view-selection-style))
pdf-view-continuous
region)
(when (pdf-util-track-mouse-dragging (event 0.05)
@@ -1418,7 +1494,8 @@ Stores the region in `pdf-view-active-region'."
(pdf-util-scale-pixel-to-relative iregion))
(pdf-view-display-region
(cons region pdf-view-active-region)
rectangle-p)
rectangle-p
selection-style)
(pdf-util-scroll-to-edges iregion)))))
(setq pdf-view-active-region
(append pdf-view-active-region
@@ -1441,7 +1518,7 @@ This is more useful for commands like
(interactive "@e")
(pdf-view-mouse-set-region event nil t))
(defun pdf-view-display-region (&optional region rectangle-p)
(defun pdf-view-display-region (&optional region rectangle-p selection-style)
;; TODO: write documentation!
(unless region
(pdf-view-assert-active-region)
@@ -1458,7 +1535,7 @@ This is more useful for commands like
page width nil
`(,(car colors) ,(cdr colors) 0.35 ,@region))
(pdf-info-renderpage-text-regions
page width nil nil
page width nil selection-style nil
`(,(car colors) ,(cdr colors) ,@region)))
:width width))))
@@ -1483,7 +1560,11 @@ This is more useful for commands like
"Return the text of the active region as a list of strings."
(pdf-view-assert-active-region)
(mapcar
(apply-partially 'pdf-info-gettext (pdf-view-current-page))
(lambda (edges)
(pdf-info-gettext
(pdf-view-current-page)
edges
pdf-view-selection-style))
pdf-view-active-region))
(defun pdf-view-extract-region-image (regions &optional page size
@@ -1554,6 +1635,20 @@ the `convert' program is used."
(dolist (f (cons result images))
(when (file-exists-p f)
(delete-file f))))))
(defun pdf-view-set-selection-style (&optional style)
"Set `pdf-view-selection-style' to STYLE in the current buffer.
When called interactively or without an argument, cycle between
the selection styles."
(interactive)
(unless style
(setq style (or (cadr (memq pdf-view-selection-style '(glyph word line)))
'glyph))
(message "Setting selection style to `%s'." style))
(pdf-view-deactivate-region)
(setq-local pdf-view-selection-style style))
;; * ================================================================== *
;; * Bookmark + Register Integration