GNU bug report logs - #16413
24.3.50; Inconsistent behavior of text property functions in narrowed buffer

Previous Next

Package: emacs;

Reported by: Nathan Trapuzzano <nbtrap <at> nbtrap.com>

Date: Sat, 11 Jan 2014 03:07:01 UTC

Severity: wishlist

Found in version 24.3.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 16413 in the body.
You can then email your comments to 16413 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 03:07:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nathan Trapuzzano <nbtrap <at> nbtrap.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 11 Jan 2014 03:07:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Fri, 10 Jan 2014 22:05:38 -0500
The various functions for examining text properties behave unintuitively
and incosistently at (point-max) on narrowed buffers.  Rather than
returning `nil', they return the prop(s) of the text at (point-max),
even though the text is not actually visible in the buffer, due to
narrowing.  By contrast, `char-after' always returns `nil' when passed
(point-max).  It seems to me the text property functions should also
return `nil', as they do at (eobp) on widened buffers.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 04:07:01 GMT) Full text and rfc822 format available.

Message #8 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Fri, 10 Jan 2014 20:05:33 -0800
On 01/10/2014 07:05 PM, Nathan Trapuzzano wrote:
> The various functions for examining text properties behave unintuitively
> and incosistently at (point-max) on narrowed buffers.  Rather than
> returning `nil', they return the prop(s) of the text at (point-max),
> even though the text is not actually visible in the buffer, due to
> narrowing.  By contrast, `char-after' always returns `nil' when passed
> (point-max).  It seems to me the text property functions should also
> return `nil', as they do at (eobp) on widened buffers.

I agree that this behavior is unintuitive, but I wonder whether we can 
fix this bug without breaking existing elisp.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 04:11:01 GMT) Full text and rfc822 format available.

Message #11 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Fri, 10 Jan 2014 20:09:37 -0800
On 01/10/2014 08:05 PM, Daniel Colascione wrote:
> On 01/10/2014 07:05 PM, Nathan Trapuzzano wrote:
>> The various functions for examining text properties behave unintuitively
>> and incosistently at (point-max) on narrowed buffers.  Rather than
>> returning `nil', they return the prop(s) of the text at (point-max),
>> even though the text is not actually visible in the buffer, due to
>> narrowing.  By contrast, `char-after' always returns `nil' when passed
>> (point-max).  It seems to me the text property functions should also
>> return `nil', as they do at (eobp) on widened buffers.
>
> I agree that this behavior is unintuitive, but I wonder whether we can
> fix this bug without breaking existing elisp.

Which functions break, exactly? The following test passes.

(ert-deftest text-property-narrowing ()
  "Test that text properties outside narrowed buffer are invisible"
  (with-temp-buffer
    (insert "  ")
    (put-text-property (1- (point-max)) (point-max) 'foo 'bar)
    (should (eq (get-text-property (1- (point-max)) 'foo) 'bar))
    (narrow-to-region (point-min) (1- (point-max)))
    (should (null (get-text-property (1- (point-max)) 'foo)))))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 08:03:02 GMT) Full text and rfc822 format available.

Message #14 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 10:01:59 +0200
> Date: Fri, 10 Jan 2014 20:05:33 -0800
> From: Daniel Colascione <dancol <at> dancol.org>
> 
> On 01/10/2014 07:05 PM, Nathan Trapuzzano wrote:
> > The various functions for examining text properties behave unintuitively
> > and incosistently at (point-max) on narrowed buffers.  Rather than
> > returning `nil', they return the prop(s) of the text at (point-max),
> > even though the text is not actually visible in the buffer, due to
> > narrowing.  By contrast, `char-after' always returns `nil' when passed
> > (point-max).  It seems to me the text property functions should also
> > return `nil', as they do at (eobp) on widened buffers.
> 
> I agree that this behavior is unintuitive, but I wonder whether we can 
> fix this bug without breaking existing elisp.

I don't even agree it's not intuitive: in the eob case there's nothing
at point-max, while in a narrowed buffer there's a character there.
Narrowing is not documented to make the text outside the region to
magically disappear, it just prevents point from moving there.

Nathan, could you show an example where this hurts anything besides
intuition?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 08:04:02 GMT) Full text and rfc822 format available.

Message #17 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 00:03:42 -0800
On 01/11/2014 12:01 AM, Eli Zaretskii wrote:
>> Date: Fri, 10 Jan 2014 20:05:33 -0800
>> From: Daniel Colascione <dancol <at> dancol.org>
>>
>> On 01/10/2014 07:05 PM, Nathan Trapuzzano wrote:
>>> The various functions for examining text properties behave unintuitively
>>> and incosistently at (point-max) on narrowed buffers.  Rather than
>>> returning `nil', they return the prop(s) of the text at (point-max),
>>> even though the text is not actually visible in the buffer, due to
>>> narrowing.  By contrast, `char-after' always returns `nil' when passed
>>> (point-max).  It seems to me the text property functions should also
>>> return `nil', as they do at (eobp) on widened buffers.
>>
>> I agree that this behavior is unintuitive, but I wonder whether we can
>> fix this bug without breaking existing elisp.
>
> I don't even agree it's not intuitive: in the eob case there's nothing
> at point-max, while in a narrowed buffer there's a character there.
> Narrowing is not documented to make the text outside the region to
> magically disappear, it just prevents point from moving there.

Narrowing *is* generally useful for treating part of a buffer as a 
consistent unit, though, especially when that part is syntactically 
different from the rest of the buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 08:14:01 GMT) Full text and rfc822 format available.

Message #20 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 10:12:57 +0200
> Date: Sat, 11 Jan 2014 00:03:42 -0800
> From: Daniel Colascione <dancol <at> dancol.org>
> CC: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
> 
> Narrowing *is* generally useful for treating part of a buffer as a 
> consistent unit, though, especially when that part is syntactically 
> different from the rest of the buffer.

Not sure what you mean by "consistent unit".

From the ELisp manual:

  30.4 Narrowing
  ==============

  "Narrowing" means limiting the text addressable by Emacs editing
  commands to a limited range of characters in a buffer.  The text that
  remains addressable is called the "accessible portion" of the buffer.

Perceiving and treating narrowing as something beyond that can,
indeed, cause conceptual and practical difficulties.  For example,
narrowing the buffer in the middle of bidirectional context will most
of the time completely screw up the text on display.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 08:18:01 GMT) Full text and rfc822 format available.

Message #23 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 00:17:19 -0800
On 01/11/2014 12:12 AM, Eli Zaretskii wrote:
>> Date: Sat, 11 Jan 2014 00:03:42 -0800
>> From: Daniel Colascione <dancol <at> dancol.org>
>> CC: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
>>
>> Narrowing *is* generally useful for treating part of a buffer as a
>> consistent unit, though, especially when that part is syntactically
>> different from the rest of the buffer.
>
> Not sure what you mean by "consistent unit".

Narrowing is useful as a poor man's mmm-mode, among other things, and 
programatically, it's useful for parsing delimited constructs (where we 
can just narrow to the region of interest). Narrowing hasn't been a 
purely visual hint, and plenty of lisp-level functions treat the edges 
of the accessible portion of the buffer as real buffer ends. Since this 
abstraction almost completely works today, we should try to fill any 
remaining gaps.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 08:29:02 GMT) Full text and rfc822 format available.

Message #26 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 10:27:53 +0200
> Date: Sat, 11 Jan 2014 00:17:19 -0800
> From: Daniel Colascione <dancol <at> dancol.org>
> CC: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org
> 
> Narrowing is useful as a poor man's mmm-mode, among other things, and 
> programatically, it's useful for parsing delimited constructs (where we 
> can just narrow to the region of interest). Narrowing hasn't been a 
> purely visual hint, and plenty of lisp-level functions treat the edges 
> of the accessible portion of the buffer as real buffer ends. Since this 
> abstraction almost completely works today, we should try to fill any 
> remaining gaps.

You will find this not an easy task, I'm afraid.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 12:21:01 GMT) Full text and rfc822 format available.

Message #29 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 07:20:10 -0500
Daniel Colascione <dancol <at> dancol.org> writes:

> Which functions break, exactly? The following test passes.
>
> (ert-deftest text-property-narrowing ()
>   "Test that text properties outside narrowed buffer are invisible"
>   (with-temp-buffer
>     (insert "  ")
>     (put-text-property (1- (point-max)) (point-max) 'foo 'bar)
>     (should (eq (get-text-property (1- (point-max)) 'foo) 'bar))
>     (narrow-to-region (point-min) (1- (point-max)))
>     (should (null (get-text-property (1- (point-max)) 'foo)))))

Those tests are looking at (1- (point-max)).  I'm talking about
(point-max).  Functions that I know to be problematic include:

get-text-property
text-properties-at
previous-single-property-change

But I would geuss the problem extends to all text property fetch/search
functions.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 12:25:02 GMT) Full text and rfc822 format available.

Message #32 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Daniel Colascione <dancol <at> dancol.org>, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 07:24:30 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

> I don't even agree it's not intuitive: in the eob case there's nothing
> at point-max, while in a narrowed buffer there's a character there.
> Narrowing is not documented to make the text outside the region to
> magically disappear, it just prevents point from moving there.
>
> Nathan, could you show an example where this hurts anything besides
> intuition?

It's unintuitive or at least inconsistent because other functions
(e.g. `char-after') treat the high edge of a narrowed buffer as though
it were the actual end of the buffer.

