Subject: [PATCH] Drop support for the dead third-party w3 package
From: Stefan Kangas <[email-masked]>
To: [email-masked]
Date: Thu, 7 Jul 2022 15:51:05 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

Severity: wishlist

The w3 package was removed from GNU ELPA in 2020 as it doesn't run on
a recent Emacs, and development had stopped over a decade before that.

If anyone wants to revive the w3 package, they should look this all
over, but it doesn't make sense for us to maintain this support code.

Ref: https://debbugs.gnu.org/25395
From 13c86a37d67675230d41aa8d47f7ba77472c7623 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Thu, 7 Jul 2022 13:25:23 +0200
Subject: [PATCH 1/2] Drop support for the dead third-party w3 package

The w3 package was removed from GNU ELPA in 2020 as it doesn't run on
a recent Emacs, and development had stopped over a decade before that.
If anyone wants to revive the w3 package, they should look this all
over, but it doesn't make sense for us to maintain this support code.
Ref: https://debbugs.gnu.org/25395

* lisp/net/browse-url.el (browse-url-w3): Make obsolete.
(browse-url--browser-defcustom-type)
(browse-url-default-browser):
* lisp/ffap.el (ffap-url-at-point, ffap-file-at-point):
* lisp/net/newst-plainview.el (newsticker--buffer-do-insert-text):
* lisp/net/newst-reader.el (newsticker-html-renderer)
(newsticker-show-news):
* lisp/net/newst-treeview.el (newsticker--treeview-render-text):
* lisp/org/ol.el (org-store-link):
* lisp/url/url.el (url-retrieve): Remove w3 support code and related
documentation and comments.

* test/lisp/net/browse-url-tests.el
(browse-url-tests-browser-kind): Adjust test for above changes.

* etc/TODO: Remove TODO to install W3.
* doc/misc/org.org (Handling Links): Don't mention W3.
* lisp/msb.el (msb--few-menus, msb--very-many-menus): Check for
eww-mode instead of w3-mode.
---
 doc/misc/org.org                  |  2 +-
 etc/TODO                          |  2 --
 lisp/ffap.el                      | 47 ++++++++++++-------------------
 lisp/msb.el                       |  4 +--
 lisp/net/browse-url.el            |  8 ++----
 lisp/net/newst-backend.el         |  1 -
 lisp/net/newst-plainview.el       | 17 ++++-------
 lisp/net/newst-reader.el          | 10 +++----
 lisp/net/newst-treeview.el        |  7 +----
 lisp/org/ol.el                    |  8 ------
 lisp/url/url.el                   |  2 +-
 lisp/widget.el                    |  1 -
 test/lisp/net/browse-url-tests.el |  2 +-
 13 files changed, 36 insertions(+), 75 deletions(-)

diff --git a/doc/misc/org.org b/doc/misc/org.org
index b1dc708498..fa8fa408c7 100644
--- a/doc/misc/org.org
+++ b/doc/misc/org.org
@@ -3352,7 +3352,7 @@ current buffer:
   ~org-link-email-description-format~.  By default, it refers to the
   addressee and the subject.
 
-- /Web browsers: W3, W3M and EWW/ ::
+- /Web browsers: W3M and EWW/ ::
 
   Here the link is the current URL, with the page title as the
   description.
diff --git a/etc/TODO b/etc/TODO
index 7ab913f779..5c55a8b999 100644
--- a/etc/TODO
+++ b/etc/TODO
@@ -722,8 +722,6 @@ bar.  In the mean time, it should process other messages.
 
 ** Get some major packages installed
 
-*** W3 (development version needs significant work)
-
 *** PSGML, _possibly_ ECB
 https://lists.gnu.org/r/emacs-devel/2007-05/msg01493.html Check the
 assignments file for other packages which might go in and have been
