unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45262: Dictionary improvements
@ 2020-12-15 20:05 Juri Linkov
  2021-02-09 18:31 ` Juri Linkov
  0 siblings, 1 reply; 2+ messages in thread
From: Juri Linkov @ 2020-12-15 20:05 UTC (permalink / raw)
  To: 45262; +Cc: torsten hilbrich

X-Debbugs-CC: Torsten Hilbrich <torsten.hilbrich@gmx.net>

Thanks for merging dictionary to master!  I tried to use it,
and encountered several minor issues that I propose to improve:

1. For scrolling most other modes use scroll-up-command,
   and also bind S-SPC to scroll-down-command like this:

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 0df9d8b142..24e2b8d2ee 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -323,8 +323,9 @@ dictionary-mode-map
     (define-key map "l" 'dictionary-previous)
     (define-key map "n" 'forward-button)
     (define-key map "p" 'backward-button)
-    (define-key map " " 'scroll-up)
-    (define-key map (read-kbd-macro "M-SPC") 'scroll-down)
+    (define-key map " " 'scroll-up-command)
+    (define-key map [?\S-\ ] 'scroll-down-command)
+    (define-key map (read-kbd-macro "M-SPC") 'scroll-down-command)
     map)
   "Keymap for the dictionary mode.")
 
2. When point is on a multi-word link in the *Dictionary* buffer
   then the command 'M-x dictionary-search' fetches only one word
   from the buffer.  Instead of this, it could fetch the whole link
   for possible editing in the minibuffer before searching again:

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 0df9d8b142..24e2b8d2ee 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -1119,9 +1120,11 @@ dictionary-display-match-lines
 ;; - if region is active returns its contents
 ;; - otherwise return the word near the point
 (defun dictionary-search-default ()
-  (if (use-region-p)
-      (buffer-substring-no-properties (region-beginning) (region-end))
-    (current-word t)))
+  (cond
+   ((use-region-p)
+    (buffer-substring-no-properties (region-beginning) (region-end)))
+   ((car (get-char-property (point) 'data)))
+   (t (current-word t))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; User callable commands

3. There is the hook dictionary-mode-hook, and I use it to enable
   outline-minor-mode in the *Dictionary* buffer (using word entry lines
   are outline-regexp headings).  But there is a need to hide subheadings
   every time when the *Dictionary* buffer is updated, but there is no such hook.
   Maybe better to add a hook with a name like dictionary-search-post-hook
   to be called from dictionary-post-buffer.

4. 'dictionary' uses switch-to-buffer-other-window to force the output buffer
   in another window.  Other commands use pop-to-buffer that requires just
   such customization to display it in the same window:

  (push '("\\`\\*Dictionary\\*\\(?:<[^>]+>\\)?\\'" display-buffer-same-window)
        display-buffer-alist)

  But since switch-to-buffer-other-window calls pop-to-buffer with 't'
  for its arg 'action', this means that this requires more complex customization:

  (push '("\\`\\*Dictionary\\*\\(?:<[^>]+>\\)?\\'"
         display-buffer-same-window
         (inhibit-same-window . nil))
      display-buffer-alist)

  The difference is in the need to add '(inhibit-same-window . nil)'.

5. When clicking on a word link in the *Dictionary* buffer,
   it displays the word definition only in the same dictionary,
   while it would be better to search it in all dictionaries
   for more coverage.

   This is not a patch, but demonstrates the problem.
   Maybe this should be customizable?

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 0df9d8b142..24e2b8d2ee 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -848,7 +849,7 @@ dictionary-mark-reference
     (unless (equal word displayed-word)
       (make-button start end :type 'dictionary-link
                    'callback call
-                   'data (cons word dictionary)
+                   'data (cons word "*")
                    'help-echo (concat "Press Mouse-2 to lookup \""
                                       word "\" in \"" dictionary "\"")))))
 





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#45262: Dictionary improvements
  2020-12-15 20:05 bug#45262: Dictionary improvements Juri Linkov
