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: martin rudalics
Subject: Re: include new package wconf.el in GNU ELPA
Date: Sat, 01 Aug 2015 12:50:36 +0200

> Ok, so is this better?

Not much.

>
> --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.

> 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.

martin



reply via email to

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