unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Nicolas Richard <theonewiththeevillook@yahoo.fr>
Cc: 14241@debbugs.gnu.org
Subject: bug#14241: 24.3; widgets and posn-at-point
Date: Mon, 22 Apr 2013 20:39:50 +0300	[thread overview]
Message-ID: <83k3nuxy55.fsf@gnu.org> (raw)
In-Reply-To: <51750A22.9050009@yahoo.fr>

> Date: Mon, 22 Apr 2013 12:00:02 +0200
> From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
> 
> Running the following code in a graphical emacs
> 
> (let (oposn opoint)
>   (widget-create 'checkbox) ; point is left after the widget
>   (setq oposn (posn-at-point)
>         opoint (point))
>   (forward-char -1) ; point now at the widget
>   (message "Old: %s (Point at %d)\nNew: %s (Point at %d)"
> 	   oposn opoint
> 	   (posn-at-point) (point)))
> 
> shows that oposn and (posn-at-point) are the same but opoint and (point)
> are different.

I don't think there's a bug here.  This behavior might be surprising,
but it is entirely predictable.

The problem is that creating the checkbox widget in a GUI session puts
an overlay over 3 buffer positions, the text "[ ]".  So the buffer
position immediately preceding opoint is, for all practical purposes,
inaccessible: you cannot put point there, because Emacs will banish it
outside the overlay right away.  To see that, try this simplified
recipe:

 M-: (widget-create 'checkbox) RET
 C-x =
 M-: (forward-char -1) RET
 C-x =

See how point doesn't move?

However, the way Emacs implements this restriction is not on the
buffer level, it is on the command-loop and cursor positioning level.
So while your Lisp code runs, it "succeeds" to put point in the
forbidden area, and assigns that to opoint.  But posn-at-point
collects its data by emulating display routines, so it abides by the
rules of cursor positioning, and reports the position after the widget
regardless.  And point is moved back to after the widget once the Lisp
code is exhausted and execution returns to top level.

Any real-life code that bumps into this needs to work around this
peculiarity.  E.g., don't try forward-char to a position that is
covered by an overlay.





  reply	other threads:[~2013-04-22 17:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-22 10:00 bug#14241: 24.3; widgets and posn-at-point Nicolas Richard
2013-04-22 17:39 ` Eli Zaretskii [this message]
     [not found]   ` <5176A068.7000201@yahoo.fr>
2013-04-23 20:21     ` Eli Zaretskii
2013-04-24 11:48       ` Nicolas Richard
2013-05-06 17:12         ` Eli Zaretskii

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=83k3nuxy55.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=14241@debbugs.gnu.org \
    --cc=theonewiththeevillook@yahoo.fr \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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