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

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

bug#47300: delete-window to select window with same position


From: Juri Linkov
Subject: bug#47300: delete-window to select window with same position
Date: Sun, 06 Jun 2021 23:47:56 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu)

>>> In general, just plugging in some existing function would usually fail
>>> here and I would like to avoid the illusion that it could work.  Also,
>>> as you can see with the 'pos' case, some work must be done _before_
>>> calling `delete-window-internal' so the actual work would have to be
>>> split among two functions at least.
>>
>> The 'pos' case is an exception.  What I meant is simple cases
>> like customizing to 'get-lru-window'.
>
> That one would have to handle the 'no-other-window' parameter.  And we
> would have to mix functions and constants as customizable values which
> looks queer in the customization interface.

The customization interface could use only functions that could be
first called before deletion, then the customized function returns
a lambda that will be called after deletion.  Then for example
all 'pos' logic could be moved to a separate function:

(defun delete-window-pos ()
  (let ((frame-selected-window-edges (window-edges frame-selected-window nil 
nil t))
        (frame-selected-window-pos (nth 2 (posn-at-point nil 
frame-selected-window))))
    (lambda ()
      (let ((new-frame-selected-window
             (window-at-pos
              (+ (nth 0 frame-selected-window-edges)
                 (car frame-selected-window-pos))
              (+ (nth 1 frame-selected-window-edges)
                 (cdr frame-selected-window-pos))
              frame t)))
        (and new-frame-selected-window
             ;; Select window at WINDOW's position at point.
             (set-frame-selected-window
              frame new-frame-selected-window))))))





reply via email to

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