For an example of where this is problematic, look at the patch I
submitted last night on this list.  I was patching functions that use
the text property search functions and had to make a special case for
where point is at (point-max) and the buffer is narrowed.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 13:07:02 GMT) Full text and rfc822 format available.

Message #35 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: dancol <at> dancol.org, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 15:05:42 +0200
> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
> Cc: Daniel Colascione <dancol <at> dancol.org>,  16413 <at> debbugs.gnu.org
> Date: Sat, 11 Jan 2014 07:24:30 -0500
> 
> For an example of where this is problematic, look at the patch I
> submitted last night on this list.  I was patching functions that use
> the text property search functions and had to make a special case for
> where point is at (point-max) and the buffer is narrowed.

point-max is and will always be a special case.  There's no way around
that.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 13:10:02 GMT) Full text and rfc822 format available.

Message #38 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: dancol <at> dancol.org, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 15:08:58 +0200
> Functions that I know to be problematic include:
> 
> get-text-property
> text-properties-at
> previous-single-property-change

The first two are low-level primitives that explicitly ignore the
narrowing; don't use them if you want them to be limited to the
narrowed region.  The last one should simply returns the search limit
if it hits the beginning of the narrowing, so I'm not sure why it is
in this list.

> But I would geuss the problem extends to all text property fetch/search
> functions.

