Skip to content

Commit

Permalink
Merge branch 'feature/emacs-26.3'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vedang committed Nov 29, 2022
2 parents d6980bc + 997467a commit 1885cef
Show file tree
Hide file tree
Showing 24 changed files with 418 additions and 545 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- run:
name: Add Cask and Gnu-SED to the Path
command: |
echo 'export PATH="$HOME"/.cask/bin:"$(brew --prefix)"/opt/gnu-sed/libexec/gnubin:"$PATH"' >> "$BASH_ENV"
echo 'export PATH="$HOME"/.cask/bin:"$(brew --prefix gnu-sed)"/libexec/gnubin:"$PATH"' >> "$BASH_ENV"
- install-pdf-tools-server

workflows:
Expand Down
2 changes: 0 additions & 2 deletions Cask
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@
"server/epdfinfo.exe")

(development
(depends-on "let-alist")
(depends-on "tablist")
(depends-on "ert-runner")
(depends-on "undercover"))
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ $(pkgfile): .cask/$(emacs_version) server/epdfinfo lisp/*.el
bytecompile: .cask/$(emacs_version)
$(CASK) exec $(emacs) --batch -L lisp -f batch-byte-compile lisp/*.el

# Clean bytecompiled sources
byteclean:
rm -f -- lisp/*.elc
rm -f -- lisp/*.eln

# Run ERT tests
test: all
PACKAGE_TAR=$(pkgfile) $(CASK) exec ert-runner
Expand Down Expand Up @@ -68,9 +73,8 @@ melpa-package: $(pkgfile)
-f $(pkgname)-melpa.tar

# Various clean targets
clean: server-clean
clean: server-clean byteclean
rm -f -- $(pkgfile)
rm -f -- lisp/*.elc
rm -f -- pdf-tools-readme.txt
rm -f -- pdf-tools-$(version).entry

Expand Down
20 changes: 18 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@

* Version 1.0.0 (Under Development)
From this version onward, we will follow Semantic Versioning for new ~pdf-tools~ releases.
** Raise the minimum supported version of Emacs to 26.1
Drop support for Emacs 24 and 25. This allows for some code cleanup.

** Breaking changes:
*** Raise the minimum supported version of Emacs to 26.3 #26
Drop support for Emacs 24 and 25. This allows for some code cleanup. *This is a major breaking change*.
*** Change the default value of pdf-view-use-scaling #133
~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.

** Improve overall user experience
- Set ~pdf-annot-list-highlight-type~ to true by default.
+ Show annotation color when listing them by default, allow the user to turn them off if need be.

** Make changes required by newer versions of Emacs
- Emacs 29 introduces ~pixel-scroll-precision-mode~, which interferes with ~pdf-view~ scrolling. This is fixed in #124

** Functionality fixes and improvements
- Fix ~revert-buffer~ to correctly work over Tramp #128
- Fix sorting by date in ~pdf-annot-list-mode~ #75

* Version 0.91
** Change the keybindings for traversing history
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.
Expand Down
403 changes: 150 additions & 253 deletions README.org

Large diffs are not rendered by default.

26 changes: 0 additions & 26 deletions TODO

This file was deleted.

21 changes: 21 additions & 0 deletions TODO.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#+TITLE: A list of important / desirable tasks

* pdf-isearch
** Allow for entering multi-byte characters with some input-methods.
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.
* pdf-forms
Recent poppler versions have some support for editing forms.
* pdf-annot
** Updating the list buffer is too slow
+ Update it incrementally.
+ Possibly skip the update if the buffer is not visible.
** Make highlighting customizable
* epdfinfo
** Maybe split the code up in several files.
* pdf-view
** Provide some kind of multi-page view
** Make persistent scrolling relative
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.
* pdf-info
** Add a report/debug command, displaying a list of open files and other information.
** Use alists for results instead of positional lists.
6 changes: 3 additions & 3 deletions lisp/pdf-cache.el
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,9 @@ WINDOW and IMAGE-WIDTH decide the page and scale of the final image."
(pdf-cache-lookup-image
page
image-width
(if (not pdf-view-use-scaling)
image-width
(* 2 image-width))))
(if pdf-view-use-scaling
(* 2 image-width)
image-width)))
(setq page (pop pdf-cache--prefetch-pages)))
(pdf-util-debug
(when (null page)
Expand Down
4 changes: 3 additions & 1 deletion lisp/pdf-info.el
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ error."
(setq pdf-info--queue (tq-create proc))))
pdf-info--queue)

(when (< emacs-major-version 27) (advice-add 'tq-process-buffer :around #'pdf-info--tq-workaround))
(when (< emacs-major-version 27)
(advice-add 'tq-process-buffer :around #'pdf-info--tq-workaround))

(defun pdf-info--tq-workaround (orig-fun tq &rest args)
"Fix a bug in trunk where the wrong callback gets called.
Expand Down
17 changes: 0 additions & 17 deletions lisp/pdf-outline.el
Original file line number Diff line number Diff line change
Expand Up @@ -572,23 +572,6 @@ not call `imenu-sort-function'."
(cons title
(nconc (nreverse keep-at-top) menulist))))

;; bugfix for imenu in Emacs 24.3 and below.
(when (condition-case nil
(progn (imenu--truncate-items '(("" 0))) nil)
(error t))
(eval-after-load "imenu"
'(defun imenu--truncate-items (menulist)
"Truncate all strings in MENULIST to `imenu-max-item-length'."
(mapc (lambda (item)
;; Truncate if necessary.
(when (and (numberp imenu-max-item-length)
(> (length (car item)) imenu-max-item-length))
(setcar item (substring (car item) 0 imenu-max-item-length)))
(when (imenu--subalist-p item)
(imenu--truncate-items (cdr item))))
menulist))))



(provide 'pdf-outline)

Expand Down
4 changes: 2 additions & 2 deletions lisp/pdf-tools.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
;; URL: http://github.com/vedang/pdf-tools/
;; Keywords: files, multimedia
;; Package: pdf-tools
;; Version: 1.0.0snapshot
;; Package-Requires: ((emacs "24.3") (nadvice "0.3") (tablist "1.0") (let-alist "1.0.4"))
;; Version: 1.0.0
;; Package-Requires: ((emacs "26.3") (tablist "1.0") (let-alist "1.0.4"))

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Expand Down
112 changes: 16 additions & 96 deletions lisp/pdf-util.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,94 +38,6 @@
(declare-function pdf-view-image-type "pdf-view")



;; * ================================================================== *
;; * Compatibility with older Emacssen (< 25.1)
;; * ================================================================== *

;; The with-file-modes macro is only available in recent Emacs
;; versions.
(eval-when-compile
(unless (fboundp 'with-file-modes)
(defmacro with-file-modes (modes &rest body)
"Execute BODY with default file permissions temporarily set to MODES.
MODES is as for `set-default-file-modes'."
(declare (indent 1) (debug t))
(let ((umask (make-symbol "umask")))
`(let ((,umask (default-file-modes)))
(unwind-protect
(progn
(set-default-file-modes ,modes)
,@body)
(set-default-file-modes ,umask)))))))

(unless (fboundp 'alist-get) ;;25.1
(defun alist-get (key alist &optional default remove)
"Get the value associated to KEY in ALIST.
DEFAULT is the value to return if KEY is not found in ALIST.
REMOVE, if non-nil, means that when setting this element, we should
remove the entry if the new value is `eql' to DEFAULT."
(ignore remove) ;;Silence byte-compiler.
(let ((x (assq key alist)))
(if x (cdr x) default))))

(require 'register)
(unless (fboundp 'register-read-with-preview)
(defalias 'register-read-with-preview #'read-char
"Compatibility alias for pdf-tools."))

;; In Emacs 24.3 window-width does not have a PIXELWISE argument.
(defmacro pdf-util-window-pixel-width (&optional window)
"Return the width of WINDOW in pixel."
(if (< (cdr (subr-arity (symbol-function 'window-body-width))) 2)
(let ((window* (make-symbol "window")))
`(let ((,window* ,window))
(* (window-body-width ,window*)
(frame-char-width (window-frame ,window*)))))
`(window-body-width ,window t)))

;; In Emacs 24.3 image-mode-winprops leads to infinite recursion.
(unless (or (> emacs-major-version 24)
(and (= emacs-major-version 24)
(>= emacs-minor-version 4)))
(require 'image-mode)
(defvar image-mode-winprops-original-function
(symbol-function 'image-mode-winprops))
(defvar image-mode-winprops-alist)
(eval-after-load "image-mode"
'(defun image-mode-winprops (&optional window cleanup)
(if (not (eq major-mode 'pdf-view-mode))
(funcall image-mode-winprops-original-function
window cleanup)
(cond ((null window)
(setq window
(if (eq (current-buffer) (window-buffer)) (selected-window) t)))
((eq window t))
((not (windowp window))
(error "Not a window: %s" window)))
(when cleanup
(setq image-mode-winprops-alist
(delq nil (mapcar (lambda (winprop)
(let ((w (car-safe winprop)))
(if (or (not (windowp w)) (window-live-p w))
winprop)))
image-mode-winprops-alist))))
(let ((winprops (assq window image-mode-winprops-alist)))
;; For new windows, set defaults from the latest.
(if winprops
;; Move window to front.
(setq image-mode-winprops-alist
(cons winprops (delq winprops image-mode-winprops-alist)))
(setq winprops (cons window
(copy-alist (cdar image-mode-winprops-alist))))
;; Add winprops before running the hook, to avoid inf-loops if the hook
;; triggers window-configuration-change-hook.
(setq image-mode-winprops-alist
(cons winprops image-mode-winprops-alist))
(run-hook-with-args 'image-mode-new-window-functions winprops))
winprops)))))



;; * ================================================================== *
;; * Transforming coordinates
Expand Down Expand Up @@ -944,14 +856,22 @@ See also `regexp-quote'."

(defun pdf-util-frame-ppi ()
"Return the PPI of the current frame."
(let* ((props (frame-monitor-attributes))
(px (nthcdr 2 (alist-get 'geometry props)))
(mm (alist-get 'mm-size props))
(dp (sqrt (+ (expt (nth 0 px) 2)
(expt (nth 1 px) 2))))
(di (sqrt (+ (expt (/ (nth 0 mm) 25.4) 2)
(expt (/ (nth 1 mm) 25.4) 2)))))
(/ dp di)))
(condition-case nil
(let* ((props (frame-monitor-attributes))
(px (nthcdr 2 (alist-get 'geometry props)))
(mm (alist-get 'mm-size props))
(dp (sqrt (+ (expt (nth 0 px) 2)
(expt (nth 1 px) 2))))
(di (sqrt (+ (expt (/ (nth 0 mm) 25.4) 2)
(expt (/ (nth 1 mm) 25.4) 2)))))
(/ dp di))
;; Calculating frame-ppi failed, return 0 to indicate unknown.
;; This can happen when (frame-monitor-attributes) does not have
;; the right properties (Emacs 26, 27). It leads to the
;; wrong-type-argument error, which is the only one we are
;; catching here. We will catch more errors only if we see them
;; happening.
(wrong-type-argument 0)))

(defvar pdf-view-use-scaling)

Expand Down
37 changes: 14 additions & 23 deletions lisp/pdf-view.el
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ FIXME: Explain dis-/advantages of imagemagick and png."
:group 'pdf-view
:type 'boolean)

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

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

(unless (version< emacs-version "24.4")
(advice-add 'cua-copy-region
:before-until
#'cua-copy-region--pdf-view-advice)
(defun cua-copy-region--pdf-view-advice (&rest _)
"If the current buffer is in `pdf-view' mode, call
`pdf-view-kill-ring-save'."
(when (eq major-mode 'pdf-view-mode)
(pdf-view-kill-ring-save)
t)))
(advice-add 'cua-copy-region
:before-until
#'cua-copy-region--pdf-view-advice)

(defun cua-copy-region--pdf-view-advice (&rest _)
"If the current buffer is in `pdf-view' mode, call `pdf-view-kill-ring-save'."
(when (eq major-mode 'pdf-view-mode)
(pdf-view-kill-ring-save)
t))

(defun pdf-view-check-incompatible-modes (&optional buffer)
"Check BUFFER for incompatible modes, maybe issue a warning."
Expand Down Expand Up @@ -964,9 +955,9 @@ See also `pdf-view-use-imagemagick'."
(let* ((size (pdf-view-desired-image-size page window))
(data (pdf-cache-renderpage
page (car size)
(if (not pdf-view-use-scaling)
(car size)
(* 2 (car size)))))
(if pdf-view-use-scaling
(* 2 (car size))
(car size))))
(hotspots (pdf-view-apply-hotspot-functions
window page size)))
(pdf-view-create-image data
Expand Down Expand Up @@ -1135,7 +1126,7 @@ If WINDOW is t, redisplay pages in all windows."
(let* ((pagesize (pdf-cache-pagesize
(or page (pdf-view-current-page window))))
(slice (pdf-view-current-slice window))
(width-scale (/ (/ (float (pdf-util-window-pixel-width window))
(width-scale (/ (/ (float (window-body-width window t))
(or (nth 2 slice) 1.0))
(float (car pagesize))))
(height (- (nth 3 (window-inside-pixel-edges window))
Expand Down
6 changes: 0 additions & 6 deletions lisp/pdf-virtual.el
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@
;; asynchronous case.

;;; Code:
(eval-when-compile
(unless (or (> emacs-major-version 24)
(and (= emacs-major-version 24)
(>= emacs-minor-version 4)))
(error "pdf-virtual.el only works with Emacs >= 24.4")))

(require 'let-alist)
(require 'pdf-info)
(require 'pdf-util)
Expand Down
Loading

0 comments on commit 1885cef

Please sign in to comment.