Merge from emacs-23
[bpt/emacs.git] / lisp / emulation / tpu-edt.el
index 686a79c..f77cf23 100644 (file)
@@ -1,7 +1,7 @@
 ;;; tpu-edt.el --- Emacs emulating TPU emulating EDT
 
-;; Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004,
-;;   2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 2000, 2001, 2002, 2003, 2004, 2005,
+;;   2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 ;; Author: Rob Riepel <riepel@networking.stanford.edu>
 ;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,9 +21,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;; TPU-edt is based on tpu.el by Jeff Kowalski and Bob Covey.
 
 ;;;  User Configurable Variables
 ;;;
 (defcustom tpu-have-ispell t
-  "If non-nil (default), TPU-edt uses Ispell for spell checking."
+  "Non-nil means `tpu-spell-check' uses `ispell-region' for spell checking.
+Otherwise, use `spell-region'."
   :type 'boolean
   :group 'tpu)
+(make-obsolete-variable 'tpu-have-ispell "the `spell' package is obsolete."
+                        "23.1")
 
 (defcustom tpu-kill-buffers-silently nil
   "If non-nil, TPU-edt kills modified buffers without asking."
@@ -734,10 +735,6 @@ Otherwise sets the tpu-match markers to nil and returns nil."
 ;;;
 ;;;  Utilities
 ;;;
-(defun tpu-caar (thingy) (car (car thingy)))
-(defun tpu-cadr (thingy) (car (cdr thingy)))
-
-(defvar zmacs-regions)
 
 (defun tpu-mark nil
   "TPU-edt version of the mark function.
@@ -751,9 +748,7 @@ version of Emacs."
 Sets the mark at POS and activates the region according to the
 current version of Emacs."
   (set-mark pos)
-  ;; We use a separate `if' for the fboundp so the byte-compiler notices it
-  ;; and doesn't complain about the subsequent call.
-  (if (fboundp 'zmacs-activate-region) (if pos (zmacs-activate-region))))
+  (when (featurep 'xemacs) (when pos (zmacs-activate-region))))
 
 (defun tpu-string-prompt (prompt history-symbol)
   "Read a string with PROMPT."
@@ -817,7 +812,7 @@ Top line is 0.  Counts each text line only once, even if it wraps."
   (interactive "p")
   (cond ((get tpu-breadcrumb-plist num)
         (switch-to-buffer (car (get tpu-breadcrumb-plist num)))
-        (goto-char (tpu-cadr (get tpu-breadcrumb-plist num)))
+        (goto-char (cadr (get tpu-breadcrumb-plist num)))
         (message "mark %d found." num))
        (t
         (message "mark %d not found." num))))
@@ -889,7 +884,7 @@ With argument, fill and justify."
          (setq tpu-newline-and-indent-p t)
          (tpu-local-set-key "\C-m" 'newline-and-indent)))
   (tpu-update-mode-line)
-  (and (interactive-p)
+  (and (called-interactively-p 'interactive)
        (message "Carriage return inserts a newline%s"
                (if tpu-newline-and-indent-p " and indents." "."))))
 
@@ -897,11 +892,14 @@ With argument, fill and justify."
   "Check the spelling of the region, or of the entire buffer,
 if no region is selected."
   (interactive)
-  (cond (tpu-have-ispell
-        (if (tpu-mark) (ispell-region (tpu-mark) (point)) (ispell-buffer)))
-       (t
-        (if (tpu-mark) (spell-region (tpu-mark) (point)) (spell-buffer))))
-  (if (tpu-mark) (tpu-unselect t)))
+  (let ((m (tpu-mark)))
+    (apply (if tpu-have-ispell 'ispell-region
+             'spell-region)
+           (if m
+               (if (> m (point)) (list (point) m)
+                 (list m (point)))
+             (list (point-min) (point-max))))
+    (if m (tpu-unselect t))))
 
 (defun tpu-toggle-overwrite-mode nil
   "Switch in and out of overwrite mode."
@@ -918,7 +916,7 @@ if no region is selected."
   "Insert a character or control code according to its ASCII decimal value."
   (interactive "P")
   (if overwrite-mode (delete-char 1))
-  (insert (if num num 0)))
+  (insert (or num 0)))
 
 (defun tpu-quoted-insert (num)
   "Read next input character and insert it.
@@ -1248,8 +1246,9 @@ and the total number of lines in the buffer."
 ;;;  Buffers and Windows
 ;;;
 (defun tpu-kill-buffer nil
-  "Kill the current buffer.  If tpu-kill-buffers-silently is non-nil,
-kills modified buffers without asking."
+  "Kill the current buffer.
+If `tpu-kill-buffers-silently' is non-nil,
+kill modified buffers without asking."
   (interactive)
   (if tpu-kill-buffers-silently (set-buffer-modified-p nil))
   (kill-buffer (current-buffer)))
@@ -1306,7 +1305,7 @@ kills modified buffers without asking."
   (interactive)
   (setq tpu-regexp-p (not tpu-regexp-p))
   (tpu-set-search)
-  (and (interactive-p)
+  (and (called-interactively-p 'interactive)
        (message "Regular expression search and substitute %sabled."
                (if tpu-regexp-p "en" "dis"))))
 
@@ -1451,7 +1450,7 @@ Used for reversing a search in progress."
   (interactive)
   (setq tpu-searching-forward (not tpu-searching-forward))
   (tpu-set-search t)
-  (and (interactive-p)
+  (and (called-interactively-p 'interactive)
        (message "Searching %sward."
                (if tpu-searching-forward "for" "back"))))
 
@@ -1502,7 +1501,7 @@ Used for reversing a search in progress."
   (setq tpu-rectangular-p (not tpu-rectangular-p))
   (setq tpu-rectangle-string (if tpu-rectangular-p " Rect" ""))
   (tpu-update-mode-line)
-  (and (interactive-p)
+  (and (called-interactively-p 'interactive)
        (message "Rectangular cut and paste %sabled."
                (if tpu-rectangular-p "en" "dis"))))
 
@@ -2274,7 +2273,7 @@ Accepts a prefix argument for the number of tpu-pan-columns to scroll."
   "Toggle control key bindings between TPU-edt and Emacs."
   (interactive)
   (tpu-reset-control-keys (not tpu-control-keys))
-  (and (interactive-p)
+  (and (called-interactively-p 'interactive)
        (message "Control keys function with %s bindings."
                (if tpu-control-keys "TPU-edt" "Emacs"))))
 
@@ -2375,7 +2374,7 @@ If FILE is nil, try to load a default file.  The default file names are
     (and (tpu-y-or-n-p "Copy key definitions to the new file now? ")
         (condition-case conditions
              (copy-file oldname newname)
-          (tpu-error (message "Sorry, couldn't copy - %s." (cdr conditions)))))
+          (error (message "Sorry, couldn't copy - %s." (cdr conditions)))))
     (kill-buffer "*TPU-Notice*")))
 
 (defvar tpu-edt-old-global-values nil)
@@ -2439,7 +2438,7 @@ If FILE is nil, try to load a default file.  The default file names are
 
 \f
 ;;;### (autoloads (tpu-set-cursor-bound tpu-set-cursor-free tpu-set-scroll-margins
-;;;;;;  tpu-cursor-free-mode) "tpu-extras" "tpu-extras.el" "e0629234f1abe076917a303456b48329")
+;;;;;;  tpu-cursor-free-mode) "tpu-extras" "tpu-extras.el" "fe5b7795d6b6720a98b805ee47a08bdf")
 ;;; Generated autoloads from tpu-extras.el
 
 (autoload 'tpu-cursor-free-mode "tpu-extras" "\