Mercurial > hg > xemacs-beta
comparison lisp/mule/mule-help.el @ 428:3ecd8885ac67 r21-2-22
Import from CVS: tag r21-2-22
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:28:15 +0200 |
parents | |
children | 7039e6323819 |
comparison
equal
deleted
inserted
replaced
427:0a0253eac470 | 428:3ecd8885ac67 |
---|---|
1 ;;; mule-help.el --- Mule-ized Help functions | |
2 | |
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc. | |
4 | |
5 ;; Author: SL Baur <steve@xemacs.org> | |
6 ;; Keywords: help, internal, mule | |
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 (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)) | |
69 6))) | |
70 (if (< n 12) | |
71 (progn (beginning-of-line) (kill-line)) | |
72 ;; Some people get confused by the large gap | |
73 (delete-backward-char 2) | |
74 (insert "]") | |
75 (beginning-of-line) | |
76 (save-excursion | |
77 (delete-char 2) | |
78 (insert "[")) | |
79 (newline (/ n 2)) | |
80 (next-line 1) | |
81 (newline (- n (/ n 2)))))) | |
82 (goto-char (point-min)) | |
83 (set-buffer-modified-p nil)))) | |
84 | |
85 | |
86 (provide 'mule-help) | |
87 | |
88 ;;; mule-help.el ends here |