GNU bug report logs - #35718
26.2; Functions in yank-handled-properties ALWAYS get called

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Xu Chunyang <mail@HIDDEN>; dated Mon, 13 May 2019 17:18:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 35718 <at> debbugs.gnu.org:


Received: (at 35718) by debbugs.gnu.org; 7 Jun 2019 13:04:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 07 09:04:09 2019
Received: from localhost ([127.0.0.1]:51525 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hZEXR-0003ad-8a
	for submit <at> debbugs.gnu.org; Fri, 07 Jun 2019 09:04:09 -0400
Received: from mail-it1-f173.google.com ([209.85.166.173]:50291)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <npostavs@HIDDEN>) id 1hZEXP-0003aN-Lh
 for 35718 <at> debbugs.gnu.org; Fri, 07 Jun 2019 09:04:08 -0400
Received: by mail-it1-f173.google.com with SMTP id a186so2567668itg.0
 for <35718 <at> debbugs.gnu.org>; Fri, 07 Jun 2019 06:04:07 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:cc:subject:references:date:in-reply-to:message-id
 :user-agent:mime-version;
 bh=4IasoY6OukO9HFq9ORSRY5Xi2zzMJljY86iOxwGM51U=;
 b=n+kkYL97gbcBBiKTY4S14+n5wNfiLkIvMfO1qG4REes6KX2astyu9ypihIn5773Dwu
 F616PTpyrx8LbzjlcFlU25H0qKtWDxynV2F+IKOua7ZuovcLZUukWAbP3ix+FkT0oABK
 BhgtnWJwoQt9+c5nt7yGcgFM8DDYRvus5kuz6p1dCgN2cta50Gnp22jyd+NFrWJYmd/5
 bvsjqe+nuxoZcpsF3e2eE6PWevdcWLxGuVmf9kLnx7U9Z+ZhrOXUCp72nbNDbhFv4vUW
 rVv3u/Nx2Q8LMbf1s9CVweRZ5Srsly21lRpwe0tUHdWYKNUv3ZX8B5yewHpYfzWQtD4j
 E/9Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to
 :message-id:user-agent:mime-version;
 bh=4IasoY6OukO9HFq9ORSRY5Xi2zzMJljY86iOxwGM51U=;
 b=Blp/Pa3LZSJnFkiL4c5E2wyJtPxrhYvW4nIt0wZtLbQi78mJzn2wN9BJKqyct/cZI3
 VD0nwk+UEu0jdpp0yyt/Ots2m3kSW+aarCL+jYgPPP1IZKaDec94j5JqVe5nZXRHPdR5
 UwXAl4TdqEVht9aqwFCjNrUdw/FSVG19EVZloNYjq/cwdE2h5fCkwilyS6S+ZUgU/2Nw
 5aTGovvsZYu9EGUHTyUyPsU1eQC67nZ0fD1tsVrWrmF+wvvQt5pC4yDIT5ace2etKs0c
 APzT5pP6sjWC233wID8BgHITdSSYhPUdXdRNgBjxpBSRhSeyt4zIN8crFKYc/nX6uqi1
 irrw==
X-Gm-Message-State: APjAAAX7AZi4g8iHbzYgXylGQwSExc1MjBQWkuAa05CwOoRHHpUNLUJR
 9dS2wkC6tuUkr62ZiNpe5YeMVG/p
X-Google-Smtp-Source: APXvYqy8mDBODpYvFrSZJR+F2McDyuXkxrMzU+8d55eEiv509ujiHEINMxha2vl1DrktG1nuaZ4DfA==
X-Received: by 2002:a24:d209:: with SMTP id z9mr3822841itf.1.1559912641429;
 Fri, 07 Jun 2019 06:04:01 -0700 (PDT)
Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34])
 by smtp.gmail.com with ESMTPSA id
 f14sm786667itb.31.2019.06.07.06.04.00
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Fri, 07 Jun 2019 06:04:00 -0700 (PDT)
From: Noam Postavsky <npostavs@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#35718: 26.2;
 Functions in yank-handled-properties ALWAYS get called
References: <m2zhnqnv8s.fsf@HIDDEN> <838sudrbit.fsf@HIDDEN>
Date: Fri, 07 Jun 2019 09:03:59 -0400
In-Reply-To: <838sudrbit.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 07 Jun
 2019 12:27:06 +0300")
