annotate lisp/obsolete/mlsupport.el @ 89905:37e044cc35f6

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