unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Marcin Borkowski <mbork@mbork.pl>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Inspecting behaviour of `make-overlay', is this expected?
Date: Sun, 25 Dec 2022 14:10:56 +0300	[thread overview]
Message-ID: <Y6gvwLkdbN2fRWFc@protected.localdomain> (raw)
In-Reply-To: <87mt7bsyer.fsf@mbork.pl>

* Marcin Borkowski <mbork@mbork.pl> [2022-12-25 11:05]:
> On 2022-12-24, at 09:36, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> >> Date: Sat, 24 Dec 2022 10:52:47 +0300
> >> From: Jean Louis <bugs@gnu.support>
> >> 
> >> XXXXXXXXXX
> >> ^
> >> | position 0 in buffer
> >> 
> >> (setq my-overlay (make-overlay 0 10))
> >> (get-buffer-window (overlay-buffer my-overlay))
> >> (overlay-put my-overlay 'display "Hello") then I get:
> >> 
> >> HelloX 
> >> 
> >> instead of "Hello"
> >> 
> >> Is this normal behavior?
> >
> > Yes.  The 10 part says that the overlay _ends_ before position 10.
> > This is standard Emacs behavior with text properties and overlays: END
> > means the first character NOT affected by the property/overlay.
> 
> Somewhat related: https://fhur.me/posts/always-use-closed-open-intervals
> (not my piece, just found it on the internet; also I do not want to
> imply the OP doesn't know/understand that - but I consider this short
> article interesting & worthwhile also for others reading this).

I did not put attention, and can't, because the advise is partially
helpful for me to think of similar issues in future, but not to
discover similar issues in past.

We have in Lisp functions like:

(elt '(1 2 3) 0) ➜ 1
(nth 0 '(1 2 3)) ➜ 1
(nth 1 '(1 2 3)) ➜ 2

then for that reason I always think that first char in buffer is 0 and
not 1, and to be conclusive then I use (goto-char (point-min)) because
I never inspected multiple times (point-min) ➜ 1, aha, now I get it.

If the function `make-list' makes 3 elements:

(make-list 3 1) ➜ (1 1 1)

then I want first element be designated as `1' representng "1st" or
"first", but first is second element. It does not give me feeling of
consistency.

(nth 1 '(1 2 3)) ➜ 2

Things already programmed one has to inspect and determine what is
going on.

k
-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



  reply	other threads:[~2022-12-25 11:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-24  7:52 Inspecting behaviour of `make-overlay', is this expected? Jean Louis
2022-12-24  8:36 ` Eli Zaretskii
2022-12-24 16:32   ` Jean Louis
2022-12-25  8:03   ` Marcin Borkowski
2022-12-25 11:10     ` Jean Louis [this message]
2022-12-24 16:30 ` [External] : " Drew Adams
2022-12-24 16:34   ` Jean Louis
2022-12-24 16:39   ` Drew Adams
2022-12-25  6:44     ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y6gvwLkdbN2fRWFc@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.org \
    --cc=mbork@mbork.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).