diff options
| author | Vedang Manerikar <ved.manerikar@gmail.com> | 2022-11-29 11:43:45 +0530 |
|---|---|---|
| committer | Vedang Manerikar <ved.manerikar@gmail.com> | 2022-11-29 11:43:45 +0530 |
| commit | 1885cefc24883c220cdd4acafdf1d14f290a6979 (patch) | |
| tree | 676d9983dccdd29c4f012e3da5aaf74a38c095fa /lisp | |
| parent | d6980bc3273e1cf1a73feee6bb523d1568405685 (diff) | |
| parent | 997467ad3bcd23de22624c538d14863479b27cba (diff) | |
Merge branch 'feature/emacs-26.3'v1.0.0
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
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/pdf-cache.el | 6 | ||||
| -rw-r--r-- | lisp/pdf-info.el | 4 | ||||
| -rw-r--r-- | lisp/pdf-outline.el | 17 | ||||
| -rw-r--r-- | lisp/pdf-tools.el | 4 | ||||
| -rw-r--r-- | lisp/pdf-util.el | 112 | ||||
| -rw-r--r-- | lisp/pdf-view.el | 37 | ||||
| -rw-r--r-- | lisp/pdf-virtual.el | 6 |
7 files changed, 38 insertions, 148 deletions
diff --git a/lisp/pdf-cache.el b/lisp/pdf-cache.el index 31073ff..650ff36 100644 --- a/lisp/pdf-cache.el +++ b/lisp/pdf-cache.el @@ -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) diff --git a/lisp/pdf-info.el b/lisp/pdf-info.el index 408dd3f..40dfc3d 100644 --- a/lisp/pdf-info.el +++ b/lisp/pdf-info.el @@ -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. diff --git a/lisp/pdf-outline.el b/lisp/pdf-outline.el index a9212b7..fc75b02 100644 --- a/lisp/pdf-outline.el +++ b/lisp/pdf-outline.el @@ -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) diff --git a/lisp/pdf-tools.el b/lisp/pdf-tools.el index 9d15269..b94c82f 100644 --- a/lisp/pdf-tools.el +++ b/lisp/pdf-tools.el @@ -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 diff --git a/lisp/pdf-util.el b/lisp/pdf-util.el index cfc77d3..1e3b7be 100644 --- a/lisp/pdf-util.el +++ b/lisp/pdf-util.el @@ -40,94 +40,6 @@ ;; * ================================================================== * -;; * 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 ;; * ================================================================== * @@ -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) diff --git a/lisp/pdf-view.el b/lisp/pdf-view.el index 0820e8f..849be6a 100644 --- a/lisp/pdf-view.el +++ b/lisp/pdf-view.el @@ -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 @@ -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) @@ -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." @@ -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 @@ -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)) diff --git a/lisp/pdf-virtual.el b/lisp/pdf-virtual.el index 575f622..f8ecf97 100644 --- a/lisp/pdf-virtual.el +++ b/lisp/pdf-virtual.el @@ -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) |
