emacs-mini-frame icon indicating copy to clipboard operation
emacs-mini-frame copied to clipboard

Feature request: position relative to the current window or to the cursor

Open mullr opened this issue 2 years ago • 4 comments

Rather than positioning the mini-frame relative to the frame, I'd like to position it relative to the current window. In some specific cases, I'd also like to be able to to position it relative to the cursor (e.g. lsp-execute-code-action)

mullr avatar Aug 05 '21 20:08 mullr

I was able to implement cursor-relative positioning using a custom mini-frame-show-parameters value:

   (lambda ()
     (cl-destructuring-bind
         ((cursor-x . cursor-y) . (frame-left . frame-top))
         (cons (window-absolute-pixel-position nil (selected-window))
               (frame-position))

       `((top . ,(- cursor-y frame-top))
         (width . (text-pixels . 1000))
         (height . 15)
         (left . ,(- cursor-x frame-left)))))

mullr avatar Aug 11 '21 16:08 mullr

But in case the point is near the bottom of the frame, we want to show the mini-frame above the point, right?

I've done point related child frame positioning in my other package and it looks a bit complicated.

I want to keep mini-frame package as simple as possible. Thats why I leave the frame positioning up to user.

Let's keep this feature request open, but please don't expect this will be implemented in the near future :)

muffinmad avatar Aug 12 '21 20:08 muffinmad

Yeah, my snippet as a lot of flaws in the ahem edge cases.

mullr avatar Aug 12 '21 20:08 mullr

Hi, mullr

Mini-frame is good enough. If you want to customize a specific position, this example may be helpful:

First, install posframe and require it, then

  (setq mini-frame-show-parameters
	(lambda()
          (let* ((info (posframe-poshandler-argbuilder))
		 (posn (posframe-poshandler-point-top-left-corner info)))
            `((left . ,(car posn))
              (top . ,(cdr posn))))))

The position provided by https://github.com/tumashu/posframe/blob/895c7ab4cde68ff9af9151d64804ae84823a9a2e/posframe.el#L327. Just check it out. : )

futuping avatar Nov 03 '21 12:11 futuping