That guess is wrong: functions that search for next/previous property
changes stop at the end of the narrowed region.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 13:53:02 GMT) Full text and rfc822 format available.

Message #41 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: dancol <at> dancol.org, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 08:52:23 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Functions that I know to be problematic include:
>> 
>> get-text-property
>> text-properties-at
>> previous-single-property-change
>
> The first two are low-level primitives that explicitly ignore the
> narrowing; don't use them if you want them to be limited to the
> narrowed region.

char-after is a primitive, and it behaves intuitively at (point-max) on
narrowed buffers.  Why shouldn't other functions behave consistently?

> The last one should simply returns the search limit if it hits the
> beginning of the narrowing, so I'm not sure why it is in this list.

Nevermind about the search functions.  I was confused about the behavior
of previous-single-property-change.  The problem lies in the functions
that fetch the properties.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 13:57:02 GMT) Full text and rfc822 format available.

Message #44 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: dancol <at> dancol.org, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 08:56:26 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
>> Cc: Daniel Colascione <dancol <at> dancol.org>,  16413 <at> debbugs.gnu.org
>> Date: Sat, 11 Jan 2014 07:24:30 -0500
>> 
>> For an example of where this is problematic, look at the patch I
>> submitted last night on this list.  I was patching functions that use
>> the text property search functions and had to make a special case for
>> where point is at (point-max) and the buffer is narrowed.
>
> point-max is and will always be a special case.  There's no way around
> that.

