GNU bug report logs - #56837
28.1.90; `current-indentation' sometimes returns zero inside invisible text

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: Ihor Radchenko <yantar92@HIDDEN>; merged with #56838, #60692; dated Sat, 30 Jul 2022 07:57:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Forcibly Merged 56837 56838 60692. Request was from Juri Linkov <juri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 56837) by debbugs.gnu.org; 31 Jul 2022 08:13:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jul 31 04:13:12 2022
Received: from localhost ([127.0.0.1]:36340 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oI44V-0005tO-Ra
	for submit <at> debbugs.gnu.org; Sun, 31 Jul 2022 04:13:12 -0400
Received: from quimby.gnus.org ([95.216.78.240]:33418)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1oI44Q-0005sp-6P
 for 56837 <at> debbugs.gnu.org; Sun, 31 Jul 2022 04:13:09 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:Date:References:
 In-Reply-To:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=wK4xeEv9QAIh8vw0+2oF9J3z+mYjTpuDlXBWQIOtlcM=; b=q0cev7HnPkfqZq9TClQzmKxeOU
 /dt8nClTKi/Wu6oPLdIE0+oHJo2+XKivcs9tSMohFNwpBoL/OlRUt7kzdbdy7CpzR/SVjNLwJCYQ8
 m8snmOXq+JYpa+4cEsZ59PfV49OFaeQRj0Y4V/bYlDkH7xz4jb8PXmsHEUsi7Ot65WEE=;
Received: from [84.212.220.105] (helo=joga)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1oI44G-00019A-9P; Sun, 31 Jul 2022 10:12:59 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#56837: 28.1.90; `current-indentation' sometimes returns
 zero inside invisible text
In-Reply-To: <83ilne6da0.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 30 Jul
 2022 14:38:47 +0300")
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
 <87v8rfq877.fsf@localhost> <83o7x66hgt.fsf@HIDDEN>
 <87lesargc2.fsf@localhost> <83ilne6da0.fsf@HIDDEN>
