annotate lisp/emulators/mlsupport.el @ 0:376386a54a3c r19-14

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