unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
@ 2024-02-22 18:39 No Wayman
  2024-02-23  7:12 ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2024-02-22 18:39 UTC (permalink / raw)
  To: 69312


Currently when searching with dictionary.el, the query is 
messaged.
e.g. in dictionary-do-search:

```emacs-lisp
(message "Searching for %s in %s" word dictionary)
```

It would be better to display this information in the resultant 
buffer somehow (inline, via the header-line, etc).
Especially for the case of `dictionary-match-words`, which matches 
against a PATTERN argument.
I'd like to not have to remember what my query was if I come back 
to that buffer at a later time.





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-02-22 18:39 bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information No Wayman
@ 2024-02-23  7:12 ` Juri Linkov
  2024-02-23 15:29   ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2024-02-23  7:12 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

> Currently when searching with dictionary.el, the query is
> messaged.
> e.g. in dictionary-do-search:
>
> ```emacs-lisp
> (message "Searching for %s in %s" word dictionary)
> ```
>
> It would be better to display this information in the resultant
> buffer somehow (inline, via the header-line, etc).
> Especially for the case of `dictionary-match-words`, which matches
> against a PATTERN argument.
> I'd like to not have to remember what my query was if I come back
> to that buffer at a later time.

Like this?

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 1981b757017..ccce0b541df 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -787,7 +787,7 @@ dictionary-do-search
 Optional argument NOMATCHING controls whether to suppress the display
 of matching words."
 
-  (message "Searching for %s in %s" word dictionary)
+  (insert (format "Searching for %s in %s\n" word dictionary))
   (dictionary-send-command (concat "define "
 				   (dictionary-encode-charset dictionary "")
 				   " \""





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-02-23  7:12 ` Juri Linkov
@ 2024-02-23 15:29   ` No Wayman
  2024-02-24 17:39     ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2024-02-23 15:29 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 69312

Juri Linkov <juri@linkov.net> writes:

>
> Like this?
>
> diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
> index 1981b757017..ccce0b541df 100644
> --- a/lisp/net/dictionary.el
> +++ b/lisp/net/dictionary.el
> @@ -787,7 +787,7 @@ dictionary-do-search
>  Optional argument NOMATCHING controls whether to suppress the 
>  display
>  of matching words."
>  
> -  (message "Searching for %s in %s" word dictionary)
> +  (insert (format "Searching for %s in %s\n" word dictionary))
>    (dictionary-send-command (concat "define "
>  				   (dictionary-encode-charset dictionary "")
>  				   " \""

Thanks, Juri. This takes care of dictionary-do-search, but 
dictionary-do-matching indirectly calls the function responsible 
for displaying the results and does not pass the query along. 
So a similar modification will not work there.





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-02-23 15:29   ` No Wayman
@ 2024-02-24 17:39     ` Juri Linkov
  2024-02-25  4:06       ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2024-02-24 17:39 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

>> diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
>> index 1981b757017..ccce0b541df 100644
>> --- a/lisp/net/dictionary.el
>> +++ b/lisp/net/dictionary.el
>> @@ -787,7 +787,7 @@ dictionary-do-search
>>  Optional argument NOMATCHING controls whether to suppress the  display
>>  of matching words."
>>  -  (message "Searching for %s in %s" word dictionary)
>> +  (insert (format "Searching for %s in %s\n" word dictionary))
>>    (dictionary-send-command (concat "define "
>>  				   (dictionary-encode-charset dictionary "")
>>  				   " \""
>
> Thanks, Juri. This takes care of dictionary-do-search, but
> dictionary-do-matching indirectly calls the function responsible for
> displaying the results and does not pass the query along. So a similar
> modification will not work there.

Sorry, I didn't notice there is another place:

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 1981b757017..e2fc2d823fd 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -787,7 +787,7 @@ dictionary-do-search
 Optional argument NOMATCHING controls whether to suppress the display
 of matching words."
 
-  (message "Searching for %s in %s" word dictionary)
+  (insert (format-message "Searching for %s in %s\n" word dictionary))
   (dictionary-send-command (concat "define "
 				   (dictionary-encode-charset dictionary "")
 				   " \""
@@ -799,7 +799,7 @@ dictionary-do-search
     (if (dictionary-check-reply reply 552)
 	(progn
 	  (unless nomatching
-	    (insert "Word not found")
+	    (insert (format-message "Word not found: %s\n" word))
 	    (dictionary-do-matching
              word
 	     dictionary
@@ -1128,8 +1128,8 @@ dictionary-new-matching
 
 (defun dictionary-do-matching (word dictionary strategy function)
   "Search for WORD with STRATEGY in DICTIONARY and display them with FUNCTION."
-  (message "Lookup matching words for %s in %s using %s"
-	   word dictionary strategy)
+  (insert (format-message "Lookup matching words for %s in %s using %s\n"
+	                  word dictionary strategy))
   (dictionary-send-command
    (concat "match " (dictionary-encode-charset dictionary "") " "
 	   (dictionary-encode-charset strategy "") " \""





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-02-24 17:39     ` Juri Linkov
@ 2024-02-25  4:06       ` No Wayman
  2024-02-25  7:19         ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2024-02-25  4:06 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 69312

Juri Linkov <juri@linkov.net> writes:

> Sorry, I didn't notice there is another place:
 
> @@ -787,7 +787,7 @@ dictionary-do-search

Thanks again.
The changes to dictionary-do-search look fine.


> @@ -1128,8 +1128,8 @@ dictionary-new-matching
>  
>  (defun dictionary-do-matching (word dictionary strategy 
>  function)
>    "Search for WORD with STRATEGY in DICTIONARY and display them 
>    with FUNCTION."
> -  (message "Lookup matching words for %s in %s using %s"
> -	   word dictionary strategy)
> +  (insert (format-message "Lookup matching words for %s in %s 
> using %s\n"
> +	                  word dictionary strategy))
>    (dictionary-send-command
>     (concat "match " (dictionary-encode-charset dictionary "") " 
>     "
>  	   (dictionary-encode-charset strategy "") " \""

This won't work. The buffer is in read-only mode, but even if that 
is inhibited, the string is overwritten by the call to the display 
function at the end:

> (funcall function reply)






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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-02-25  4:06       ` No Wayman
@ 2024-02-25  7:19         ` Juri Linkov
  2024-03-02 17:31           ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2024-02-25  7:19 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

[-- Attachment #1: Type: text/plain, Size: 852 bytes --]

>> @@ -1128,8 +1128,8 @@ dictionary-new-matching
>>   (defun dictionary-do-matching (word dictionary strategy  function)
>>    "Search for WORD with STRATEGY in DICTIONARY and display them    with
>> FUNCTION."
>> -  (message "Lookup matching words for %s in %s using %s"
>> -	   word dictionary strategy)
>> +  (insert (format-message "Lookup matching words for %s in %s using
>> %s\n"
>> +	                  word dictionary strategy))
>>    (dictionary-send-command
>>     (concat "match " (dictionary-encode-charset dictionary "") "     "
>>  	   (dictionary-encode-charset strategy "") " \""
>
> This won't work. The buffer is in read-only mode, but even if that is
> inhibited, the string is overwritten by the call to the display function at
> the end:
>
>> (funcall function reply)

This means that we need more reformatting of error messages:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: dictionary-messages.patch --]
[-- Type: text/x-diff, Size: 3249 bytes --]

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 1981b757017..e8ac9b679a0 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -787,7 +787,7 @@ dictionary-do-search
 Optional argument NOMATCHING controls whether to suppress the display
 of matching words."
 
-  (message "Searching for %s in %s" word dictionary)
+  (insert (format-message "Searching for `%s' in `%s'\n" word dictionary))
   (dictionary-send-command (concat "define "
 				   (dictionary-encode-charset dictionary "")
 				   " \""
@@ -799,13 +799,13 @@ dictionary-do-search
     (if (dictionary-check-reply reply 552)
 	(progn
 	  (unless nomatching
-	    (insert "Word not found")
+	    (insert (format-message "Word `%s' not found\n" word))
 	    (dictionary-do-matching
              word
 	     dictionary
 	     "."
 	     (lambda (reply)
-               (insert ", maybe you are looking for one of these words\n\n")
+               (insert "Maybe you are looking for one of these words\n")
                (dictionary-display-only-match-result reply)))
 	    (dictionary-post-buffer)))
       (if (dictionary-check-reply reply 550)
@@ -1128,8 +1128,8 @@ dictionary-new-matching
 
 (defun dictionary-do-matching (word dictionary strategy function)
   "Search for WORD with STRATEGY in DICTIONARY and display them with FUNCTION."
-  (message "Lookup matching words for %s in %s using %s"
-	   word dictionary strategy)
+  (insert (format-message "Lookup matching words for `%s' in `%s' using `%s'\n"
+                          word dictionary strategy))
   (dictionary-send-command
    (concat "match " (dictionary-encode-charset dictionary "") " "
 	   (dictionary-encode-charset strategy "") " \""
@@ -1141,10 +1141,13 @@ dictionary-do-matching
     (if (dictionary-check-reply reply 551)
 	(error "Strategy \"%s\" is invalid" strategy))
     (if (dictionary-check-reply reply 552)
-	(error (concat
-		"No match for \"%s\" with strategy \"%s\" in "
-		"dictionary \"%s\".")
-	       word strategy dictionary))
+	(let ((errmsg (format-message
+                       (concat
+		        "No match for `%s' with strategy `%s' in "
+		        "dictionary `%s'.")
+	               word strategy dictionary)))
+          (insert errmsg "\n")
+          (user-error errmsg)))
     (unless (dictionary-check-reply reply 152)
       (error "Unknown server answer: %s" (dictionary-reply reply)))
     (funcall function reply)))
@@ -1271,7 +1274,7 @@ dictionary-lookup-definition
   (interactive)
   (let ((word (current-word)))
     (unless word
-      (error "No word at point"))
+      (user-error "No word at point"))
     (dictionary-new-search (cons word dictionary-default-dictionary))))
 
 (defun dictionary-previous ()
@@ -1311,7 +1314,8 @@ dictionary-mouse-popup-matching-words
 (defun dictionary-popup-matching-words (&optional word)
   "Display entries matching WORD or the current word if not given."
   (interactive)
-  (dictionary-do-matching (or word (current-word) (error "Nothing to search for"))
+  (dictionary-do-matching (or word (current-word)
+                              (user-error "Nothing to search for"))
 			  dictionary-default-dictionary
 			  dictionary-default-popup-strategy
 			  'dictionary-process-popup-replies))

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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-02-25  7:19         ` Juri Linkov
@ 2024-03-02 17:31           ` Juri Linkov
  2024-03-03  1:46             ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2024-03-02 17:31 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

close 69312 30.0.50
thanks

> This means that we need more reformatting of error messages:

So now the patch is pushed to master.





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-03-02 17:31           ` Juri Linkov
@ 2024-03-03  1:46             ` No Wayman
  2024-03-03  7:50               ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2024-03-03  1:46 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 69312

Juri Linkov <juri@linkov.net> writes:

> close 69312 30.0.50
> thanks
>
>> This means that we need more reformatting of error messages:
>
> So now the patch is pushed to master.

This bug should be re-opened. 
The patch did not address what I mentioned here:

> This won't work. The buffer is in read-only mode, but even if 
> that is inhibited,
> the string is overwritten by the call to the display function at 
> the end:

> (funcall function reply)

With it installed, the dictionary-do-matching command is broken.
It results in:

dictionary-do-matching: Buffer is read-only: #<buffer 
*Dictionary*>





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-03-03  1:46             ` No Wayman
@ 2024-03-03  7:50               ` Juri Linkov
  2024-03-03 16:59                 ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2024-03-03  7:50 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

reopen 69312
thanks

> This bug should be re-opened. The patch did not address what I mentioned
> here:
>
>> This won't work. The buffer is in read-only mode, but even if that is
>> inhibited,
>> the string is overwritten by the call to the display function at the end:
>
>> (funcall function reply)
>
> With it installed, the dictionary-do-matching command is broken.
> It results in:
>
> dictionary-do-matching: Buffer is read-only: #<buffer *Dictionary*>

Please provide a test case to reproduce the issue that you see.





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-03-03  7:50               ` Juri Linkov
@ 2024-03-03 16:59                 ` Juri Linkov
  2024-03-03 17:16                   ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2024-03-03 16:59 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

close 69312 30.0.50
thanks

>>> This won't work. The buffer is in read-only mode, but even if that is
>>> inhibited,
>>> the string is overwritten by the call to the display function at the end:
>>
>>> (funcall function reply)
>>
>> With it installed, the dictionary-do-matching command is broken.
>> It results in:
>>
>> dictionary-do-matching: Buffer is read-only: #<buffer *Dictionary*>
>
> Please provide a test case to reproduce the issue that you see.

Never mind, I see now what is missing.  So this is fixed now.
Thanks for the bug report.





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-03-03 16:59                 ` Juri Linkov
@ 2024-03-03 17:16                   ` No Wayman
  2024-03-03 17:49                     ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2024-03-03 17:16 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 69312

Juri Linkov <juri@linkov.net> writes:

> close 69312 30.0.50
> thanks
>
>>>> This won't work. The buffer is in read-only mode, but even if 
>>>> that is
>>>> inhibited,
>>>> the string is overwritten by the call to the display function 
>>>> at the end:
>>>
>>>> (funcall function reply)
>>>
>>> With it installed, the dictionary-do-matching command is 
>>> broken.
>>> It results in:
>>>
>>> dictionary-do-matching: Buffer is read-only: #<buffer 
>>> *Dictionary*>
>>
>> Please provide a test case to reproduce the issue that you see.
>
> Never mind, I see now what is missing.  So this is fixed now.
> Thanks for the bug report.

To clarify the issue:

(defun dictionary-do-matching (word dictionary strategy function)
  "Search for WORD with STRATEGY in DICTIONARY and display them 
  with FUNCTION."

;;This insertion is thrown away...

  (insert (format-message "Lookup matching words for `%s' in `%s' 
  using `%s'\n"
                          word dictionary strategy))

;; [OMITTED FUNCTION BODY]

;; ...when this display function is called
    (funcall function reply)))





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-03-03 17:16                   ` No Wayman
@ 2024-03-03 17:49                     ` Juri Linkov
  2024-03-03 20:59                       ` No Wayman
  0 siblings, 1 reply; 14+ messages in thread
From: Juri Linkov @ 2024-03-03 17:49 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

> To clarify the issue:
>
> (defun dictionary-do-matching (word dictionary strategy function)
>  "Search for WORD with STRATEGY in DICTIONARY and display them   with
> FUNCTION."
>
> ;;This insertion is thrown away...
>
>  (insert (format-message "Lookup matching words for `%s' in `%s'   using
> `%s'\n"
>                          word dictionary strategy))
>
> ;; [OMITTED FUNCTION BODY]
>
> ;; ...when this display function is called
>    (funcall function reply)))

Thanks for the detailed explanation.
Hopefully this is now fixed as well.





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-03-03 17:49                     ` Juri Linkov
@ 2024-03-03 20:59                       ` No Wayman
  2024-03-05 16:43                         ` Juri Linkov
  0 siblings, 1 reply; 14+ messages in thread
From: No Wayman @ 2024-03-03 20:59 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 69312

Juri Linkov <juri@linkov.net> writes:

> Thanks for the detailed explanation.
> Hopefully this is now fixed as well.

Confirmed that it does work.
Thanks again, Juri.

I've found another, separate bug while testing.
I'll open a separate thread for that.





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

* bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information
  2024-03-03 20:59                       ` No Wayman
@ 2024-03-05 16:43                         ` Juri Linkov
  0 siblings, 0 replies; 14+ messages in thread
From: Juri Linkov @ 2024-03-05 16:43 UTC (permalink / raw)
  To: No Wayman; +Cc: 69312

>> Thanks for the detailed explanation.
>> Hopefully this is now fixed as well.
>
> Confirmed that it does work.

Oh, it turned out this is not the whole story.  Using
dictionary-select-dictionary immediately after
dictionary-new-matching failed because it stored a state
that didn't disable read-only.

The problem is that dictionary-new-matching was out of sync from
dictionary-new-search, therefore it falls apart.  That required adding
dictionary-new-matching-internal like the existing
dictionary-new-search-internal, which is now done.





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

end of thread, other threads:[~2024-03-05 16:43 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22 18:39 bug#69312: 30.0.50; [WISHLIST] dicitionary buffer should retain search information No Wayman
2024-02-23  7:12 ` Juri Linkov
2024-02-23 15:29   ` No Wayman
2024-02-24 17:39     ` Juri Linkov
2024-02-25  4:06       ` No Wayman
2024-02-25  7:19         ` Juri Linkov
2024-03-02 17:31           ` Juri Linkov
2024-03-03  1:46             ` No Wayman
2024-03-03  7:50               ` Juri Linkov
2024-03-03 16:59                 ` Juri Linkov
2024-03-03 17:16                   ` No Wayman
2024-03-03 17:49                     ` Juri Linkov
2024-03-03 20:59                       ` No Wayman
2024-03-05 16:43                         ` 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).