From 013c2caf882c329714445f3394fff4672e500e08 Mon Sep 17 00:00:00 2001 From: Vasilij Schneidermann Date: Mon, 20 Dec 2021 15:09:26 +0100 Subject: Use a dedicated keymap for buttons (thanks, Greg!) --- nov.el | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nov.el b/nov.el index 9691382..4153573 100644 --- a/nov.el +++ b/nov.el @@ -402,10 +402,6 @@ Each alist item consists of the identifier and full path." (define-key map (kbd "t") 'nov-goto-toc) (define-key map (kbd "l") 'nov-history-back) (define-key map (kbd "r") 'nov-history-forward) - (define-key map (kbd "RET") 'nov-browse-url) - (define-key map (kbd "c") 'nov-copy-url) - (define-key map (kbd "") 'mouse-face) - (define-key map (kbd "") 'nov-browse-url) (define-key map (kbd "TAB") 'shr-next-link) (define-key map (kbd "M-TAB") 'shr-previous-link) (define-key map (kbd "") 'shr-previous-link) @@ -416,6 +412,14 @@ Each alist item consists of the identifier and full path." (define-key map (kbd "") 'end-of-buffer) map)) +(defvar nov-button-map + (let ((map (make-sparse-keymap))) + (set-keymap-parent map shr-map) + (define-key map (kbd "RET") 'nov-browse-url) + (define-key map (kbd "") 'nov-browse-url) + (define-key map (kbd "c") 'nov-copy-url) + map)) + (defun nov-clean-up () "Delete temporary files of the current EPUB buffer." (when nov-temp-dir @@ -509,7 +513,7 @@ chapter title." "Render HTML in current buffer with shr." (run-hooks 'nov-pre-html-render-hook) (let (;; HACK: make buttons use our own commands - (shr-map nov-mode-map) + (shr-map nov-button-map) (shr-external-rendering-functions nov-shr-rendering-functions) (shr-use-fonts nov-variable-pitch)) ;; HACK: `shr-external-rendering-functions' doesn't cover -- cgit v1.2.3