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 XEmacs.
10 ;; XEmacs is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; XEmacs is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 ;;; Synched up with: Emacs 20.1
33 ;; TUTORIAL arg is XEmacs addition
34 (defun help-with-tutorial (&optional arg tutorial)
35 "Select the XEmacs learn-by-doing tutorial.
36 If there is a tutorial version written in the language
37 of the selected language environment, that version is used.
38 If there's no tutorial in that language, `TUTORIAL' is selected.
39 With arg, you are asked to select which language."
41 (let (lang filename file)
43 (or (setq lang (read-language-name 'tutorial "Language: "))
44 (error "No tutorial file of the specified language"))
45 (setq lang current-language-environment))
46 ;; The menubar buttons call this function like this:
47 ;; (help-with-tutorial nil "tutorial.lang")
48 (setq filename (if (and (not arg) tutorial)
50 (or (get-language-info lang 'tutorial)
51 (or tutorial "TUTORIAL"))))
52 (setq file (expand-file-name (concat "~/" filename)))
53 (delete-other-windows)
54 (if (get-file-buffer file)
55 (switch-to-buffer (get-file-buffer file))
56 (switch-to-buffer (create-file-buffer file))
57 (setq buffer-file-name file)
58 (setq default-directory (expand-file-name "~/"))
59 (setq buffer-auto-save-file-name nil)
60 (let ((coding-system-for-read
61 (get-language-info lang 'tutorial-coding-system)))
62 (insert-file-contents (locate-data-file filename)))
63 (goto-char (point-min))
64 ;; The 'didactic' blank lines: Possibly insert blank lines
65 ;; around <<nya nya nya>>, and change << >> to [ ].
66 (if (re-search-forward "^<<.+>>" nil t)
67 (let ((n (- (window-height (selected-window))
68 (count-lines (point-min) (point-at-bol))
71 (progn (beginning-of-line) (kill-line))
72 ;; Some people get confused by the large gap
73 (delete-backward-char 2)
81 (newline (- n (/ n 2))))))
82 (goto-char (point-min))
83 (set-buffer-modified-p nil))))
88 ;;; mule-help.el ends here