annotate lisp/hm--html-menus/adapt.el @ 46:6a22abad6937 r19-15

Import from CVS: tag r19-15
author cvs
date Mon, 13 Aug 2007 08:55:31 +0200
parents 8fc7fe29b841
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
1 ;;; $Id: adapt.el,v 1.3 1997/03/26 22:42:37 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
3 ;;; Copyright (C) 1993 - 1997 Heiko Muenkel
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;; email: muenkel@tnt.uni-hannover.de
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; Description:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;;
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
23 ;;; General functions to port XEmacs functions to GNU Emacs 19.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;; Installation:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Put this file in one of your lisp load directories.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 (defun adapt-xemacsp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 "Returns non nil if the editor is the XEmacs."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (or (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (string-match "XEmacs" emacs-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (defun adapt-lemacsp ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 "Returns non nil if the editor is the XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 Old version, use `adapt-xemacsp' instead of this."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 (or (string-match "Lucid" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (string-match "XEmacs" emacs-version)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 (defun adapt-emacs19p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 "Returns non nil if the editor is the GNU Emacs 19."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (not (adapt-xemacsp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (string= (substring emacs-version 0 2) "19")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
50 ;;; Functions, which don't exist in both emacs versions
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (defun adapt-region-active-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 "Returns t, if a region is active."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (if (adapt-xemacsp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 mark-active))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
58 (if (not (fboundp 'file-remote-p))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
59 (defun file-remote-p (file)
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
60 "Test wether file resides on the local system.
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
61 The special value 'unknown is returned if no remote file acess package
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
62 has been loaded."
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
63 (if (not (featurep 'ange-ftp))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
64 (require 'ange-ftp))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
65 (if (not (fboundp 'ange-ftp-ftp-p))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
66 nil ; better than nothing, if no ange-ftp-ftp-p exists
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
67 (ange-ftp-ftp-path file))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
69
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
70 ;;; Functions, which don't exist in the Emacs 19
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (if (adapt-emacs19p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (load-library "lucid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (load-library "lmenu")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (if window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (require 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (make-face 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (defun read-number (prompt &optional integers-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 "Reads a number from the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (let ((error t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (number nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (if integers-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (while error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (let ((input-string (read-string prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 (setq number (if (string= "" input-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (read input-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 (if (integerp number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (setq error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (while error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (let ((input-string (read-string prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (setq number (if (string= "" input-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (read input-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 (if (numberp number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (setq error nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defvar original-read-string-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 "Points to the original Emacs 19 function read-string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (if (not original-read-string-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (fset 'original-read-string-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (symbol-function 'read-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defun read-string (prompt &optional initial-contents history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 "Return a string from the minibuffer, prompting with string PROMPT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 If non-nil, optional second arg INITIAL-CONTENTS is a string to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 in the minibuffer before reading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Third arg HISTORY, if non-nil, specifies a history list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (read-from-minibuffer prompt initial-contents nil nil history))
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 make-extent (beg end &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (make-overlay beg end buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defun set-extent-property (extent prop value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (if (eq prop 'duplicable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (cond ((and value (not (overlay-get extent prop)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; If becoming duplicable,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; copy all overlay props to text props.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (add-text-properties (overlay-start extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (overlay-end extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (overlay-properties extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (overlay-buffer extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; If becoming no longer duplicable, remove these text props.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ((and (not value) (overlay-get extent prop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (remove-text-properties (overlay-start extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (overlay-end extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (overlay-properties extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (overlay-buffer extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; If extent is already duplicable, put this property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;; on the text as well as on the overlay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (if (overlay-get extent 'duplicable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (put-text-property (overlay-start extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (overlay-end extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 prop value (overlay-buffer extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (overlay-put extent prop value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defun set-extent-face (extent face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (set-extent-property extent 'face face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (defun delete-extent (extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (set-extent-property extent 'duplicable nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (delete-overlay extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ; (defun make-extent (from to &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ; "Make extent for range [FROM, TO) in BUFFER -- BUFFER defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;current buffer. Insertions at point TO will be outside of the extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;insertions at FROM will be inside the extent (and the extent will grow.).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;This is only a simple emulation of the Lucid Emacs extents !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ; (list 'extent from to buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ; (defun set-extent-face (extent face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ; "Make the given EXTENT have the graphic attributes specified by FACE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;This is only a simple emulation of the Lucid Emacs extents !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ; (put-text-property (car (cdr extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ; (car (cdr (cdr extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ; 'face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ; face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ; (car (cdr (cdr (cdr extent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ; (defun delete-extent (extent_obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ; "Remove EXTENT from its buffer; this does not modify the buffer's text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;only its display properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;This is only a simple emulation of the Lucid Emacs extents !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ; (remove-text-properties (car (cdr extent_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ; (car (cdr (cdr extent_obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ; (list 'face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ; (car (cdr (cdr (cdr extent_obj))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (if (not (fboundp 'emacs-pid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defun emacs-pid ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 "Return the process ID of Emacs, as an integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 This is a dummy function for old versions of the Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 You should install a new version, which has `emacs-pid' implemented."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (not (fboundp 'facep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defun facep (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Whether OBJECT is a FACE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 It's only a dummy function in the Emacs 19, which returns always nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ; (if (not (fboundp 'set-extent-property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ; (defun set-extent-property (extent property value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ; "Change a property of an extent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;Only a dummy version in Emacs 19."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
197 (if (not (fboundp 'region-active-p))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 (defun region-active-p ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
199 "Non-nil iff the region is active.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 If `zmacs-regions' is true, this is equivalent to `region-exists-p'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
201 Otherwise, this function always returns false."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
202 (adapt-region-active-p)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 (if (not (fboundp 'next-command-event))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 (defun next-command-event (&optional event prompt)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 "Unlike the XEmacs version it reads the next event, if
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207 it is a command event or not.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
208
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
209 Return the next available \"user\" event.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 Pass this object to `dispatch-event' to handle it.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 If EVENT is non-nil, it should be an event object and will be filled in
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213 and returned; otherwise a new event object will be created and returned.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 If PROMPT is non-nil, it should be a string and will be displayed in the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
215 echo area while this function is waiting for an event.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
216
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
217 The event returned will be a keyboard, mouse press, or mouse release event.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
218 If there are non-command events available (mouse motion, sub-process output,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
219 etc) then these will be executed (with `dispatch-event') and discarded. This
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
220 function is provided as a convenience; it is equivalent to the lisp code
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
221
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
222 (while (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
223 (next-event event prompt)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
224 (not (or (key-press-event-p event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
225 (button-press-event-p event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
226 (button-release-event-p event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
227 (misc-user-event-p event))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
228 (dispatch-event event))"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
229 (message prompt)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
230 (or event
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
231 (read-event))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
232
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
233 (if (not (fboundp 'button-event-p))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
234 (defun button-event-p (obj)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
235 "True if OBJ is a button-press or button-release event object."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
236 (and (eventp obj)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
237 (or (eq 'mouse-1 (event-basic-type obj))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
238 (eq 'mouse-2 (event-basic-type obj))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
239 (eq 'mouse-3 (event-basic-type obj))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
240
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
241 (if (not (fboundp 'button-press-event-p))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
242 (defun button-press-event-p (obj)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
243 "True if OBJ is a mouse-button-press event object."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
244 (and (button-event-p obj)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
245 (member 'down (event-modifiers obj)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
246
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
247 (if (not (fboundp 'button-release-event-p))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
248 (defun button-release-event-p (obj)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
249 "True if OBJ is a mouse-button-release event object."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
250 (and (button-event-p obj)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
251 (not (button-press-event-p obj)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
252
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
253 (if (not (fboundp 'button-click-event-p))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
254 (defun button-click-event-p (obj)
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
255 "True if OBJ is a click event obkect."
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
256 ;; only for the Emacs 19
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
257 ;; doesn't exist and can't (?) exist in the XEmacs
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
258 (and (button-event-p obj)
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
259 (member 'click (event-modifiers obj)))))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
260
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
261 (if (not (fboundp 'mouse-event-p))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
262 (defun mouse-event-p (obj)
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
263 "True if OBJ is a button-press, button-release, or mouse-motion event object."
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
264 (or (button-event-p obj)
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
265 (member 'drag (event-modifiers obj)))))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
266
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
267 (if (not (fboundp 'event-window))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
268 (defun event-window (event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
269 "Return the window of the given mouse event.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
270 This may be nil if the event occurred in the border or over a toolbar.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
271 The modeline is considered to be in the window it represents."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
272 (and (eventp event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
273 (listp event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
274 (listp (cdr event))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
275 (listp (car (cdr event)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
276 (car (car (cdr event))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
277
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
278 (if (not (fboundp 'event-buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
279 (defun event-buffer (event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
280 "Given a mouse-motion, button-press, or button-release event, return
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
281 the buffer on which that event occurred. This will be nil for non-mouse
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
282 events. If event-over-text-area-p is nil, this will also be nil."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
283 (if (button-event-p event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
284 (window-buffer (event-window event)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
285
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
286
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
287 (if (not (fboundp 'event-closest-point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
288 (defun event-closest-point (event)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
289 "Return the character position of the given mouse event.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
290 If the event did not occur over a window or over text, return the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
291 closest point to the location of the event. If the Y pixel position
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
292 overlaps a window and the X pixel position is to the left of that
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
293 window, the closest point is the beginning of the line containing the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
294 Y position. If the Y pixel position overlaps a window and the X pixel
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
295 position is to the right of that window, the closest point is the end
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
296 of the line containing the Y position. If the Y pixel position is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
297 above a window, return 0. If it is below a window, return the value
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
298 of (window-end)."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
299 (posn-point (event-start event))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
300
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
301 (if (not (fboundp 'add-minor-mode))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
302 (defun add-minor-mode (toggle
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
303 name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
304 &optional
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
305 keymap
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
306 after
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
307 toggle-fun)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
308 "Add a minor mode to `minor-mode-alist' and `minor-mode-map-alist'.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
309 TOGGLE is a symbol whose value as a variable specifies whether the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
310 minor mode is active. NAME is the name that should appear in the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
311 modeline (it should be a string beginning with a space). KEYMAP is a
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
312 keymap to make active when the minor mode is active. AFTER is the
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
313 toggling symbol used for another minor mode. If AFTER is non-nil,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
314 then it is used to position the new mode in the minor-mode alists.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
315
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
316 TOGGLE-FUN is only a dummy variable in the Emacs 19. In the XEmacs
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
317 it has the following description:
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
318 TOGGLE-FUN specifies an interactive function that is called to toggle
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
319 the mode on and off; this affects what happens when button2 is pressed
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
320 on the mode, and when button3 is pressed somewhere in the list of
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
321 modes. If TOGGLE-FUN is nil and TOGGLE names an interactive function,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
322 TOGGLE is used as the toggle function.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
323
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
324 Example: (add-minor-mode 'view-minor-mode \" View\" view-mode-map)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
325
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
326 WARNING: THIS FUNCTION ISN'T READ YET."
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
327 (if after
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
328 (add-minor-mode-1 toggle name keymap after)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
329 (if (not (assq toggle minor-mode-alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
330 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
331 (setq minor-mode-alist
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
332 (cons (list toggle name)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
333 minor-mode-alist))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
334 (if (not (assq toggle minor-mode-map-alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
335 (progn
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
336 (setq minor-mode-map-alist
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
337 (cons (cons toggle keymap)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
338 minor-mode-map-alist))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
339 ))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
340 )
22
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 2
diff changeset
341
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 2
diff changeset
342 (if (not (fboundp 'redraw-modeline))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 2
diff changeset
343 (defalias 'redraw-modeline 'force-mode-line-update))
8fc7fe29b841 Import from CVS: tag r19-15b94
cvs
parents: 2
diff changeset
344
46
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
345 (if (not (fboundp 'mouse-track))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
346 (defalias 'mouse-track 'mouse-drag-region))
6a22abad6937 Import from CVS: tag r19-15
cvs
parents: 22
diff changeset
347
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
349
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (provide 'adapt)