X-Now-Playing: Simple Minds's _Sons and Fascination_: "In Trance as Mission"
Date: Sun, 31 Jul 2022 10:12:55 +0200
Message-ID: <87mtcp4s54.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Eli Zaretskii <eliz@HIDDEN> writes: >> (defmacro
 org-current-text-indentation
 () >> "Like `current-indentation', but ignore display/invisible properties."
 >> `(let ((buffer-invisibility-spec nil)) >> (current-indentation))) >> >>
 (defma [...] 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56837
Cc: Ihor Radchenko <yantar92@HIDDEN>, 56837 <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 (---)

Eli Zaretskii <eliz@HIDDEN> writes:

>> (defmacro org-current-text-indentation ()
>>   "Like `current-indentation', but ignore display/invisible properties."
>>   `(let ((buffer-invisibility-spec nil))
>>      (current-indentation)))
>> 
>> (defmacro org-current-text-column ()
>>   "Like `current-column', but ignore display/invisible properties."
>>   `(string-width (buffer-substring-no-properties
>> 		  (line-beginning-position) (point))))
>
> Sounds strange to have this, but if Lars thinks it's useful, I won't
> object.

It seems quite special-purpose -- I'm not sure there's much general
utility for functions like this.





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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 16:36:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 12:36:02 2022
Received: from localhost ([127.0.0.1]:35676 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHpRa-0002zK-2U
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 12:36:02 -0400
Received: from eggs.gnu.org ([209.51.188.92]:50232)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oHpRX-0002z0-OW
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 12:36:00 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:38460)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHpRS-00055f-EC; Sat, 30 Jul 2022 12:35:54 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=tcPwV0XAekJWP6EYyRj9if2qIXOgaTtB/9GMYp6kYx4=; b=mZaZ0ucw5PGO
 wx63utxXu5QAWsAqYBYtZ89/VXfcXtASG4ORpCyEe5NcXmXY47iKR0cpk+NVYG4D3TvWzJPg9yKNX
 hXxNq1Xhu7yySThSMphBET8qknufdcZZzQRYlDkf6PTogUlZmrTuI+DLPxcQx1phHFOCQnTT1xENy
 Qk/SsReeSAVOQ7/5fn2i6NEiWb2MtS/AlYw9NP3atQ7yOUX8wNKcyUnvdiQ1cXVIecl6nLODep8De
 GeWyQfxxxUWisSBmoM+URpXD14fn/3p36YHIfTp/p3H5IiBd6AevvqSkYMKdcgOMuIiTovbrurVej
 /fMu0W672I7Ib175l6/SVA==;
Received: from [87.69.77.57] (port=4932 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHpRR-00061j-Tr; Sat, 30 Jul 2022 12:35:54 -0400
Date: Sat, 30 Jul 2022 19:35:40 +0300
Message-Id: <8335ei5zj7.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: yantar92@HIDDEN, larsi@HIDDEN
In-Reply-To: <83ilne6da0.fsf@HIDDEN> (message from Eli Zaretskii on Sat, 30
 Jul 2022 14:38:47 +0300)
Subject: Re: bug#56837: 28.1.90;
 `current-indentation' sometimes returns zero inside invisible text
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
 <87v8rfq877.fsf@localhost> <83o7x66hgt.fsf@HIDDEN> <87lesargc2.fsf@localhost>
 <83ilne6da0.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56837
Cc: 56837 <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 (---)

> Cc: 56837 <at> debbugs.gnu.org
> Date: Sat, 30 Jul 2022 14:38:47 +0300
> From: Eli Zaretskii <eliz@HIDDEN>
> 
> > If not, could you at least mention the invisible text issues in
> > `current-indentation' docstring?
> 
> OK.

Now done.




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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 13:26:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 09:26:04 2022
Received: from localhost ([127.0.0.1]:34353 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHmTj-0001aA-WF
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 09:26:04 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52940)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oHmTi-0001Zf-5d
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 09:26:02 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:35898)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHmTc-0003Yl-Pg; Sat, 30 Jul 2022 09:25:56 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=bZElVLo3pczHdLkzhMqMtUIu6hDONWLks5Zx/izRYpw=; b=j+Kb9YiWPWM9
 K0CHC/5r6JYvbXfIEp3SO87OyBpzG0V8kS70p31MIpsqS6Vatmq6Qgpfmm/j1fawPtO7a6RCFKe+3
 dnwKi0cSCIX6s3zgzx7r4FaZOQbjp7U4w6tjee6jfKHk/bcOVeioKzm68Lt9rRpXrYtefryhaqicU
 pau60w8uO6w0OkHzHP2/4Nd/ykjINZtROLxNFvch3CsRphC1zW8mBoV7g8wqeG4V5wjTzWcOp33aI
 b1sttzXqJTzXnNAXkeReFm+Cyi5ibQY20qjG/jQ5liuFSZmpY3r6IGjg9rZHoUYOsnU1XP1LPksxH
 ngS2EL+4qShz+62I/JqIqQ==;
Received: from [87.69.77.57] (port=1182 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHmTb-0002SP-Ne; Sat, 30 Jul 2022 09:25:56 -0400
Date: Sat, 30 Jul 2022 16:25:47 +0300
Message-Id: <83edy268bo.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <87ilnerfa9.fsf@localhost> (message from Ihor Radchenko on Sat,
 30 Jul 2022 19:49:50 +0800)
Subject: Re: bug#56837: 28.1.90; `current-indentation' sometimes returns
 zero inside invisible text
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
 <87v8rfq877.fsf@localhost> <83o7x66hgt.fsf@HIDDEN>
 <87lesargc2.fsf@localhost> <83ilne6da0.fsf@HIDDEN> <87ilnerfa9.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56837
Cc: larsi@HIDDEN, 56837 <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: Ihor Radchenko <yantar92@HIDDEN>
> Cc: Lars Ingebrigtsen <larsi@HIDDEN>,  56837 <at> debbugs.gnu.org
> Date: Sat, 30 Jul 2022 19:49:50 +0800
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> >> A simpler version would be let-binding buffer-invisibility-spec.
> >
> > Really?
> 
> Could you please elaborate? Do I miss something?

Just that I know very well what let-binding does.

The snippet I sent was copy/pasted from the experiments I performed,
it wasn't supposed to be the peak of elegance.

> > These are all display-related, in that their results are supposed to
> > closely reflect what will be shown on display.
> 
> I understand. current-column even express it clearly in the docstring
> (unlike, current-indentation). However, as I tried to explain,
> display-independent versions can be useful during parsing. And not only
> in Org mode.
> 
> If you think otherwise, we will simply implement the required versions
> in Org.

Let's see what Lars thinks about this.




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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 11:48:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 07:48:57 2022
Received: from localhost ([127.0.0.1]:34207 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHkxk-0000yh-V3
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 07:48:57 -0400
Received: from mail-pl1-f172.google.com ([209.85.214.172]:43725)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1oHkxh-0000yM-HP
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 07:48:54 -0400
Received: by mail-pl1-f172.google.com with SMTP id y15so6660295plp.10
 for <56837 <at> debbugs.gnu.org>; Sat, 30 Jul 2022 04:48:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:in-reply-to:references:date:message-id
 :mime-version; bh=11H1KIar8t3vf/T+rRYuMb3+fg1AnyBc6SF9S4I0LWY=;
 b=MDupwDJmRKmedNFKGAIzGvPowKkrbJtrb+0c6CWyd/kGMUNEicmDd6wuphH7gRzIJY
 +cHGiijXWvaAhJsPZawkZ8+Yf3UBwHK2VQOR8dkczA+hcSzZVAgSfYK3EKUggw8t6RRg
 SGBN5hgECrm9m0yeXcJDwDar1bN7ZlQ2RlLuVdyJdd7i5+w+xRPKsuE7Q/21PyTI3u3c
 8mrHEU+fY2av6lDPOR71quTU4bE4ABhsKt9a+ubU/sBndsoBtBKdzaWLVlyNzJSlXiZI
 bsSjiZVjeFF+TXDfmc0G/9BeuGOBEc4ThlYq0Un3gXNKmBOvuYKeWep1Ztn+2lLNSGqA
 Xqkg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date
 :message-id:mime-version;
 bh=11H1KIar8t3vf/T+rRYuMb3+fg1AnyBc6SF9S4I0LWY=;
 b=NiFO8hzkey652bShhE50GBSJ0l5tueZ5SsRdIHkZuBw/fKxONa69RfUVZ8eNou4zth
 yb+lqL4zlzZ1IyOhwDaXHRq9gH5Jqa1cfUQdPNPUxL47rAgDqWFfq2l+uAie5RT0h5Z7
 a0QvavHdc6gxnYG2Y9Hru/qSqM52TLZ/wdFXIv53qgsPIuVxSDe7K5cuJq9K0T7s179u
 7TsvAjvCnOa0JAZKBwwGsUNdPh8L/waQLA8ZYyhaiu5rT9bVRlGlx1l9N2e3tPwrGHJC
 yqqdWU5gESrFG2Umg3SXXZXdKlcIRHYIKFQg7MyxSnOac3PBDN3Z1wOMqLGfuvjrMPsh
 fplQ==
X-Gm-Message-State: ACgBeo1yED+1l1TRhzYjVKVdRUuz4i3P3fMn+e51+MHHRY4gN7Zvv0Mo
 T48F/K6iJrSeDBSQ3Qxphf4=
X-Google-Smtp-Source: AA6agR5JY+mTekIaA7PMCEkwonaUehDdlqnKNxcpPHJ/V2SLOIdGE7zMddXkOYfpbJkv65yohgEd0w==
X-Received: by 2002:a17:90b:1c82:b0:1ee:eb41:b141 with SMTP id
 oo2-20020a17090b1c8200b001eeeb41b141mr9026482pjb.143.1659181727312; 
 Sat, 30 Jul 2022 04:48:47 -0700 (PDT)
Received: from localhost ([2409:8a70:217:4f80:8ec6:81ff:fe70:339d])
 by smtp.gmail.com with ESMTPSA id
 j12-20020a170903024c00b0016c50179b1esm5593563plh.152.2022.07.30.04.48.45
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Jul 2022 04:48:46 -0700 (PDT)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#56837: 28.1.90; `current-indentation' sometimes returns
 zero inside invisible text
In-Reply-To: <83ilne6da0.fsf@HIDDEN>
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
 <87v8rfq877.fsf@localhost> <83o7x66hgt.fsf@HIDDEN>
 <87lesargc2.fsf@localhost> <83ilne6da0.fsf@HIDDEN>
Date: Sat, 30 Jul 2022 19:49:50 +0800
Message-ID: <87ilnerfa9.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.2 (/)
X-Debbugs-Envelope-To: 56837
Cc: Lars Ingebrigtsen <larsi@HIDDEN>, 56837 <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: -0.8 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

>> A simpler version would be let-binding buffer-invisibility-spec.
>
> Really?

Could you please elaborate? Do I miss something?

I tested let-binding, and it does work if you try to let-bind
buffer-invisibility spec around the calls to `current-indentation' in my
reproducer.

AFAIK, remove-from-invisibility-spec simply does
(setq buffer-invisibility-spec ...)
let-binding is less cumbersome and not limited to outline spec which is
not even used by Org. Org uses multiple specs + other font-lock staff
may set more arbitrary specs in third-party packages.

>> Note that there is similar issue with current-column, though
>> current-column is much less likely to be used without considering
>> display properties.
>
> These are all display-related, in that their results are supposed to
> closely reflect what will be shown on display.

I understand. current-column even express it clearly in the docstring
(unlike, current-indentation). However, as I tried to explain,
display-independent versions can be useful during parsing. And not only
in Org mode.

If you think otherwise, we will simply implement the required versions
in Org.

>> If not, could you at least mention the invisible text issues in
>> `current-indentation' docstring?
>
> OK.

Thanks!

Best,
Ihor




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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 11:39:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 07:39:03 2022
Received: from localhost ([127.0.0.1]:34184 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHkoA-0000f3-GX
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 07:39:02 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38318)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oHko8-0000eY-Hx
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 07:39:00 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:34564)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHko3-0002n5-34; Sat, 30 Jul 2022 07:38:55 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=tYzqutWuBkZVkrRusAgWUoQDgbwwjot23s70hPK3sMg=; b=CX26jMyI2yFp
 EgnHzhLvfErvYPLP6X3CxlM+jEvCbuROg6sbCTzizkntQMQz16NjkbGEYhuQcSE0TS3EYiRqpsqVU
 8Lwx8PT5yGByIiicbD2l2sX+mZ9WaKnKfQOfL0ducBugvreMDSGX3cD4zUEFrSXesqS628PfMaivL
 YvjU+lLaoNurY1/lck4Y+9gWzN6r6jb6O4P7WUvjvDMDB3fW86PT7Ns9bvwf18goCAqEsVWU99qjw
 1Fd1PUDuXQ2xcch+87+YLENQ9RFNsJ4+PcTAciMYkygSRJTdXlZMplF0U1rpXK1AgT3w2X0sb1g3O
 W+mROf9WtOCa/LmJVy8KYg==;
Received: from [87.69.77.57] (port=2394 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHko1-0003JO-RO; Sat, 30 Jul 2022 07:38:54 -0400
Date: Sat, 30 Jul 2022 14:38:47 +0300
Message-Id: <83ilne6da0.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>,
 Lars Ingebrigtsen <larsi@HIDDEN>
In-Reply-To: <87lesargc2.fsf@localhost> (message from Ihor Radchenko on Sat,
 30 Jul 2022 19:27:09 +0800)
Subject: Re: bug#56837: 28.1.90; `current-indentation' sometimes returns
 zero inside invisible text
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
 <87v8rfq877.fsf@localhost> <83o7x66hgt.fsf@HIDDEN> <87lesargc2.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56837
Cc: 56837 <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: Ihor Radchenko <yantar92@HIDDEN>
> Cc: 56837 <at> debbugs.gnu.org
> Date: Sat, 30 Jul 2022 19:27:09 +0800
> 
> A simpler version would be let-binding buffer-invisibility-spec.

Really?

> Note that there is similar issue with current-column, though
> current-column is much less likely to be used without considering
> display properties.

These are all display-related, in that their results are supposed to
closely reflect what will be shown on display.

> Would it be possible to include the "text" versions of
> current-indentation and current-column into Emacs?
> 
> Something like
> 
> (defmacro org-current-text-indentation ()
>   "Like `current-indentation', but ignore display/invisible properties."
>   `(let ((buffer-invisibility-spec nil))
>      (current-indentation)))
> 
> (defmacro org-current-text-column ()
>   "Like `current-column', but ignore display/invisible properties."
>   `(string-width (buffer-substring-no-properties
> 		  (line-beginning-position) (point))))

Sounds strange to have this, but if Lars thinks it's useful, I won't
object.

> If not, could you at least mention the invisible text issues in
> `current-indentation' docstring?

OK.




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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 11:26:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 07:26:17 2022
Received: from localhost ([127.0.0.1]:34153 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHkbp-0006bu-BB
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 07:26:17 -0400
Received: from mail-pl1-f179.google.com ([209.85.214.179]:35566)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1oHkbm-0006bg-SH
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 07:26:16 -0400
Received: by mail-pl1-f179.google.com with SMTP id t2so6661420ply.2
 for <56837 <at> debbugs.gnu.org>; Sat, 30 Jul 2022 04:26:14 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:in-reply-to:references:date:message-id
 :mime-version; bh=sX79YgWaDV9a0nA+xTL6Y6t+CgG5hoeqVtvNuJ01zXo=;
 b=kqBwgDS7E6J8d9l/77wBtBfGEydJc4G6pOIafEY5Fv9u1Q0x+sGU55K8Gq4IvRTNXo
 1Su3jKpHBXy3r62ubHUUUjrSOGWAfpukYJ96AxaGYuQvNk08GZzh4iRD74CmlMreyR/Y
 oPRzizAzy+rr1nMl46J8hl+RPmbqGg2alzCW18PNyQ0ttRriQv15wbeAejxvtmX95BF5
 DPrLPxJbcaSTXXcqugVXa3AFaqSb3VQLHybFwcuEnV85TVmMMS0VU/qpfom0i8o7D1Cj
 eHGDPE2xqpUneOrKIs0ECi7KGnpNdelZgpvZ3cltczL56pwHsic7NhCkO/4oyR+PXZxF
 flfg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date
 :message-id:mime-version;
 bh=sX79YgWaDV9a0nA+xTL6Y6t+CgG5hoeqVtvNuJ01zXo=;
 b=Qge7cjReAr3sk4SSb+hgp10XdVP9LsPfGoyjF8LoDRNMmtQczHtDfxFAIom4bV4Ddp
 rnbmMnrMI/UVsvQbtteOJlOlxrMaWOI61i0WXREyl+EcS28r4U7V/fEhgapTtlsjzx2t
 K/kTrA9e76l79AIe3g2Z9IHZwzUS7nbzWclzin3O2rcfFVpOzd4gwVzdYnLfVXNHyago
 Tl/ATrt7Nz4yCmfmC1M5aEO8Lq11hemcm4cU/M8mOfz+gg4YDFgPRxBi7ctSPmyxjsel
 FRfOoVJgxnwQuV4A7R3Ik/sjdBwYsWImmtPzmpyrbZnitvr7uJO9kAa2XCz2GOzimUDE
 OC9A==
X-Gm-Message-State: ACgBeo3k4xBXyI5c7VOqRDZcMaqM6WtL4D03qhTUByMaHo2cImLZ1FyW
 I2jFeLtEkEMGhSKWkYDn/imbr4b2MmjVmbkb
X-Google-Smtp-Source: AA6agR4jGUzCkKCaGJAqi2iezfCmWru3MF1FGDtZqOx8qiklR0WyxXrDIXMAXhbiTVQWa6AJHtyyhA==
X-Received: by 2002:a17:903:2347:b0:16d:c671:5d53 with SMTP id
 c7-20020a170903234700b0016dc6715d53mr7858237plh.47.1659180369016; 
 Sat, 30 Jul 2022 04:26:09 -0700 (PDT)
Received: from localhost ([2409:8a70:217:4f80:8ec6:81ff:fe70:339d])
 by smtp.gmail.com with ESMTPSA id
 b13-20020a65578d000000b00419fc2c27d8sm4092588pgr.43.2022.07.30.04.26.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Jul 2022 04:26:07 -0700 (PDT)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#56837: 28.1.90; `current-indentation' sometimes returns
 zero inside invisible text
In-Reply-To: <83o7x66hgt.fsf@HIDDEN>
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
 <87v8rfq877.fsf@localhost> <83o7x66hgt.fsf@HIDDEN>
Date: Sat, 30 Jul 2022 19:27:09 +0800
Message-ID: <87lesargc2.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 56837
Cc: 56837 <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: -0.7 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> I guess you should temporarily remove the invisible property?  Like
> this:
>
>   (let ((invis-spec buffer-invisibility-spec)
>         indent)
>      (remove-from-invisibility-spec '(outline . t))
>      (setq indent
>            (save-excursion (search-forward " a") (current-indentation)))
>      (setq buffer-invisibility-spec invis-spec) indent)

A simpler version would be let-binding buffer-invisibility-spec.

Note that there is similar issue with current-column, though
current-column is much less likely to be used without considering
display properties.

Would it be possible to include the "text" versions of
current-indentation and current-column into Emacs?

Something like

(defmacro org-current-text-indentation ()
  "Like `current-indentation', but ignore display/invisible properties."
  `(let ((buffer-invisibility-spec nil))
     (current-indentation)))

(defmacro org-current-text-column ()
  "Like `current-column', but ignore display/invisible properties."
  `(string-width (buffer-substring-no-properties
		  (line-beginning-position) (point))))

If not, could you at least mention the invisible text issues in
`current-indentation' docstring? The current undefined behaviour is very
hard to debug.

Best,
Ihor





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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 10:08:34 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 06:08:34 2022
Received: from localhost ([127.0.0.1]:34067 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHjOb-00028y-QX
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 06:08:34 -0400
Received: from eggs.gnu.org ([209.51.188.92]:56756)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oHjOY-00028g-LM
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 06:08:33 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:33730)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHjOT-0006PO-9i; Sat, 30 Jul 2022 06:08:25 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=E7x5DpQrMOW0a6paMjis5aOh3OE2zKH0j8C4KuBGuRs=; b=ihvjiBeekHXm
 SFrcDiiTTNHiuVUSCd1oUz1DfvLmKY3mmeDGt2gh/4TPNV02orqC+Btf3lNYvN/Vh3yb4Qnfrva3S
 IFaf2qyzxEkBS6OLOsG5j8+v+9PMtK57ZszYaXypPCTpTEDThr3+1blBg3e9aT+WyNeRd8GA+zrC3
 VQXiAA8ejXElx0lMH8VRtF5cZUC5g8nTEbMlsygle3sy01GRRa/ZcjC1dJ8zjq4inlQ2sGPJqSIkm
 Ri6nrhXIqFMLbf2t0oX0okxuC0VUyusfxplEpxa2a6NISDlWTUD4JioSlO4nTUCqkpNeDEOZHkdFb
 HKjpEaTX7+E+4NfCa5keGg==;
Received: from [87.69.77.57] (port=4806 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHjOS-0000fT-NT; Sat, 30 Jul 2022 06:08:25 -0400
Date: Sat, 30 Jul 2022 13:08:18 +0300
Message-Id: <83o7x66hgt.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <87v8rfq877.fsf@localhost> (message from Ihor Radchenko on Sat,
 30 Jul 2022 17:08:12 +0800)
Subject: Re: bug#56837: 28.1.90; `current-indentation' sometimes returns
 zero inside invisible text
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
 <87v8rfq877.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56837
Cc: 56837 <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: Ihor Radchenko <yantar92@HIDDEN>
> Cc: 56837 <at> debbugs.gnu.org
> Date: Sat, 30 Jul 2022 17:08:12 +0800
> 
> > Bottom line: I think you are hitting undefined behavior here.
> 
> Maybe. But then I'd like to be able to get the "hard" indentation
> information for the underlying text in buffer, accounting for tab-width,
> and disregarding overlays and other font-lock staff.

I guess you should temporarily remove the invisible property?  Like
this:

  (let ((invis-spec buffer-invisibility-spec)
        indent)
     (remove-from-invisibility-spec '(outline . t))
     (setq indent
           (save-excursion (search-forward " a") (current-indentation)))
     (setq buffer-invisibility-spec invis-spec) indent)




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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 09:07:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 05:07:21 2022
Received: from localhost ([127.0.0.1]:34028 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHiRN-0000R2-DM
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 05:07:21 -0400
Received: from mail-pj1-f51.google.com ([209.85.216.51]:55940)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1oHiRJ-0000Qk-FG
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 05:07:20 -0400
Received: by mail-pj1-f51.google.com with SMTP id b10so6505001pjq.5
 for <56837 <at> debbugs.gnu.org>; Sat, 30 Jul 2022 02:07:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:in-reply-to:references:date:message-id
 :mime-version; bh=YCRDEZM0TdTFlBeTPhseiHWNkPYU7cXuYRPtmj5Y8/0=;
 b=LZbNF2omA6fekXL0TTSKvjXkw77reT46fO/dOQ3DWIhMF5cxugUuC/4dumzG6WK0Pg
 izYJDz17ZHRWV/qCGRAaHhA6/brA4WdvECZTsrn2BGCT4DnNMt8jWXWC9Ec+9W8OK5OA
 yXwsoBDpDRbweHzbaKAVVaZKj+k8pVMJiv0ESZ/jRCwgTD1Vxwab5zWz4BC1Y5gNeuAv
 FVrJqgvRDX/yJnSlAgYJlmGIJOZ3Ox3tgyDcIYD1fdgB59L+d2s+f1+N35ddFeua/WKL
 9L9TiCFuPNMXIpeTrecp2HPiTCfdV2RzVQ3rpsAWaql4MD3KsXIhyHesLGG8RsVji2u4
 08kQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date
 :message-id:mime-version;
 bh=YCRDEZM0TdTFlBeTPhseiHWNkPYU7cXuYRPtmj5Y8/0=;
 b=NL5lqwruNUvtXeQKsbxvcc4PH3bDQrAMUJBQ4Xu4g4pUwaZvgGb6vuPXwHk4yZB4r9
 mA4Bs67foblEadbWe9ekmAQHtzMkT2prMnBcBoiNEQys16Dy0hRVXQpQNLCBQnu61jhu
 0TTX7SiqPsRiu9iw2Q4XuaRtIuzp2j8oXNL44Wyb1lr++qUl34NdYCXFEEFN8hAldUmS
 f9rCpZTKLthJUDsMLruZv1M2+rKavJJ/9KXuulXUtY1Tqhg69tuR2LheK+o1mLuKWvZr
 GP0iKLbXzhKry3IsBZxGlPUYSeHjWswRfRnBQsYuWIYQ2uimxJi+u0ujcEUx9wnDVe6g
 T60g==
X-Gm-Message-State: ACgBeo0RrZ1JHG3CeczcmGQTby64Ar6SbP/yrimh44ANGMLR817xTQwy
 XF64AZiQytXULAUgo7BfAWO8fCDpMGqr1A==
X-Google-Smtp-Source: AA6agR6qiSRXnKCiUU+ke4XPui9Kh5VwpEWXBmfaOpkSQcBp9nf/5RbMXmsVNf1Ggn3iBkNtBlgGVA==
X-Received: by 2002:a17:90b:390e:b0:1f2:b7b6:9f9 with SMTP id
 ob14-20020a17090b390e00b001f2b7b609f9mr8727966pjb.64.1659172031468; 
 Sat, 30 Jul 2022 02:07:11 -0700 (PDT)
Received: from localhost ([1.83.155.1]) by smtp.gmail.com with ESMTPSA id
 q17-20020aa78431000000b0052d2b55be32sm297153pfn.171.2022.07.30.02.07.09
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Jul 2022 02:07:10 -0700 (PDT)
From: Ihor Radchenko <yantar92@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#56837: 28.1.90; `current-indentation' sometimes returns
 zero inside invisible text
In-Reply-To: <83r12356fy.fsf@HIDDEN>
References: <875yjfrq2w.fsf@localhost> <83r12356fy.fsf@HIDDEN>
Date: Sat, 30 Jul 2022 17:08:12 +0800
Message-ID: <87v8rfq877.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.3 (/)
X-Debbugs-Envelope-To: 56837
Cc: 56837 <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: -0.7 (/)

Eli Zaretskii <eliz@HIDDEN> writes:

> I don't understand what is the purpose of asking about indentation of
> a line that is completely invisible.  current-indentation skips
> invisible characters, so if everything is invisible, why do you expect
> any useful result?

This is needed for parsing. In Org, indentation defines the list level.
Similarly, indentation is meaningful in Python.

Since parsed text can be hidden inside fold (using org-mode,
or outline-mode; the latter may also be used in Python buffers), getting
an accurate indentation is important even when text is invisible.

> Technically, the difference between the two results is because
> current-indentation tries to account for the ellipsis (which is
> present in the first case but not in the second).  But that's not
> relevant to the larger issue at hand here.

I do not understand how ellipsis can be meaningfully accounted for with
regard to indentation. AFAIU, they are not. Try

* something
          a
* else

4. Move point to "* <point>something"
5. <TAB> to fold the outline
6. M-: (save-excursion (search-forward " a") (current-indentation))
   ;; => 10

> Bottom line: I think you are hitting undefined behavior here.

Maybe. But then I'd like to be able to get the "hard" indentation
information for the underlying text in buffer, accounting for tab-width,
and disregarding overlays and other font-lock staff.

As I mentioned above, this is required for parsing.

Best,
Ihor




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

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


Received: (at 56837) by debbugs.gnu.org; 30 Jul 2022 08:52:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 04:52:02 2022
Received: from localhost ([127.0.0.1]:34013 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHiCX-0008Qg-L2
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 04:52:02 -0400
Received: from eggs.gnu.org ([209.51.188.92]:48402)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oHiCS-0008QI-7K
 for 56837 <at> debbugs.gnu.org; Sat, 30 Jul 2022 04:52:00 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:33296)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHiCN-0004PD-0K; Sat, 30 Jul 2022 04:51:51 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=/INip7e2ib4GIxQVcwlZC0KzB93Vnsprrlo2lVuo9ww=; b=M2Qqnn1EH6g3
 CqH0bxTX20W1PhawAXdMG4CzqThbcMxRUet/pQ8I97xZUznXTbd9a5LCS9y+w/Mn30tCJrC5oCEL4
 SPfrHuMBegM/Fem+kHYKG4O2gHJ8npkS4QAr/2k3ZBhQhqwtBWRpe547dOIvRvjDnRgm6yQmmeZ30
 eO02F6Vwug0f//ZHur0llUj7TFrHYX539QKiJqiiJZHhKkYpDpbTOHuECtaohI193wbAsXiUiHKLk
 02/Syq7KZ/QnhiaRYDQD1qer4Cq7Zyl/0Ql+aud9vPnfvzk3aqOZ1Xg0M1IKmVmXazB+2pisGtJjp
 pqbsRezsr1PWnNUyhnJezA==;
Received: from [87.69.77.57] (port=4108 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oHiCM-0006xs-AK; Sat, 30 Jul 2022 04:51:50 -0400
Date: Sat, 30 Jul 2022 11:51:45 +0300
Message-Id: <83r12356fy.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Ihor Radchenko <yantar92@HIDDEN>
In-Reply-To: <875yjfrq2w.fsf@localhost> (message from Ihor Radchenko on Sat,
 30 Jul 2022 15:56:39 +0800)
Subject: Re: bug#56837: 28.1.90;
 `current-indentation' sometimes returns zero inside invisible text
References: <875yjfrq2w.fsf@localhost>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 56837
Cc: 56837 <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: Ihor Radchenko <yantar92@HIDDEN>
> Date: Sat, 30 Jul 2022 15:56:39 +0800
> 
> 1. emacs -Q
> 2. M-x outline-mode
> 3. Insert
> 
> * something
>   a
> * else
> 
> 4. Move point to "* <point>something"
> 5. <TAB> to fold the outline
> 6. M-: (save-excursion (search-forward " a") (current-indentation))
>    ;; => 2
> 7. M-: (remove-from-invisibility-spec '(outline . t))
> 8. M-: (add-to-invisibility-spec '(outline))
> 9. M-: (save-excursion (search-forward " a") (current-indentation))
>    ;; => 0; expected: => 2

I don't understand what is the purpose of asking about indentation of
a line that is completely invisible.  current-indentation skips
invisible characters, so if everything is invisible, why do you expect
any useful result?

Technically, the difference between the two results is because
current-indentation tries to account for the ellipsis (which is
present in the first case but not in the second).  But that's not
relevant to the larger issue at hand here.

Bottom line: I think you are hitting undefined behavior here.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#56837; Package emacs. Full text available.
Forcibly Merged 56837 56838. Request was from Stefan Kangas <stefan@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at submit) by debbugs.gnu.org; 30 Jul 2022 07:56:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jul 30 03:56:19 2022
Received: from localhost ([127.0.0.1]:33953 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oHhKc-0004eq-PW
	for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 03:56:19 -0400
Received: from lists.gnu.org ([209.51.188.17]:43788)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <yantar92@HIDDEN>) id 1oHhKZ-0004eg-To
 for submit <at> debbugs.gnu.org; Sat, 30 Jul 2022 03:56:17 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:54136)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1oHhKU-0001cB-T0
 for bug-gnu-emacs@HIDDEN; Sat, 30 Jul 2022 03:56:15 -0400
Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]:39485)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <yantar92@HIDDEN>)
 id 1oHhKG-0004xj-6l
 for bug-gnu-emacs@HIDDEN; Sat, 30 Jul 2022 03:56:10 -0400
Received: by mail-pj1-x102c.google.com with SMTP id
 h21-20020a17090aa89500b001f31a61b91dso7534766pjq.4
 for <bug-gnu-emacs@HIDDEN>; Sat, 30 Jul 2022 00:55:52 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:subject:date:message-id:mime-version;
 bh=rHfBm4Q78IaSS+zFBC7kCLSKbA6+EzZ+lc4xdZZzgAw=;
 b=MBl6bVqqKdSVJJk/ehv+tIMZzbibAYKN6hiHjAPVUuqzj56ULuV/rpWVXxVCq1Rpks
 rv7sG20N+ktJ2NcZXdOphZ1/5VXWDhXSWsiXzKWpoAoVTPVBxxBkbKNeAqfjERfMGcI2
 NbKWkzCfeZT4CtYZ5MxmA6XoV8eRxIVINPCx0sZyh/LH7GMq0L2M7sg55w5daNV8Jx0X
 v19zeyhEGP2wrlqJExvb+S7CtJ3cyfaK/BNAFXAJGOY6ig9yspcqaF+SRz+7wCu9tETr
 RMHDF6gI2M+XfFbLrY0A/mv1hsmK+dSuiR8emgmNfUTd8IJNdUmsQ7GnMdhXelx5/kCL
 fPNQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version;
 bh=rHfBm4Q78IaSS+zFBC7kCLSKbA6+EzZ+lc4xdZZzgAw=;
 b=vmVQCc3tFUdKM+VW/xKu2OcZaYlCQuH2uz+MfL/0pRUNV9zwMNpCwJwQUd0ealCr9b
 07SA2bvL6iuIemE8Y6ccZmzUVEVXj4Fb6Kp6WK+xW8lEFlmjIa/LE7lYu+pET+cK6Yik
 z3GiJvzS1+kxny56R+nKktWUO0HoWri4nmmyb4iH234gwDGxELzbjv876rEX6PuIw+yG
 k5twZbpkMWv0VxofRje+atlsRtHtCxwSBDlfu6DLfrUVE/nidS5iDo9YTw8d10jy62DU
 OUzszjaqA2nUPVQcbkF1eVKar2WM3n+orxCi2CeBIAH2gikHXgDvQ+jA0TdoPBMubPJm
 q3Zg==
X-Gm-Message-State: ACgBeo0QSOVLAx7Zh3YiaK2qpcdM8zaY6QjaJYthkh0U3Mfx8hqrFd2I
 A/Cnt5FKKFARB/mJoUD4SzEmXY8ecaTVvA==
X-Google-Smtp-Source: AA6agR76ZQPhf76SezS8Ez+6mr7i4xOB5u+x5E4wRfaUTH3SBxSjQtCfgUcf3p6QLuJtVenoQJ/DAQ==
X-Received: by 2002:a17:90a:94c2:b0:1f3:2590:8693 with SMTP id
 j2-20020a17090a94c200b001f325908693mr8722141pjw.153.1659167750890; 
 Sat, 30 Jul 2022 00:55:50 -0700 (PDT)
Received: from localhost ([1.83.155.1]) by smtp.gmail.com with ESMTPSA id
 t128-20020a625f86000000b0052ad49292f0sm4168524pfb.48.2022.07.30.00.55.48
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Jul 2022 00:55:50 -0700 (PDT)
From: Ihor Radchenko <yantar92@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 28.1.90; `current-indentation' sometimes returns zero inside
 invisible text
Date: Sat, 30 Jul 2022 15:56:39 +0800
Message-ID: <875yjfrq2w.fsf@localhost>
MIME-Version: 1.0
Content-Type: text/plain
Received-SPF: pass client-ip=2607:f8b0:4864:20::102c;
 envelope-from=yantar92@HIDDEN; helo=mail-pj1-x102c.google.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.1 (-)
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.1 (--)

Hi,

Try to do the following:
1. emacs -Q
2. M-x outline-mode
3. Insert

* something
  a
* else

4. Move point to "* <point>something"
5. <TAB> to fold the outline
6. M-: (save-excursion (search-forward " a") (current-indentation))
   ;; => 2
7. M-: (remove-from-invisibility-spec '(outline . t))
8. M-: (add-to-invisibility-spec '(outline))
9. M-: (save-excursion (search-forward " a") (current-indentation))
   ;; => 0; expected: => 2

First reported in https://orgmode.org/list/87k0h49s7z.fsf@localhost   

Best,
Ihor





Acknowledgement sent to Ihor Radchenko <yantar92@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#56837; 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: Tue, 10 Jan 2023 08:30:02 UTC

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