@ 2021-02-09 18:31 ` Juri Linkov
  0 siblings, 0 replies; 2+ messages in thread
From: Juri Linkov @ 2021-02-09 18:31 UTC (permalink / raw)
  To: 45262

tags 45262 fixed
close 45262 28.0.50
quit

> Thanks for merging dictionary to master!  I tried to use it,
> and encountered several minor issues that I propose to improve:

I guess it's time now to close this request.

> 1. For scrolling most other modes use scroll-up-command,
>    and also bind S-SPC to scroll-down-command like this:
>
> diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
> index 0df9d8b142..24e2b8d2ee 100644
> --- a/lisp/net/dictionary.el
> +++ b/lisp/net/dictionary.el
> @@ -323,8 +323,9 @@ dictionary-mode-map
>      (define-key map "l" 'dictionary-previous)
>      (define-key map "n" 'forward-button)
>      (define-key map "p" 'backward-button)
> -    (define-key map " " 'scroll-up)
> -    (define-key map (read-kbd-macro "M-SPC") 'scroll-down)
> +    (define-key map " " 'scroll-up-command)
> +    (define-key map [?\S-\ ] 'scroll-down-command)
> +    (define-key map (read-kbd-macro "M-SPC") 'scroll-down-command)
>      map)
>    "Keymap for the dictionary mode.")

Now pushed to master in 552d2b9083.

> 2. When point is on a multi-word link in the *Dictionary* buffer
>    then the command 'M-x dictionary-search' fetches only one word
>    from the buffer.  Instead of this, it could fetch the whole link
>    for possible editing in the minibuffer before searching again:
>
> diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
> index 0df9d8b142..24e2b8d2ee 100644
> --- a/lisp/net/dictionary.el
> +++ b/lisp/net/dictionary.el
> @@ -1119,9 +1120,11 @@ dictionary-display-match-lines
>  ;; - if region is active returns its contents
>  ;; - otherwise return the word near the point
>  (defun dictionary-search-default ()
> -  (if (use-region-p)
> -      (buffer-substring-no-properties (region-beginning) (region-end))
> -    (current-word t)))
> +  (cond
> +   ((use-region-p)
> +    (buffer-substring-no-properties (region-beginning) (region-end)))
> +   ((car (get-char-property (point) 'data)))
> +   (t (current-word t))))

Pushed to master in the same commit.

> 3. There is the hook dictionary-mode-hook, and I use it to enable
>    outline-minor-mode in the *Dictionary* buffer (using word entry lines
>    are outline-regexp headings).  But there is a need to hide subheadings
>    every time when the *Dictionary* buffer is updated, but there is no such hook.
>    Maybe better to add a hook with a name like dictionary-search-post-hook
>    to be called from dictionary-post-buffer.

Added a new hook 'dictionary-post-buffer-hook'.

> 4. 'dictionary' uses switch-to-buffer-other-window to force the output buffer
>    in another window.  Other commands use pop-to-buffer that requires just
>    such customization to display it in the same window:
>
>   (push '("\\`\\*Dictionary\\*\\(?:<[^>]+>\\)?\\'" display-buffer-same-window)
>         display-buffer-alist)
>
>   But since switch-to-buffer-other-window calls pop-to-buffer with 't'
>   for its arg 'action', this means that this requires more complex customization:
>
>   (push '("\\`\\*Dictionary\\*\\(?:<[^>]+>\\)?\\'"
>          display-buffer-same-window
>          (inhibit-same-window . nil))
>       display-buffer-alist)
>
>   The difference is in the need to add '(inhibit-same-window . nil)'.

Not changed since there are many commands that use
switch-to-buffer-other-window, so it looks like a legitimate use.

> 5. When clicking on a word link in the *Dictionary* buffer,
>    it displays the word definition only in the same dictionary,
>    while it would be better to search it in all dictionaries
>    for more coverage.
>
>    This is not a patch, but demonstrates the problem.
>    Maybe this should be customizable?

Added a new customizable option 'dictionary-link-dictionary'.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-09 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-15 20:05 bug#45262: Dictionary improvements Juri Linkov
2021-02-09 18:31 ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).