Subject: Patches to clean up ispell.el
From: Reuben Thomas <[email-masked]>
To: bug-emacs <[email-masked]>
Date: Sun, 4 Dec 2016 17:10:42 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

The attached patch series is mostly aimed at removing XEmacs-specific code,
which is not needed, since our version of ispell.el has been part of GNU
Emacs for some time, and is not imported from upstream (the most recent
upstream release was over 20 years ago). Similarly, some workarounds for
older versions of GNU Emacs are removed (since ispell.el is not distributed
separately); in any case, most of the workarounds seem to pertain to GNU
Emacs pre-version 21.

The pre-VCS change history is also removed by the patch.

This clean-up series is aimed at making things neat before I add enchant
support (bug #17742), which will be a very simple change.

One patch also removes the pre-GNU Emacs maintainer information, so that
attentive users (who read the source!) do not mistakenly try to file bug
reports &c. with the original upstream.

I have supplied the patches as a series for ease of reading, but could
compress them if desired for installation in Emacs git.

-- 
http://rrt.sc3d.org
From 9572d5868e8a58b25a9eda94164f149b102031eb Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 00:49:35 +0000
Subject: [PATCH 02/15] Remove ispell.el pre-GNU Emacs comments

* lisp/textmodes/ispell.el (Commentary): Remove original maintainer
  details, as Emacs version, bug report address and so forth should be
  used instead for this version.  Remove in-line change history; use
  git instead.
---
 lisp/textmodes/ispell.el | 77 ------------------------------------------------
 1 file changed, 77 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 5d5d422..25099e3 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -3,12 +3,7 @@
 ;; Copyright (C) 1994-1995, 1997-2016 Free Software Foundation, Inc.
 
 ;; Author:           Ken Stevens <[email-masked]>
-;; Maintainer:       Ken Stevens <[email-masked]>
-;; Stevens Mod Date: Mon Jan  7 12:32:44 PST 2003
-;; Stevens Revision: 3.6
 ;; Status          : Release with 3.1.12+ and 3.2.0+ ispell.
-;; Bug Reports     : [email-masked]
-;; Web Site        : http://kdstevens.com/~stevens/ispell-page.html
 ;; Keywords: unix wp
 
 ;; This file is part of GNU Emacs.
@@ -123,78 +118,6 @@
 ;;  Recursive edits (?C-r or ?R) inside a keyboard text replacement check (?r)
 ;;    can cause misalignment errors.
 
-;; HISTORY
-
-;; Modifications made in latest versions:
-
-;; Revision 3.6 2003/01/07 12:32:44	kss
-;; Removed extra -d LIB in dictionary defs. (Pavel Janik)
-;; Filtered process calls with duplicate dictionary entries.
-;; Fixed bug where message-text-end is inside a mime skipped region.
-;; Minor fixes to get ispell menus right in XEmacs
-;; Fixed skip regexp so it doesn't match stuff like `/.\w'.
-;; Detecting dictionary change not working.  Fixed.  kss
-;; function `ispell-change-dictionary' now only completes valid dicts.
-
-;; Revision 3.5 2001/7/11 18:43:57	kss
-;; Added fix for aspell to work in XEmacs (ispell-check-version).
-;; Added Portuguese dictionary definition.
-;; New feature: MIME mail message support, Fcc support.
-;; Bug fix: retain comment syntax on lines with region skipping. (TeX $ bug...)
-;; Improved allocation for graphic mode lines.  (Miles Bader)
-;; Support -v flag for old versions of aspell.  (Eli Zaretskii)
-;; Clear minibuffer on ^G from ispell-help (Tak Ota)
-
-;; Revision 3.4 2000/8/4 09:41:50	kss
-;; Support new color display functions.
-;; Fixed misalignment offset bug when replacing a string after a shift made.
-;; Set to standard Author/Maintainer heading,
-;; ensure localwords lists are separated from the text by newline. (Dave Love)
-;; Added dictionary definition for Italian (William Deakin)
-;; HTML region skipping greatly improved. (Chuck D. Phillips)
-;; improved menus.  Fixed regexp matching http/email addresses.
-;; one arg always for XEmacs sleep-for (gunnar Evermann)
-;; support for synchronous processes (Eli Zaretskii)
-
-;; Revision 3.3  1999/11/29 11:38:34     kss
-;; Only word replacements entered in from the keyboard are rechecked.
-;; This fixes a bug in tex parsing and misalignment.
-;; Exceptions exist for recursive edit and query-replace, with tex error
-;; condition tested.  Recursive editing improved.
-;; XEmacs repair for when `enable-multibyte-characters' defined - Didier Verna.
-;; ispell-help fixed for XEmacs.  Choices minibuffer now displayed in XEmacs.
-;; Only list valid dictionaries in Spell menu.  Russian dictionary doesn't allow
-;; run-together words, and uses koi8-r font.  Don't skip text in html <TT>
-;; fonts.
-
-;; Revision 3.2  1999/5/7 14:25:14	kss
-;; Accept ispell versions 3.X.Y where X>=1
-;; fine tuned latex region skipping.  Fixed bug in ispell-word that did not
-;; point in right place on words < 2 chars.  Simplified ispell-minor-mode.
-;; Fixed bug in TeX parsing when math commands are in the comments.
-;; Removed calls to `when' macro.
-
-;; Revision 3.1  1998/12/1 13:21:52	kss
-;; Improved and fixed customize support.
-;; Improved and fixed comments in variables and messages.
-;; A coding system is now required for all languages.
-;; casechars improved for castellano, castellano8, and norsk dictionaries.
-;; Dictionary norsk7-tex removed.  Dictionary polish added.
-;; Dictionaries redefined at load-time to support dictionary changes.
-;; Menu redefined at load time to support dictionary changes.
-;; ispell-check-version added as an alias for `check-ispell-version'.
-;; Spelling suggestions returned in order generated by ispell.
-;; Small bug fixed in matching ispell error messages.
-;; Robustness added to ensure `case-fold-search' doesn't get redefined.
-;; Fixed bug that didn't respect case of word in `ispell-complete-word'.
-;; Multibyte character coding support added for process interactions.
-;; Ensure ispell process has terminated before starting new process.
-;;  This can otherwise confuse process filters and hang ispell.
-;; Improved skipping support for SGML.
-;; Fixed bug using ^M rather than \r in `ispell-minor-check'.
-;; Improved message reference matching in `ispell-message'.
-;; Fixed bug in returning to nroff mode from tex mode.
-
 ;;; Compatibility code for XEmacs and (not too) older emacsen:
 (defalias 'ispell-check-minver
   (if (fboundp 'version<=) 'version<=
-- 
2.7.4

From 8cf4109cf660239326e18566ab67a2c5d1d19829 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 00:54:04 +0000
Subject: [PATCH 03/15] Assume we have version<= for checking ispell version

* lisp/textmodes/ispell.el (ispell-check-minver): Remove.
(ispell-check-version): Use version<= directly.
---
 lisp/textmodes/ispell.el | 46 +++++-----------------------------------------
 1 file changed, 5 insertions(+), 41 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 25099e3..14a782d 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -118,42 +118,6 @@
 ;;  Recursive edits (?C-r or ?R) inside a keyboard text replacement check (?r)
 ;;    can cause misalignment errors.
 
-;;; Compatibility code for XEmacs and (not too) older emacsen:
-(defalias 'ispell-check-minver
-  (if (fboundp 'version<=) 'version<=
-    (lambda (minver version)
-      "Check if string VERSION is at least string MINVER.
-Both must be in [0-9]+.[0-9]+... format.  This is a fallback
-compatibility function in case `version<=' is not available."
-      (let ((pending t)
-            (return t)
-            start-ver start-mver)
-        ;; Loop until an absolute greater or smaller condition is reached
-        ;; or until no elements are left in any of version and minver. In
-        ;; this case version is exactly the minimal, so return OK.
-        (while pending
-          (let (ver mver)
-            (if (string-match "[0-9]+" version start-ver)
-                (setq start-ver (match-end 0)
-                      ver (string-to-number (match-string 0 version))))
-            (if (string-match "[0-9]+" minver start-mver)
-                (setq start-mver (match-end 0)
-                      mver (string-to-number (match-string 0 minver))))
-
-            (if (or ver mver)
-                (progn
-                  (or ver  (setq ver 0))
-                  (or mver (setq mver 0))
-                  ;; If none of below conditions match, this element is the
-                  ;; same. Go checking next element.
-                  (if (> ver mver)
-                      (setq pending nil)
-                    (if (< ver mver)
-                        (setq pending nil
-                              return nil))))
-              (setq pending nil))))
-        return))))
-
 ;; XEmacs does not have looking-back
 (defalias 'ispell-looking-back
   (if (fboundp 'looking-back) 'looking-back
@@ -829,8 +793,8 @@ ispell-check-version
 	    (ispell-minver    "3.1.12")
 	    (hunspell8-minver "1.1.6"))
 
-	(if (ispell-check-minver ispell0-minver ispell-program-version)
-	    (or (ispell-check-minver ispell-minver ispell-program-version)
+	(if (version<= ispell0-minver ispell-program-version)
+	    (or (version<= ispell-minver ispell-program-version)
 		(setq ispell-offset 0))
 	  (error "%s release %s or greater is required"
 		 ispell-program-name
@@ -838,14 +802,14 @@ ispell-check-version
 
 	(cond
 	 (ispell-really-aspell
-	  (if (ispell-check-minver aspell-minver ispell-really-aspell)
-	      (if (ispell-check-minver aspell8-minver ispell-really-aspell)
+	  (if (version<= aspell-minver ispell-really-aspell)
+	      (if (version<= aspell8-minver ispell-really-aspell)
 		  (progn
 		    (setq ispell-aspell-supports-utf8 t)
 		    (setq ispell-encoding8-command "--encoding=")))
 	    (setq ispell-really-aspell nil)))
 	 (ispell-really-hunspell
-	  (if (ispell-check-minver hunspell8-minver ispell-really-hunspell)
+	  (if (version<= hunspell8-minver ispell-really-hunspell)
 	      (setq ispell-encoding8-command "-i")
 	    (setq ispell-really-hunspell nil))))))
     result))
-- 
2.7.4

From c5b9cfc88078940a631b2239807d8fb1bfaa7685 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 01:06:26 +0000
Subject: [PATCH 04/15] Remove unused ispell-looking-back

* lisp/textmodes/ispell.el (ispell-looking-back): Remove unused alias.
---
 lisp/textmodes/ispell.el | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 14a782d..554905c 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -118,21 +118,6 @@
 ;;  Recursive edits (?C-r or ?R) inside a keyboard text replacement check (?r)
 ;;    can cause misalignment errors.
 
-;; XEmacs does not have looking-back
-(defalias 'ispell-looking-back
-  (if (fboundp 'looking-back) 'looking-back
-    (lambda (regexp &optional limit &rest ignored)
-      "Return non-nil if text before point matches regular expression REGEXP.
-Like `looking-at' except matches before point, and is slower.
-LIMIT if non-nil speeds up the search by specifying a minimum
-starting position, to avoid checking matches that would start
-before LIMIT.
-
-This is a stripped down compatibility function for use when
-full featured `looking-back' function is missing."
-      (save-excursion
-        (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)))))
-
 ;;; XEmacs21 does not have `with-no-warnings'. Taken from org mode.
 (defmacro ispell-with-no-warnings (&rest body)
   (cons (if (fboundp 'with-no-warnings) 'with-no-warnings 'progn) body))
-- 
2.7.4

From 8fdca7c7c23eaa83aa470276d19a40d1be3a28a4 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 13:52:04 +0000
Subject: [PATCH 05/15] Remove tests for built-in functions

* lisp/textmodes/ispell.el (buffer-substring-no-properties): Remove
back-up definition.
(ispell-command-loop): Remove test for flyspell-unhighlight-at.
(ispell-add-per-file-word-list): Remove tests for comment-padright and
comment-normalize-vars.
---
 lisp/textmodes/ispell.el | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 554905c..85661e7 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -132,10 +132,6 @@ ispell
   "User variables for Emacs ispell interface."
   :group 'applications)
 
-(if (not (fboundp 'buffer-substring-no-properties))
-    (defun buffer-substring-no-properties (start end)
-      (buffer-substring start end)))
-
 (defalias 'check-ispell-version 'ispell-check-version)
 
 ;;; **********************************************************************
@@ -2300,15 +2296,13 @@ ispell-command-loop
 		   ((= char ?i)		; accept and insert word into pers dict
 		    (ispell-send-string (concat "*" word "\n"))
 		    (setq ispell-pdict-modified-p '(t)) ; dictionary modified!
-		    (and (fboundp 'flyspell-unhighlight-at)
-			 (flyspell-unhighlight-at start))
+		    (flyspell-unhighlight-at start)
 		    nil)
 		   ((or (= char ?a) (= char ?A)) ; accept word without insert
 		    (ispell-send-string (concat "@" word "\n"))
 		    (cl-pushnew word ispell-buffer-session-localwords
                                 :test #'equal)
-		    (and (fboundp 'flyspell-unhighlight-at)
-			 (flyspell-unhighlight-at start))
+		    (flyspell-unhighlight-at start)
 		    (or ispell-buffer-local-name ; session localwords might conflict
 			(setq ispell-buffer-local-name (buffer-name)))
 		    (if (null ispell-pdict-modified-p)
@@ -4286,16 +4280,12 @@ ispell-add-per-file-word-list
 		    (unless found (newline))
 		    (insert (if comment-start
                                 (concat
-                                  (if (fboundp 'comment-padright)
-                                      ;; Try and use the proper comment marker,
-                                      ;; e.g. ";;" rather than ";".
-				      (progn
-					;; XEmacs: comment-normalize-vars
-					;; (newcomment.el) only in >= 21.5
-					(and (fboundp 'comment-normalize-vars)
-					     (comment-normalize-vars))
-					(comment-padright comment-start
-							  (comment-add nil)))
+                                  (progn
+                                   ;; Try and use the proper comment marker,
+                                   ;; e.g. ";;" rather than ";".
+                                    (comment-normalize-vars)
+                                    (comment-padright comment-start
+                                                      (comment-add nil))
                                     comment-start)
                                   " ")
                               "")
-- 
2.7.4

From f06962a566835c8b687b78848ab76d7a35c54eee Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 13:55:31 +0000
Subject: [PATCH 06/15] Generalise over-specific documentation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/textmodes/ispell.el (ispell-personal-dictionary): Rather than
document precise personal wordlist filenames for only two supported
spelling checkers, simply say that the default personal dictionary
depends on the chosen spelling checker.  The user can check the
spelling checker’s documentation if necessary.  This is simpler, and
works for other supported (and future, or unknown) spelling checkers.
---
 lisp/textmodes/ispell.el | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 85661e7..dc46647 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -349,9 +349,7 @@ ispell-use-framepop-p
 ;;;###autoload
 (defcustom ispell-personal-dictionary nil
   "File name of your personal spelling dictionary, or nil.
-If nil, the default personal dictionary, (\"~/.ispell_DICTNAME\" for ispell or
-\"~/.aspell.LANG.pws\" for Aspell) is used, where DICTNAME is the name of your
-default dictionary and LANG the two letter language code."
+If nil, the default personal dictionary for your spelling checker is used."
   :type '(choice file
 		 (const :tag "default" nil))
   :group 'ispell)
-- 
2.7.4

From 9f87d8487acfeaea22a3d92c2fe74822bd270e33 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 13:59:59 +0000
Subject: [PATCH 07/15] Remove some XEmacs-specific code from ispell.el

* lisp/textmodes/ispell.el: Remove XEmacs menubar setup.
(ispell-int-char): Remove.
---
 lisp/textmodes/ispell.el | 69 +++++-------------------------------------------
 1 file changed, 6 insertions(+), 63 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index dc46647..0bf6c75 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1466,62 +1466,6 @@ ispell-valid-dictionary-list
       ;;(put 'ispell-region 'menu-enable 'mark-active)
       (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))
 
-;;; XEmacs versions 19 & 20
-(if (and (featurep 'xemacs)
-	 (featurep 'menubar)
-	 ;;(null ispell-menu-xemacs)
-	 (not (and (boundp 'infodock-version) infodock-version)))
-    (let ((dicts (if (fboundp 'ispell-valid-dictionary-list)
-		     (reverse (ispell-valid-dictionary-list))))
-	  (current-menubar (or current-menubar default-menubar))
-	  (menu
-	   '(["Help"		(describe-function 'ispell-help) t]
-	     ;;["Help"		(popup-menu ispell-help-list)	t]
-	     ["Check Message"	ispell-message			t]
-	     ["Check Buffer"	ispell-buffer			t]
-	     ["Check Comments"	ispell-comments-and-strings	t]
-	     ["Check Word"	ispell-word			t]
-	     ["Check Region"	ispell-region  (or (not zmacs-regions) (mark))]
-	     ["Continue Check"	ispell-continue			t]
-	     ["Complete Word Frag"ispell-complete-word-interior-frag t]
-	     ["Complete Word"	ispell-complete-word		t]
-	     ["Kill Process"	(ispell-kill-ispell nil 'clear) t]
-	     ["Customize..."	(customize-group 'ispell)	t]
-	     ;; flyspell-mode may not be bound...
-	     ;;["flyspell"	flyspell-mode
-	     ;;			:style toggle :selected flyspell-mode ]
-	     "-"
-	     ["Save Personal Dict"(ispell-pdict-save t t)	t]
-	     ["Change Dictionary" ispell-change-dictionary	t])))
-      (if (null dicts)
-	  (setq dicts (cons "default" nil)))
-      (dolist (name dicts)
-	(setq menu (append menu
-			   (list
-			     (vector
-			      (concat "Select " (capitalize name))
-			      (list 'ispell-change-dictionary name)
-			      t)))))
-      (setq ispell-menu-xemacs menu)
-      (if current-menubar
-	  (progn
-	    (if (car (find-menu-item current-menubar '("Cmds")))
-		(progn
-		  ;; XEmacs 21.2
-		  (delete-menu-item '("Cmds" "Spell-Check"))
-		  (add-menu '("Cmds") "Spell-Check" ispell-menu-xemacs))
-	      ;; previous
-	      (delete-menu-item '("Edit" "Spell")) ; in case already defined
-	      (add-menu '("Edit") "Spell" ispell-menu-xemacs))))))
-
-(defalias 'ispell-int-char
-  ;; Allow incrementing characters as integers in XEmacs 20
-  (if (and (featurep 'xemacs)
-	   (fboundp 'int-char))
-      'int-char
-    ;; Emacs and XEmacs 19 or earlier
-    'identity))
-
 
 ;;; **********************************************************************
 
@@ -2230,12 +2174,12 @@ ispell-command-loop
 	;; not so good if there are over 20 or 30 options, but then, if
 	;; there are that many you don't want to scan them all anyway...
 	(while (memq count command-characters) ; skip command characters.
-	  (setq count (ispell-int-char (1+ count))
+	  (setq count (1+ count)
 		skipped (1+ skipped)))
 	(insert "(" count ") " (car choices) "  ")
 	(setq choices (cdr choices)
-	      count (ispell-int-char (1+ count))))
-      (setq count (ispell-int-char (- count ?0 skipped))))
+	      count (1+ count)))
+      (setq count (- count ?0 skipped)))
 
     (run-hooks 'ispell-update-post-hook)
 
@@ -2380,13 +2324,12 @@ ispell-command-loop
 					 (window-width))
 				  (insert "\n"))
 				(while (memq count command-characters)
-				  (setq count (ispell-int-char (1+ count))
+				  (setq count (1+ count)
 					skipped (1+ skipped)))
 				(insert "(" count ") " (car choices) "  ")
 				(setq choices (cdr choices)
-				      count (ispell-int-char (1+ count))))
-			      (setq count (ispell-int-char
-					   (- count ?0 skipped))))
+				      count (1+ count)))
+			      (setq count (- count ?0 skipped)))
 			    (setq textwin (selected-window))
 			    (ispell-show-choices)
 			    (select-window textwin))))
-- 
2.7.4

From a9032afb7b17f9f6499f91ec098434bcbcd077c7 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:02:48 +0000
Subject: [PATCH 08/15] Assume Emacs supports [:alpha:] in regexps

* lisp/textmodes/ispell.el (ispell-emacs-alpha-regexp): Remove.
(ispell-set-spellchecker-params): Remove tests of
ispell-emacs-alpha-regexp.
---
 lisp/textmodes/ispell.el | 55 +++++++++++++++++++-----------------------------
 1 file changed, 22 insertions(+), 33 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 0bf6c75..2e59414 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -666,12 +666,6 @@ ispell-dicts-name2locale-equivs-alist
   "Alist with known matching locales for standard dict names in
   `ispell-dictionary-base-alist'.")
 
-(defvar ispell-emacs-alpha-regexp
-  (if (string-match "^[[:alpha:]]+$" "abcde")
-      "[[:alpha:]]"
-    nil)
-  "[[:alpha:]] if Emacs supports [:alpha:] regexp, nil
-otherwise (current XEmacs does not support it).")
 
 ;;; **********************************************************************
 ;;; The following are used by ispell, and should not be changed.
@@ -1244,11 +1238,9 @@ ispell-set-spellchecker-params
 		   (setq ispell-library-directory (ispell-check-version))
 		   t)
 	       (error nil))
-	     ispell-encoding8-command
-	     ispell-emacs-alpha-regexp)
+	     ispell-encoding8-command)
 	;; auto-detection will only be used if spellchecker is not
-	;; ispell, supports a way  to set communication to UTF-8 and
-	;; Emacs flavor supports [:alpha:]
+	;; ispell and supports a way to set communication to UTF-8.
 	(if ispell-really-aspell
 	    (or ispell-aspell-dictionary-alist
 		(ispell-find-aspell-dictionaries))
@@ -1262,9 +1254,8 @@ ispell-set-spellchecker-params
     ;; installed dictionaries and add to it elements of the original
     ;; list that are not present there. Allow distro info.
     (let ((found-dicts-alist
-	   (if (and ispell-encoding8-command
-		    ispell-emacs-alpha-regexp)
-	       (if ispell-really-aspell
+	   (if ispell-encoding8-command
+               (if ispell-really-aspell
 		   ispell-aspell-dictionary-alist
 		 (if ispell-really-hunspell
 		     ispell-hunspell-dictionary-alist))
@@ -1331,28 +1322,26 @@ ispell-set-spellchecker-params
 	  (push dict all-dicts-alist)))
       (setq ispell-dictionary-alist all-dicts-alist))
 
-    ;; If Emacs flavor supports [:alpha:] use it for global dicts.  If
-    ;; spellchecker also supports UTF-8 via command-line option use it
+    ;; If spellchecker supports UTF-8 via command-line option, use it
     ;; in communication.  This does not affect definitions in your
     ;; init file.
-    (if ispell-emacs-alpha-regexp
-     	(let (tmp-dicts-alist)
-    	  (dolist (adict ispell-dictionary-alist)
-	    (cl-pushnew (if (cadr adict) ;; Do not touch hunspell uninitialized entries
-                            (list
-                             (nth 0 adict)   ; dict name
-                             "[[:alpha:]]"   ; casechars
-                             "[^[:alpha:]]"  ; not-casechars
-                             (nth 3 adict)   ; otherchars
-                             (nth 4 adict)   ; many-otherchars-p
-                             (nth 5 adict)   ; ispell-args
-                             (nth 6 adict)   ; extended-character-mode
-                             (if ispell-encoding8-command
-                                 'utf-8
-                               (nth 7 adict)))
-                          adict)
-                        tmp-dicts-alist :test #'equal))
-	  (setq ispell-dictionary-alist tmp-dicts-alist)))))
+    (let (tmp-dicts-alist)
+      (dolist (adict ispell-dictionary-alist)
+        (cl-pushnew (if (cadr adict) ;; Do not touch hunspell uninitialized entries
+                        (list
+                         (nth 0 adict)   ; dict name
+                         "[[:alpha:]]"   ; casechars
+                         "[^[:alpha:]]"  ; not-casechars
+                         (nth 3 adict)   ; otherchars
+                         (nth 4 adict)   ; many-otherchars-p
+                         (nth 5 adict)   ; ispell-args
+                         (nth 6 adict)   ; extended-character-mode
+                         (if ispell-encoding8-command
+                             'utf-8
+                           (nth 7 adict)))
+                      adict)
+                    tmp-dicts-alist :test #'equal))
+      (setq ispell-dictionary-alist tmp-dicts-alist))))
 
 (defun ispell-valid-dictionary-list ()
   "Return a list of valid dictionaries.
-- 
2.7.4

From 01f7558b203c4aad9e566d0be871129b422a244e Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:05:07 +0000
Subject: [PATCH 09/15] Remove XEmacs and old Emacs highlighting code

* lisp/textmodes/ispell.el
(ispell-highlight-spelling-error-xemacs): Remove.
(ispell-highlight-spelling-error): Assume display-color-p exists.
---
 lisp/textmodes/ispell.el | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 2e59414..84b7141 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2631,17 +2631,6 @@ ispell-highlight-spelling-error-generic
 	  (if (eq 'block refresh) start (- start 2)) end t))))

-(defun ispell-highlight-spelling-error-xemacs (start end &optional highlight)
-  "Highlight the word from START to END using `isearch-highlight'.
-When the optional third arg HIGHLIGHT is set, the word is highlighted,
-otherwise it is displayed normally."
-  (if highlight
-      (isearch-highlight start end)
-    (isearch-dehighlight))
-  ;;(sit-for 0)
-  )
-
-
 (defun ispell-highlight-spelling-error-overlay (start end &optional highlight)
   "Highlight the word from START to END using overlays.
 When the optional third arg HIGHLIGHT is set, the word is highlighted
@@ -2677,14 +2666,9 @@ ispell-highlight-spelling-error-overlay

 (defun ispell-highlight-spelling-error (start end &optional highlight refresh)
-  (cond
-   ((featurep 'xemacs)
-    (ispell-highlight-spelling-error-xemacs start end highlight))
-   ((and (featurep 'faces)
-	 (or (and (fboundp 'display-color-p) (display-color-p))
-	     window-system))
-    (ispell-highlight-spelling-error-overlay start end highlight))
-   (t (ispell-highlight-spelling-error-generic start end highlight refresh))))
+  (if (display-color-p)
+      (ispell-highlight-spelling-error-overlay start end highlight)
+    (ispell-highlight-spelling-error-generic start end highlight refresh)))
 
 (defun ispell-display-buffer (buffer)
   "Show BUFFER in new window above selected one.
-- 
2.7.4

From d90f4bdfb5ab6a822ac828bcf5d7c4bc84e61e1b Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:15:50 +0000
Subject: [PATCH 10/15] Remove some commented-out code

lisp/textmodes/ispell.el (ispell-process)
ispell-valid-dictionary-list): Remove commented-out code.
---
 lisp/textmodes/ispell.el | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 84b7141..64ca428 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -860,11 +860,7 @@ ispell-process
 
 (defvar ispell-async-processp (and (fboundp 'delete-process)
 				   (fboundp 'process-send-string)
-				   (fboundp 'accept-process-output)
-				   ;;(fboundp 'make-process)
-				   ;;(fboundp 'set-process-filter)
-				   ;;(fboundp 'process-kill-without-query)
-				   )
+				   (fboundp 'accept-process-output))
   "Non-nil means that the OS supports asynchronous processes.")
 
 ;; Make ispell.el work better with aspell.
@@ -1452,7 +1448,6 @@ ispell-valid-dictionary-list
       (define-key ispell-menu-map [ispell-buffer]
 	`(menu-item ,(purecopy "Spell-Check Buffer") ispell-buffer
 		    :help ,(purecopy "Check spelling of selected buffer")))
-      ;;(put 'ispell-region 'menu-enable 'mark-active)
       (fset 'ispell-menu-map (symbol-value 'ispell-menu-map))))

-- 
2.7.4

From 6ff7dd700036d8ab5b70bc596338d25b5b18bfe8 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:19:26 +0000
Subject: [PATCH 11/15] Remove XEmacs-specific code from ispell.el

* lisp/textmodes/ispell.el (ispell-menu-xemacs): Remove
(ispell-menu-map-needed): Remove XEmacs-specific check.
(ispell-word): Remove XEmacs-specific extent code.
(ispell-init-process): Remove XEmacs workaround for local add-hook.
Assume we have set-process-query-on-exit-flag.
(ispell-kill-ispell, ispell-change-dictionary): Remove XEmacs
workaround for called-interactively-p.
---
 lisp/textmodes/ispell.el | 55 +++++++++---------------------------------------
 1 file changed, 10 insertions(+), 45 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 64ca428..8b0c922 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -833,22 +833,10 @@ ispell-menu-map
 ;; Redo menu when loading ispell to get dictionary modifications
 (setq ispell-menu-map nil)
 
-;;;###autoload
-(defvar ispell-menu-xemacs nil
-  "Spelling menu for XEmacs.
-If nil when package is loaded, a standard menu will be set,
-and added as a submenu of the \"Edit\" menu.")
-
-;; Break out XEmacs menu and split into several calls to avoid having
-;; long lines in loaddefs.el.  Detect need off following constant.
-
 ;;; Set up dictionary
 ;;;###autoload
 (defvar ispell-menu-map-needed
-  ;; only needed when not version 18 and not XEmacs.
-  (and (not ispell-menu-map)
-       (not (featurep 'xemacs))
-       'reload))
+  (unless (ispell-menu-map) 'reload))
 
 (defvar ispell-library-directory (condition-case ()
 				     (ispell-check-version)
@@ -1932,32 +1920,20 @@ ispell-word
       (cond ((eq poss t)
 	     (or quietly
 		 (message "%s is correct"
-			  (funcall ispell-format-word-function word)))
-	     (and (featurep 'xemacs)
-		  (extent-at start)
-		  (and (fboundp 'delete-extent)
-		       (delete-extent (extent-at start)))))
+			  (funcall ispell-format-word-function word))))
 	    ((stringp poss)
 	     (or quietly
 		 (message "%s is correct because of root %s"
 			  (funcall ispell-format-word-function word)
-			  (funcall ispell-format-word-function poss)))
-	     (and (featurep 'xemacs)
-		  (extent-at start)
-		  (and (fboundp 'delete-extent)
-		       (delete-extent (extent-at start)))))
+			  (funcall ispell-format-word-function poss))))
 	    ((null poss)
 	     (message "Error checking word %s using %s with %s dictionary"
 		      (funcall ispell-format-word-function word)
 		      (file-name-nondirectory ispell-program-name)
 		      (or ispell-current-dictionary "default")))
 	    (ispell-check-only	      ; called from ispell minor mode.
-	     (if (fboundp 'make-extent)
-		 (if (fboundp 'set-extent-property)
-		     (let ((ext (make-extent start end)))
-		       (set-extent-property ext 'face ispell-highlight-face)
-		       (set-extent-property ext 'priority 2000)))
-	       (beep)
+	     (progn
+               (beep)
 	       (message "%s is incorrect"
                         (funcall ispell-format-word-function word))))
 	    (t				; prompt for correct word.
@@ -2888,10 +2864,7 @@ ispell-init-process
 		;; to avoid over and over ispell kill.
 		(window-buffer (minibuffer-selected-window))
 	      (current-buffer))
-	  ;; 'local does not automatically make hook buffer-local in XEmacs.
-	  (if (featurep 'xemacs)
-	      (make-local-hook 'kill-buffer-hook))
-	  (add-hook 'kill-buffer-hook
+          (add-hook 'kill-buffer-hook
 		    (lambda () (ispell-kill-ispell t)) nil 'local)))
 
       (if ispell-async-processp
@@ -2936,12 +2909,8 @@ ispell-init-process
       (let ((extended-char-mode (ispell-get-extended-character-mode)))
 	(if extended-char-mode		; ~ extended character mode
 	    (ispell-send-string (concat extended-char-mode "\n"))))
-      (if ispell-async-processp
-	  (if (featurep 'emacs)
-	      (set-process-query-on-exit-flag ispell-process nil)
-	    (if (fboundp 'set-process-query-on-exit-flag)
-		(set-process-query-on-exit-flag ispell-process nil)
-	      (process-kill-without-query ispell-process)))))))
+      (when ispell-async-processp
+        (set-process-query-on-exit-flag ispell-process nil)))))
 
 ;;;###autoload
 (defun ispell-kill-ispell (&optional no-error clear)
@@ -2953,9 +2922,7 @@ ispell-kill-ispell
   ;; to optimize the common cases.
   (run-hooks 'ispell-kill-ispell-hook)
   (if (or clear
-	  (if (featurep 'xemacs)
-	      (interactive-p)
-	    (called-interactively-p 'interactive)))
+	  (called-interactively-p 'interactive))
       (setq ispell-buffer-session-localwords nil))
   (if (not (and ispell-process
 		(eq (ispell-process-status) 'run)))
@@ -3004,9 +2971,7 @@ ispell-change-dictionary
 	 ;; Specified dictionary is the default already. Could reload
 	 ;; the dictionaries if needed.
 	 (ispell-internal-change-dictionary)
-	 (and (if (featurep 'xemacs)
-		  (interactive-p)
-		(called-interactively-p 'interactive))
+	 (when (called-interactively-p 'interactive)
 	      (message "No change, using %s dictionary" dict)))
 	(t				; reset dictionary!
 	 (if (or (assoc dict ispell-local-dictionary-alist)
-- 
2.7.4

From 904e47a07c45296fa435b260e4d265e92262a0e8 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:35:42 +0000
Subject: [PATCH 12/15] Remove XEmacs-specific code dealing with
 enable-multibyte-characters

* lisp/textmodes/ispell.el (ispell-decode-string):
(ispell-init-process):  Remove XEmacs-specific guard.
---
 lisp/textmodes/ispell.el | 19 +++----------------
 1 file changed, 3 insertions(+), 16 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 8b0c922..8b5ae9e 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1451,17 +1451,8 @@ ispell-current-personal-dictionary
 This is passed to the Ispell process using the `-p' switch.")
 
 (defun ispell-decode-string (str)
-  "Decodes multibyte character strings.
-Protects against bogus binding of `enable-multibyte-characters' in XEmacs."
-  ;; FIXME: enable-multibyte-characters is read-only, so bogus bindings are
-  ;; really nasty (they signal an error in Emacs): Who does that?  --Stef
-  (if (and (or (featurep 'xemacs)
-	       (and (boundp 'enable-multibyte-characters)
-		    enable-multibyte-characters))
-	   (fboundp 'decode-coding-string)
-	   (ispell-get-coding-system))
-      (decode-coding-string str (ispell-get-coding-system))
-    str))
+  "Decodes multibyte character strings."
+  (decode-coding-string str (ispell-get-coding-system)))
 
 ;; Return a string decoded from Nth element of the current dictionary.
 (defun ispell-get-decoded-string (n)
@@ -2869,11 +2860,7 @@ ispell-init-process
 
       (if ispell-async-processp
 	  (set-process-filter ispell-process 'ispell-filter))
-      ;; Protect against XEmacs bogus binding of `enable-multibyte-characters'.
-      (if (and (or (featurep 'xemacs)
-		   (and (boundp 'enable-multibyte-characters)
-			enable-multibyte-characters))
-	       (fboundp 'set-process-coding-system)
+      (if (and enable-multibyte-characters
                ;; Evidently, some people use the synchronous mode even
                ;; when async subprocesses are supported, in which case
                ;; set-process-coding-system is bound, but
-- 
2.7.4

From 1a98d3b69819c479a80f3979235231c37a7a3c8c Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:37:37 +0000
Subject: [PATCH 13/15] Remove XEmacs-specific horizontal scrollbar handling in
 ispell.el

* lisp/textmodes/ispell.el (ispell-command-loop): Remove
XEmacs-specific code.
---
 lisp/textmodes/ispell.el | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 8b5ae9e..4b2a79c 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2094,15 +2094,9 @@ ispell-command-loop
              "--  %b  --  word: " word
              "  --  dict: " (or ispell-current-dictionary "default")
              "  --  prog: " (file-name-nondirectory ispell-program-name)))
-      ;; XEmacs: no need for horizontal scrollbar in choices window
+      ;; No need for horizontal scrollbar in choices window
       (ispell-with-no-warnings
-       (and (fboundp 'set-specifier)
-	    (boundp 'horizontal-scrollbar-visible-p)
-	    (set-specifier horizontal-scrollbar-visible-p nil
-			   (cons (current-buffer) nil))))
-      (ispell-with-no-warnings
-       (and (boundp 'horizontal-scroll-bar)
-	    (setq horizontal-scroll-bar nil)))
+       (setq horizontal-scroll-bar nil))
       (erase-buffer)
       (if guess
 	  (progn
-- 
2.7.4

From d087d57bb7306729411abe4b67c0d014aec7716d Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:38:51 +0000
Subject: [PATCH 14/15] Remove XEmacs-specific minibuffer handling code from
 ispell.el

* lisp/textmodes/ispell.el (ispell-init-process): Assume we are not in
XEmacs.
---
 lisp/textmodes/ispell.el | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index 4b2a79c..f9d2424 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -2792,7 +2792,7 @@ ispell-init-process
 	 (current-ispell-directory default-directory) ;FIXME: Unused?
 	 ;; The default directory for the process.
 	 ;; Use "~/" as default-directory unless using Ispell with per-dir
-	 ;; personal dictionaries and not in a minibuffer under XEmacs
+	 ;; personal dictionaries
 	 (default-directory
 	   (if (or ispell-really-aspell
 		   ispell-really-hunspell
@@ -2805,9 +2805,8 @@ ispell-init-process
 						     ".ispell_"
 						     (or dict-bname
 							 "default")))))
-		   ;; Ispell, in a minibuffer, and XEmacs
-		   (and (window-minibuffer-p)
-			(not (fboundp 'minibuffer-selected-window))))
+		   ;; Ispell, in a minibuffer
+		   (window-minibuffer-p))
 	       (expand-file-name "~/")
 	     (expand-file-name default-directory))))
     ;; Check if process needs restart
@@ -2839,12 +2838,11 @@ ispell-init-process
 
       (unless (equal ispell-process-directory (expand-file-name "~/"))
 	;; At this point, `ispell-process-directory' will be "~/" unless using
-	;; Ispell with directory-specific dicts and not in XEmacs minibuffer.
+	;; Ispell with directory-specific dicts.
 	;; If not, kill ispell process when killing buffer.  It may be in a
 	;; removable device that would otherwise become un-mountable.
 	(with-current-buffer
-	    (if (and (window-minibuffer-p)                  ;; In minibuffer
-		     (fboundp 'minibuffer-selected-window)) ;; Not XEmacs.
+	    (if (window-minibuffer-p)                  ;; In minibuffer
 		;; In this case kill ispell only when parent buffer is killed
 		;; to avoid over and over ispell kill.
 		(window-buffer (minibuffer-selected-window))
-- 
2.7.4

From 275fb8a2f7eb3a3850df7341a965bb9d523d300f Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Sun, 4 Dec 2016 14:39:42 +0000
Subject: [PATCH 15/15] Remove remaining mentions of XEmacs from ispell.el

* lisp/textmodes/ispell.el (ispell-valid-dictionary-list):
(ispell-add-per-file-word-list): Remove mentions of XEmacs from
comments.
---
 lisp/textmodes/ispell.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el
index f9d2424..a10f04b 100644
--- a/lisp/textmodes/ispell.el
+++ b/lisp/textmodes/ispell.el
@@ -1331,8 +1331,7 @@ ispell-valid-dictionary-list
   "Return a list of valid dictionaries.
 The variable `ispell-library-directory' defines their location."
   ;; Initialize variables and dictionaries alists for desired spellchecker.
-  ;; Make sure ispell.el is loaded to avoid some autoload loops in XEmacs
-  ;; (and may be others)
+  ;; Make sure ispell.el is loaded to avoid some autoload loops.
   (if (featurep 'ispell)
       (ispell-set-spellchecker-params))
 
@@ -4187,6 +4186,6 @@ ispell-add-per-file-word-list
 ; LocalWords:  minipage pers dict unhighlight buf grep sync prev inc
 ; LocalWords:  fn oldot NB AIX msg init read's bufs pt cmd Quinlan eg
 ; LocalWords:  uuencoded unidiff sc nn VM SGML eval IspellPersDict
-; LocalWords:  lns XEmacs HTML casechars Multibyte
+; LocalWords:  lns HTML casechars Multibyte
 
 ;;; ispell.el ends here
-- 
2.7.4