emacs-devel
[Top][All Lists]
Advanced

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

Re: include new package wconf.el in GNU ELPA


From: Tassilo Horn
Subject: Re: include new package wconf.el in GNU ELPA
Date: Mon, 03 Aug 2015 09:45:51 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

martin rudalics <address@hidden> writes:

>> --8<---------------cut here---------------start------------->8---
>> ;; Keep window selection and point
>> (defun th/window-config-keep-points-and-selected-window (old config)
>>    (let ((bufpoints (mapcar (lambda (win)
>>                           (cons (window-buffer win) (window-point win)))
>>                         (window-list (selected-frame))))
>
> Here you record window points ...
>
>>      (selected-buf (current-buffer)))
>>      (funcall old config)
>>      ;; Do our magic only if called interactively.
>>      (when (and (memq this-command '(jump-to-register winner-undo 
>> winner-redo))
>>             (called-interactively-p 'interactive))
>>        ;; Restore selected window
>>        (when-let ((w (get-buffer-window selected-buf)))
>>      (select-window w))
>>        ;; The setting of point is not performed by `set-window-configuration'
>>        ;; itself but by `jump-to-register' or the winner functions.
>>        (run-with-timer 0.139 nil
>>                    (lambda ()
>>                      (dolist (bp bufpoints)
>>                        (when-let ((w (get-buffer-window (car bp))))
>>                          (set-window-point win (cdr bp)))))))))
>
> ... and here you restore them in some completely arbitrary manner.
> This can work reasonably iff all windows show different buffers.

Yes, that was kind of an assumption.  In the presence of multiple
windows on the same buffer in either the from or to window
configuration, there are lots of special cases to which I don't have an
answer, yet.  (Neither code nor what should actually happen.)

>> You mean, get the state of all windows in the current window
>> configuration, then switch to the other, and then put the state back
>> for all windows of buffers that were also displayed in the previous
>> WC?
>
> `window-state-get' gets you a Lisp object that you can manipulate.
> For example, you can replace point positions in some arbitrary way.
> Doing the same with an object returned by
> `current-window-configuration' is practically impossible.

I see, thanks.

Bye,
Tassilo



reply via email to

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