branch: elpa/pdf-tools
commit c451c0e3db5b367d191bddf428e38fd8a21c0102
Author: Vedang Manerikar <[email protected]>
Commit: Vedang Manerikar <[email protected]>
Auto enable pdf-view-dark-minor-mode if the theme is dark
This is meant as a workaround for #166 (which see).
Best guess about what is happening and why this workaround works comes
from @d8660091 (lightly edited):
> I'm using M2 and I can reproduce the issue with just the following
> snippets I extracted from pdf-isearch-current-colors, which was
> invoked during a pdf isearch:
(add-hook 'pdf-tools-enabled-hook
(lambda ()
(pdf-util-face-colors 'pdf-isearch-match nil)
(pdf-util-face-colors 'pdf-isearch-lazy nil)))
> And run `pdf-tools-install`
> I tried adding `(sit-for 1)` before `(delete-frame f)`, the crash
> was gone.
> But I am still not sure what's really happening.
> I think `pdf-view-dark-minor-mode` works because new frame is not
> created and `delete-frame` doesn't happen.
If anyone has an idea about what is happening here and what the
correct way to fix it is, please get in touch via the linked issue!
Closes: #166
---
lisp/pdf-tools.el | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/lisp/pdf-tools.el b/lisp/pdf-tools.el
index aa19969bfd..382d5b6e91 100644
--- a/lisp/pdf-tools.el
+++ b/lisp/pdf-tools.el
@@ -134,20 +134,25 @@ In order to customize dark and light colors use
pdf-virtual-global-minor-mode))
(defcustom pdf-tools-enabled-modes
- '(pdf-history-minor-mode
- pdf-isearch-minor-mode
- pdf-links-minor-mode
- pdf-misc-minor-mode
- pdf-outline-minor-mode
- pdf-misc-size-indication-minor-mode
- pdf-misc-menu-bar-minor-mode
- pdf-annot-minor-mode
- pdf-sync-minor-mode
- pdf-misc-context-menu-minor-mode
- pdf-cache-prefetch-minor-mode
- pdf-occur-global-minor-mode
- ;; pdf-virtual-global-minor-mode
- )
+ (append '(pdf-history-minor-mode
+ pdf-isearch-minor-mode
+ pdf-links-minor-mode
+ pdf-misc-minor-mode
+ pdf-outline-minor-mode
+ pdf-misc-size-indication-minor-mode
+ pdf-misc-menu-bar-minor-mode
+ pdf-annot-minor-mode
+ pdf-sync-minor-mode
+ pdf-misc-context-menu-minor-mode
+ pdf-cache-prefetch-minor-mode
+ pdf-occur-global-minor-mode)
+ ;; 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))
+ '(pdf-view-dark-minor-mode)))
"A list of automatically enabled minor-modes.
PDF Tools is build as a series of minor-modes. This variable and