all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Tassilo Horn <tsdh@gnu.org>
To: Ingo Lohmar <i.lohmar@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: include new package wconf.el in GNU ELPA
Date: Fri, 31 Jul 2015 07:35:50 +0200	[thread overview]
Message-ID: <87lhdwhosp.fsf@gnu.org> (raw)
In-Reply-To: <871tfp8ir0.fsf@acer.localhost.com> (Ingo Lohmar's message of "Thu, 30 Jul 2015 22:58:59 +0200")

Ingo Lohmar <i.lohmar@gmail.com> 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)
				  (point))))
		    (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)))
			    (with-selected-window
				(goto-char p)))))))))

(advice-add #'set-window-configuration :around
	    #'th/window-config-keep-points-and-selected-window)
--8<---------------cut here---------------end--------------->8---

Bye,
Tassilo



  reply	other threads:[~2015-07-31  5:35 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30 15:31 include new package wconf.el in GNU ELPA Ingo Lohmar
2015-07-30 18:57 ` Dmitry Gutov
2015-07-30 19:17 ` Tassilo Horn
2015-07-30 20:58   ` Ingo Lohmar
2015-07-31  5:35     ` Tassilo Horn [this message]
2015-07-31  7:10       ` martin rudalics
2015-07-31  8:27         ` Tassilo Horn
2015-07-31  9:56           ` martin rudalics
2015-07-31 13:39             ` Tassilo Horn
2015-08-01 10:50               ` martin rudalics
2015-08-03  7:45                 ` Tassilo Horn
2015-07-31  9:24       ` Ingo Lohmar
2015-07-31  7:10   ` martin rudalics
2015-07-31  8:37     ` Tassilo Horn
2015-07-31  9:56       ` martin rudalics
2015-07-31 13:56         ` Tassilo Horn
2015-08-01 10:50           ` martin rudalics

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhdwhosp.fsf@gnu.org \
    --to=tsdh@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=i.lohmar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.