aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/net/dictionary-link.el12
-rw-r--r--lisp/net/dictionary.el126
2 files changed, 21 insertions, 117 deletions
diff --git a/lisp/net/dictionary-link.el b/lisp/net/dictionary-link.el
index 86e853e64e6..549f199e02a 100644
--- a/lisp/net/dictionary-link.el
+++ b/lisp/net/dictionary-link.el
@@ -113,14 +113,10 @@ link. Upon clicking the `function' is called with `data' as argument."
113(defun dictionary-link-initialize-keymap (keymap) 113(defun dictionary-link-initialize-keymap (keymap)
114 "Defines the necessary bindings inside keymap" 114 "Defines the necessary bindings inside keymap"
115 115
116 (if (and (boundp 'running-xemacs) running-xemacs) 116 (define-key keymap [mouse-2] 'dictionary-link-mouse-click)
117 (progn 117 (define-key keymap [M-mouse-2] 'dictionary-link-mouse-click-all)
118 (define-key keymap [button2] 'dictionary-link-mouse-click) 118 (define-key keymap "\r" 'dictionary-link-selected)
119 (define-key keymap [(meta button2)] 'dictionary-link-mouse-click-all)) 119 (define-key keymap "\M-\r" 'dictionary-link-selected-all))
120 (define-key keymap [mouse-2] 'dictionary-link-mouse-click)
121 (define-key keymap [M-mouse-2] 'dictionary-link-mouse-click-all))
122 (define-key keymap "\r" 'dictionary-link-selected)
123 (define-key keymap "\M-\r" 'dictionary-link-selected-all))
124 120
125(provide 'dictionary-link) 121(provide 'dictionary-link)
126;;; dictionary-link.el ends here 122;;; dictionary-link.el ends here
diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 4b2f25c26b4..ef667f1fe35 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -34,9 +34,7 @@
34 34
35;;; Code: 35;;; Code:
36 36
37(eval-when-compile 37(require 'cl-lib)
38 (require 'cl))
39
40(require 'easymenu) 38(require 'easymenu)
41(require 'custom) 39(require 'custom)
42(require 'dictionary-connection) 40(require 'dictionary-connection)
@@ -46,16 +44,6 @@
46;; Stuff for customizing. 44;; Stuff for customizing.
47;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 45;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
48 46
49(eval-when-compile
50 (unless (fboundp 'defface)
51 (message "Please update your custom.el file: %s"
52 "http://www.dina.kvl.dk/~abraham/custom/"))
53
54 (unless (fboundp 'defgroup)
55 (defmacro defgroup (&rest ignored))
56 (defmacro defcustom (var value doc &rest ignored)
57 (list 'defvar var value doc))))
58
59(defvar dictionary-server) 47(defvar dictionary-server)
60(defun dictionary-set-server-var (name value) 48(defun dictionary-set-server-var (name value)
61 (if (and (boundp 'dictionary-connection) 49 (if (and (boundp 'dictionary-connection)
@@ -351,7 +339,7 @@ by the choice value:
351 " 339 "
352 340
353 (unless (eq major-mode 'dictionary-mode) 341 (unless (eq major-mode 'dictionary-mode)
354 (incf dictionary-instances)) 342 (cl-incf dictionary-instances))
355 343
356 (kill-all-local-variables) 344 (kill-all-local-variables)
357 (buffer-disable-undo) 345 (buffer-disable-undo)
@@ -370,8 +358,6 @@ by the choice value:
370 (make-local-variable 'dictionary-default-dictionary) 358 (make-local-variable 'dictionary-default-dictionary)
371 (make-local-variable 'dictionary-default-strategy) 359 (make-local-variable 'dictionary-default-strategy)
372 360
373 (if (featurep 'xemacs)
374 (make-local-hook 'kill-buffer-hook))
375 (add-hook 'kill-buffer-hook 'dictionary-close t t) 361 (add-hook 'kill-buffer-hook 'dictionary-close t t)
376 (run-hooks 'dictionary-mode-hook)) 362 (run-hooks 'dictionary-mode-hook))
377 363
@@ -519,7 +505,7 @@ by the choice value:
519 (if (eq major-mode 'dictionary-mode) 505 (if (eq major-mode 'dictionary-mode)
520 (progn 506 (progn
521 (setq major-mode nil) 507 (setq major-mode nil)
522 (if (<= (decf dictionary-instances) 0) 508 (if (<= (cl-decf dictionary-instances) 0)
523 (dictionary-connection-close dictionary-connection)) 509 (dictionary-connection-close dictionary-connection))
524 (let ((configuration dictionary-window-configuration) 510 (let ((configuration dictionary-window-configuration)
525 (selected-window dictionary-selected-window)) 511 (selected-window dictionary-selected-window))
@@ -1210,8 +1196,6 @@ It presents the word at point as default input and allows editing it."
1210 1196
1211;;; Tooltip support 1197;;; Tooltip support
1212 1198
1213;; Common to GNU Emacs and XEmacs
1214
1215;; Add a mode indicater named "Dict" 1199;; Add a mode indicater named "Dict"
1216(defvar dictionary-tooltip-mode 1200(defvar dictionary-tooltip-mode
1217 nil 1201 nil
@@ -1235,79 +1219,6 @@ It presents the word at point as default input and allows editing it."
1235 (let ((list (dictionary-simple-split-string (dictionary-read-answer) "\n+"))) 1219 (let ((list (dictionary-simple-split-string (dictionary-read-answer) "\n+")))
1236 (mapconcat 'identity (cdr list) "\n"))) 1220 (mapconcat 'identity (cdr list) "\n")))
1237 1221
1238(defconst dictionary-use-balloon-help
1239 (eval-when-compile
1240 (condition-case nil
1241 (require 'balloon-help)
1242 (error nil))))
1243
1244(make-variable-buffer-local 'dictionary-balloon-help-extent)
1245
1246(if dictionary-use-balloon-help
1247 (progn
1248
1249;; The following definition are only valid for XEmacs with balloon-help
1250
1251(defvar dictionary-balloon-help-position nil
1252 "Current position to lookup word")
1253
1254(defun dictionary-balloon-help-store-position (event)
1255 (setq dictionary-balloon-help-position (event-point event)))
1256
1257(defun dictionary-balloon-help-description (&rest extent)
1258 "Get the word from the cursor and lookup it"
1259 (if dictionary-balloon-help-position
1260 (let ((word (save-window-excursion
1261 (save-excursion
1262 (goto-char dictionary-balloon-help-position)
1263 (current-word)))))
1264 (let ((definition
1265 (dictionary-definition word dictionary-tooltip-dictionary)))
1266 (if definition
1267 (dictionary-decode-charset definition
1268 dictionary-tooltip-dictionary)
1269 nil)))))
1270
1271(defvar dictionary-balloon-help-extent nil
1272 "The extent for activating the balloon help")
1273
1274;;;###autoload
1275(defun dictionary-tooltip-mode (&optional arg)
1276 "Display tooltips for the current word"
1277 (interactive "P")
1278 (let* ((on (if arg
1279 (> (prefix-numeric-value arg) 0)
1280 (not dictionary-tooltip-mode))))
1281 (make-local-variable 'dictionary-tooltip-mode)
1282 (if on
1283 ;; active mode
1284 (progn
1285 ;; remove old extend
1286 (if dictionary-balloon-help-extent
1287 (delete-extent dictionary-balloon-help-extent))
1288 ;; create new one
1289 (setq dictionary-balloon-help-extent (make-extent (point-min)
1290 (point-max)))
1291 (set-extent-property dictionary-balloon-help-extent
1292 'balloon-help
1293 'dictionary-balloon-help-description)
1294 (set-extent-property dictionary-balloon-help-extent
1295 'start-open nil)
1296 (set-extent-property dictionary-balloon-help-extent
1297 'end-open nil)
1298 (add-hook 'mouse-motion-hook
1299 'dictionary-balloon-help-store-position))
1300
1301 ;; deactivate mode
1302 (if dictionary-balloon-help-extent
1303 (delete-extent dictionary-balloon-help-extent))
1304 (remove-hook 'mouse-motion-hook
1305 'dictionary-balloon-help-store-position))
1306 (setq dictionary-tooltip-mode on)
1307 (balloon-help-minor-mode on)))
1308
1309) ;; end of XEmacs part
1310
1311(defvar global-dictionary-tooltip-mode 1222(defvar global-dictionary-tooltip-mode
1312 nil) 1223 nil)
1313 1224
@@ -1317,16 +1228,16 @@ It presents the word at point as default input and allows editing it."
1317 (interactive "e") 1228 (interactive "e")
1318 (if dictionary-tooltip-dictionary 1229 (if dictionary-tooltip-dictionary
1319 (let ((word (save-window-excursion 1230 (let ((word (save-window-excursion
1320 (save-excursion 1231 (save-excursion
1321 (mouse-set-point event) 1232 (mouse-set-point event)
1322 (current-word))))) 1233 (current-word)))))
1323 (let ((definition 1234 (let ((definition
1324 (dictionary-definition word dictionary-tooltip-dictionary))) 1235 (dictionary-definition word dictionary-tooltip-dictionary)))
1325 (if definition 1236 (if definition
1326 (tooltip-show 1237 (tooltip-show
1327 (dictionary-decode-charset definition 1238 (dictionary-decode-charset definition
1328 dictionary-tooltip-dictionary))) 1239 dictionary-tooltip-dictionary)))
1329 t)) 1240 t))
1330 nil)) 1241 nil))
1331 1242
1332;;;###autoload 1243;;;###autoload
@@ -1335,8 +1246,8 @@ It presents the word at point as default input and allows editing it."
1335 (interactive "P") 1246 (interactive "P")
1336 (require 'tooltip) 1247 (require 'tooltip)
1337 (let ((on (if arg 1248 (let ((on (if arg
1338 (> (prefix-numeric-value arg) 0) 1249 (> (prefix-numeric-value arg) 0)
1339 (not dictionary-tooltip-mode)))) 1250 (not dictionary-tooltip-mode))))
1340 (make-local-variable 'dictionary-tooltip-mode) 1251 (make-local-variable 'dictionary-tooltip-mode)
1341 (setq dictionary-tooltip-mode on) 1252 (setq dictionary-tooltip-mode on)
1342 ;; make sure that tooltip is still (global available) even is on 1253 ;; make sure that tooltip is still (global available) even is on
@@ -1352,16 +1263,13 @@ It presents the word at point as default input and allows editing it."
1352 (interactive "P") 1263 (interactive "P")
1353 (require 'tooltip) 1264 (require 'tooltip)
1354 (let* ((on (if arg (> (prefix-numeric-value arg) 0) 1265 (let* ((on (if arg (> (prefix-numeric-value arg) 0)
1355 (not global-dictionary-tooltip-mode))) 1266 (not global-dictionary-tooltip-mode)))
1356 (hook-fn (if on 'add-hook 'remove-hook))) 1267 (hook-fn (if on 'add-hook 'remove-hook)))
1357 (setq global-dictionary-tooltip-mode on) 1268 (setq global-dictionary-tooltip-mode on)
1358 (tooltip-mode 1) 1269 (tooltip-mode 1)
1359 (funcall hook-fn 'tooltip-hook 'dictionary-display-tooltip) 1270 (funcall hook-fn 'tooltip-hook 'dictionary-display-tooltip)
1360 (setq-default dictionary-tooltip-mode on) 1271 (setq-default dictionary-tooltip-mode on)
1361 (setq-default track-mouse on))) 1272 (setq-default track-mouse on)))
1362 1273
1363) ;; end of GNU Emacs part
1364
1365(provide 'dictionary) 1274(provide 'dictionary)
1366
1367;;; dictionary.el ends here 1275;;; dictionary.el ends here