From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: include new package wconf.el in GNU ELPA Date: Fri, 31 Jul 2015 15:39:32 +0200 Message-ID: <87h9okh2ej.fsf@gnu.org> References: <877fph8xwx.fsf@acer.localhost.com> <87d1z9a210.fsf@gnu.org> <871tfp8ir0.fsf@acer.localhost.com> <87lhdwhosp.fsf@gnu.org> <55BB1F61.7030104@gmx.at> <87twskhgu6.fsf@gnu.org> <55BB463D.4080202@gmx.at> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1438350012 30392 80.91.229.3 (31 Jul 2015 13:40:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 31 Jul 2015 13:40:12 +0000 (UTC) Cc: Ingo Lohmar , emacs-devel@gnu.org To: martin rudalics Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jul 31 15:39:56 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZLAXT-0007WE-Tn for ged-emacs-devel@m.gmane.org; Fri, 31 Jul 2015 15:39:56 +0200 Original-Received: from localhost ([::1]:44559 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLAXT-0006oN-AB for ged-emacs-devel@m.gmane.org; Fri, 31 Jul 2015 09:39:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58909) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLAXI-0006oH-2B for emacs-devel@gnu.org; Fri, 31 Jul 2015 09:39:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZLAXC-0004nm-Jr for emacs-devel@gnu.org; Fri, 31 Jul 2015 09:39:44 -0400 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:53691) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZLAXC-0004nL-Ft for emacs-devel@gnu.org; Fri, 31 Jul 2015 09:39:38 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5D505209A1 for ; Fri, 31 Jul 2015 09:39:36 -0400 (EDT) Original-Received: from frontend1 ([10.202.2.160]) by compute3.internal (MEProxy); Fri, 31 Jul 2015 09:39:36 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=Eo10vmwONaSWnnTGLgvsSvSq6c4=; b=N2FuF dlB4JrVEOhdu+3xfui/vJcfTffnUUmgssxze8u5vddSIfrooVXR0HYXnJoJHUQNv 9BZu3OIEx4ThHFUr6WaHE/QXmwO6O0F3UyXatg4n8Ytg/R4q6MxE5JGH4u4nQqYL 0LvMnKjrD8qr9IgU+UbdogfQI10cMpFKbfqXW4= X-Sasl-enc: RVDlmoyXm/Krf9NiXqlD9IeO2jvzQL1PQ8ukRIDxc9mm 1438349975 Original-Received: from thinkpad-t440p (unknown [2.162.149.230]) by mail.messagingengine.com (Postfix) with ESMTPA id 29745C0001C; Fri, 31 Jul 2015 09:39:34 -0400 (EDT) Mail-Followup-To: martin rudalics , Ingo Lohmar , emacs-devel@gnu.org In-Reply-To: <55BB463D.4080202@gmx.at> (martin rudalics's message of "Fri, 31 Jul 2015 11:56:13 +0200") User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.25 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:188235 Archived-At: martin rudalics writes: >> They use `goto-char' in the window which is selected after setting >> the window configuration, so I guess it's the buffer's point. > > I still don't get what you want instead. > >> (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))))) > > All you can possibly want here are window-points, the positions of the > cursor in any window shown before or after setting the configuration. > Calling `buffer-list' makes no sense. Ok, so is this better? --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)))) (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))))))))) (advice-add #'set-window-configuration :around #'th/window-config-keep-points-and-selected-window) --8<---------------cut here---------------end--------------->8--- It seems to do what I had in mind. >> But that's also really bad. For example, `edebug' uses >> `set-window-configuration' internally, so point always jumps back >> after each edebug step. > > `set-window-configuration' should be used only "internally". It's > main design goal is that the user should _not_ be aware of its > existence. > > Maybe you could use `window-state-get' and `window-state-put' instead. 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? Bye, Tassilo