[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 10:27:45 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

martin rudalics <address@hidden> writes:

>> 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.
> I didn't look into these.  But do they really change a buffer's point?
> Or do they change a window's point (aka `window-point').

They use `goto-char' in the window which is selected after setting the
window configuration, so I guess it's the buffer's point.

BTW, my advice was completely broken.  Here is a better version:

--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)))))
        (selected-buf (current-buffer)))
    (funcall old config)
    ;; 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)
                        (let ((buf (car bp))
                              (p   (cdr bp)))
                          (when-let ((w (get-buffer-window buf)))
                            (with-selected-window w
                              (goto-char p)))))))))

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

But that's also really bad.  For example, `edebug' uses
`set-window-configuration' internally, so point always jumps back after
each edebug step.

Seems like I can't achieve what I'm looking for too easily.


reply via email to

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