bug#81552: [PATCH] Fix handling of spaces for webjump's Wikipedia query
Perry Fraser <[email protected]> Tue, 04 Aug 2026 17:02:21 -0400
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
--=-=-= Content-Type: multipart/alternative; boundary="==-=-=" --==-=-= Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Currently, `webjump' with Wikipedia doesn't quite work for queries that include spaces or queries that don't exactly match an existing page. The former is because Wikipedia interprets a `+' literally in a search URI, and instead expects an underscore for any spaces. The latter is because the URL used is just the prefix for viewing a Wikipedia page; it makes more sense to use `Special:Search/' at the prefix as that will still redirect to an article if it's an exact match to the query, while otherwise acting as a normal search. I've attached a patch that addresses this. It's my first time submitting a patch, and I would especially appreciate even nitpicky feedback if there's something I could've done better. Thanks, =E2=80=95 Perry --==-=-= Content-Type: text/html; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable <html xmlns=3D"http://www.w3.org/1999/xhtml" lang=3D"en" xml:lang=3D"en"><h= ead><!-- 2026-08-04 Tue 17:02 --><meta http-equiv=3D"Content-Type" content= =3D"text/html;charset=3Dutf-8"/><meta name=3D"viewport" content=3D"width=3D= device-width, initial-scale=3D1"/><meta name=3D"generator" content=3D"Org M= ode"/></head><body> <div id=3D"content" class=3D"content"> <p style=3D"text-decoration:none;"> Currently, <code style=3D"font-family:monospace;">webjump</code> with Wikip= edia doesn=E2=80=99t quite work for queries<br/> that include spaces or queries that don=E2=80=99t exactly match an existing= <br/> page. The former is because Wikipedia interprets a <code style=3D"font-fami= ly:monospace;">+</code> literally in a<br/> search URI, and instead expects an underscore for any spaces. The<br/> latter is because the URL used is just the prefix for viewing a<br/> Wikipedia page; it makes more sense to use <code style=3D"font-family:monos= pace;">Special:Search/</code> at the<br/> prefix as that will still redirect to an article if it=E2=80=99s an exact<b= r/> match to the query, while otherwise acting as a normal search.<br/></p> <p style=3D"text-decoration:none;"> I=E2=80=99ve attached a patch that addresses this. It=E2=80=99s my first ti= me<br/> submitting a patch, and I would especially appreciate even nitpicky<br/> feedback if there=E2=80=99s something I could=E2=80=99ve done better.<br/><= /p> <p style=3D"text-decoration:none;"> Thanks,<br/></p> <p style=3D"text-decoration:none;"> =E2=80=95 Perry<br/></p> </div> </body></html> --==-=-=-- --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-webjump-s-encoding-of-spaces-for-Wikipedia.patch 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. * lisp/net/webjump.el (webjump-sample-sites): Make Wikipedia's query a search and improve its handling of spaces. Copyright-paperwork-exempt: yes --- lisp/net/webjump.el | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/net/webjump.el b/lisp/net/webjump.el index 709f58b88a5..ba495282ec1 100644 --- a/lisp/net/webjump.el +++ b/lisp/net/webjump.el @@ -109,8 +109,8 @@ webjump-sample-sites ("DuckDuckGo" . [simple-query "https://duckduckgo.com" "https://duckduckgo.com/?q=" ""]) - ("Wikipedia" . - [simple-query "https://wikipedia.org" "https://wikipedia.org/wiki/" ""]) + + ("Wikipedia" . webjump-to-wikipedia) ;; Computer social issues, privacy, professionalism. ("Association for Computing Machinery" . "https://www.acm.org") @@ -228,6 +228,13 @@ webjump-to-risks (format "catless.ncl.ac.uk/Risks/%d.%02d.html" volume issue) "catless.ncl.ac.uk/Risks/"))) +(defun webjump-to-wikipedia (_) + ;; Wikipedia expects spaces to be encoded as underscores, not pluses. + (string-replace "+" "_" (webjump-do-simple-query + "Wikipedia" + "https://wikipedia.org" + "https://wikipedia.org/wiki/Special:Search/" ""))) + ;;-------------------------------------------------------------- Core Functions ;;;###autoload -- 2.55.0 --=-=-=--