Message-ID: <871s0535ts.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 35718
Cc: Xu Chunyang <mail@HIDDEN>, 35718 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


>> 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.

I think the question is more about whether we distinguish between an
absent property, and a property whose value is nil
(remove-yank-excluded-properties currently does not, which is what I
think this bug report is complaining about).  The manual doesn't say
either way, but text-property-any (and other property checking
functions) seem to treat them the same as well:

(text-property-any 0 2 'xxx nil (propertize "foo" 'xxx nil)) ;=> 0
(text-property-any 0 2 'xxx nil (propertize "foo" 'xxx t)) ;=> nil
(text-property-any 0 2 'xxx nil "foo") ;=> 0





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35718; Package emacs. Full text available.

Message received at 35718 <at> debbugs.gnu.org:


Received: (at 35718) by debbugs.gnu.org; 7 Jun 2019 09:27:30 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jun 07 05:27:30 2019
Received: from localhost ([127.0.0.1]:51388 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hZB9l-0000Ea-MY
	for submit <at> debbugs.gnu.org; Fri, 07 Jun 2019 05:27:29 -0400
Received: from eggs.gnu.org ([209.51.188.92]:43212)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1hZB9k-0000EL-7K
 for 35718 <at> debbugs.gnu.org; Fri, 07 Jun 2019 05:27:28 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:34009)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1hZB9e-0004GX-Vv; Fri, 07 Jun 2019 05:27:23 -0400
Received: from [176.228.60.248] (port=4450 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1hZB9Z-00014n-6d; Fri, 07 Jun 2019 05:27:20 -0400
Date: Fri, 07 Jun 2019 12:27:06 +0300
Message-Id: <838sudrbit.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Xu Chunyang <mail@HIDDEN>
In-reply-to: <m2zhnqnv8s.fsf@HIDDEN> (message from Xu Chunyang on Tue, 
 14 May 2019 01:02:11 +0800)
Subject: Re: bug#35718: 26.2;
 Functions in yank-handled-properties ALWAYS get called
References: <m2zhnqnv8s.fsf@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 35718
Cc: 35718 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Xu Chunyang <mail@HIDDEN>
> 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.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#35718; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 13 May 2019 17:17:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon May 13 13:17:26 2019
Received: from localhost ([127.0.0.1]:46038 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hQEZq-0001XA-Ip
	for submit <at> debbugs.gnu.org; Mon, 13 May 2019 13:17:26 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56552)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mail@HIDDEN>) id 1hQEZm-0001Ws-Vc
 for submit <at> debbugs.gnu.org; Mon, 13 May 2019 13:17:23 -0400
Received: from lists.gnu.org ([209.51.188.17]:44795)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <mail@HIDDEN>) id 1hQEZh-0004Hs-Li
 for submit <at> debbugs.gnu.org; Mon, 13 May 2019 13:17:17 -0400
Received: from eggs.gnu.org ([209.51.188.92]:42624)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <mail@HIDDEN>) id 1hQEZe-0006mF-8R
 for bug-gnu-emacs@HIDDEN; Mon, 13 May 2019 13:17:17 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_50,RCVD_IN_DNSWL_LOW,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <mail@HIDDEN>) id 1hQELQ-00062D-Pz
 for bug-gnu-emacs@HIDDEN; Mon, 13 May 2019 13:02:34 -0400
Received: from wout3-smtp.messagingengine.com ([64.147.123.19]:47687)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <mail@HIDDEN>) id 1hQELK-0005rn-MT
 for bug-gnu-emacs@HIDDEN; Mon, 13 May 2019 13:02:29 -0400
Received: from compute6.internal (compute6.nyi.internal [10.202.2.46])
 by mailout.west.internal (Postfix) with ESMTP id 238D452D
 for <bug-gnu-emacs@HIDDEN>; Mon, 13 May 2019 13:02:18 -0400 (EDT)
