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