[Top][All Lists]

[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: Fri, 31 Jul 2015 07:35:50 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Ingo Lohmar <address@hidden> writes:

Hi Ingo,

> I have not thought about the point and window business yet, so there's
> no option.  Generally I am wary of dealing with window-config details
> (which I did in a much earlier version of the package), but this seems
> like a general and useful switch to have.. Maybe I will add that.  It
> would help me if you could add a github issue describing the option
> behavior, otherwise I'll try to keep a note myself.

I've thought about it, and I think such an option should be in emacs
itself so that you can have that behavior with winner, wconf, or
whatever else you use for window config business.

I had a look at the corresponding code in emacs, and actually the
restoration of point is not done in `set-window-configuration' but
instead it's done afterwards in `jump-to-register', in `winner-set', and
probably other places as well.

The best I could come up so far is this advice, which uses an ugly timer
to reclaim back the current points...

--8<---------------cut here---------------start------------->8---
(defun th/window-config-keep-points-and-selected-window (old config)
  (let ((bufpoints (mapcar
                    (lambda (buf)
                      (cons buf (with-selected-window (get-buffer-window buf)
                    (cl-remove-if-not #'get-buffer-window
                                      (buffer-list (selected-frame)))))
        (p (point)))
    (funcall old config)
    (when-let ((w (get-buffer-window)))
      (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)
                        (let ((buf (car bp))
                              (p   (cdr bp)))
                          (when-let ((w (get-buffer-window buf)))
                                (goto-char p)))))))))

(advice-add #'set-window-configuration :around
--8<---------------cut here---------------end--------------->8---


reply via email to

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