annotate lisp/emulators/mlsupport.el @ 7:c153ca296910

Added tag r19-15b4 for changeset 27bc7f280385
author cvs
date Mon, 13 Aug 2007 08:47:16 +0200
parents b82b59fe008d
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; mlsupport.el --- run-time support for mocklisp code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1985 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: extensions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
23 ;; 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
25 ;;; Synched up with: FSF 19.34.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This package provides equivalents of certain primitives from Gosling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Emacs (including the commercial UniPress versions). These have an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; ml- prefix to distinguish them from native GNU Emacs functions with
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
32 ;; similar names. The package mlconvert.el translates Mocklisp code
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; to use these names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (or (fboundp 'ml-prefix-argument-loop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (error "emacs was not compiled with #define MOCKLISP_SUPPORT in config.h"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (defmacro ml-defun (&rest defs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (list 'ml-defun-1 (list 'quote defs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defun ml-defun-1 (args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (fset (car (car args)) (cons 'mocklisp (cdr (car args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (setq args (cdr args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defmacro declare-buffer-specific (&rest vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (cons 'progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (mapcar (function (lambda (var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (list 'make-variable-buffer-local (list 'quote var))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 vars)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defun ml-set-default (varname value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (set-default (intern varname) value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ; Lossage: must make various things default missing args to the prefix arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ; Alternatively, must make provide-prefix-argument do something hairy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (defun >> (val count)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (lsh val (- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (defun novalue ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (defun ml-not (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (if (zerop arg) 1 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (defun provide-prefix-arg (arg form)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (funcall (car form) arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun define-keymap (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (fset (intern name) (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
74 ;; Make it work to use ml-use-...-map on "esc" and such.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
75 (fset 'esc-map esc-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
76 (fset 'ctl-x-map ctl-x-map)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
77
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (defun ml-use-local-map (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (use-local-map (intern (concat name "-map"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defun ml-use-global-map (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (use-global-map (intern (concat name "-map"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defun local-bind-to-key (name key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (or (current-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (use-local-map (make-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (define-key (current-local-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (if (integerp key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (if (>= key 128)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (concat (char-to-string meta-prefix-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (char-to-string (- key 128)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (char-to-string key))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (intern name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defun bind-to-key (name key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (define-key global-map (if (integerp key) (char-to-string key) key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (intern name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun ml-autoload (name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (autoload (intern name) file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (defun ml-define-string-macro (name defn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (fset (intern name) defn))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (defun push-back-character (char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (setq unread-command-event (character-to-event char)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (defun to-col (column)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (indent-to column 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defmacro is-bound (&rest syms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (cons 'and (mapcar (function (lambda (sym) (list 'boundp (list 'quote sym)))) syms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (defmacro declare-global (&rest syms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (cons 'progn (mapcar (function (lambda (sym) (list 'defvar sym nil))) syms)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (defmacro error-occurred (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (list 'condition-case nil (cons 'progn (append body '(nil))) '(error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (defun return-prefix-argument (value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (setq prefix-arg value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (defun ml-prefix-argument ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (cond ((null current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ((listp current-prefix-arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (car current-prefix-arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ((eq current-prefix-arg '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 current-prefix-arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (defun ml-print (varname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (interactive "vPrint variable: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (if (boundp varname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (message "%s => %s" (symbol-name varname) (symbol-value varname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (message "%s has no value" (symbol-name varname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defun ml-set (str val) (set (intern str) val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (defun ml-message (&rest args) (message "%s" (apply 'concat args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defun kill-to-end-of-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (ml-prefix-argument-loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (if (eolp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (kill-region (point) (1+ (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (kill-region (point) (if (search-forward ?\n nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (1- (point)) (point-max))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defun set-auto-fill-hook (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (setq auto-fill-function (intern arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (defun auto-execute (function pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (/= (aref pattern 0) ?*)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (error "Only patterns starting with * supported in auto-execute"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq auto-mode-alist (cons (cons (concat "\\." (substring pattern 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 "\\'")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 auto-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defun move-to-comment-column ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (indent-to comment-column))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (defun erase-region ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (delete-region (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defun delete-region-to-buffer (bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (copy-to-buffer bufname (point) (mark))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (delete-region (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun copy-region-to-buffer (bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (copy-to-buffer bufname (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defun append-region-to-buffer (bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (append-to-buffer bufname (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (defun prepend-region-to-buffer (bufname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (prepend-to-buffer bufname (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defun delete-next-character ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (delete-char (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (defun delete-next-word ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (delete-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (progn (forward-word (ml-prefix-argument)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defun delete-previous-word ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (delete-region (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (progn (backward-word (ml-prefix-argument)) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (defun delete-previous-character ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (delete-backward-char (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun forward-character ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (forward-char (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defun backward-character ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (backward-char (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun ml-newline ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (newline (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defun ml-next-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (next-line (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defun ml-previous-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (previous-line (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defun delete-to-kill-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (kill-region (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defun narrow-region ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (narrow-to-region (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 (defun ml-newline-and-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (let ((column (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (newline (ml-prefix-argument))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (indent-to column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun newline-and-backup ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (open-line (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (defun quote-char ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (quoted-insert (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (defun ml-current-column ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (1+ (current-column)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (defun ml-current-indent ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (1+ (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (defun region-around-match (&optional n)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (set-mark (match-beginning n))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (goto-char (match-end n)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (defun region-to-string ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (buffer-substring (min (point) (mark)) (max (point) (mark))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun use-abbrev-table (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (let ((symbol (intern (concat name "-abbrev-table"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (or (boundp symbol)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (define-abbrev-table symbol nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (symbol-value symbol)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
246 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (defun define-hooked-local-abbrev (name exp hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (define-abbrev (or local-abbrev-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (error "Major mode has no abbrev table"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (downcase name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 exp (intern hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
253 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defun define-hooked-global-abbrev (name exp hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (define-abbrev global-abbrev-table (downcase name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 exp (intern hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (defun case-word-lower ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (ml-casify-word 'downcase-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defun case-word-upper ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (ml-casify-word 'upcase-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (defun case-word-capitalize ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (ml-casify-word 'capitalize-region))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defun ml-casify-word (fun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (forward-char 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (forward-word -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (funcall fun (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (progn (forward-word (ml-prefix-argument))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (defun case-region-lower ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (downcase-region (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (defun case-region-upper ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (upcase-region (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (defun case-region-capitalize ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (capitalize-region (point) (mark)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (defvar saved-command-line-args nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (defun argc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (or saved-command-line-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq saved-command-line-args command-line-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 command-line-args ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (length command-line-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (defun argv (i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (or saved-command-line-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (setq saved-command-line-args command-line-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 command-line-args ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (nth i saved-command-line-args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (defun invisible-argc ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (length (or saved-command-line-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 command-line-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (defun invisible-argv (i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (nth i (or saved-command-line-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 command-line-args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (defun exit-emacs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (condition-case ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (exit-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (error (kill-emacs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; Lisp function buffer-size returns total including invisible;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; mocklisp wants just visible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (defun ml-buffer-size ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (- (point-max) (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (defun previous-command ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 last-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (defun beginning-of-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (goto-char (window-start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (defun end-of-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (goto-char (window-start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (vertical-motion (- (window-height) 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (defun ml-search-forward (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (search-forward string nil nil (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (defun ml-re-search-forward (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (re-search-forward string nil nil (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (defun ml-search-backward (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (search-backward string nil nil (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (defun ml-re-search-backward (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (re-search-backward string nil nil (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (defvar use-users-shell 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 "Mocklisp compatibility variable; 1 means use shell from SHELL env var.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 0 means use /bin/sh.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (defvar use-csh-option-f 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 "Mocklisp compatibility variable; 1 means pass -f when calling csh.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
346 ;; XEmacs (FSF bugfix? -sb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun filter-region (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (let* ((shell (if (/= use-users-shell 0) shell-file-name "/bin/sh"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (csh (equal (file-name-nondirectory shell) "csh")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (call-process-region (point) (mark) shell t t nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (if (and csh use-csh-option-f) "-cf" "-c")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (concat "exec " command))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
354 ;; XEmacs (FSF bugfix? -sb)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defun execute-monitor-command (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (let* ((shell (if (/= use-users-shell 0) shell-file-name "/bin/sh"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (csh (equal (file-name-nondirectory shell) "csh")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (call-process shell nil t t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 (if (and csh use-csh-option-f) "-cf" "-c")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (concat "exec " command))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (defun use-syntax-table (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (set-syntax-table (symbol-value (intern (concat name "-syntax-table")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defun line-to-top-of-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (recenter (1- (ml-prefix-argument))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defun ml-previous-page (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (let ((count (or arg (ml-prefix-argument))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (while (> count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (scroll-down nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (setq count (1- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (while (< count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (scroll-up nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (setq count (1+ count)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defun ml-next-page ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (ml-previous-page (- (ml-prefix-argument))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun page-next-window (&optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (let ((count (or arg (ml-prefix-argument))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (while (> count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (scroll-other-window nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (setq count (1- count)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (while (< count 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (scroll-other-window '-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq count (1+ count)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (defun ml-next-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (select-window (next-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun ml-previous-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (select-window (previous-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (defun scroll-one-line-up ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (scroll-up (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (defun scroll-one-line-down ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (scroll-down (ml-prefix-argument)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (defun split-current-window ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (split-window (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (defun last-key-struck () last-command-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (defun execute-mlisp-line (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (eval (read string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (defun move-dot-to-x-y (x y)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (goto-char (window-start (selected-window)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (vertical-motion (1- y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (move-to-column (1- x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (defun ml-modify-syntax-entry (string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (let ((i 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (len (length string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (datastring (substring string 0 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (if (= (aref string 0) ?\-)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (aset datastring 0 ?\ ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (if (= (aref string 2) ?\{)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (if (= (aref string 4) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (aset datastring 0 ?\<)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (error "Two-char comment delimiter: use modify-syntax-entry directly")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if (= (aref string 3) ?\})
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if (= (aref string 4) ?\ )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (aset datastring 0 ?\>)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (error "Two-char comment delimiter: use modify-syntax-entry directly")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (while (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (modify-syntax-entry (aref string i) datastring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (setq i (1+ i))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (if (and (< i len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (= (aref string i) ?\-))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (let ((c (aref string (1- i)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (lim (aref string (1+ i))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (while (<= c lim)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (modify-syntax-entry c datastring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq c (1+ c)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq i (+ 2 i)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (defun ml-substr (string from to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (let ((length (length string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (if (< from 0) (setq from (+ from length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (if (< to 0) (setq to (+ to length)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (substring string from (+ from to))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
448 ;; XEmacs
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (defun ml-nargs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 "Number of arguments to currently executing mocklisp function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (if (eq mocklisp-arguments 'interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (length mocklisp-arguments)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defun ml-arg (n prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "Argument number N to currently executing mocklisp function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (if (eq mocklisp-arguments 'interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (read-from-minibuffer prompt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; Mocklisp likes to be origin 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (elt mocklisp-arguments (1- n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun ml-interactive ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 "True if currently executing mocklisp function was called interactively."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (eq mocklisp-arguments 'interactive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 ;; Now in subr.el, because too many loser call it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;(defun insert-string (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ; "Mocklisp-compatibility insert function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;Like the function `insert' except that any argument that is a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;is converted into a string by expressing it in decimal. (Yuck!!)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ; (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ; (let ((arg (car args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 ; (if (integerp arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 ; (insert (number-to-string arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ; (insert arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 ; (setq args (cdr args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (defun ml-concat (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (let ((newargs nil) this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (while args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (setq this (car args))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if (numberp this)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (setq this (number-to-string this)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (setq newargs (cons this newargs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 args (cdr args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (apply 'concat (nreverse newargs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;;; Lose, please. None of these should be used in non-automatically-converted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;;; code, so issue compilation warnings in case someone is using them because
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ;;; they don't know any better.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (make-obsolete 'read-no-blanks-input 'read-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (make-obsolete 'declare-buffer-specific 'make-variable-buffer-local)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (make-obsolete '>> 'lsh)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (make-obsolete 'novalue 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (make-obsolete 'define-keymap "use (fset 'symbol (make-keymap))")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (make-obsolete 'local-bind-to-key 'local-set-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (make-obsolete 'bind-to-key 'global-set-key)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (make-obsolete 'to-col 'indent-to)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (make-obsolete 'is-bound 'boundp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (make-obsolete 'declare-global 'defvar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (make-obsolete 'error-occurred 'condition-case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (make-obsolete 'set-auto-fill-hook "set variable auto-fill-function instead")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (make-obsolete 'auto-execute "set variable auto-mode-alist instead")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (make-obsolete 'move-to-comment-column "use (indent-to comment-column)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (make-obsolete 'erase-region 'delete-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (make-obsolete 'delete-region-to-buffer "use copy-to-buffer and delete-region")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (make-obsolete 'copy-region-to-buffer 'copy-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (make-obsolete 'append-region-to-buffer 'append-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (make-obsolete 'prepend-region-to-buffer 'prepend-to-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (make-obsolete 'delete-next-character 'delete-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (make-obsolete 'forward-character 'forward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (make-obsolete 'backward-character 'backward-char)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (make-obsolete 'delete-to-kill-buffer 'kill-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (make-obsolete 'narrow-region 'narrow-to-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (make-obsolete 'newline-and-backup 'open-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (make-obsolete 'quote-char 'quoted-insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (make-obsolete 'region-to-string 'buffer-substring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (make-obsolete 'define-hooked-local-abbrev 'define-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (make-obsolete 'define-hooked-global-abbrev 'define-abbrev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (make-obsolete 'filter-region 'call-process-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (make-obsolete 'execute-monitor-command 'call-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (make-obsolete 'use-syntax-table 'set-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (make-obsolete 'line-to-top-of-window 'recenter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (make-obsolete 'insert-string 'insert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (provide 'mlsupport)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;;; mlsupport.el ends here