1 ;;; mule-help.el --- Mule-ized Help functions
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
5 ;; Author: SL Baur <steve@xemacs.org>
6 ;; Keywords: help, internal, mule
8 ;; This file is part of SXEmacs.
10 ;; SXEmacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; SXEmacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Synched up with: Emacs 20.1
31 ;; TUTORIAL arg is XEmacs addition
32 (defun help-with-tutorial (&optional arg tutorial)
33 "Select the XEmacs learn-by-doing tutorial.
34 If there is a tutorial version written in the language
35 of the selected language environment, that version is used.
36 If there's no tutorial in that language, `TUTORIAL' is selected.
37 With arg, you are asked to select which language."
39 (let (lang filename file)
41 (or (setq lang (read-language-name 'tutorial "Language: "))
42 (error "No tutorial file of the specified language"))
43 (setq lang current-language-environment))
44 ;; The menubar buttons call this function like this:
45 ;; (help-with-tutorial nil "tutorial.lang")
46 (setq filename (if (and (not arg) tutorial)
48 (or (get-language-info lang 'tutorial)
49 (or tutorial "TUTORIAL"))))
50 (setq file (expand-file-name (concat "~/" filename)))
51 (delete-other-windows)
52 (if (get-file-buffer file)
53 (switch-to-buffer (get-file-buffer file))
54 (switch-to-buffer (create-file-buffer file))
55 (setq buffer-file-name file)
56 (setq default-directory (expand-file-name "~/"))
57 (setq buffer-auto-save-file-name nil)
58 (let ((coding-system-for-read
59 (get-language-info lang 'tutorial-coding-system)))
60 (insert-file-contents (locate-data-file filename)))
61 (goto-char (point-min))
62 ;; The 'didactic' blank lines: Possibly insert blank lines
63 ;; around <<nya nya nya>>, and change << >> to [ ].
64 (if (re-search-forward "^<<.+>>" nil t)
65 (let ((n (- (window-height (selected-window))
66 (count-lines (point-min) (point-at-bol))
69 (progn (beginning-of-line) (kill-line))
70 ;; Some people get confused by the large gap
71 (delete-backward-char 2)
79 (newline (- n (/ n 2))))))
80 (goto-char (point-min))
81 (set-buffer-modified-p nil))))
86 ;;; mule-help.el ends here