[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
display property strangeness
From: |
Chong Yidong |
Subject: |
display property strangeness |
Date: |
Sat, 12 Mar 2005 06:22:38 -0800 |
This is a strange one. Evaluate the following two functions. Both of
them should do the same thing: replace each of the first 3 letters in
the buffer with the letter "A".
(defun foo ()
(interactive)
(let ((pos '(1 2 3)))
(while pos
(put-text-property (car pos) (1+ (car pos)) 'display "A")
(setq pos (cdr pos)))))
(defun bar ()
(interactive)
(progn (put-text-property 1 2 'display "A")
(put-text-property 2 3 'display "A")
(put-text-property 3 4 'display "A")))
The amazing thing is that the first one doesn't work. Open up a new,
empty buffer and enter the string
12345
Type M-x foo. You end up with
A45
Now undo that, and type M-x bar. That gives you the correct result:
AAA45
Why does the first function give nonsensical results?
- display property strangeness,
Chong Yidong <=