diff options
| author | Andreas Politz <politza@hochschule-trier.de> | 2018-11-18 21:51:53 +0100 |
|---|---|---|
| committer | Andreas Politz <politza@hochschule-trier.de> | 2018-11-18 21:51:53 +0100 |
| commit | 9e765939ee42d59ba0280e52a2ce70f41c61f71e (patch) | |
| tree | 3f5ff874bad462193d613af92e29d6d86e981dd7 | |
| parent | 105dd014fea424c5556f8e0a3e3d652722c46084 (diff) | |
| parent | c7126308abf79dd384a625048765ac7b7f6a6830 (diff) | |
Merge branch 'ericdanan/cua'
| -rw-r--r-- | lisp/pdf-view.el | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lisp/pdf-view.el b/lisp/pdf-view.el index f1e3846..1dc8f35 100644 --- a/lisp/pdf-view.el +++ b/lisp/pdf-view.el @@ -32,6 +32,8 @@ (require 'bookmark) (require 'password-cache) +(declare-function cua-copy-region "cua-base") + ;; * ================================================================== * ;; * Customizations @@ -377,10 +379,13 @@ PNG images in Emacs buffers." ;; Enable transient-mark-mode, so region deactivation when quitting ;; will work. (setq-local transient-mark-mode t) - ;; Disable cua-mode, since it does not work with pdf-view-mode. + ;; 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 (bound-and-true-p cua-mode) + (when (and (bound-and-true-p cua-mode) + (version< emacs-version "24.4")) (setq-local cua-mode nil)) (add-hook 'window-configuration-change-hook @@ -405,6 +410,18 @@ PNG images in Emacs buffers." ;; Setup initial page and start display (pdf-view-goto-page (or (pdf-view-current-page) 1))) +(unless (version< emacs-version "24.4") + (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 pdf-view-check-incompatible-modes (&optional buffer) "Check BUFFER for incompatible modes, maybe issue a warning." (with-current-buffer (or buffer (current-buffer)) |
