annotate lisp/mule/mule-help.el @ 333:4f79e16b1112 r21-0-64

Import from CVS: tag r21-0-64
author cvs
date Mon, 13 Aug 2007 10:49:50 +0200
parents
children 74fd4e045ea6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
333
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
1 ;;; mule-help.el --- Mule-ized Help functions
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
2
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 by Free Software Foundation, Inc.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
4
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
5 ;; Author: SL Baur <steve@altair.xemacs.org>
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
6 ;; Keywords: help, internal
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
7
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
9
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
13 ;; any later version.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
14
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
18 ;; General Public License for more details.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
19
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
24
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
25 ;;; Synched up with: Emacs 20.1
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
26
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
27 ;;; Commentary:
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
28
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
29 ;;
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
30
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
31 ;;; Code:
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
32
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
33 ;; TUTORIAL arg is XEmacs addition
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
34 (defun help-with-tutorial (&optional arg tutorial)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
35 "Select the XEmacs learn-by-doing tutorial.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
36 If there is a tutorial version written in the language
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
37 of the selected language environment, that version is used.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
38 If there's no tutorial in that language, `TUTORIAL' is selected.
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
39 With arg, you are asked to select which language."
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
40 (interactive "P")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
41 (let (lang filename file)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
42 (if arg
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
43 (or (setq lang (read-language-name 'tutorial "Language: "))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
44 (error "No tutorial file of the specified language"))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
45 (setq lang current-language-environment))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
46 ;; The menubar buttons call this function like this:
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
47 ;; (help-with-tutorial nil "tutorial.lang")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
48 (setq filename (if (and (not arg) tutorial)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
49 tutorial
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
50 (or (get-language-info lang 'tutorial)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
51 (or tutorial "TUTORIAL"))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
52 (setq file (expand-file-name (concat "~/" filename)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
53 (delete-other-windows)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
54 (if (get-file-buffer file)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
55 (switch-to-buffer (get-file-buffer file))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
56 (switch-to-buffer (create-file-buffer file))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
57 (setq buffer-file-name file)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
58 (setq default-directory (expand-file-name "~/"))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
59 (setq buffer-auto-save-file-name nil)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
60 (insert-file-contents (locate-data-file filename))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
61 (goto-char (point-min))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
62 ;; The 'didactic' blank lines: Possibly insert blank lines
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
63 ;; around <<nya nya nya>>, and change << >> to [ ].
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
64 (if (re-search-forward "^<<.+>>" nil t)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
65 (let ((n (- (window-height (selected-window))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
66 (count-lines (point-min) (point-at-bol))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
67 6)))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
68 (if (< n 12)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
69 (progn (beginning-of-line) (kill-line))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
70 ;; Some people get confused by the large gap
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
71 (delete-backward-char 2)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
72 (insert "]")
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
73 (beginning-of-line)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
74 (save-excursion
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
75 (delete-char 2)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
76 (insert "["))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
77 (newline (/ n 2))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
78 (next-line 1)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
79 (newline (- n (/ n 2))))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
80 (goto-char (point-min))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
81 (set-buffer-modified-p nil))))
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
82
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
83
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
84 (provide 'mule-help)
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
85
4f79e16b1112 Import from CVS: tag r21-0-64
cvs
parents:
diff changeset
86 ;;; mule-help.el ends here