all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How do I position a child-frame below the point?
@ 2018-01-06  7:29 Aaron Jensen
  2018-01-07 13:26 ` Alan Third
  2018-01-07 16:09 ` martin rudalics
  0 siblings, 2 replies; 6+ messages in thread
From: Aaron Jensen @ 2018-01-06  7:29 UTC (permalink / raw)
  To: emacs-devel

Hi,

I have a few questions about child-frames.

Question #1: I'm trying to create a new child-frame and position it
below the point in the parent frame. If I don't use a child-frame, this
isn't hard:

(defun make-peek-frame ()
  (interactive)
  (let* ((current-frame (selected-frame))
         (abs-pixel-pos (save-excursion
                          (beginning-of-thing 'symbol)
                          (window-absolute-pixel-position)))
         (x (car abs-pixel-pos))
         (y (+ (cdr abs-pixel-pos) (frame-char-height)))
         (buffer (get-buffer-create "*Child Frame*"))
         (peek-frame (make-frame `(
                                   (unsplittable . t)
                                   (name . "*Peek Frame*")
                                   (width . 80)
                                   (visibility . nil)
                                   (cursor-type . nil)
                                   (height . 15)))))
    (set-frame-position peek-frame x y)

    (with-selected-frame peek-frame
      (set-window-buffer (car (window-list)) buffer)
      (with-current-buffer buffer
        (let ((inhibit-read-only t))
          (erase-buffer)
          (insert "HELLO WORLD"))
        (setq-local mode-line-format nil)
        (recenter-top-bottom 0)
        (read-only-mode))
      (raise-frame peek-frame))
    (select-frame current-frame)))

However, if I try this with a child-frame then I'm in frame local
coordinates and I have no idea how to get the appropriate frame local
coordinates for the current point. 

Question #2: 

How do I raise the child frame on macOS without selecting it? I only
want to display it above the current frame, I don't want it to have
focus.

Question #3:

How do I hide the point? I've tried (cursor-type . nil) as above, but it
shows up as a block nonetheless. I do wonder if evil is doing that,
however...

Thanks,

Aaron



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I position a child-frame below the point?
  2018-01-06  7:29 How do I position a child-frame below the point? Aaron Jensen
@ 2018-01-07 13:26 ` Alan Third
  2018-01-07 16:09   ` martin rudalics
  2018-01-07 16:09 ` martin rudalics
  1 sibling, 1 reply; 6+ messages in thread
From: Alan Third @ 2018-01-07 13:26 UTC (permalink / raw)
  To: Aaron Jensen; +Cc: emacs-devel

On Fri, Jan 05, 2018 at 11:29:54PM -0800, Aaron Jensen wrote:
> Question #1: I'm trying to create a new child-frame and position it
> below the point in the parent frame. If I don't use a child-frame, this
> isn't hard:
<snip> 
> However, if I try this with a child-frame then I'm in frame local
> coordinates and I have no idea how to get the appropriate frame local
> coordinates for the current point. 

Could you get the parent frame’s coordinates and subtract them?

    (frame-position (frame-parent child))

> Question #2: 
> 
> How do I raise the child frame on macOS without selecting it? I only
> want to display it above the current frame, I don't want it to have
> focus.

You can turn on no-focus-on-map, but iirc that doesn’t work on macOS.
no-accept-focus does work, but means you can never select that frame.

Alternatively you could try changing the z-group to above, although it
could cause trouble when switching to a different application, I
suppose.

-- 
Alan Third



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I position a child-frame below the point?
  2018-01-06  7:29 How do I position a child-frame below the point? Aaron Jensen
  2018-01-07 13:26 ` Alan Third
@ 2018-01-07 16:09 ` martin rudalics
  2018-01-07 19:44   ` Aaron Jensen
  1 sibling, 1 reply; 6+ messages in thread
From: martin rudalics @ 2018-01-07 16:09 UTC (permalink / raw)
  To: Aaron Jensen, emacs-devel

 > Question #1: I'm trying to create a new child-frame and position it
 > below the point in the parent frame. If I don't use a child-frame, this
 > isn't hard:
 >
 > (defun make-peek-frame ()
 >    (interactive)
 >    (let* ((current-frame (selected-frame))
 >           (abs-pixel-pos (save-excursion
 >                            (beginning-of-thing 'symbol)
 >                            (window-absolute-pixel-position)))

`window-absolute-pixel-position' is a function I wrote so on systems
where child frames are not available (or do not behave well) normal
frames can be used instead.  If you look at its code you will see that
`pos-visible-in-window-p' does all the work, so that's the function to
use.  Thereafter you have to translate window coordinates to native
frame coordinates using `window-inside-pixel-edges' IIRC.  Our
documentation of this is still unsatisfactory.

 > Question #3:
 >
 > How do I hide the point? I've tried (cursor-type . nil) as above, but it
 > shows up as a block nonetheless. I do wonder if evil is doing that,
 > however...

Which "evil"?  The window manager?

martin



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I position a child-frame below the point?
  2018-01-07 13:26 ` Alan Third
@ 2018-01-07 16:09   ` martin rudalics
  0 siblings, 0 replies; 6+ messages in thread
From: martin rudalics @ 2018-01-07 16:09 UTC (permalink / raw)
  To: Alan Third, Aaron Jensen; +Cc: emacs-devel

 >> Question #2:
 >>
 >> How do I raise the child frame on macOS without selecting it? I only
 >> want to display it above the current frame, I don't want it to have
 >> focus.
 >
 > You can turn on no-focus-on-map, but iirc that doesn’t work on macOS.
 > no-accept-focus does work, but means you can never select that frame.

Maybe using 'no-accept-focus' when raising the frame and resetting
it afterwards could work then.  But that's a very crude hack.

 > Alternatively you could try changing the z-group to above, although it
 > could cause trouble when switching to a different application, I
 > suppose.

Conceptually it should not cause any troubles so that's the best
solution IMO.

martin




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I position a child-frame below the point?
  2018-01-07 16:09 ` martin rudalics
@ 2018-01-07 19:44   ` Aaron Jensen
  2018-01-08  5:30     ` Aaron Jensen
  0 siblings, 1 reply; 6+ messages in thread
From: Aaron Jensen @ 2018-01-07 19:44 UTC (permalink / raw)
  To: martin rudalics, emacs-devel

From: martin rudalics (mailto:rudalics@gmx.at)
> > Question #3:
> >
> > How do I hide the point? I've tried (cursor-type . nil) as above, but it
> > shows up as a block nonetheless. I do wonder if evil is doing that,
> > however...
>
> Which "evil"? The window manager?

The vim emulation mode.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: How do I position a child-frame below the point?
  2018-01-07 19:44   ` Aaron Jensen
@ 2018-01-08  5:30     ` Aaron Jensen
  0 siblings, 0 replies; 6+ messages in thread
From: Aaron Jensen @ 2018-01-08  5:30 UTC (permalink / raw)
  To: martin rudalics, emacs-devel

From: Aaron Jensen (mailto:aaronjensen@gmail.com)
> From: martin rudalics (mailto:rudalics@gmx.at)
> > > Question #3:
> > >
> > > How do I hide the point? I've tried (cursor-type . nil) as above, but it
> > > shows up as a block nonetheless. I do wonder if evil is doing that,
> > > however...
> >
> > Which "evil"? The window manager?
>
> The vim emulation mode.

It was indeed evil-mode. Disabling it for that buffer works to hide
the point. An example for posterity:

(add-to-list 'evil-buffer-regexps '("^ \\*company-childframe\\*”))

Aaron



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-01-08  5:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-06  7:29 How do I position a child-frame below the point? Aaron Jensen
2018-01-07 13:26 ` Alan Third
2018-01-07 16:09   ` martin rudalics
2018-01-07 16:09 ` martin rudalics
2018-01-07 19:44   ` Aaron Jensen
2018-01-08  5:30     ` Aaron Jensen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.