(define-minor-mode): A nil argument to the minor mode turns the mode ON.
[bpt/emacs.git] / lisp / tutorial.el
index df71ea9..de7f7ab 100644 (file)
@@ -1,16 +1,16 @@
 ;;; tutorial.el --- tutorial for Emacs
 
-;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help, internal
 
 ;; 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
@@ -18,9 +18,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/>.
 
 ;;; Commentary:
 
@@ -76,7 +74,7 @@ Where
               for the function it is remapped to)"
   (with-output-to-temp-buffer (help-buffer)
     (help-setup-xref (list #'tutorial--describe-nonstandard-key value)
-                     (interactive-p))
+                     (called-interactively-p 'interactive))
     (with-current-buffer (help-buffer)
       (insert
        "Your Emacs customizations override the default binding for this key:"
@@ -140,9 +138,11 @@ options:
                     " is the command `")
             (insert (format "%s" db))
             (insert "'.  "
-                    "However, your customizations have rebound it to the command `")
-            (insert (format "%s" cb))
-            (insert "'.")
+                    "However, your customizations have "
+                    (if cb
+                        (format "rebound it to the command `%s'" cb)
+                      "unbound it"))
+            (insert ".")
             (when mapsym
               (insert "  (For the more advanced user:"
                       " This binding is in the keymap `"
@@ -163,7 +163,7 @@ options:
                       (format "%s" db)
                       "'.")))
           (fill-region (point-min) (point)))))
-      (print-help-return-message))))
+      (help-print-return-message))))
 
 (defun tutorial--sort-keys (left right)
   "Sort predicate for use with `tutorial--default-keys'.
@@ -210,19 +210,17 @@ LEFT and RIGHT are the elements to compare."
 (defconst tutorial--default-keys
   ;; On window system, `suspend-emacs' is replaced in the default
   ;; keymap
-  (let* ((suspend-emacs (if window-system
-                            'iconify-or-deiconify-frame
-                          'suspend-emacs))
+  (let* ((suspend-emacs 'suspend-frame)
          (default-keys
            `((ESC-prefix [27])
              (Control-X-prefix [?\C-x])
              (mode-specific-command-prefix [?\C-c])
-             (save-buffers-kill-emacs [?\C-x ?\C-c])
+             (save-buffers-kill-terminal [?\C-x ?\C-c])
 
              ;; * SUMMARY
              (scroll-up [?\C-v])
              (scroll-down [?\M-v])
-             (recenter [?\C-l])
+             (recenter-top-bottom [?\C-l])
 
              ;; * BASIC CURSOR CONTROL
              (forward-char [?\C-f])
@@ -266,8 +264,7 @@ LEFT and RIGHT are the elements to compare."
              (yank-pop [?\M-y])
 
              ;; * UNDO
-             (advertised-undo [?\C-x ?u])
-             (advertised-undo [?\C-x ?u])
+             (undo [?\C-x ?u])
 
              ;; * FILES
              (find-file [?\C-x ?\C-f])
@@ -326,7 +323,7 @@ LEFT and RIGHT are the elements to compare."
   "Give detailed help about changed keys."
   (with-output-to-temp-buffer (help-buffer)
     (help-setup-xref (list #'tutorial--detailed-help button)
-                     (interactive-p))
+                     (called-interactively-p 'interactive))
     (with-current-buffer (help-buffer)
       (let* ((tutorial-buffer  (button-get button 'tutorial-buffer))
              (explain-key-desc (button-get button 'explain-key-desc))
@@ -390,7 +387,7 @@ from the Emacs default:\n\n" )
         (insert "
 It is OK to change key bindings, but changed bindings do not
 correspond to what the tutorial says.\n\n")
-        (print-help-return-message)))))
+        (help-print-return-message)))))
 
 (defun tutorial--find-changed-keys (default-keys)
   "Find the key bindings used in the tutorial that have changed.
@@ -629,7 +626,7 @@ with some explanatory links."
 
 (defun tutorial--saved-dir ()
   "Directory to which tutorials are saved."
-  (expand-file-name "tutorial" user-emacs-directory))
+  (locate-user-emacs-file "tutorial/"))
 
 (defun tutorial--saved-file ()
   "File name in which to save tutorials."
@@ -667,7 +664,8 @@ position where the display of changed bindings was inserted."
   ;; This runs in a hook so protect it:
   (condition-case err
       (if (y-or-n-p "Save your position in the tutorial? ")
-         (tutorial--save-tutorial-to (tutorial--saved-file)))
+         (tutorial--save-tutorial-to (tutorial--saved-file))
+       (message "Tutorial position not saved"))
     (error (message "Error saving tutorial state: %s"
                    (error-message-string err)))))
 
@@ -776,9 +774,7 @@ Run the Viper tutorial? "))
                        current-language-environment
                      "English")))
            (filename (get-language-info lang 'tutorial))
-           ;; Choose a buffer name including the language so that
-           ;; several languages can be tested simultaneously:
-           (tut-buf-name (concat "TUTORIAL (" lang ")"))
+           (tut-buf-name filename)
            (old-tut-buf (get-buffer tut-buf-name))
            (old-tut-win (when old-tut-buf (get-buffer-window old-tut-buf t)))
            (old-tut-is-ok (when old-tut-buf
@@ -810,7 +806,7 @@ Run the Viper tutorial? "))
       ;; (Re)build the tutorial buffer if it is not ok
       (unless old-tut-is-ok
         (switch-to-buffer (get-buffer-create tut-buf-name))
-        (unless old-tut-buf (text-mode))
+        ;; (unless old-tut-buf (text-mode))
         (unless lang (error "Variable lang is nil"))
         (setq tutorial--lang lang)
         (setq old-tut-file (file-exists-p (tutorial--saved-file)))
@@ -847,7 +843,7 @@ Run the Viper tutorial? "))
               (delete-region (point-min) (point))
               (goto-char tutorial--point-before-chkeys)
               (setq tutorial--point-before-chkeys (point-marker)))
-          (insert-file-contents (expand-file-name filename data-directory))
+          (insert-file-contents (expand-file-name filename tutorial-directory))
           (forward-line)
           (setq tutorial--point-before-chkeys (point-marker)))
 
@@ -867,6 +863,10 @@ Run the Viper tutorial? "))
               (when (< old-point 1)
                 (setq old-point 1))
               (goto-char old-point))
+          ;; Delete the arch-tag line, so as not to confuse readers.
+          (goto-char (point-max))
+          (if (search-backward ";;; arch-tag: " nil t)
+              (delete-region (point) (point-max)))
           (goto-char (point-min))
           (search-forward "\n<<")
           (beginning-of-line)
@@ -932,7 +932,7 @@ See `get-lang-string' for more information.")
 In certain places Emacs can replace a string shown to the user with
 a language specific string.  This function retrieves such strings.
 
-LANG is the language specification. It should be one of those
+LANG is the language specification.  It should be one of those
 strings that can be returned by `read-language-name'.  STRINGID
 is a symbol that specifies the string to retrieve.