comparison lisp/mule/mule-help.el @ 392:1f50e6fe4f3f r21-2-11

Import from CVS: tag r21-2-11
author cvs
date Mon, 13 Aug 2007 11:10:50 +0200
parents 4f79e16b1112
children 74fd4e045ea6
comparison
equal deleted inserted replaced
391:e50d8e68d7a5 392:1f50e6fe4f3f
1 ;;; mule-help.el --- Mule-ized Help functions
2
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
4
5 ;; Author: SL Baur <steve@altair.xemacs.org>
6 ;; Keywords: help, internal
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: Emacs 20.1
26
27 ;;; Commentary:
28
29 ;;
30
31 ;;; Code:
32
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."
40 (interactive "P")
41 (let (lang filename file)
42 (if arg
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)
49 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 (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))
67 6)))
68 (if (< n 12)
69 (progn (beginning-of-line) (kill-line))
70 ;; Some people get confused by the large gap
71 (delete-backward-char 2)
72 (insert "]")
73 (beginning-of-line)
74 (save-excursion
75 (delete-char 2)
76 (insert "["))
77 (newline (/ n 2))
78 (next-line 1)
79 (newline (- n (/ n 2))))))
80 (goto-char (point-min))
81 (set-buffer-modified-p nil))))
82
83
84 (provide 'mule-help)
85
86 ;;; mule-help.el ends here