help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

posn-at-point returns nil after goto-char


From: D Chiesa
Subject: posn-at-point returns nil after goto-char
Date: Sun, 11 Apr 2010 03:30:21 -0400

I've got a function that looks something like this:

   (defun my-move-and-popup-menu ()
     "move the point, then pop up a menu."
       (goto-char xxxx)
       (setq p (posn-at-point))
       (my-popup-menu p ...)
   )

Basically, move the point, then retrieve the screen position at that point, and then popup a menu at that screen position.

But I am finding that `posn-at-point` returns non-nil, only if the xxxx character position (the *after* position) is visible in the window, *before* the call to `goto-char`. It seems that the position is not actually updated until exit from the function. If `goto-char` goes a long way, more than one screenful, then the retrieved position is always nil, and my code doesn't know where to popup the menu.

The reason I suggest that the position is not actually updated until exit from the function - when the menu successfully pops up (which happens when the xxxx position is visible, though not at point, before entering the function), the cursor is clearly visible in its previous location while the popup menu is being displayed. When I dismiss the menu, the cursor moves to where I expected it to move, during the `goto-char` call.

How can I get the position to be *really* updated, between `goto-char` and `posn-at-point`, so that `posn-at-point` will not return nil?

Thanks for any hints y'all can provide.


D Chiesa






reply via email to

[Prev in Thread] Current Thread [Next in Thread]