aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrégoire Jadi2013-07-18 19:54:12 +0200
committerGrégoire Jadi2013-07-18 19:54:12 +0200
commitfeac206c91e75b17c40991953baeca88e316f37b (patch)
treefb60efc82603cb9028f1faa86d3280842018920a
parent6fc319db18669e6fd6ea395e840e560016c2e136 (diff)
downloademacs-feac206c91e75b17c40991953baeca88e316f37b.tar.gz
emacs-feac206c91e75b17c40991953baeca88e316f37b.zip
* lisp/xwidget.el: Fix the interaction between `image-mode' and xwidget.
(xwidget-image-mode-navigation-adaptor xwidget-image-mode-navigation-adaptor-p): `flet' has been deprecated and `cl-flet' doesn't work like the old `flet', we now use a `defadvice' around `image-display-size' instead. (xwidget-webkit-mode-map): No need to use the adaptators now.
-rw-r--r--lisp/xwidget.el58
1 files changed, 26 insertions, 32 deletions
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index 81589e3d57d..87c6636dd9a 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -91,18 +91,12 @@ defaults to the string looking like a url around the cursor position."
91 (cons (aref xwi 2) 91 (cons (aref xwi 2)
92 (aref xwi 3)))) 92 (aref xwi 3))))
93 93
94(defmacro xwidget-image-mode-navigation-adaptor (fn) 94(defadvice image-display-size (around image-display-size-for-xwidget
95 "Image code adaptor. `image-mode' FN is called." 95 (spec &optional pixels frame)
96 `(lambda () (interactive) 96 activate)
97 (cl-flet ((image-display-size (spec) (xwidget-image-display-size spec))) 97 (if (eq (car spec) 'xwidget)
98 (funcall ,fn )))) 98 (setq ad-return-value (xwidget-image-display-size spec pixels frame))
99 99 ad-do-it))
100(defmacro xwidget-image-mode-navigation-adaptor-p (fn)
101 "Image code adaptor. `image-mode' FN is called with interactive arg."
102 `(lambda (n) (interactive "p")
103 (cl-flet ((image-display-size (spec) (xwidget-image-display-size spec)))
104 (funcall ,fn n))))
105
106 100
107;;todo. 101;;todo.
108;; - check that the webkit support is compiled in 102;; - check that the webkit support is compiled in
@@ -117,26 +111,26 @@ defaults to the string looking like a url around the cursor position."
117 (define-key map "w" 'xwidget-webkit-current-url) 111 (define-key map "w" 'xwidget-webkit-current-url)
118 112
119 ;;similar to image mode bindings 113 ;;similar to image mode bindings
120 (define-key map (kbd "SPC") (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) 114 (define-key map (kbd "SPC") 'image-scroll-up)
121 (define-key map (kbd "DEL") (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) 115 (define-key map (kbd "DEL") 'image-scroll-down)
122 116
123 (define-key map [remap scroll-up] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) 117 (define-key map [remap scroll-up] 'image-scroll-up)
124 (define-key map [remap scroll-up-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-up)) 118 (define-key map [remap scroll-up-command] 'image-scroll-up)
125 119
126 (define-key map [remap scroll-down] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) 120 (define-key map [remap scroll-down] 'image-scroll-down)
127 (define-key map [remap scroll-down-command] (xwidget-image-mode-navigation-adaptor 'image-scroll-down)) 121 (define-key map [remap scroll-down-command] 'image-scroll-down)
128 122
129 (define-key map [remap forward-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) 123 (define-key map [remap forward-char] 'image-forward-hscroll)
130 (define-key map [remap backward-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) 124 (define-key map [remap backward-char] 'image-backward-hscroll)
131 (define-key map [remap right-char] (xwidget-image-mode-navigation-adaptor-p 'image-forward-hscroll)) 125 (define-key map [remap right-char] 'image-forward-hscroll)
132 (define-key map [remap left-char] (xwidget-image-mode-navigation-adaptor-p 'image-backward-hscroll)) 126 (define-key map [remap left-char] 'image-backward-hscroll)
133 (define-key map [remap previous-line] (xwidget-image-mode-navigation-adaptor-p 'image-previous-line)) 127 (define-key map [remap previous-line] 'image-previous-line)
134 (define-key map [remap next-line] (xwidget-image-mode-navigation-adaptor-p 'image-next-line)) 128 (define-key map [remap next-line] 'image-next-line)
135 129
136 (define-key map [remap move-beginning-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-bol)) 130 (define-key map [remap move-beginning-of-line] 'image-bol)
137 (define-key map [remap move-end-of-line] (xwidget-image-mode-navigation-adaptor-p 'image-eol)) 131 (define-key map [remap move-end-of-line] 'image-eol)
138 (define-key map [remap beginning-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-bob)) 132 (define-key map [remap beginning-of-buffer] 'image-bob)
139 (define-key map [remap end-of-buffer] (xwidget-image-mode-navigation-adaptor 'image-eob)) 133 (define-key map [remap end-of-buffer] 'image-eob)
140 map) 134 map)
141 "Keymap for `xwidget-webkit-mode'.") 135 "Keymap for `xwidget-webkit-mode'.")
142 136