unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#58552: 29.0.50; [PATCH] dictionary-lookup-definition "Wrong type argument" error when there is no word at point
       [not found] <m14jw4q3p8.fsf.ref@yahoo.es>
@ 2022-10-15 19:36 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-10-16  9:25   ` Lars Ingebrigtsen
  2022-10-16 20:53   ` Richard Stallman
  0 siblings, 2 replies; 3+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-10-15 19:36 UTC (permalink / raw)
  To: 58552

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


Steps to reproduce the issue:

emacs -Q
M-x dictionary-lookup-definition RET
Answer "y" if asked about using dict.org.

Expected result:

As there is no word at point to act on, the operation should inform the
user right away.

Actual result:

dictionary-encode-charset: Wrong type argument: stringp, nil

An empty dictionary buffer is shown, which is confusing.

The attached patch informs the user that there is no word at point to
act on and aborts the operation early.

If you think it's a good patch, please install on my behalf.  Thanks.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Signal-an-error-in-dictionary-lookup-if-there-s-no-w.patch --]
[-- Type: text/x-patch, Size: 1084 bytes --]

From ac9505d3105138c69b018d6432182e45d12a2bb5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
Date: Sat, 15 Oct 2022 21:25:59 +0200
Subject: [PATCH] Signal an error in dictionary lookup if there's no word at
 point

* lisp/net/dictionary.el (dictionary-lookup-definition): Signal an
error when there is no word at point.
---
 lisp/net/dictionary.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 4c52382c67..b8f5018005 100644
--- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -1173,7 +1173,10 @@ dictionary-search
 (defun dictionary-lookup-definition ()
   "Unconditionally lookup the word at point."
   (interactive)
-  (dictionary-new-search (cons (current-word) dictionary-default-dictionary)))
+  (let ((word (current-word)))
+    (unless word
+      (error "No word at point"))
+    (dictionary-new-search (cons word dictionary-default-dictionary))))
 
 (defun dictionary-previous ()
   "Go to the previous location in the current buffer."
-- 
2.34.1


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

* bug#58552: 29.0.50; [PATCH] dictionary-lookup-definition "Wrong type argument" error when there is no word at point
  2022-10-15 19:36 ` bug#58552: 29.0.50; [PATCH] dictionary-lookup-definition "Wrong type argument" error when there is no word at point Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2022-10-16  9:25   ` Lars Ingebrigtsen
  2022-10-16 20:53   ` Richard Stallman
  1 sibling, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2022-10-16  9:25 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 58552

Daniel Martín <mardani29@yahoo.es> writes:

> If you think it's a good patch, please install on my behalf.  Thanks.

Looks good to me; now pushed to Emacs 29.





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

* bug#58552: 29.0.50; [PATCH] dictionary-lookup-definition "Wrong type argument" error when there is no word at point
  2022-10-15 19:36 ` bug#58552: 29.0.50; [PATCH] dictionary-lookup-definition "Wrong type argument" error when there is no word at point Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2022-10-16  9:25   ` Lars Ingebrigtsen
@ 2022-10-16 20:53   ` Richard Stallman
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Stallman @ 2022-10-16 20:53 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 58552

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

As far as I can tell, the message below was sent only to me.
But the message is strange.  So I decided to forward it here.

------- Start of forwarded message -------
From: Daniel Martín <mardani29@yahoo.es>
Date: Sat, 15 Oct 2022 21:25:59 +0200
Subject: [PATCH] Signal an error in dictionary lookup if there's no word at
 point

* lisp/net/dictionary.el (dictionary-lookup-definition): Signal an
error when there is no word at point.
- ---
 lisp/net/dictionary.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/net/dictionary.el b/lisp/net/dictionary.el
index 4c52382c67..b8f5018005 100644
- --- a/lisp/net/dictionary.el
+++ b/lisp/net/dictionary.el
@@ -1173,7 +1173,10 @@ dictionary-search
 (defun dictionary-lookup-definition ()
   "Unconditionally lookup the word at point."
   (interactive)
- -  (dictionary-new-search (cons (current-word) dictionary-default-dictionary)))
+  (let ((word (current-word)))
+    (unless word
+      (error "No word at point"))
+    (dictionary-new-search (cons word dictionary-default-dictionary))))
 
 (defun dictionary-previous ()
   "Go to the previous location in the current buffer."
- -- 
2.34.1


- --=-=-=--
------- End of forwarded message -------
-- 
Dr Richard Stallman (https://stallman.org)
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







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

end of thread, other threads:[~2022-10-16 20:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m14jw4q3p8.fsf.ref@yahoo.es>
2022-10-15 19:36 ` bug#58552: 29.0.50; [PATCH] dictionary-lookup-definition "Wrong type argument" error when there is no word at point Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-16  9:25   ` Lars Ingebrigtsen
2022-10-16 20:53   ` Richard Stallman

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).