summaryrefslogtreecommitdiff
path: root/lisp/subr.el
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>2006-09-28 19:06:39 +0000
committerRichard M. Stallman <rms@gnu.org>2006-09-28 19:06:39 +0000
commit5de851afdc5d6491a948451bc9aa411da2a00186 (patch)
tree6ed49bc1efe7a6a21c497935a2475681a7131424 /lisp/subr.el
parente711f732bc8386a50539d8e528e3f93d763d3320 (diff)
downloademacs-5de851afdc5d6491a948451bc9aa411da2a00186.tar.gz
(insert-for-yank-1): Handle `font-lock-face' specially.
Diffstat (limited to 'lisp/subr.el')
-rw-r--r--lisp/subr.el23
1 files changed, 22 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 45decd63924..6668f6423d6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2167,11 +2167,32 @@ If UNDO is present and non-nil, it is a function that will be called
(let* ((handler (and (stringp string)
(get-text-property 0 'yank-handler string)))
(param (or (nth 1 handler) string))
- (opoint (point)))
+ (opoint (point))
+ end)
+
(setq yank-undo-function t)
(if (nth 0 handler) ;; FUNCTION
(funcall (car handler) param)
(insert param))
+ (setq end (point))
+
+ ;; What should we do with `font-lock-face' properties?
+ (if font-lock-defaults
+ ;; No, just wipe them.
+ (remove-list-of-text-properties opoint end '(font-lock-face))
+ ;; Convert them to `face'.
+ (save-excursion
+ (goto-char opoint)
+ (while (< (point) end)
+ (let ((face (get-text-property (point) 'font-lock-face))
+ run-end)
+ (setq run-end
+ (next-single-property-change (point) 'font-lock-face nil end))
+ (when face
+ (remove-text-properties (point) run-end '(font-lock-face nil))
+ (put-text-property (point) run-end 'face face))
+ (goto-char run-end)))))
+
(unless (nth 2 handler) ;; NOEXCLUDE
(remove-yank-excluded-properties opoint (point)))
(if (eq yank-undo-function t) ;; not set by FUNCTION