diff --git a/lisp/ffap.el b/lisp/ffap.el
index ae86e55490..3d48281531 100644
--- a/lisp/ffap.el
+++ b/lisp/ffap.el
@@ -68,8 +68,8 @@
 ;; If you do not like these bindings, modify the variable
 ;; `ffap-bindings', or write your own.
 ;;
-;; If you use ange-ftp, browse-url, complete, efs, or w3, it is best
-;; to load or autoload them before ffap.  If you use ff-paths, load it
+;; If you use ange-ftp, browse-url, complete, efs, it is best to load
+;; or autoload them before ffap.  If you use ff-paths, load it
 ;; afterwards.  Try apropos {C-h a ffap RET} to get a list of the many
 ;; option variables.  In particular, if ffap is slow, try these:
 ;;
@@ -79,7 +79,7 @@
 ;; (setq ffap-shell-prompt-regexp nil)  ; disable shell prompt stripping
 ;; (setq ffap-gopher-regexp nil)        ; disable gopher bookmark matching
 ;;
-;; ffap uses `browse-url' (if found, else `w3-fetch') to fetch URLs.
+;; ffap uses `browse-url' to fetch URLs.
 ;; For a hairier `ffap-url-fetcher', try ffap-url.el (same ftp site).
 ;; Also, you can add `ffap-menu-rescan' to various hooks to fontify
 ;; the file and URL references within a buffer.
@@ -97,7 +97,6 @@
 ;; * break long menus into multiple panes (like imenu?)
 ;; * notice node in "(dired)Virtual Dired" (quotes, parentheses, whitespace)
 ;; * notice "machine.dom blah blah blah dir/file" (how?)
-;; * as w3 becomes standard, rewrite to rely more on its functions
 ;; * regexp options for ffap-string-at-point, like font-lock (MCOOK)
 ;; * v19: could replace `ffap-locate-file' with a quieter `locate-library'
 ;; * handle "$(VAR)" in Makefiles
@@ -1326,29 +1325,24 @@ ffap-copy-string-as-kill
       ;; Older: (apply 'copy-region-as-kill ffap-string-at-point-region)
       (message "Copied to kill ring: %s"  str))))
 
