]> code.delx.au - gnu-emacs/blobdiff - lisp/tutorial.el
(sieve-string-bytes): Remove.
[gnu-emacs] / lisp / tutorial.el
index f1da71a8e5d15bda01a7795c144437fdf6da2daf..1e9c7712e6df440c61e41c46754bc9fa0f13de2c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; tutorial.el --- tutorial for Emacs
 
-;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: help, internal
@@ -9,7 +9,7 @@
 
 ;; 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 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -154,7 +154,10 @@ options:
                           (format "%s" db)
                           " RET instead."))
               (insert "\n\nWith your current key bindings"
-                      " you can use the key "
+                      " you can use "
+                      (if (string-match "^the .*menus?$" where)
+                          ""
+                        "the key")
                       where
                       " to get the function `"
                       (format "%s" db)
@@ -207,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])
@@ -403,8 +404,8 @@ where
   WHERE       is a text describing the key sequences to which DEF-FUN is
               bound now (or, if it is remapped, a key sequence
               for the function it is remapped to)
-  REMARK      is a list with info about rebinding. It has either of these
-              formats:
+  REMARK      is a list with info about rebinding. It has either of
+              these formats:
 
                 \(TEXT cua-mode)
                 \(TEXT current-binding KEY-FUN DEF-FUN KEY WHERE)
@@ -428,17 +429,35 @@ where
               (def-fun (nth 0 kdf))
               (def-fun-txt (format "%s" def-fun))
               (rem-fun (command-remapping def-fun))
+              ;; Handle prefix definitions specially
+              ;; so that a mode that rebinds some subcommands
+              ;; won't make it appear that the whole prefix is gone.
               (key-fun (if (eq def-fun 'ESC-prefix)
                            (lookup-key global-map [27])
-                         (key-binding key)))
-              (where (where-is-internal (if rem-fun rem-fun def-fun))))
+                         (if (eq def-fun 'Control-X-prefix)
+                             (lookup-key global-map [24])
+                           (key-binding key))))
+              (where (where-is-internal (if rem-fun rem-fun def-fun)))
+              cwhere)
+
          (if where
              (progn
-               (setq where (key-description (car where)))
+               (setq cwhere (car where)
+                     where (key-description cwhere))
                (when (and (< 10 (length where))
                           (string= (substring where 0 (length "<menu-bar>"))
                                    "<menu-bar>"))
-                 (setq where "the menus")))
+                 (setq where
+                       (if (and (vectorp cwhere)
+                                (setq cwhere (elt cwhere 1))
+                                (setq cwhere
+                                      (cadr
+                                       (assoc cwhere
+                                              (lookup-key global-map
+                                                          [menu-bar]))))
+                                (stringp cwhere))
+                           (format "the `%s' menu" cwhere)
+                         "the menus"))))
            (setq where ""))
          (setq remark nil)
          (unless
@@ -608,8 +627,7 @@ with some explanatory links."
 
 (defun tutorial--saved-dir ()
   "Directory to which tutorials are saved."
-  (expand-file-name "tutorial"
-                   (if (eq system-type 'ms-dos) "~/_emacs.d/" "~/.emacs.d/")))
+  (expand-file-name "tutorial" user-emacs-directory))
 
 (defun tutorial--saved-file ()
   "File name in which to save tutorials."
@@ -647,7 +665,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)))))
 
@@ -827,7 +846,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)))
 
@@ -909,14 +928,14 @@ See `get-lang-string' for more information.")
 
 (defun get-lang-string (lang stringid &optional no-eng-fallback)
   "Get a language specific string for Emacs.
-In certain places Emacs can replace a string showed to the user with a language specific string.
-This function retrieves such strings.
+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
 strings that can be returned by `read-language-name'.  STRINGID
 is a symbol that specifies the string to retrieve.
 
-If no string is found for STRINGID in the choosen language then
+If no string is found for STRINGID in the chosen language then
 the English string is returned unless NO-ENG-FALLBACK is non-nil.
 
 See `lang-strings' for more information.