But when dealing with text properties (and apparently only when dealing
with text properties), there are _two_ special cases: (point-max) in a
narrowed buffer, and (point-max) in a widened buffer.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 14:18:01 GMT) Full text and rfc822 format available.

Message #47 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: dancol <at> dancol.org, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 16:17:21 +0200
> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
> Cc: dancol <at> dancol.org,  16413 <at> debbugs.gnu.org
> Date: Sat, 11 Jan 2014 08:52:23 -0500
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> Functions that I know to be problematic include:
> >> 
> >> get-text-property
> >> text-properties-at
> >> previous-single-property-change
> >
> > The first two are low-level primitives that explicitly ignore the
> > narrowing; don't use them if you want them to be limited to the
> > narrowed region.
> 
> char-after is a primitive, and it behaves intuitively at (point-max) on
> narrowed buffers.  Why shouldn't other functions behave consistently?

I don't know.  One reason could be that we might need a primitive that
can report properties of characters that are not reachable.  But I
don't have any evidence to that effect.

> Nevermind about the search functions.  I was confused about the behavior
> of previous-single-property-change.  The problem lies in the functions
> that fetch the properties.

The usual paradigm is to search for a possible place where the you
might have the property, then examine the properties at that point.
With this paradigm, if you never look at the properties when the
search hits the limit of the search, you will never have this problem.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 14:19:02 GMT) Full text and rfc822 format available.

Message #50 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: dancol <at> dancol.org, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 16:18:24 +0200
> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
> Cc: dancol <at> dancol.org,  16413 <at> debbugs.gnu.org
> Date: Sat, 11 Jan 2014 08:56:26 -0500
> 
> > point-max is and will always be a special case.  There's no way around
> > that.
> 
> But when dealing with text properties (and apparently only when dealing
> with text properties), there are _two_ special cases: (point-max) in a
> narrowed buffer, and (point-max) in a widened buffer.

Not if you never look at the properties when you hit the limit of the
search for previous/next property change.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 19:44:01 GMT) Full text and rfc822 format available.

Message #53 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: dancol <at> dancol.org, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 14:43:11 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

>> char-after is a primitive, and it behaves intuitively at (point-max) on
>> narrowed buffers.  Why shouldn't other functions behave consistently?
>
> I don't know.  One reason could be that we might need a primitive that
> can report properties of characters that are not reachable.  But I
> don't have any evidence to that effect.

Even if there were such a need, it could always be achieved with
`save-restriction', etc.  On the other hand, users should be able to
expect that functions behave consistently with respect to narrowing, and
these clearly don't

>> Nevermind about the search functions.  I was confused about the behavior
>> of previous-single-property-change.  The problem lies in the functions
>> that fetch the properties.
>
> The usual paradigm is to search for a possible place where the you
> might have the property, then examine the properties at that point.
> With this paradigm, if you never look at the properties when the
> search hits the limit of the search, you will never have this problem.

I was confused by how `previous-single-property-change' actually
doesn't look at the property at POSITION.  It starts looking at (1-
position) and then find the first difference from that point.  It's not
intuitive, but it makes sense if you think about it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 19:45:01 GMT) Full text and rfc822 format available.

Message #56 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 14:44:28 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

>> But when dealing with text properties (and apparently only when dealing
>> with text properties), there are _two_ special cases: (point-max) in a
>> narrowed buffer, and (point-max) in a widened buffer.
>
> Not if you never look at the properties when you hit the limit of the
> search for previous/next property change.