-;; External.
-(declare-function w3-view-this-url "ext:w3" (&optional no-show))
-
 (defun ffap-url-at-point ()
   "Return URL from around point if it exists, or nil.
 
 Sets the variable `ffap-string-at-point-region' to the bounds of URL, if any."
   (when ffap-url-regexp
-    (or (and (eq major-mode 'w3-mode) ; In a w3 buffer button?
-	     (w3-view-this-url t))
-	(let ((thing-at-point-beginning-of-url-regexp ffap-url-regexp)
-	      (thing-at-point-default-mail-uri-scheme ffap-foo-at-bar-prefix)
-              val)
-	  (setq val (thing-at-point-url-at-point ffap-lax-url
-                                                 (if (use-region-p)
-                                                     (cons (region-beginning)
-                                                           (region-end)))))
-          (if val
-              (let ((bounds (thing-at-point-bounds-of-url-at-point
-                             ffap-lax-url)))
-                (setq ffap-string-at-point-region
-                      (list (car bounds) (cdr bounds)))))
-          val))))
+    (let ((thing-at-point-beginning-of-url-regexp ffap-url-regexp)
+          (thing-at-point-default-mail-uri-scheme ffap-foo-at-bar-prefix)
+          val)
+      (setq val (thing-at-point-url-at-point ffap-lax-url
+                                             (if (use-region-p)
+                                                 (cons (region-beginning)
+                                                       (region-end)))))
+      (if val
+          (let ((bounds (thing-at-point-bounds-of-url-at-point
+                         ffap-lax-url)))
+            (setq ffap-string-at-point-region
+                  (list (car bounds) (cdr bounds)))))
+      val)))
 
 (defvar ffap-gopher-regexp
   "\\<\\(Type\\|Name\\|Path\\|Host\\|Port\\) *= *"
@@ -1489,12 +1483,7 @@ ffap-file-at-point
 		   ((and (eq major-mode 'internal-ange-ftp-mode)
 			 (string-match "^\\*ftp \\(.*\\)@\\(.*\\)\\*$"
 				       (buffer-name)))
-		    (concat "/" (substring (buffer-name) 5 -1) ":"))
-		   ;; This is too often a bad idea:
-		   ;;((and (eq major-mode 'w3-mode)
-		   ;;	   (stringp url-current-server))
-		   ;; (host-to-ange-path url-current-server))
-		   )))
+                    (concat "/" (substring (buffer-name) 5 -1) ":")))))
 	    (and remote-dir
 		 (or
 		  (and (string-match "\\`\\(/?~?ftp\\)/" name)
@@ -1868,7 +1857,7 @@ ffap-at-mouse
 ;;; ffap-other-*, ffap-read-only-*, ffap-alternate-* commands:
 
 ;; There could be a real `ffap-noselect' function, but we would need
-;; at least two new user variables, and there is no w3-fetch-noselect.
+;; at least two new user variables.
 ;; So instead, we just fake it with a slow save-window-excursion.
 
 (defun ffap-other-window (filename)
diff --git a/lisp/msb.el b/lisp/msb.el
index 616799f067..5f03995623 100644
--- a/lisp/msb.el
+++ b/lisp/msb.el
@@ -103,7 +103,7 @@ msb--few-menus
     ((eq major-mode 'Man-mode)
      4090
      "Manuals (%d)")
-    ((eq major-mode 'w3-mode)
+    ((eq major-mode 'eww-mode)
      4020
      "WWW (%d)")
     ((or (memq major-mode
@@ -154,7 +154,7 @@ msb--very-many-menus
     ((eq major-mode 'Man-mode)
      5030
      "Manuals (%d)")
-    ((eq major-mode 'w3-mode)
+    ((eq major-mode 'eww-mode)
      5020
      "WWW (%d)")
     ((or (memq major-mode
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 7cffe3e32e..355f9c12c0 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -40,7 +40,6 @@
 ;; browse-url-chromium                Chromium    3.0
 ;; browse-url-epiphany                GNOME Web (Epiphany)    Don't know
 ;; browse-url-webpositive             WebPositive 1.2-alpha (Haiku R1/beta3)
-;; browse-url-w3                      w3          0
 ;; browse-url-text-*	              Any text browser     0
 ;; browse-url-generic                 arbitrary
 ;; browse-url-default-windows-browser MS-Windows browser
@@ -108,9 +107,9 @@
 ;; Gnus provides a standard feature to activate URLs in article
 ;; buffers for invocation of browse-url.
 
-;; Use the Emacs w3 browser when not running under X11:
+;; Use the Emacs Web Wowser (EWW) when not running under X11:
 ;;	(or (eq window-system 'x)
-;;	    (setq browse-url-browser-function 'browse-url-w3))
+;;	    (setq browse-url-browser-function #'eww-browse-url))
 
 ;; To always save modified buffers before displaying the file in a browser:
 ;;	(setq browse-url-save-file t)
@@ -150,7 +149,6 @@ browse-url
 
 (defvar browse-url--browser-defcustom-type
   '(choice
-    (function-item :tag "Emacs W3" :value  browse-url-w3)
     (function-item :tag "eww" :value  eww-browse-url)
     (function-item :tag "Mozilla" :value  browse-url-mozilla)
     (function-item :tag "Firefox" :value browse-url-firefox)
@@ -1033,7 +1031,6 @@ browse-url-default-browser
     ((executable-find browse-url-chrome-program) 'browse-url-chrome)
     ((executable-find browse-url-webpositive-program) 'browse-url-webpositive)
     ((executable-find browse-url-xterm-program) 'browse-url-text-xterm)
-    ((locate-library "w3") 'browse-url-w3)
     (t
      (lambda (&rest _ignore) (error "No usable browser found"))))
    url args))
@@ -1367,6 +1364,7 @@ browse-url-w3
 
 When called non-interactively, optional second argument NEW-WINDOW is
 used instead of `browse-url-new-window-flag'."
+  (declare (obsolete nil "29.1"))
   (interactive (browse-url-interactive-arg "W3 URL: "))
   (require 'w3)			; w3-fetch-other-window not autoloaded
   (if (browse-url-maybe-new-window new-window)
diff --git a/lisp/net/newst-backend.el b/lisp/net/newst-backend.el
index 7ae58884f9..5ae2df769a 100644
--- a/lisp/net/newst-backend.el
+++ b/lisp/net/newst-backend.el
@@ -40,7 +40,6 @@
 
 ;; Silence warnings
 (defvar newsticker-groups)
-(defvar w3-mode-map)
 (defvar w3m-minor-mode-map)
 
 (defvar newsticker--retrieval-timer-list nil
diff --git a/lisp/net/newst-plainview.el b/lisp/net/newst-plainview.el
index df574dfa2f..4eb6f6c695 100644
--- a/lisp/net/newst-plainview.el
+++ b/lisp/net/newst-plainview.el
@@ -37,7 +37,6 @@
 (require 'xml)
 
 ;; Silence warnings
-(defvar w3-mode-map)
 (defvar w3m-minor-mode-map)
 
 ;; ======================================================================
@@ -1232,7 +1231,6 @@ newsticker--buffer-insert-item
   (newsticker--buffer-do-insert-text item 'desc feed-name-symbol))
 
 (defvar w3m-fill-column)
-(defvar w3-maximum-line-length)
 
 (defun newsticker--buffer-do-insert-text (item type feed-name-symbol)
   "Actually insert contents of news item, format it, render it and all that.
@@ -1366,19 +1364,14 @@ newsticker--buffer-do-insert-text
                             "</?[A-Za-z1-6]*\\|&#?[A-Za-z0-9]+;" pos-text-end t)
                        ;; (message "%s" (newsticker--title item))
                        (let ((w3m-fill-column (if newsticker-use-full-width
-                                                  -1 fill-column))
-                             (w3-maximum-line-length
-                              (if newsticker-use-full-width nil fill-column)))
+                                                  -1 fill-column)))
                          (save-excursion
                            (funcall newsticker-html-renderer pos-text-start
                                     pos-text-end)))
-                       (cond ((eq newsticker-html-renderer 'w3m-region)
-                              (add-text-properties pos (point-max)
-                                                   (list 'keymap
-                                                         w3m-minor-mode-map)))
-                             ((eq newsticker-html-renderer 'w3-region)
-                              (add-text-properties pos (point-max)
-                                                   (list 'keymap w3-mode-map))))
+                       (when (eq newsticker-html-renderer 'w3m-region)
+                         (add-text-properties pos (point-max)
+                                              (list 'keymap
+                                                    w3m-minor-mode-map)))
                        (setq is-rendered-HTML t)))
                  (error
                   (message "Error: HTML rendering failed: %s, %s"
diff --git a/lisp/net/newst-reader.el b/lisp/net/newst-reader.el
index 7e00ac93e7..4a7f0b8e3e 100644
--- a/lisp/net/newst-reader.el
+++ b/lisp/net/newst-reader.el
@@ -112,18 +112,18 @@ newsticker-html-renderer
   "Function for rendering HTML contents.
 If non-nil, newsticker.el will call this function whenever it
 finds HTML-like tags in item descriptions.
-Possible functions include `shr-render-region', `w3m-region', `w3-region', and
+Possible functions include `shr-render-region', `w3m-region', and
 `newsticker-htmlr-render'.
-Newsticker automatically loads the respective package w3m, w3, or
+Newsticker automatically loads the respective package w3m, or
 htmlr if this option is set."
   :type '(choice :tag "Function"
                  (const :tag "None" nil)
                  (const :tag "SHR" shr-render-region)
-                 (const :tag "w3" w3-region)
                  (const :tag "w3m" w3m-region)
                  (const :tag "htmlr" newsticker-htmlr-render))
   :set #'newsticker--set-customvar-formatting
-  :group 'newsticker-reader)
+  :group 'newsticker-reader
+  :version "29.1")
 
 (defcustom newsticker-date-format
   "(%A, %H:%M)"
@@ -315,8 +315,6 @@ newsticker-show-news
   (if newsticker-html-renderer
       (cond ((eq newsticker-html-renderer 'w3m-region)
              (require 'w3m))
-            ((eq newsticker-html-renderer 'w3-region)
-             (require 'w3-auto))
             ((eq newsticker-html-renderer 'newsticker-htmlr-render)
              (require 'htmlr))))
   (funcall newsticker-frontend))
diff --git a/lisp/net/newst-treeview.el b/lisp/net/newst-treeview.el
index b429a33dec..c7dbef86c6 100644
--- a/lisp/net/newst-treeview.el
+++ b/lisp/net/newst-treeview.el
@@ -252,7 +252,6 @@ newsticker--treeview-get-current-node
 
 (declare-function w3m-toggle-inline-images "ext:w3m" (&optional force no-cache))
 (defvar w3m-fill-column)
-(defvar w3-maximum-line-length)
 
 (defun newsticker--treeview-render-text (start end)
   "Render text between markers START and END."
@@ -272,17 +271,13 @@ newsticker--treeview-render-text
                      "</?[A-Za-z1-6]*\\|&#?[A-Za-z0-9]+;" end t)
                 ;; (message "%s" (newsticker--title item))
                 (let ((w3m-fill-column (if newsticker-use-full-width
-                                           -1 fill-column))
-                      (w3-maximum-line-length
-                       (if newsticker-use-full-width nil fill-column)))
+                                           -1 fill-column)))
                   (select-window (newsticker--treeview-item-window))
                   (save-excursion
                     (funcall newsticker-html-renderer start end)))
                 ;;(cond ((eq newsticker-html-renderer 'w3m-region)
                 ;;     (add-text-properties start end (list 'keymap
                 ;;                                        w3m-minor-mode-map)))
-                ;;((eq newsticker-html-renderer 'w3-region)
-                ;;(add-text-properties start end (list 'keymap w3-mode-map))))
                 (if (eq newsticker-html-renderer 'w3m-region)
                     (w3m-toggle-inline-images t))
                 t)))
diff --git a/lisp/org/ol.el b/lisp/org/ol.el
index a03d85f618..a0dad926bc 100644
--- a/lisp/org/ol.el
+++ b/lisp/org/ol.el
@@ -1580,14 +1580,6 @@ org-store-link
 			      nil nil nil))))
 	  (org-link-store-props :type "calendar" :date cd)))
 
-       ((eq major-mode 'w3-mode)
-	(setq cpltxt (if (and (buffer-name)
-			      (not (string-match "Untitled" (buffer-name))))
-			 (buffer-name)
-		       (url-view-url t))
-	      link (url-view-url t))
-	(org-link-store-props :type "w3" :url (url-view-url t)))
-
        ((eq major-mode 'image-mode)
 	(setq cpltxt (concat "file:"
 			     (abbreviate-file-name buffer-file-name))
diff --git a/lisp/url/url.el b/lisp/url/url.el
index 4592f0f2e7..d08ff04eda 100644
--- a/lisp/url/url.el
+++ b/lisp/url/url.el
@@ -158,7 +158,7 @@ url-retrieve
 URL-encoded before it's used."
   ;; XXX: There is code in Emacs that does dynamic binding
   ;; of the following variables around url-retrieve:
-  ;; url-standalone-mode, url-gateway-unplugged, w3-honor-stylesheets,
+  ;; url-standalone-mode, url-gateway-unplugged,
   ;; url-confirmation-func, url-cookie-multiple-line,
   ;; url-cookie-{{,secure-}storage,confirmation}
   ;; url-standalone-mode and url-gateway-unplugged should work as
diff --git a/lisp/widget.el b/lisp/widget.el
index 300a95bd22..e6a856b292 100644
--- a/lisp/widget.el
+++ b/lisp/widget.el
@@ -91,7 +91,6 @@ define-widget
   (put name 'widget-documentation (purecopy doc))
   name)
 
-;; This is used by external widget code (in W3, at least).
 (define-obsolete-function-alias 'widget-plist-member #'plist-member "26.1")
 
 (provide 'widget)
diff --git a/test/lisp/net/browse-url-tests.el b/test/lisp/net/browse-url-tests.el
index 8fcc831d53..1c993958b8 100644
--- a/test/lisp/net/browse-url-tests.el
+++ b/test/lisp/net/browse-url-tests.el
@@ -31,7 +31,7 @@
 (require 'ert-x)
 
 (ert-deftest browse-url-tests-browser-kind ()
-  (should (eq (browse-url--browser-kind #'browse-url-w3 "gnu.org")
+  (should (eq (browse-url--browser-kind #'browse-url-emacs "gnu.org")
               'internal))
   (should
    (eq (browse-url--browser-kind #'browse-url-firefox "gnu.org")
-- 
2.30.2

From b14f95b7357dc8bc91e14d86cabf5b05e93f630e Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Thu, 7 Jul 2022 13:43:53 +0200
Subject: [PATCH 2/2] Make browse-url-default-browser fall back to EWW

* lisp/net/browse-url.el (browse-url-default-browser): Fall back
to EWW.
---
 lisp/net/browse-url.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 355f9c12c0..c5055ac4a5 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -1031,12 +1031,11 @@ browse-url-default-browser
     ((executable-find browse-url-chrome-program) 'browse-url-chrome)
     ((executable-find browse-url-webpositive-program) 'browse-url-webpositive)
     ((executable-find browse-url-xterm-program) 'browse-url-text-xterm)
-    (t
-     (lambda (&rest _ignore) (error "No usable browser found"))))
+    (t #'eww-browse-url))
    url args))
 
 (function-put 'browse-url-default-browser 'browse-url-browser-kind
-              ;; Well, most probably external if we ignore w3.
+              ;; Well, most probably external if we ignore EWW.
               'external)
 
 (defun browse-url-can-use-xdg-open ()
-- 
2.30.2