update.
[chise/xemacs-chise.git.1] / lisp / help-nomule.el
1 ;;; help-nomule.el --- Help functions when not in Mule
2
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
4
5 ;; Maintainer: XEmacs Development Team
6 ;; Keywords: help, internal, dumped
7
8 ;; This file is part of XEmacs.
9
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)
13 ;; any later version.
14
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.
19
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
23 ;; 02111-1307, USA.
24
25 ;;; Synched up with: Not in FSF
26
27 ;;; Commentary:
28
29 ;; This file is dumped with XEmacs.
30
31 ;;; Code:
32
33 (defconst tutorial-supported-languages
34   '(
35     ("Croatian" hr iso-8859-2)
36     ("French" fr iso-8859-1)
37     ("German" de iso-8859-1)
38     ("Norwegian" no iso-8859-1)
39     ("Polish" pl iso-8859-2)
40     ("Romanian" ro iso-8859-2)
41     ("Swedish" se iso-8859-1)
42     )
43   "Alist of supported languages in TUTORIAL files.
44 Add languages here, as more are translated.")
45
46 ;; TUTORIAL arg is XEmacs addition
47 (defun help-with-tutorial (&optional tutorial language)
48   "Select the XEmacs learn-by-doing tutorial.
49 Optional arg TUTORIAL specifies the tutorial file; default is \"TUTORIAL\".
50 With a prefix argument, choose the language."
51   (interactive "i\nP")
52   (or tutorial
53       (setq tutorial "TUTORIAL"))
54   (when (and language (consp language))
55     (let ((completion-ignore-case t))
56       (setq language (assoc (completing-read "Language: "
57                                              tutorial-supported-languages
58                                              nil t)
59                             tutorial-supported-languages))))
60   (when language
61     (setq tutorial (format "%s.%s" tutorial (cadr language))))
62   (let ((file (expand-file-name tutorial "~")))
63     (delete-other-windows)
64     (let ((buffer (or (get-file-buffer file)
65                       (create-file-buffer file)))
66           (window-configuration (current-window-configuration)))
67       (condition-case error-data
68           (progn
69             (switch-to-buffer buffer)
70             (setq buffer-file-name file)
71             (setq default-directory (expand-file-name "~/"))
72             (setq buffer-auto-save-file-name nil)
73             ;; Because of non-Mule users, TUTORIALs are not coded
74             ;; independently, so we must guess the coding according to
75             ;; the language.
76             (let ((coding-system-for-read (nth 2 language)))
77               (insert-file-contents (locate-data-file tutorial)))
78             (goto-char (point-min))
79             ;; The 'didactic' blank lines: possibly insert blank lines
80             ;; around <<nya nya nya>> and replace << >> with [ ].
81             (if (re-search-forward "^<<.+>>")
82                 (let ((n (- (window-height (selected-window))
83                             (count-lines (point-min) (point-at-bol))
84                             6)))
85                   (if (< n 12)
86                       (progn (beginning-of-line) (kill-line))
87                     ;; Some people get confused by the large gap
88                     (delete-backward-char 2)
89                     (insert "]")
90                     (beginning-of-line)
91                     (save-excursion
92                       (delete-char 2)
93                       (insert "["))
94                     (newline (/ n 2))
95                     (next-line 1)
96                     (newline (- n (/ n 2))))))
97             (goto-char (point-min))
98             (set-buffer-modified-p nil))
99         ;; TUTORIAL was not found: kill the buffer and restore the
100         ;; window configuration.
101         (file-error (kill-buffer buffer)
102                     (set-window-configuration window-configuration)
103                     ;; Now, signal the error
104                     (signal (car error-data) (cdr error-data)))))))
105
106 ;; General Mule-compatibility stuffs
107 (define-function 'string-width 'length)
108
109 ;; The following was originally in subr.el
110 (defun make-char (charset &optional arg1 arg2)
111   "Make a character from CHARSET and octets ARG1 and ARG2.
112 This function is available for compatibility with Mule-enabled XEmacsen.
113 When CHARSET is `ascii', return (int-char ARG1).  Otherwise, return
114 that value with the high bit set.  ARG2 is always ignored."
115   (int-char (if (eq charset 'ascii)
116                 arg1
117               (logior arg1 #x80))))
118
119
120 (provide 'help-nomule)
121
122 ;;; help-nomule.el ends here