From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: window.el modify current emacs23 behavior of anything. Date: Wed, 21 Sep 2011 08:34:09 +0200 Message-ID: <87ipom8kv2.fsf@gmail.com> References: <87aaaab8jn.fsf@gmail.com> <4E6FA0E6.2090003@gmx.at> <877h585trj.fsf@gmail.com> <4E738310.2070005@gmx.at> <8739fw5lip.fsf@gmail.com> <4E745D84.8050301@gmx.at> <87pqiz3xov.fsf@gmail.com> <4E74D8AF.8000603@gmx.at> <87r53ecj65.fsf@gmail.com> <4E78BA49.4070306@gmx.at> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1316586866 11697 80.91.229.12 (21 Sep 2011 06:34:26 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 21 Sep 2011 06:34:26 +0000 (UTC) Cc: martin rudalics , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 21 08:34:22 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R6GNw-0004b6-Am for ged-emacs-devel@m.gmane.org; Wed, 21 Sep 2011 08:34:20 +0200 Original-Received: from localhost ([::1]:50438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6GNv-0007nk-Ra for ged-emacs-devel@m.gmane.org; Wed, 21 Sep 2011 02:34:19 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:34592) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6GNt-0007nP-El for emacs-devel@gnu.org; Wed, 21 Sep 2011 02:34:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6GNs-0001ER-2m for emacs-devel@gnu.org; Wed, 21 Sep 2011 02:34:17 -0400 Original-Received: from mail-wy0-f180.google.com ([74.125.82.180]:46303) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6GNr-0001E9-Lt for emacs-devel@gnu.org; Wed, 21 Sep 2011 02:34:15 -0400 Original-Received: by wyj26 with SMTP id 26so2333005wyj.39 for ; Tue, 20 Sep 2011 23:34:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=Ha5XU7V36IFLFmR0ysUf25zytzm0mxbsMmuPN+pf920=; b=o3HPSY1MzWuYcL17bagNXjH1YKBM80/GTPLQhnZ1xv3RJwdMOADWcHvPEf6UfcrVam JxI6TaKSHWVACrxaMydJeWL1uq6ALMOAYdXUcQDh9g8ECW6vuZz2CMgsi2JGe6S3i1Xf cpaY6XUuM/3pgO+H8/gqeqpQM3TwRUbCPnrSE= Original-Received: by 10.216.132.226 with SMTP id o76mr1775458wei.17.1316586854492; Tue, 20 Sep 2011 23:34:14 -0700 (PDT) Original-Received: from thierry-MM061 (82.211.85.79.rev.sfr.net. [79.85.211.82]) by mx.google.com with ESMTPS id gd6sm5644909wbb.1.2011.09.20.23.34.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Sep 2011 23:34:12 -0700 (PDT) In-Reply-To: (Stefan Monnier's message of "Tue, 20 Sep 2011 18:08:25 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 74.125.82.180 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:144136 Archived-At: Stefan Monnier writes: >> When `bury-buffer' restores the buffer previously shown in the selected >> window, it also restores that buffer's `window-start' and `window-point' >> position in the window. If the window is selected, this implicitly >> moves the buffer's point to the window's point. This means that if the >> restored buffer's point was changed before calling `bury-buffer', that >> position is lost. > > Oh, I see the problem: > > Try M-: (progn (set-window-start (selected-window) (point)) (goto-char (point-min))) > > and you'll see the that set-window-point wins even though it's run > before the goto-char. > > That's why a sit-for works around the problem: it causes the > set-window-start to be "executed", letting the subsequent goto-char do > its job. > > So maybe the right fix is to remove the call to set-window-start. Using the NOFORCE arg of `set-window-start' seem to fix problem in anything, but don't know if it can create problems in other places: #+BEGIN_SRC lisp (defun set-window-buffer-start-and-point (window buffer &optional start point) "Set WINDOW's buffer to BUFFER. Optional argument START non-nil means set WINDOW's start position to START. Optional argument POINT non-nil means set WINDOW's point to POINT. If WINDOW is selected this also sets BUFFER's `point' to POINT. If WINDOW is selected and the buffer it showed before was current this also makes BUFFER the current buffer." (let ((selected (eq window (selected-window))) (current (eq (window-buffer window) (current-buffer)))) (set-window-buffer window buffer) (when (and selected current) (set-buffer buffer)) (when start (set-window-start window start t)) ;; Use noforce arg. (when point (if selected (with-current-buffer buffer (goto-char point)) (set-window-point window point))))) #+END_SRC `set-window-buffer-start-and-point' is called by `switch-to-prev-buffer' which is called by `bury-buffer'. -- A+ Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997