From 85c8c5b6533138643a7fafe819a12a2630c98752 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Agust=C3=ADn=20Mart=C3=ADn?= Date: Mon, 28 May 2012 18:11:15 +0200 Subject: [PATCH] textmodex/{ispell,flyspell}.el: Decrease XEmacs incompatibilities. * flyspell.el: (flyspell-check-pre-word-p): Use `string-match'. (flyspell-delete-region-overlays): Use alternative definition for XEmacs. (flyspell-delete-all-overlays): Use `flyspell-delete-region-overlays'. (flyspell-word): Use `process-kill-without-query' if XEmacs. (flyspell-mode-on): Use `interactive-p' if XEmacs. (flyspell-incorrect-face, flyspell-duplicate-face): Do not use `define-obsolete-face-alias' under XEmacs, but old method. * ispell.el: (ispell-with-no-warnings): XEmacs alternative `with-no-warnings' definition or Emacs alias. (ispell-command-loop, ispell-message): Use `ispell-with-no-warnings'. (ispell-word): Do not use `region-p' if XEmacs. --- lisp/ChangeLog | 18 ++++++++++++++++++ lisp/textmodes/flyspell.el | 33 ++++++++++++++++++++++++--------- lisp/textmodes/ispell.el | 28 ++++++++++++++++++++++------ 3 files changed, 64 insertions(+), 15 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c95ffe0eb93..68e8b764ec4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,21 @@ +2012-05-28 Agustín Martín Domingo + + Decrease XEmacs incompatibilities. + * textmodes/flyspell.el (flyspell-check-pre-word-p): + Use `string-match'. + (flyspell-delete-region-overlays): Use alternative definition for + XEmacs. + (flyspell-delete-all-overlays): Use `flyspell-delete-region-overlays'. + (flyspell-word): Use `process-kill-without-query' if XEmacs. + (flyspell-mode-on): Use `interactive-p' if XEmacs. + (flyspell-incorrect-face, flyspell-duplicate-face): Do not use + `define-obsolete-face-alias' under XEmacs, but old method. + + * textmodes/ispell.el (ispell-with-no-warnings): XEmacs alternative + `with-no-warnings' definition or Emacs alias. + (ispell-command-loop, ispell-message): Use `ispell-with-no-warnings'. + (ispell-word): Do not use `region-p' if XEmacs. + 2012-05-28 Agustín Martín Domingo * textmodes/ispell.el (ispell-find-aspell-dictionaries): diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index c0b0a837a9d..26d39f33163 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el @@ -450,7 +450,9 @@ like \"Some." (t (:bold t))) "Face used for marking a misspelled word in Flyspell." :group 'flyspell) -(define-obsolete-face-alias 'flyspell-incorrect-face 'flyspell-incorrect "22.1") +(if (featurep 'emacs) + (define-obsolete-face-alias 'flyspell-incorrect-face 'flyspell-incorrect "22.1") + (put 'flyspell-incorrect-face 'face-alias 'flyspell-incorrect)) (defface flyspell-duplicate '((((class color)) (:foreground "Gold3" :bold t :underline t)) @@ -458,7 +460,9 @@ like \"Some." "Face used for marking a misspelled word that appears twice in the buffer. See also `flyspell-duplicate-distance'." :group 'flyspell) -(define-obsolete-face-alias 'flyspell-duplicate-face 'flyspell-duplicate "22.1") +(if (featurep 'emacs) + (define-obsolete-face-alias 'flyspell-duplicate-face 'flyspell-duplicate "22.1") + (put 'flyspell-duplicate-face 'face-alias 'flyspell-duplicate)) (defvar flyspell-overlay nil) @@ -615,7 +619,9 @@ in your .emacs file. ;; the welcome message (if (and flyspell-issue-message-flag flyspell-issue-welcome-flag - (called-interactively-p 'interactive)) + (if (featurep 'xemacs) + (interactive-p) ;; XEmacs does not have (called-interactively-p) + (called-interactively-p 'interactive))) (let ((binding (where-is-internal 'flyspell-auto-correct-word nil 'non-ascii))) (message "%s" @@ -739,7 +745,7 @@ before the current command." ((or (and (= flyspell-pre-point (- (point) 1)) (or (eq (char-syntax (char-after flyspell-pre-point)) ?w) (and (not (string= "" ispell-otherchars)) - (string-match-p + (string-match ispell-otherchars (buffer-substring-no-properties flyspell-pre-point (1+ flyspell-pre-point)))))) @@ -758,7 +764,7 @@ before the current command." (null (char-after flyspell-pre-point)) (or (eq (char-syntax (char-after flyspell-pre-point)) ?w) (and (not (string= "" ispell-otherchars)) - (string-match-p + (string-match ispell-otherchars (buffer-substring-no-properties flyspell-pre-point (1+ flyspell-pre-point))))))) @@ -1112,7 +1118,9 @@ misspelling and skips redundant spell-checking step." (ispell-send-string (concat "^" word "\n")) ;; we mark the ispell process so it can be killed ;; when emacs is exited without query - (set-process-query-on-exit-flag ispell-process nil) + (if (featurep 'xemacs) + (process-kill-without-query ispell-process) + (set-process-query-on-exit-flag ispell-process nil)) ;; Wait until ispell has processed word. (while (progn (accept-process-output ispell-process) @@ -1646,12 +1654,19 @@ FLYSPELL-BUFFER." ;;*---------------------------------------------------------------------*/ (defun flyspell-delete-region-overlays (beg end) "Delete overlays used by flyspell in a given region." - (remove-overlays beg end 'flyspell-overlay t)) - + (if (featurep 'emacs) + (remove-overlays beg end 'flyspell-overlay t) + ;; XEmacs does not have `remove-overlays' + (let ((l (overlays-in beg end))) + (while (consp l) + (progn + (if (flyspell-overlay-p (car l)) + (delete-overlay (car l))) + (setq l (cdr l))))))) (defun flyspell-delete-all-overlays () "Delete all the overlays used by flyspell." - (remove-overlays (point-min) (point-max) 'flyspell-overlay t)) + (flyspell-delete-region-overlays (point-min) (point-max))) ;;*---------------------------------------------------------------------*/ ;;* flyspell-unhighlight-at ... */ diff --git a/lisp/textmodes/ispell.el b/lisp/textmodes/ispell.el index 1dd2c9488ba..1d45a7059c1 100644 --- a/lisp/textmodes/ispell.el +++ b/lisp/textmodes/ispell.el @@ -203,6 +203,7 @@ (declare-function ispell-check-minver "ispell" (v1 v2)) (declare-function ispell-looking-back "ispell" (regexp &optional limit &rest ignored)) +(declare-function ispell-with-no-warnings (&rest body)) (if (fboundp 'version<=) (defalias 'ispell-check-minver 'version<=) @@ -254,6 +255,16 @@ full featured `looking-back' function is missing." (save-excursion (re-search-backward (concat "\\(?:" regexp "\\)\\=") limit t)))) +;;; XEmacs21 does not have `with-no-warnings' + +(if (fboundp 'with-no-warnings) + (defalias 'ispell-with-no-warnings 'with-no-warnings) + (defun ispell-with-no-warnings (&rest body) + "Like `progn', but prevents compiler warnings in the body." + ;; Taken from Emacs' byte-run.el + ;; The implementation for the interpreter is basically trivial. + (car (last body)))) + ;;; Code: (defvar mail-yank-prefix) @@ -1703,7 +1714,12 @@ nil word is correct or spelling is accepted. quit spell session exited." (interactive (list ispell-following-word ispell-quietly current-prefix-arg t)) (cond - ((and region (use-region-p)) + ((and region + (if (featurep 'emacs) + (use-region-p) + (and (boundp 'transient-mark-mode) transient-mark-mode + (boundp 'mark-active) mark-active + (not (eq (region-beginning) (region-end)))))) (ispell-region (region-beginning) (region-end))) (continue (ispell-continue)) (t @@ -1929,7 +1945,7 @@ Global `ispell-quit' set to start location to continue spell session." " -- dict: " (or ispell-current-dictionary "default") " -- prog: " (file-name-nondirectory ispell-program-name))) ;; XEmacs: no need for horizontal scrollbar in choices window - (with-no-warnings + (ispell-with-no-warnings (and (fboundp 'set-specifier) (boundp 'horizontal-scrollbar-visible-p) (set-specifier horizontal-scrollbar-visible-p nil @@ -3708,23 +3724,23 @@ You can bind this to the key C-c i in GNUS or mail by adding to (cite-regexp ;Prefix of quoted text (cond ((functionp 'sc-cite-regexp) ; sc 3.0 - (with-no-warnings + (ispell-with-no-warnings (concat "\\(" (sc-cite-regexp) "\\)" "\\|" (ispell-non-empty-string sc-reference-tag-string)))) ((boundp 'sc-cite-regexp) ; sc 2.3 (concat "\\(" sc-cite-regexp "\\)" "\\|" - (with-no-warnings + (ispell-with-no-warnings (ispell-non-empty-string sc-reference-tag-string)))) ((or (equal major-mode 'news-reply-mode) ;GNUS 4 & below (equal major-mode 'message-mode)) ;GNUS 5 (concat "In article <" "\\|" "[^,;&+=\n]+ <[^,;&+=]+> writes:" "\\|" - (with-no-warnings message-cite-prefix-regexp) + (ispell-with-no-warnings message-cite-prefix-regexp) "\\|" default-prefix)) ((equal major-mode 'mh-letter-mode) ; mh mail message (concat "[^,;&+=\n]+ writes:" "\\|" - (with-no-warnings + (ispell-with-no-warnings (ispell-non-empty-string mh-ins-buf-prefix)))) ((not internal-messagep) ; Assume nn sent us this message. (concat "In [a-zA-Z.]+ you write:" "\\|" -- 2.39.2