Skip to content

Commit 1885cef

Browse files
committed
Merge branch 'feature/emacs-26.3'
Creating a merge commit in order to create a 1.0.0 tag. Note that this merge has breaking changes, as described in the NEWS section. * feature/emacs-26.3: autobuild: Recognize NetBSD and install packages via pkgin Bump the minimum Emacs version to 26.3! 🎉🤞 Extend docker testing framework to test against Emacs versions Update and cleanup the Install section Make sure pkg-config is correctly set in autobuild Add support for Alpine Linux to autobuild Render crisp images for HiDPI screens by default Remove Emacs 24.4 guards for cua-mode Remove compatibility function for image-mode-winprops Remove pdf-util-window-pixel-width, fallback to window-body-width Remove macro / function re-definitions Remove bugfix for imenu in Emacs 24.3 and below Remove guards in `pdf-virtual` tests and code. Explicitly declare documentation files as Org files Add a byteclean target in the Makefile
2 parents d6980bc + 997467a commit 1885cef

24 files changed

+418
-545
lines changed

Diff for: .circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
- run:
9696
name: Add Cask and Gnu-SED to the Path
9797
command: |
98-
echo 'export PATH="$HOME"/.cask/bin:"$(brew --prefix)"/opt/gnu-sed/libexec/gnubin:"$PATH"' >> "$BASH_ENV"
98+
echo 'export PATH="$HOME"/.cask/bin:"$(brew --prefix gnu-sed)"/libexec/gnubin:"$PATH"' >> "$BASH_ENV"
9999
- install-pdf-tools-server
100100

101101
workflows:

Diff for: Cask

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,5 @@
99
"server/epdfinfo.exe")
1010

1111
(development
12-
(depends-on "let-alist")
13-
(depends-on "tablist")
1412
(depends-on "ert-runner")
1513
(depends-on "undercover"))

