summaryrefslogtreecommitdiff
path: root/lisp/net
diff options
context:
space:
mode:
authorTorsten Hilbrich <torsten.hilbrich@gmx.net>2020-10-09 06:04:35 +0200
committerTorsten Hilbrich <torsten.hilbrich@gmx.net>2020-10-09 20:05:38 +0200
commit329b6a0210f28d8abf8a8ce7afa6a7a6d3f84977 (patch)
tree478c1095dc023a9f72f2acb8b8f7073b912bd392 /lisp/net
parent1773b9b68742c95b1648a90c56eb7b56c77db591 (diff)
downloademacs-329b6a0210f28d8abf8a8ce7afa6a7a6d3f84977.tar.gz
emacs-329b6a0210f28d8abf8a8ce7afa6a7a6d3f84977.tar.bz2
emacs-329b6a0210f28d8abf8a8ce7afa6a7a6d3f84977.zip
Adding details page for dictionary
* net/lisp/dictionary.el (dictionary-display-dictionary-line): Allow getting more details on a dictionary by clicking the "(Details)" link. I had the functionality to query the dictionary information but no mechanism to invoke it. So just add a button after the short description of the dictionary to get more information.
Diffstat (limited to 'lisp/net')
-rw-r--r--lisp/net/dictionary.el25
1 files changed, 20 insertions, 5 deletions
diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index b25dda5c69c..c852f6cfdc7 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -680,8 +680,13 @@ This function knows about the special meaning of quotes (\")"
(define-button-type 'dictionary-link
'face 'dictionary-reference-face
- 'action (lambda (button) (funcall (button-get button 'callback)
- (button-get button 'data))))
+ 'action (lambda (button)
+ (let ((func (button-get button 'callback))
+ (data (button-get button 'data))
+ (list-data (button-get button 'list-data)))
+ (if list-data
+ (apply func list-data)
+ (funcall func data)))))
(define-button-type 'dictionary-button
:supertype 'dictionary-link
@@ -863,6 +868,12 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
'callback 'dictionary-set-dictionary
'data (cons dictionary description)
'help-echo (purecopy "Mouse-2 to select this dictionary"))
+ (unless (dictionary-special-dictionary dictionary)
+ (insert " ")
+ (insert-button "(Details)" :type 'dictionary-link
+ 'callback 'dictionary-set-dictionary
+ 'list-data (list (cons dictionary description) t)
+ 'help-echo (purecopy "Mouse-2 to get more information")))
(insert "\n")))))
(defun dictionary-set-dictionary (param &optional more)
@@ -875,13 +886,17 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(dictionary-restore-state)
(message "Dictionary %s has been selected" dictionary))))
+(defun dictionary-special-dictionary (name)
+ "Checks whether the special * or ! dictionary are seen"
+ (or (equal name "*")
+ (equal name "!")))
+
(defun dictionary-display-more-info (param)
"Display the available information on the dictionary"
(let ((dictionary (car param))
(description (cdr param)))
- (unless (or (equal dictionary "*")
- (equal dictionary "!"))
+ (unless (dictionary-special-dictionary dictionary)
(dictionary-store-positions)
(message "Requesting more information on %s" dictionary)
(dictionary-send-command
@@ -1048,7 +1063,7 @@ If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"."
(mapc (lambda (word)
(setq word (dictionary-decode-charset word dictionary))
(insert " ")
- (insert-button word :type 'dictionary-button
+ (insert-button word :type 'dictionary-link
'callback 'dictionary-new-search
'data (cons word dictionary)
'help-echo (purecopy "Mouse-2 to lookup word"))