That may be true for searching, but the problem for fetching
(`get-text-property', etc.) remains.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 20:00:01 GMT) Full text and rfc822 format available.

Message #59 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 21:58:51 +0200
> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
> Cc: 16413 <at> debbugs.gnu.org
> Date: Sat, 11 Jan 2014 14:44:28 -0500
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> But when dealing with text properties (and apparently only when dealing
> >> with text properties), there are _two_ special cases: (point-max) in a
> >> narrowed buffer, and (point-max) in a widened buffer.
> >
> > Not if you never look at the properties when you hit the limit of the
> > search for previous/next property change.
> 
> That may be true for searching, but the problem for fetching
> (`get-text-property', etc.) remains.

You need to fetch after searching, and never do that when the search
hits the limit.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 20:14:01 GMT) Full text and rfc822 format available.

Message #62 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 15:13:44 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
>> Cc: 16413 <at> debbugs.gnu.org
>> Date: Sat, 11 Jan 2014 14:44:28 -0500
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> >> But when dealing with text properties (and apparently only when dealing
>> >> with text properties), there are _two_ special cases: (point-max) in a
>> >> narrowed buffer, and (point-max) in a widened buffer.
>> >
>> > Not if you never look at the properties when you hit the limit of the
>> > search for previous/next property change.
>> 
>> That may be true for searching, but the problem for fetching
>> (`get-text-property', etc.) remains.
>
> You need to fetch after searching, and never do that when the search
> hits the limit.

I'm sorry, but this just seems totally contrived.  Are people actually
supposed to know this?  And who's to say there's searching involved?
What if I just want to look at the text properties at point?  It
shouldn't matter whether the buffer is narrowed.  (If you think it
_should_ matter, then why shouldn't it also matter for `char-after',
etc.  It's a consistency problem.)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 20:28:01 GMT) Full text and rfc822 format available.

Message #65 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 22:27:17 +0200
> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
> Cc: 16413 <at> debbugs.gnu.org
> Date: Sat, 11 Jan 2014 15:13:44 -0500
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> >> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
> >> Cc: 16413 <at> debbugs.gnu.org
> >> Date: Sat, 11 Jan 2014 14:44:28 -0500
> >> 
> >> Eli Zaretskii <eliz <at> gnu.org> writes:
> >> 
> >> >> But when dealing with text properties (and apparently only when dealing
> >> >> with text properties), there are _two_ special cases: (point-max) in a
> >> >> narrowed buffer, and (point-max) in a widened buffer.
> >> >
> >> > Not if you never look at the properties when you hit the limit of the
> >> > search for previous/next property change.
> >> 
> >> That may be true for searching, but the problem for fetching
> >> (`get-text-property', etc.) remains.
> >
> > You need to fetch after searching, and never do that when the search
> > hits the limit.
> 
> I'm sorry, but this just seems totally contrived.  Are people actually
> supposed to know this?  And who's to say there's searching involved?
> What if I just want to look at the text properties at point?  It
> shouldn't matter whether the buffer is narrowed.

I was just trying to help you have less special cases in your code,
that's all.

How are you supposed to know about that? by reading the available code
of course.  That's how I learned this.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 20:41:02 GMT) Full text and rfc822 format available.

Message #68 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 15:40:41 -0500
Eli Zaretskii <eliz <at> gnu.org> writes:

> I was just trying to help you have less special cases in your code,
> that's all.

Okay, I thought you were generalizing.

> How are you supposed to know about that? by reading the available code
> of course.  That's how I learned this.

I don't think people should have to read code to know what to expect
from interfaces.

So do you think the current behavior is consistent, or are you just
cautious about trying to change it?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sat, 11 Jan 2014 20:47:02 GMT) Full text and rfc822 format available.

Message #71 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 22:46:04 +0200
> From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
> Cc: 16413 <at> debbugs.gnu.org
> Date: Sat, 11 Jan 2014 15:40:41 -0500
> 
> So do you think the current behavior is consistent, or are you just
> cautious about trying to change it?

I'm cautious about changing this and don't see the apparent
inconsistency as a big deal.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sun, 12 Jan 2014 03:43:02 GMT) Full text and rfc822 format available.

Message #74 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 16413 <at> debbugs.gnu.org, nbtrap <at> nbtrap.com
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 22:42:33 -0500
> Narrowing *is* generally useful for treating part of a buffer
> as a consistent unit, though, especially when that part is syntactically
> different from the rest of the buffer.

Actually, from where I stand, narrowing is harmful.  If I could get rid
of it, I would.  The reason is precisely because it means different
things to different people in different contexts, and these things
require subtly different behaviors which are mutually incompatible.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sun, 12 Jan 2014 04:36:02 GMT) Full text and rfc822 format available.

Message #77 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 16413 <at> debbugs.gnu.org, nbtrap <at> nbtrap.com
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sat, 11 Jan 2014 20:35:01 -0800
On 01/11/2014 07:42 PM, Stefan Monnier wrote:
>> Narrowing *is* generally useful for treating part of a buffer
>> as a consistent unit, though, especially when that part is syntactically
>> different from the rest of the buffer.
>
> Actually, from where I stand, narrowing is harmful.  If I could get rid
> of it, I would.

Really? It's a very useful feature at a *user* level even if we ignore 
the lisp-level implications. Doesn't everyone whack C-x n d once in a 
while? Would you have implemented narrowing by putting invisible 
properties on the inaccessible region?

> The reason is precisely because it means different
> things to different people in different contexts, and these things
> require subtly different behaviors which are mutually incompatible.

As I see it, there are generally two use cases:

1) I'm a user and want to limit my view of the buffer, and
2) I'm a lisp program and want to put ad-hoc bounds on various operations.

I don't see why the two uses would be incompatible.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sun, 12 Jan 2014 15:55:03 GMT) Full text and rfc822 format available.

Message #80 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: nbtrap <at> nbtrap.com, 16413 <at> debbugs.gnu.org, monnier <at> iro.umontreal.ca
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sun, 12 Jan 2014 17:53:47 +0200
> Date: Sat, 11 Jan 2014 20:35:01 -0800
> From: Daniel Colascione <dancol <at> dancol.org>
> CC: Eli Zaretskii <eliz <at> gnu.org>, nbtrap <at> nbtrap.com, 
>  16413 <at> debbugs.gnu.org
> 
> > The reason is precisely because it means different
> > things to different people in different contexts, and these things
> > require subtly different behaviors which are mutually incompatible.
> 
> As I see it, there are generally two use cases:
> 
> 1) I'm a user and want to limit my view of the buffer, and
> 2) I'm a lisp program and want to put ad-hoc bounds on various operations.
> 
> I don't see why the two uses would be incompatible.

I think Stefan meant use cases with different Lisp-level features and
operations, like moving point as opposed to examining text properties.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sun, 12 Jan 2014 21:38:02 GMT) Full text and rfc822 format available.

Message #83 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 16413 <at> debbugs.gnu.org, nbtrap <at> nbtrap.com
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sun, 12 Jan 2014 16:37:46 -0500
> As I see it, there are generally two use cases:
> 1) I'm a user and want to limit my view of the buffer, and
> 2) I'm a lisp program and want to put ad-hoc bounds on various operations.
> I don't see why the two uses would be incompatible.

Typical problematic questions:
- should line-number-at-pos count from point-min or from 1?
- should syntax-ppss consider that point-min is "outside of any
  comment/string/paren/..."?

  

        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Sun, 12 Jan 2014 22:19:01 GMT) Full text and rfc822 format available.

Message #86 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Daniel Colascione <dancol <at> dancol.org>,
 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sun, 12 Jan 2014 17:17:51 -0500
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> Typical problematic questions:
> - should line-number-at-pos count from point-min or from 1?
> - should syntax-ppss consider that point-min is "outside of any
>   comment/string/paren/..."?

Apart from the consideration of breaking existing elisp, do you think
there's substantial disagreement on these questions?  In the case of the
second question at least, the answer seems obvious if the end goal is
proper syntax recognition in narrowed buffers.  But maybe that's naïve.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Mon, 13 Jan 2014 04:02:01 GMT) Full text and rfc822 format available.

Message #89 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Daniel Colascione <dancol <at> dancol.org>,
 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sun, 12 Jan 2014 23:01:27 -0500
> Apart from the consideration of breaking existing elisp, do you think
> there's substantial disagreement on these questions?

Oh yes.  Look at the uses of narrowing in info-mode for an example.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Mon, 13 Jan 2014 04:05:02 GMT) Full text and rfc822 format available.

Message #92 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Daniel Colascione <dancol <at> dancol.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>, 
 Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sun, 12 Jan 2014 20:04:25 -0800
On 01/12/2014 08:01 PM, Stefan Monnier wrote:
>> Apart from the consideration of breaking existing elisp, do you think
>> there's substantial disagreement on these questions?
>
> Oh yes.  Look at the uses of narrowing in info-mode for an example.

What about it? It looks like normal elisp use of narrowing to me.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Mon, 13 Jan 2014 04:22:01 GMT) Full text and rfc822 format available.

Message #95 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Colascione <dancol <at> dancol.org>
Cc: Nathan Trapuzzano <nbtrap <at> nbtrap.com>, 16413 <at> debbugs.gnu.org,
 Eli Zaretskii <eliz <at> gnu.org>
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Sun, 12 Jan 2014 23:21:13 -0500
>>> Apart from the consideration of breaking existing elisp, do you think
>>> there's substantial disagreement on these questions?
>> Oh yes.  Look at the uses of narrowing in info-mode for an example.
> What about it? It looks like normal elisp use of narrowing to me.

To the user, the text outside of the visible area doesn't exist at all.
(line-number-at-pos (point-min)) should return 1 there, even though
there are always several/many lines of text before point-min.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Mon, 13 Jan 2014 12:10:02 GMT) Full text and rfc822 format available.

Message #98 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Daniel Colascione <dancol <at> dancol.org>,
 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Mon, 13 Jan 2014 07:09:06 -0500
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> To the user, the text outside of the visible area doesn't exist at all.
> (line-number-at-pos (point-min)) should return 1 there, even though
> there are always several/many lines of text before point-min.

So maybe there should be a defcustom that says whether to number lines
according to the whole buffer or just the narrowed part.  These problems
seem far from insurmountable.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Mon, 13 Jan 2014 14:52:02 GMT) Full text and rfc822 format available.

Message #101 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, Daniel Colascione <dancol <at> dancol.org>,
 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50;
 Inconsistent behavior of text property functions in narrowed buffer
Date: Mon, 13 Jan 2014 09:51:22 -0500
> So maybe there should be a defcustom that says whether to number lines
> according to the whole buffer or just the narrowed part.

No, a variable is not sufficient: you can still use narrowing within the
info-mode's narrowed page.  The "outer narrowing" should give the
illusion that the outer text doesn't exist, while the inner one shouldn't.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#16413; Package emacs. (Thu, 28 Apr 2022 11:11:02 GMT) Full text and rfc822 format available.

Message #104 received at 16413 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Nathan Trapuzzano <nbtrap <at> nbtrap.com>, 16413 <at> debbugs.gnu.org
Subject: Re: bug#16413: 24.3.50; Inconsistent behavior of text property
 functions in narrowed buffer
Date: Thu, 28 Apr 2022 13:09:58 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> So do you think the current behavior is consistent, or are you just
>> cautious about trying to change it?
>
> I'm cautious about changing this and don't see the apparent
> inconsistency as a big deal.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

I don't think we want to change the behaviour at this point, as that
might break a lot of code subtly out there, but it should be documented.
So I've now done that in Emacs 29, and I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 16413 <at> debbugs.gnu.org and Nathan Trapuzzano <nbtrap <at> nbtrap.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Thu, 28 Apr 2022 11:11:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 26 May 2022 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 1 year and 335 days ago.

Previous Next


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