I need to get the coordinate of point for childframe and currently my approach is this (copied from the manual):

(let* ((pos (posn-at-point point window))
         (x-y (posn-x-y pos))
         (window (posn-window pos))
         (edges (window-body-pixel-edges window)))
    (cons (+ (car x-y) (car edges))
          (+ (cdr x-y) (cadr edges))))

This worked well for the most part, but the coordinate is off when I enable ‘tool-bar-mode’ on NS build in Emacs 27 which is odd. Because according to the manual, tool-bar is not included in the native frame for NS and GTK+ build, and IIUC childframe's coordinate is relative to the native frame.

Anyhow, I just want to know if there is a reliable/portable way to get the coordinate of the point that can be used for childframe.

P.S. My Emacs build:

GNU Emacs 27.0.50 (build1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G103)) of 2019-10-08```
  • posn-at-point is defined in keyboard.c in the Emacs internals written in C. If one or more of the values returned by that function is/are incorrect, then you should report this is as a bug -- providing a recipe beginning with zero user configuration. M-x report-emacs-bug – lawlist Nov 2 '19 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.