Diff for: Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ $(pkgfile): .cask/$(emacs_version) server/epdfinfo lisp/*.el
2727
bytecompile: .cask/$(emacs_version)
2828
$(CASK) exec $(emacs) --batch -L lisp -f batch-byte-compile lisp/*.el
2929

30+
# Clean bytecompiled sources
31+
byteclean:
32+
rm -f -- lisp/*.elc
33+
rm -f -- lisp/*.eln
34+
3035
# Run ERT tests
3136
test: all
3237
PACKAGE_TAR=$(pkgfile) $(CASK) exec ert-runner
@@ -68,9 +73,8 @@ melpa-package: $(pkgfile)
6873
-f $(pkgname)-melpa.tar
6974

7075
# Various clean targets
71-
clean: server-clean
76+
clean: server-clean byteclean
7277
rm -f -- $(pkgfile)
73-
rm -f -- lisp/*.elc
7478
rm -f -- pdf-tools-readme.txt
7579
rm -f -- pdf-tools-$(version).entry
7680

Diff for: NEWS

+18-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22

33
* Version 1.0.0 (Under Development)
44
From this version onward, we will follow Semantic Versioning for new ~pdf-tools~ releases.
5-
** Raise the minimum supported version of Emacs to 26.1
6-
Drop support for Emacs 24 and 25. This allows for some code cleanup.
5+
6+
** Breaking changes:
7+
*** Raise the minimum supported version of Emacs to 26.3 #26
8+
Drop support for Emacs 24 and 25. This allows for some code cleanup. *This is a major breaking change*.
9+
*** Change the default value of pdf-view-use-scaling #133
10+
~pdf-view-use-scaling~ is now true by default, leading to rendering of crisp images on high-resolution screens. This should not cause problems on low-resolution screen (other than taking up more cache space / increasing rendering time), but if it does, please ~(setq pdf-view-use-scaling nil)~ in your configuration.
11+
12+
** Improve overall user experience
13+
- Set ~pdf-annot-list-highlight-type~ to true by default.
14+
+ Show annotation color when listing them by default, allow the user to turn them off if need be.
15+
16+
** Make changes required by newer versions of Emacs
17+
- Emacs 29 introduces ~pixel-scroll-precision-mode~, which interferes with ~pdf-view~ scrolling. This is fixed in #124
18+
19+
** Functionality fixes and improvements
20+
- Fix ~revert-buffer~ to correctly work over Tramp #128
21+
- Fix sorting by date in ~pdf-annot-list-mode~ #75
22+
723
* Version 0.91
824
** Change the keybindings for traversing history
925
This is a minor but *breaking change*. ~l~ (backward) and ~r~ (forward) are the conventional bindings for history navigation in Emacs, but ~pdf-tools~ uses ~B~ and ~N~. The previous keybindings are kept as-is for people who were used to it, while introducing ~l~ and ~r~ keybindings as well.

Diff for: README.org

+150-253
Large diffs are not rendered by default.

Diff for: TODO

-26
This file was deleted.

Diff for: TODO.org

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#+TITLE: A list of important / desirable tasks
2+
3+
* pdf-isearch
4+
** Allow for entering multi-byte characters with some input-methods.
5+
The PDF buffer is in uni-byte mode. It prohibits the user from inserting multi-byte characters in the minibuffer with some input-methods, while editing the search string.
6+
* pdf-forms
7+
Recent poppler versions have some support for editing forms.
8+
* pdf-annot
9+
** Updating the list buffer is too slow
10+
+ Update it incrementally.
11+
+ Possibly skip the update if the buffer is not visible.
12+
** Make highlighting customizable
13+
* epdfinfo
14+
** Maybe split the code up in several files.
15+
* pdf-view
16+
** Provide some kind of multi-page view
17+
** Make persistent scrolling relative
18+
Currently the scrolling is kept when changing the image's size (in pdf-view-display-image), which is actually not so desirable, since it is absolute. This results e.g. in the image popping out of the window, when it is shrunken.
19+
* pdf-info
20+
** Add a report/debug command, displaying a list of open files and other information.
21+
** Use alists for results instead of positional lists.

Diff for: lisp/pdf-cache.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,9 @@ WINDOW and IMAGE-WIDTH decide the page and scale of the final image."
429429
(pdf-cache-lookup-image
430430
page
431431
image-width
432-
(if (not pdf-view-use-scaling)
433-
image-width
434-
(* 2 image-width))))
432+
(if pdf-view-use-scaling
433+
(* 2 image-width)
434+
image-width)))
435435
(setq page (pop pdf-cache--prefetch-pages)))
436436
(pdf-util-debug
437437
(when (null page)

Diff for: lisp/pdf-info.el

+3-1
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,9 @@ error."
305305
(setq pdf-info--queue (tq-create proc))))
306306
pdf-info--queue)
307307

308-
(when (< emacs-major-version 27) (advice-add 'tq-process-buffer :around #'pdf-info--tq-workaround))
308+
(when (< emacs-major-version 27)
309+
(advice-add 'tq-process-buffer :around #'pdf-info--tq-workaround))
310+
309311
(defun pdf-info--tq-workaround (orig-fun tq &rest args)
310312
"Fix a bug in trunk where the wrong callback gets called.
311313

Diff for: lisp/pdf-outline.el

-17
Original file line numberDiff line numberDiff line change
@@ -572,23 +572,6 @@ not call `imenu-sort-function'."
572572
(cons title
573573
(nconc (nreverse keep-at-top) menulist))))
574574

575-
;; bugfix for imenu in Emacs 24.3 and below.
576-
(when (condition-case nil
577-
(progn (imenu--truncate-items '(("" 0))) nil)
578-
(error t))
579-
(eval-after-load "imenu"
580-
'(defun imenu--truncate-items (menulist)
581-
"Truncate all strings in MENULIST to `imenu-max-item-length'."
582-
(mapc (lambda (item)
583-
;; Truncate if necessary.
584-
(when (and (numberp imenu-max-item-length)
585-
(> (length (car item)) imenu-max-item-length))
586-
(setcar item (substring (car item) 0 imenu-max-item-length)))
587-
(when (imenu--subalist-p item)
588-
(imenu--truncate-items (cdr item))))
589-
menulist))))
590-
591-
592575

593576
(provide 'pdf-outline)
594577

Diff for: lisp/pdf-tools.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
;; URL: http://github.com/vedang/pdf-tools/
88
;; Keywords: files, multimedia
99
;; Package: pdf-tools
10-
;; Version: 1.0.0snapshot
11-
;; Package-Requires: ((emacs "24.3") (nadvice "0.3") (tablist "1.0") (let-alist "1.0.4"))
10+
;; Version: 1.0.0
11+
;; Package-Requires: ((emacs "26.3") (tablist "1.0") (let-alist "1.0.4"))
1212

1313
;; This program is free software; you can redistribute it and/or modify
1414
;; it under the terms of the GNU General Public License as published by

Diff for: lisp/pdf-util.el

+16-96
Original file line numberDiff line numberDiff line change
@@ -38,94 +38,6 @@
3838
(declare-function pdf-view-image-type "pdf-view")
3939

4040

41-
42-
;; * ================================================================== *
43-
;; * Compatibility with older Emacssen (< 25.1)
44-
;; * ================================================================== *
45-
46-
;; The with-file-modes macro is only available in recent Emacs
47-
;; versions.
48-
(eval-when-compile
49-
(unless (fboundp 'with-file-modes)
50-
(defmacro with-file-modes (modes &rest body)
51-
"Execute BODY with default file permissions temporarily set to MODES.
52-
MODES is as for `set-default-file-modes'."
53-
(declare (indent 1) (debug t))
54-
(let ((umask (make-symbol "umask")))
55-
`(let ((,umask (default-file-modes)))
56-
(unwind-protect
57-
(progn
58-
(set-default-file-modes ,modes)
59-
,@body)
60-
(set-default-file-modes ,umask)))))))
61-
62-
(unless (fboundp 'alist-get) ;;25.1
63-
(defun alist-get (key alist &optional default remove)
64-
"Get the value associated to KEY in ALIST.
65-
DEFAULT is the value to return if KEY is not found in ALIST.
66-
REMOVE, if non-nil, means that when setting this element, we should
67-
remove the entry if the new value is `eql' to DEFAULT."
68-
(ignore remove) ;;Silence byte-compiler.
69-
(let ((x (assq key alist)))
70-
(if x (cdr x) default))))
71-
72-
(require 'register)
73-
(unless (fboundp 'register-read-with-preview)
74-
(defalias 'register-read-with-preview #'read-char
75-
"Compatibility alias for pdf-tools."))
76-
77-
;; In Emacs 24.3 window-width does not have a PIXELWISE argument.
78-
(defmacro pdf-util-window-pixel-width (&optional window)
79-
"Return the width of WINDOW in pixel."
80-
(if (< (cdr (subr-arity (symbol-function 'window-body-width))) 2)
81-
(let ((window* (make-symbol "window")))
82-
`(let ((,window* ,window))
83-
(* (window-body-width ,window*)
84-
(frame-char-width (window-frame ,window*)))))
85-
`(window-body-width ,window t)))
86-
87-
;; In Emacs 24.3 image-mode-winprops leads to infinite recursion.
88-
(unless (or (> emacs-major-version 24)
89-
(and (= emacs-major-version 24)
90-
(>= emacs-minor-version 4)))
91-
(require 'image-mode)
92-
(defvar image-mode-winprops-original-function
93-
(symbol-function 'image-mode-winprops))
94-
(defvar image-mode-winprops-alist)
95-
(eval-after-load "image-mode"
96-
'(defun image-mode-winprops (&optional window cleanup)
97-
(if (not (eq major-mode 'pdf-view-mode))
98-
(funcall image-mode-winprops-original-function
99-
window cleanup)
100-
(cond ((null window)
101-
(setq window
102-
(if (eq (current-buffer) (window-buffer)) (selected-window) t)))
103-
((eq window t))
104-
((not (windowp window))
105-
(error "Not a window: %s" window)))
106-
(when cleanup
107-
(setq image-mode-winprops-alist
108-
(delq nil (mapcar (lambda (winprop)
109-
(let ((w (car-safe winprop)))
110-
(if (or (not (windowp w)) (window-live-p w))
111-
winprop)))
112-
image-mode-winprops-alist))))
113-
(let ((winprops (assq window image-mode-winprops-alist)))
114-
;; For new windows, set defaults from the latest.
115-
(if winprops
116-
;; Move window to front.
117-
(setq image-mode-winprops-alist
118-
(cons winprops (delq winprops image-mode-winprops-alist)))
119-
(setq winprops (cons window
120-
(copy-alist (cdar image-mode-winprops-alist))))
121-
;; Add winprops before running the hook, to avoid inf-loops if the hook
122-
;; triggers window-configuration-change-hook.
123-
(setq image-mode-winprops-alist
124-
(cons winprops image-mode-winprops-alist))
125-
(run-hook-with-args 'image-mode-new-window-functions winprops))
126-
winprops)))))
127-
128-
12941

13042
;; * ================================================================== *
13143
;; * Transforming coordinates
@@ -944,14 +856,22 @@ See also `regexp-quote'."
944856

945857
(defun pdf-util-frame-ppi ()
946858
"Return the PPI of the current frame."
947-
(let* ((props (frame-monitor-attributes))
948-
(px (nthcdr 2 (alist-get 'geometry props)))
949-
(mm (alist-get 'mm-size props))
950-
(dp (sqrt (+ (expt (nth 0 px) 2)
951-
(expt (nth 1 px) 2))))
952-
(di (sqrt (+ (expt (/ (nth 0 mm) 25.4) 2)
953-
(expt (/ (nth 1 mm) 25.4) 2)))))
954-
(/ dp di)))
859+
(condition-case nil
860+
(let* ((props (frame-monitor-attributes))
861+
(px (nthcdr 2 (alist-get 'geometry props)))
862+
(mm (alist-get 'mm-size props))
863+
(dp (sqrt (+ (expt (nth 0 px) 2)
864+
(expt (nth 1 px) 2))))
865+
(di (sqrt (+ (expt (/ (nth 0 mm) 25.4) 2)
866+
(expt (/ (nth 1 mm) 25.4) 2)))))
867+
(/ dp di))
868+
;; Calculating frame-ppi failed, return 0 to indicate unknown.
869+
;; This can happen when (frame-monitor-attributes) does not have
870+
;; the right properties (Emacs 26, 27). It leads to the
871+
;; wrong-type-argument error, which is the only one we are
872+
;; catching here. We will catch more errors only if we see them
873+
;; happening.
874+
(wrong-type-argument 0)))
955875

956876
(defvar pdf-view-use-scaling)
957877

Diff for: lisp/pdf-view.el

+14-23
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ FIXME: Explain dis-/advantages of imagemagick and png."
8686
:group 'pdf-view
8787
:type 'boolean)
8888

89-
(defcustom pdf-view-use-scaling nil
89+
(defcustom pdf-view-use-scaling t
9090
"Whether images should be allowed to be scaled for rendering.
9191
9292
This variable affects both the reuse of higher-resolution images
@@ -374,14 +374,6 @@ PNG images in Emacs buffers."
374374
;; Enable transient-mark-mode, so region deactivation when quitting
375375
;; will work.
376376
(setq-local transient-mark-mode t)
377-
;; In Emacs >= 24.4, `cua-copy-region' should have been advised when
378-
;; loading pdf-view.el so as to make it work with
379-
;; pdf-view-mode. Disable cua-mode if that is not the case.
380-
;; FIXME: cua-mode is a global minor-mode, but setting cua-mode to
381-
;; nil seems to do the trick.
382-
(when (and (bound-and-true-p cua-mode)
383-
(version< emacs-version "24.4"))
384-
(setq-local cua-mode nil))
385377

386378
(add-hook 'window-configuration-change-hook
387379
'pdf-view-redisplay-some-windows nil t)
@@ -403,16 +395,15 @@ PNG images in Emacs buffers."
403395
(pdf-view-check-incompatible-modes buffer)))
404396
(current-buffer)))
405397

406-
(unless (version< emacs-version "24.4")
407-
(advice-add 'cua-copy-region
408-
:before-until
409-
#'cua-copy-region--pdf-view-advice)
410-
(defun cua-copy-region--pdf-view-advice (&rest _)
411-
"If the current buffer is in `pdf-view' mode, call
412-
`pdf-view-kill-ring-save'."
413-
(when (eq major-mode 'pdf-view-mode)
414-
(pdf-view-kill-ring-save)
415-
t)))
398+
(advice-add 'cua-copy-region
399+
:before-until
400+
#'cua-copy-region--pdf-view-advice)
401+
402+
(defun cua-copy-region--pdf-view-advice (&rest _)
403+
"If the current buffer is in `pdf-view' mode, call `pdf-view-kill-ring-save'."
404+
(when (eq major-mode 'pdf-view-mode)
405+
(pdf-view-kill-ring-save)
406+
t))
416407

417408
(defun pdf-view-check-incompatible-modes (&optional buffer)
418409
"Check BUFFER for incompatible modes, maybe issue a warning."
@@ -964,9 +955,9 @@ See also `pdf-view-use-imagemagick'."
964955
(let* ((size (pdf-view-desired-image-size page window))
965956
(data (pdf-cache-renderpage
966957
page (car size)
967-
(if (not pdf-view-use-scaling)
968-
(car size)
969-
(* 2 (car size)))))
958+
(if pdf-view-use-scaling
959+
(* 2 (car size))
960+
(car size))))
970961
(hotspots (pdf-view-apply-hotspot-functions
971962
window page size)))
972963
(pdf-view-create-image data
@@ -1135,7 +1126,7 @@ If WINDOW is t, redisplay pages in all windows."
11351126
(let* ((pagesize (pdf-cache-pagesize
11361127
(or page (pdf-view-current-page window))))
11371128
(slice (pdf-view-current-slice window))
1138-
(width-scale (/ (/ (float (pdf-util-window-pixel-width window))
1129+
(width-scale (/ (/ (float (window-body-width window t))
11391130
(or (nth 2 slice) 1.0))
11401131
(float (car pagesize))))
11411132
(height (- (nth 3 (window-inside-pixel-edges window))

Diff for: lisp/pdf-virtual.el

-6
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
3131
;; asynchronous case.
3232

3333
;;; Code:
34-
(eval-when-compile
35-
(unless (or (> emacs-major-version 24)
36-
(and (= emacs-major-version 24)
37-
(>= emacs-minor-version 4)))
38-
(error "pdf-virtual.el only works with Emacs >= 24.4")))
39-
4034
(require 'let-alist)
4135
(require 'pdf-info)
4236
(require 'pdf-util)

0 commit comments

Comments
 (0)