From: Torsten Hilbrich Date: Fri, 9 Oct 2020 04:04:35 +0000 (+0200) Subject: Adding details page for dictionary X-Git-Tag: emacs-28.0.90~4726^2~22 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=329b6a0210;p=emacs.git 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. --- 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"))