diff options
| author | Stefan Monnier | 2001-11-28 04:03:53 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2001-11-28 04:03:53 +0000 |
| commit | aa3b4ded23a702a250ca209f603edd92d2f395a5 (patch) | |
| tree | 4425bc2b0109610c9152c96f17d5bcf722713ce1 | |
| parent | 5faa1e9c9f8b19e305526d5108ea855edd7108bc (diff) | |
| download | emacs-aa3b4ded23a702a250ca209f603edd92d2f395a5.tar.gz emacs-aa3b4ded23a702a250ca209f603edd92d2f395a5.zip | |
(copy-overlay, remove-overlays): New funs.
| -rw-r--r-- | lisp/subr.el | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index b4203fd7371..3125a577fd2 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -993,7 +993,7 @@ 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; |
| @@ -1037,6 +1037,41 @@ If MESSAGE is nil, instructions to type EXIT-CHAR are displayed there." | |||
| 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. |