comparison lisp/help-fns.el @ 73550:6deaec97f21b

* help-fns.el (help-with-tutorial): Moved to tutorial.el. * tutorial.el: New file. (help-with-tutorial): Moved here from help-fns.el. Added help for rebound keys. Fixed resume of tutorial. (tutorial--describe-nonstandard-key, tutorial--sort-keys) (tutorial--find-changed-keys, tutorial--display-changes) (tutorial--saved-dir, tutorial--saved-file) (tutorial--save-tutorial): New functions to support the changes in help-with-tutorial.
author Chong Yidong <cyd@stupidchicken.com>
date Mon, 30 Oct 2006 14:30:59 +0000
parents d636f1f6f544
children c8981abb2053 c71725faff1a 02cf29720f31
comparison
equal deleted inserted replaced
73549:e68d05a41cab 73550:6deaec97f21b
33 33
34 ;;; Code: 34 ;;; Code:
35 35
36 (require 'help-mode) 36 (require 'help-mode)
37 37
38
39 ;;;###autoload
40 (defun help-with-tutorial (&optional arg)
41 "Select the Emacs learn-by-doing tutorial.
42 If there is a tutorial version written in the language
43 of the selected language environment, that version is used.
44 If there's no tutorial in that language, `TUTORIAL' is selected.
45 With ARG, you are asked to choose which language."
46 (interactive "P")
47 (let ((lang (if arg
48 (let ((minibuffer-setup-hook minibuffer-setup-hook))
49 (add-hook 'minibuffer-setup-hook
50 'minibuffer-completion-help)
51 (read-language-name 'tutorial "Language: " "English"))
52 (if (get-language-info current-language-environment 'tutorial)
53 current-language-environment
54 "English")))
55 file filename)
56 (setq filename (get-language-info lang 'tutorial))
57 (setq file (expand-file-name (concat "~/" filename)))
58 (delete-other-windows)
59 (if (get-file-buffer file)
60 (switch-to-buffer (get-file-buffer file))
61 (switch-to-buffer (create-file-buffer file))
62 (setq buffer-file-name file)
63 (setq default-directory (expand-file-name "~/"))
64 (setq buffer-auto-save-file-name nil)
65 (insert-file-contents (expand-file-name filename data-directory))
66 (hack-local-variables)
67 (goto-char (point-min))
68 (search-forward "\n<<")
69 (beginning-of-line)
70 ;; Convert the <<...>> line to the proper [...] line,
71 ;; or just delete the <<...>> line if a [...] line follows.
72 (cond ((save-excursion
73 (forward-line 1)
74 (looking-at "\\["))
75 (delete-region (point) (progn (forward-line 1) (point))))
76 ((looking-at "<<Blank lines inserted.*>>")
77 (replace-match "[Middle of page left blank for didactic purposes. Text continues below]"))
78 (t
79 (looking-at "<<")
80 (replace-match "[")
81 (search-forward ">>")
82 (replace-match "]")))
83 (beginning-of-line)
84 (let ((n (- (window-height (selected-window))
85 (count-lines (point-min) (point))
86 6)))
87 (if (< n 8)
88 (progn
89 ;; For a short gap, we don't need the [...] line,
90 ;; so delete it.
91 (delete-region (point) (progn (end-of-line) (point)))
92 (newline n))
93 ;; Some people get confused by the large gap.
94 (newline (/ n 2))
95
96 ;; Skip the [...] line (don't delete it).
97 (forward-line 1)
98 (newline (- n (/ n 2)))))
99 (goto-char (point-min))
100 (setq buffer-undo-list nil)
101 (set-buffer-modified-p nil))))
102
103
104 ;; Functions 38 ;; Functions
105 39
106 ;;;###autoload 40 ;;;###autoload
107 (defun describe-function (function) 41 (defun describe-function (function)
108 "Display the full documentation of FUNCTION (a symbol)." 42 "Display the full documentation of FUNCTION (a symbol)."