>From c8bf763dc0392ef9059044ff724aca825cd450be Mon Sep 17 00:00:00 2001 From: Manuel Giraud Date: Sun, 26 Feb 2023 16:25:17 +0100 Subject: [PATCH] New user option 'doc-view-svg-honor-theme' * lisp/doc-view.el (doc-view-svg-honor-theme): New user option that makes SVG in DocView to follow the current theme. (doc-view-insert-image): Use it. --- etc/NEWS | 8 ++++++++ lisp/doc-view.el | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index 4b0e4e6bd46..ea8297f932e 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -192,6 +192,14 @@ This command adds a docstring comment to the current defun. If a comment already exists, point is only moved to the comment. It is bound to 'C-c C-d' in 'go-ts-mode'. +** DocView + +--- +*** New user option 'doc-view-svg-honor-theme' +When set to non-nil, this option tells DocView to follow the current +theme background and foreground colors instead of +'doc-view-svg-background' and 'doc-view-svg-foreground'. + * New Modes and Packages in Emacs 30.1 diff --git a/lisp/doc-view.el b/lisp/doc-view.el index 0303fec67a6..5d2348a023f 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el @@ -237,17 +237,25 @@ doc-view-imenu-flatten :version "29.1") (defcustom doc-view-svg-background "white" - "Background color for svg images. + "Background color for svg images. This is bypassed if +`doc-view-svg-honor-theme' is non-nil. See `doc-view-mupdf-use-svg'." :type 'color :version "29.1") (defcustom doc-view-svg-foreground "black" - "Foreground color for svg images. + "Foreground color for svg images. This is bypassed if +`doc-view-svg-honor-theme' is non-nil. See `doc-view-mupdf-use-svg'." :type 'color :version "29.1") +(defcustom doc-view-svg-honor-theme nil + "Does SVG foreground and background color honor the current +theme." + :type 'boolean + :version "30.1") + (defcustom doc-view-ghostscript-options '("-dSAFER" ;; Avoid security problems when rendering files from untrusted ;; sources. @@ -1602,8 +1610,11 @@ doc-view-insert-image (unless (member :transform-smoothing args) (setq args `(,@args :transform-smoothing t))) (when (eq doc-view--image-type 'svg) - (setq args `(,@args :background ,doc-view-svg-background - :foreground ,doc-view-svg-foreground))) + (if doc-view-svg-honor-theme + (setq args `(,@args :background ,(face-background 'default) + :foreground ,(face-foreground 'default))) + (setq args `(,@args :background ,doc-view-svg-background + :foreground ,doc-view-svg-foreground)))) (apply #'create-image file doc-view--image-type nil args)))) (slice (doc-view-current-slice)) (img-width (and image (car (image-size image)))) -- 2.39.1