Received: from mailfrontend2 ([10.202.2.163])
 by compute6.internal (MEProxy); Mon, 13 May 2019 13:02:18 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xuchunyang.me;
 h=from:to:subject:date:message-id:mime-version:content-type; s=
 fm1; bh=djqKb6nDIFAkufvULmzR+Gy2MCkl44+vFx8nU/iFucM=; b=bL3K/eR7
 xBfMmKpypunPIIvW/p7wopet7xNCRIaQ0IBvGtTdBsSOvQgCXWHqs8FVCIKHB/SG
 tpQPtBPKBPVqcP9Mgjq1lhSLWnsY5bq9qmfi6JVhuBVcCLwnW+8TOaXfsKXs/s7K
 kIB4k92LMft+rZuCnp3sD0CqrENDpYnsJkRVHS2Zm9A7yrFQjv5w39bgnRBdShyM
 y/Dt5oLJFNhTPkmtJZ5LFUkY1pbgIhcBJJ/tajYbhDkppczP+tfccv/CcfH/gor7
 FZ47meeISQ7nDW1vvOh9NsT9dCjbBDZfLe0FD0XLBj2AcNpUgPHWA9pvSKL+y63A
 WEb4jHVbOz0vFA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=content-type:date:from:message-id
 :mime-version:subject:to:x-me-proxy:x-me-proxy:x-me-sender
 :x-me-sender:x-sasl-enc; s=fm2; bh=djqKb6nDIFAkufvULmzR+Gy2MCkl4
 4+vFx8nU/iFucM=; b=bj2+Derl3NZBpjW77zKej1pkYaaYyW/quUh3AfnhPLefN
 QT1nYMWKy9YMECiQDJQWpQcFwdgG+Kne/+FR59iFZarhaLnrDXRaAzBXcUMNkvqo
 lIikFaVi5roCu0qNZ3e8TBNtNHwoJX5l0WQXnqK7nv3pgyo58K9AVQjxFMUi1ILi
 AC9bYA3vCE6jDcv2WiERIfNq1ZUJcq8uwDUMMM4QFXWdXO4S7XnIQRxsHwII6jcr
 ZxGqcJt0KV/yZPxv8RWs860YgEjF6o+5URGyeQlJAkun4oVIQwzcfTnyAjcnriUR
 kfUUDRW6JuefoGTUrODSo9lTuAiA2rn9TtOiYWyhg==
X-ME-Sender: <xms:GaPZXNm_WaDRYW09NLTXJhOVeqqtF91dOeXfMsGX4Mvjlp1JgVglmg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrleeggddutdekucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufgffkfggtgesthdtredttd
 ertdenucfhrhhomhepighuucevhhhunhihrghnghcuoehmrghilhesgihutghhuhhnhigr
 nhhgrdhmvgeqnecukfhppeduudejrdelfedrvddttddrvdeinecurfgrrhgrmhepmhgrih
 hlfhhrohhmpehmrghilhesgihutghhuhhnhigrnhhgrdhmvgenucevlhhushhtvghrufhi
 iigvpedt
X-ME-Proxy: <xmx:GaPZXGrRPSEDKExYP1fUZVCYmmugiRhSZRwQ5MdeyBAa86TAvxKiCg>
 <xmx:GaPZXF_kJdLM1rglRM25x4fZAUrcaRkARy9qr2z9pxhWJ2MOAvJohQ>
 <xmx:GaPZXAy2lgacbT2DqoS0WTvIWCyKkcLPnZt1Xagwe3LIRV8MvJIiXg>
 <xmx:GaPZXFc1rMBbv1qrj3dBJEO3lzn3ze5aPVwgoXFnm14ktkWtXsGflw>
Received: from Chunyangs-MacBook-Air.local (unknown [117.93.200.26])
 by mail.messagingengine.com (Postfix) with ESMTPA id AFD5F103D0
 for <bug-gnu-emacs@HIDDEN>; Mon, 13 May 2019 13:02:15 -0400 (EDT)
From: Xu Chunyang <mail@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 26.2; Functions in yank-handled-properties ALWAYS get called
User-Agent: Emacs/26.2 using message.el and smtpmail.el
Date: Tue, 14 May 2019 01:02:11 +0800
Message-ID: <m2zhnqnv8s.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 64.147.123.19
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

Hi,

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)))


--
In GNU Emacs 26.2 (build 1, x86_64-apple-darwin18.5.0, Carbon Version 158 AppKit 1671.4)
 of 2019-04-20 built on Chunyangs-MacBook-Air.local
Repository revision: d21490f428a6baf568ad0669425b4a7b39a6bd73
Windowing system distributor 'Apple Inc.', version 10.14.4




Acknowledgement sent to Xu Chunyang <mail@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#35718; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.