annotate lisp/hm--html-menus/adapt.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; $Id: adapt.el,v 1.1.1.1 1996/12/18 03:34:31 steve Exp $
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1993, 1994, 1995 Heiko Muenkel
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 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;; General functions to port Lucid Emacs to GNU Emacs 19.
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;; Functions, which doesn't exist in both emacses
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (if (adapt-emacs19p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (load-library "lucid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (load-library "lmenu")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if window-system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (require 'font-lock)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (make-face 'font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (defun read-number (prompt &optional integers-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 "Reads a number from the minibuffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (let ((error t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (number nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (if integers-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (while error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (let ((input-string (read-string prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (setq number (if (string= "" input-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (read input-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (if (integerp number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (setq error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (while error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (let ((input-string (read-string prompt)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (setq number (if (string= "" input-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 (read input-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 (if (numberp number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (setq error nil)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 number))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defvar original-read-string-function nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Points to the original Emacs 19 function read-string.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (if (not original-read-string-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 (fset 'original-read-string-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (symbol-function 'read-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defun read-string (prompt &optional initial-contents history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "Return a string from the minibuffer, prompting with string PROMPT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 If non-nil, optional second arg INITIAL-CONTENTS is a string to insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 in the minibuffer before reading.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 Third arg HISTORY, if non-nil, specifies a history list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (read-from-minibuffer prompt initial-contents nil nil history))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun make-extent (beg end &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (make-overlay beg end buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defun set-extent-property (extent prop value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 (if (eq prop 'duplicable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (cond ((and value (not (overlay-get extent prop)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; If becoming duplicable,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; copy all overlay props to text props.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (add-text-properties (overlay-start extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (overlay-end extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (overlay-properties extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (overlay-buffer extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; If becoming no longer duplicable, remove these text props.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ((and (not value) (overlay-get extent prop))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (remove-text-properties (overlay-start extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (overlay-end extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (overlay-properties extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (overlay-buffer extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; If extent is already duplicable, put this property
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; on the text as well as on the overlay.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (if (overlay-get extent 'duplicable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (put-text-property (overlay-start extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (overlay-end extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 prop value (overlay-buffer extent))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (overlay-put extent prop value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (defun set-extent-face (extent face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (set-extent-property extent 'face face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defun delete-extent (extent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (set-extent-property extent 'duplicable nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (delete-overlay extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ; (defun make-extent (from to &optional buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ; "Make extent for range [FROM, TO) in BUFFER -- BUFFER defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;current buffer. Insertions at point TO will be outside of the extent;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;insertions at FROM will be inside the extent (and the extent will grow.).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;This is only a simple emulation of the Lucid Emacs extents !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ; (list 'extent from to buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ; (defun set-extent-face (extent face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ; "Make the given EXTENT have the graphic attributes specified by FACE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;This is only a simple emulation of the Lucid Emacs extents !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ; (put-text-property (car (cdr extent))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ; (car (cdr (cdr extent)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ; 'face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ; face
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ; (car (cdr (cdr (cdr extent))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ; (defun delete-extent (extent_obj)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ; "Remove EXTENT from its buffer; this does not modify the buffer's text,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;only its display properties.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;This is only a simple emulation of the Lucid Emacs extents !"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ; (remove-text-properties (car (cdr extent_obj))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ; (car (cdr (cdr extent_obj)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ; (list 'face nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ; (car (cdr (cdr (cdr extent_obj))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (if (not (fboundp 'emacs-pid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (defun emacs-pid ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 "Return the process ID of Emacs, as an integer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 This is a dummy function for old versions of the Emacs 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 You should install a new version, which has `emacs-pid' implemented."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (if (not (fboundp 'facep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (defun facep (object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "Whether OBJECT is a FACE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 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
178 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ; (if (not (fboundp 'set-extent-property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ; (defun set-extent-property (extent property value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ; "Change a property of an extent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;Only a dummy version in Emacs 19."))
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (provide 'adapt)