Move lisp/emacs-lisp/authors.el to admin/
[bpt/emacs.git] / lisp / tutorial.el
index 77a5f29..8925a02 100644 (file)
@@ -1,9 +1,10 @@
 ;;; tutorial.el --- tutorial for Emacs
 
-;; Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2014 Free Software Foundation, Inc.
 
-;; Maintainer: FSF
+;; Maintainer: emacs-devel@gnu.org
 ;; Keywords: help, internal
+;; Package: emacs
 
 ;; This file is part of GNU Emacs.
 
@@ -155,7 +156,7 @@ options:
                           " RET instead."))
               (insert "\n\nWith your current key bindings"
                       " you can use "
-                      (if (string-match "^the .*menus?$" where)
+                      (if (string-match-p "^the .*menus?$" where)
                           ""
                         "the key")
                       where
@@ -181,7 +182,7 @@ LEFT and RIGHT are the elements to compare."
                 (equal (car x) (car y)))
       (setq x (cdr x))
       (setq y (cdr y)))
-    ;; Try to make a comparision that is useful for presentation (this
+    ;; Try to make a comparison that is useful for presentation (this
     ;; could be made nicer perhaps):
     (let ((cx (car x))
           (cy (car y)))
@@ -218,8 +219,8 @@ LEFT and RIGHT are the elements to compare."
              (save-buffers-kill-terminal [?\C-x ?\C-c])
 
              ;; * SUMMARY
-             (scroll-up [?\C-v])
-             (scroll-down [?\M-v])
+             (scroll-up-command [?\C-v])
+             (scroll-down-command [?\M-v])
              (recenter-top-bottom [?\C-l])
 
              ;; * BASIC CURSOR CONTROL
@@ -297,7 +298,7 @@ LEFT and RIGHT are the elements to compare."
              (isearch-backward [?\C-r])
 
              ;; * MULTIPLE WINDOWS
-             (split-window-vertically [?\C-x ?2])
+             (split-window-below [?\C-x ?2])
              (scroll-other-window [?\C-\M-v])
              (other-window [?\C-x ?o])
              (find-file-other-window [?\C-x ?4 ?\C-f])
@@ -345,10 +346,8 @@ from the Emacs default:\n\n" )
                    (def-fun-txt (nth 2 tk))
                    (where       (nth 3 tk))
                    (remark      (nth 4 tk))
-                   (rem-fun (command-remapping def-fun))
                    (key-txt (key-description key))
-                   (key-fun (with-current-buffer tutorial-buffer (key-binding key)))
-                   tot-len)
+                   (key-fun (with-current-buffer tutorial-buffer (key-binding key))))
               (unless (eq def-fun key-fun)
                 ;; Insert key binding description:
                 (when (string= key-txt explain-key-desc)
@@ -584,7 +583,6 @@ with some explanatory links."
           (not (get-text-property (match-beginning 1) 'tutorial-remark))
           (let* ((desc    (car changed-key))
                  (ck      (cdr changed-key))
-                 (key     (nth 0 ck))
                  (def-fun (nth 1 ck))
                  (where   (nth 3 ck))
                  s1 s2 help-string)
@@ -723,9 +721,7 @@ See `tutorial--save-tutorial' for more information."
                            saved-file
                            (error-message-string err))))
             ;; An error is raised here?? Is this a bug?
-            (condition-case err
-                (undo-only)
-              (error nil))
+            (ignore-errors (undo-only))
             ;; Restore point
             (goto-char old-point)
             (if save-err
@@ -765,14 +761,13 @@ Run the Viper tutorial? "))
                       (funcall 'viper-tutorial 0))
              (message "Tutorial aborted by user"))
          (message prompt1)))
-    (let* ((lang (if arg
-                     (let ((minibuffer-setup-hook minibuffer-setup-hook))
-                       (add-hook 'minibuffer-setup-hook
-                                 'minibuffer-completion-help)
-                       (read-language-name 'tutorial "Language: " "English"))
-                   (if (get-language-info current-language-environment 'tutorial)
-                       current-language-environment
-                     "English")))
+    (let* ((lang (cond
+                  (arg
+                   (minibuffer-with-setup-hook #'minibuffer-completion-help
+                     (read-language-name 'tutorial "Language: " "English")))
+                  ((get-language-info current-language-environment 'tutorial)
+                   current-language-environment)
+                  (t "English")))
            (filename (get-language-info lang 'tutorial))
            (tut-buf-name filename)
            (old-tut-buf (get-buffer tut-buf-name))
@@ -829,6 +824,10 @@ Run the Viper tutorial? "))
         (if old-tut-file
             (progn
               (insert-file-contents (tutorial--saved-file))
+             (let ((enable-local-variables :safe)
+                    (enable-local-eval nil)
+                    (enable-dir-local-variables nil)) ; bug#11127
+               (hack-local-variables))
               (goto-char (point-min))
               (setq old-tut-point
                     (string-to-number
@@ -844,6 +843,10 @@ Run the Viper tutorial? "))
               (goto-char tutorial--point-before-chkeys)
               (setq tutorial--point-before-chkeys (point-marker)))
           (insert-file-contents (expand-file-name filename tutorial-directory))
+         (let ((enable-local-variables :safe)
+                (enable-local-eval nil)
+                (enable-dir-local-variables nil)) ; bug#11127
+           (hack-local-variables))
           (forward-line)
           (setq tutorial--point-before-chkeys (point-marker)))
 
@@ -874,7 +877,7 @@ Run the Viper tutorial? "))
           ;; or just delete the <<...>> line if a [...] line follows.
           (cond ((save-excursion
                    (forward-line 1)
-                   (looking-at "\\["))
+                   (looking-at-p "\\["))
                  (delete-region (point) (progn (forward-line 1) (point))))
                 ((looking-at "<<Blank lines inserted.*>>")
                  (replace-match "[Middle of page left blank for didactic purposes.   Text continues below]"))
@@ -884,7 +887,12 @@ Run the Viper tutorial? "))
                  (search-forward ">>")
                  (replace-match "]")))
           (beginning-of-line)
-          (let ((n (- (window-height (selected-window))
+          ;; FIXME: if the window is not tall, and especially if the
+          ;; big red "NOTICE: The main purpose..." text has been
+          ;; inserted at the start of the buffer, the "type C-v to
+          ;; move to the next screen" might not be visible on the
+          ;; first screen (n < 0).  How will the novice know what to do?
+          (let ((n (- (window-height)
                       (count-lines (point-min) (point))
                       6)))
             (if (< n 8)
@@ -892,7 +900,7 @@ Run the Viper tutorial? "))
                   ;; For a short gap, we don't need the [...] line,
                   ;; so delete it.
                   (delete-region (point) (progn (end-of-line) (point)))
-                  (newline n))
+                  (if (> n 0) (newline n)))
               ;; Some people get confused by the large gap.
               (newline (/ n 2))
 
@@ -958,5 +966,4 @@ Currently this feature is only used in `help-with-tutorial'."
 
 (provide 'tutorial)
 
-;; arch-tag: c8e80aef-c3bb-4ffb-8af6-22171bf0c100
 ;;; tutorial.el ends here