bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#35718: 26.2; Functions in yank-handled-properties ALWAYS get called


From: Eli Zaretskii
Subject: bug#35718: 26.2; Functions in yank-handled-properties ALWAYS get called
Date: Fri, 07 Jun 2019 12:27:06 +0300

> From: Xu Chunyang <mail@xuchunyang.me>
> Date: Tue, 14 May 2019 01:02:11 +0800
> 
> I want to change how image is pasted (e.g., save the image to disk and
> insert a markdown image link). When I play with yank-handled-properties:
> 
>     (add-to-list 'yank-handled-properties '(image . foo))
>     
>     (defun foo (image beg end)
>       (message "=> %S %S %S" image beg end))
> 
> However, the function foo is always called even there is no image at
> all. This is unexpected since the function should only be called when
> the property 'image is found according to the documentation:
> 
>     When the `yank' command inserts text into the buffer, it scans the
>     inserted text for stretches of text that have `eq' values of the text
>     property PROP; for each such stretch of text, FUN is called with three
>     arguments...
> 
> The function is called inside remove-yank-excluded-properties, however
> FUN is always called no matter what PROP is:
> 
>     (while (< run-start end)
>       (let ((value (get-text-property run-start prop))
>             (run-end (next-single-property-change
>                       run-start prop nil end)))
>         (funcall fun value run-start run-end)
>         (setq run-start run-end)))

The above code actually calls the handler function whenever PROP's
value _changes_, not just where PROP is non-nil.  Not sure if this is
a bug or a feature; opinions welcome.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]