bug#81552: [PATCH] Fix handling of spaces for webjump's Wikipedia query

Perry Fraser <[email protected]> Wed, 05 Aug 2026 11:48:14 -0400
Newsgroups gmane.emacs.bugs
Message-ID <[email protected]>
Sean Whitton <[email protected]> writes:

> Perry Fraser [05/Aug 10:33am -04] wrote:
>> Sean Whitton <[email protected]> writes:
>>
>>> Perry Fraser [04/Aug  5:02pm -04] wrote:
>>>> From 1a0e57c09514f1469ebf858e649d8ceb27477543 Mon Sep 17 00:00:00 2001
>>>> From: Perry Fraser <[email protected]>
>>>> Date: Tue, 4 Aug 2026 16:29:27 -0400
>>>> Subject: [PATCH] Fix webjump's encoding of spaces for Wikipedia
>>>>
>>>> Wikipedia expects spaces to be encoded as underscores rather than
>>>> pluses, so give it a site function that wraps
>>>> `webjump-do-simple-query' and makes that replacement. Also adjust
>>>> its URL to use Special:Search which will redirect to a search
>>>> page if the query doesn't match an existing article.
>>>
>>> We prefer things like this to be in code comments instead of in the
>>> commit message.
>>
>> Interesting—that definitely goes against my normal instinct. For
>> example, the note about changing to using `Special:Search', it
>> wouldn't make sense to leave that as a comment. In my mind that
>> belongs in the commit message.
>
> If it truly about why we had to *change* it rather than the content of
> the code before or after, then it can go in the commit.
>
> In this case using Special:Search at all seems like something worth
> explaining in a comment.

In the process of explaining a decision you make, do you ever end up
stumbling upon a /way/ better solution to a problem? I was about to
mention in an aside that an alternative would've been using the
`/w/index.php?search=' syntax... which would mean we can just use
normal query parameter encoding anyway. Oops. :)

Massively simplified patch attached!

Thanks,

― Perry
0001-lisp-net-webjump.el-webjump-sample-sites-Fix-Wikiped.patch (text/x-patch, 963 B)
From 1866c4c731dfab27624920c34fdbb5de9c0d1c86 Mon Sep 17 00:00:00 2001
From: Perry Fraser <[email protected]>
Date: Tue, 4 Aug 2026 16:29:27 -0400
Subject: [PATCH] * lisp/net/webjump.el (webjump-sample-sites): Fix Wikipedia's
 query

Copyright-paperwork-exempt: yes
---
 lisp/net/webjump.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el
index 709f58b88a5..c2f49f9f9ea 100644
--- a/lisp/net/webjump.el
+++ b/lisp/net/webjump.el
@@ -110,7 +110,8 @@ webjump-sample-sites
      [simple-query "https://duckduckgo.com"
 		   "https://duckduckgo.com/?q=" ""])
     ("Wikipedia" .
-     [simple-query "https://wikipedia.org" "https://wikipedia.org/wiki/" ""])
+     [simple-query "https://wikipedia.org"
+                   "https://wikipedia.org/w/?search=" ""])
 
     ;; Computer social issues, privacy, professionalism.
     ("Association for Computing Machinery" . "https://www.acm.org")
-- 
2.55.0