comparison lisp/subr.el @ 41618:812e52cc5162

(copy-overlay, remove-overlays): New funs.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Wed, 28 Nov 2001 04:03:53 +0000
parents f3b21013637a
children 241e553840f9
comparison
equal deleted inserted replaced
41617:fde712c2fd73 41618:812e52cc5162
991 "Force the mode-line of the current buffer to be redisplayed. 991 "Force the mode-line of the current buffer to be redisplayed.
992 With optional non-nil ALL, force redisplay of all mode-lines." 992 With optional non-nil ALL, force redisplay of all mode-lines."
993 (if all (save-excursion (set-buffer (other-buffer)))) 993 (if all (save-excursion (set-buffer (other-buffer))))
994 (set-buffer-modified-p (buffer-modified-p))) 994 (set-buffer-modified-p (buffer-modified-p)))
995 995
996 (defun momentary-string-display (string pos &optional exit-char message) 996 (defun momentary-string-display (string pos &optional exit-char message)
997 "Momentarily display STRING in the buffer at POS. 997 "Momentarily display STRING in the buffer at POS.
998 Display remains until next character is typed. 998 Display remains until next character is typed.
999 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed; 999 If the char is EXIT-CHAR (optional third arg, default is SPC) it is swallowed;
1000 otherwise it is then available as input (as a command if nothing else). 1000 otherwise it is then available as input (as a command if nothing else).
1001 Display MESSAGE (optional fourth arg) in the echo area. 1001 Display MESSAGE (optional fourth arg) in the echo area.
1035 (delete-region pos insert-end))) 1035 (delete-region pos insert-end)))
1036 (setq buffer-file-name name) 1036 (setq buffer-file-name name)
1037 (set-buffer-modified-p modified)))) 1037 (set-buffer-modified-p modified))))
1038 1038
1039 1039
1040 ;;;; Overlay operations
1041
1042 (defun copy-overlay (o)
1043 "Return a copy of overlay O."
1044 (let ((o1 (make-overlay (overlay-start o) (overlay-end o)
1045 ;; FIXME: there's no easy way to find the
1046 ;; insertion-type of the two markers.
1047 (overlay-buffer o)))
1048 (props (overlay-properties o)))
1049 (while props
1050 (overlay-put o1 (pop props) (pop props)))
1051 o1))
1052
1053 (defun remove-overlays (beg end name val)
1054 "Clear BEG and END of overlays whose property NAME has value VAL.
1055 Overlays might be moved and or split."
1056 (if (< end beg)
1057 (setq beg (prog1 end (setq end beg))))
1058 (save-excursion
1059 (dolist (o (overlays-in beg end))
1060 (when (eq (overlay-get o name) val)
1061 ;; Either push this overlay outside beg...end
1062 ;; or split it to exclude beg...end
1063 ;; or delete it entirely (if it is contained in beg...end).
1064 (if (< (overlay-start o) beg)
1065 (if (> (overlay-end o) end)
1066 (progn
1067 (move-overlay (copy-overlay o)
1068 (overlay-start o) beg)
1069 (move-overlay o end (overlay-end o)))
1070 (move-overlay o (overlay-start o) beg))
1071 (if (> (overlay-end o) end)
1072 (move-overlay o end (overlay-end o))
1073 (delete-overlay o)))))))
1074
1040 ;;;; Miscellanea. 1075 ;;;; Miscellanea.
1041 1076
1042 ;; A number of major modes set this locally. 1077 ;; A number of major modes set this locally.
1043 ;; Give it a global value to avoid compiler warnings. 1078 ;; Give it a global value to avoid compiler warnings.
1044 (defvar font-lock-defaults nil) 1079 (defvar font-lock-defaults nil)