From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Re: How to get back to a place in a buffer, or: what is a window configuration? Date: Wed, 03 Aug 2016 20:42:00 +0200 Message-ID: <87r3a5u22v.fsf@mbork.pl> References: <87zioutd4v.fsf@mbork.pl> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1470249770 9830 195.159.176.226 (3 Aug 2016 18:42:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Aug 2016 18:42:50 +0000 (UTC) User-Agent: mu4e 0.9.16; emacs 25.1.50.6 Cc: Help Gnu Emacs mailing list To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 03 20:42:45 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bV17r-0001ly-PU for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Aug 2016 20:42:43 +0200 Original-Received: from localhost ([::1]:36214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV17o-0007xY-ED for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Aug 2016 14:42:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV17E-0007vY-Nd for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 14:42:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bV17B-0007up-IG for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 14:42:04 -0400 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:60940) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV17B-0007uC-6v for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 14:42:01 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id C8883E620E; Wed, 3 Aug 2016 20:41:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZqS3wdq_pcEs; Wed, 3 Aug 2016 20:41:55 +0200 (CEST) Original-Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id B29C1E603B; Wed, 3 Aug 2016 20:41:54 +0200 (CEST) In-reply-to: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:5e00:2:52::8 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111055 Archived-At: On 2016-08-03, at 16:42, Drew Adams wrote: >> sometimes I work on a particular place in some buffer, > > A place (position) in a buffer has little or nothing to do with > windows. By "place", I meant two things: (1) where the point is and (2) what is the first (topmost) actually displayed (visible) line. > It sounds, from the rest of your question, like you are more > interested in restoring a window configuration. But your > question is still unclear, to me. Hopefully, Kaushal's answer > gives you what you want. More or less. I'm now convinced that window configurations were what I was looking for. >> and Emacs for some reason scrolls me out of that place. I want >> then to get back to it. > > Getting back to a buffer position is simple - you can use > temporary bookmarks or the mark ring or other methods. But > I don't think that's really what you're asking. Right, it's not what I meant. >> Is there a way (in stock Emacs or with help of M?elpa) to >> accomplish that? >> >> Bonus points for a package/command which /temporarily/ disables C-v/M-v >> and other commands that might result in scrolling text in the window. > > I don't see the connection between that and your request > (apparently) to restore a window config. Is it that you really > (or additionally?) want to prevent moving `window-point'? > or perhaps prevent it from moving too far? The underlying > question or use case is not clear to me. My goal (though probably not my words;-), sorry) is simple: I want the "place" (in the sense of the above definition) to stay the same, /or/ I want to be able to easily restore it. The former should be doable with narrowing, the latter probably with window configurations. >> (Narrowing to what is currently visible should do the trick, so >> a combination of M-r, C-e and C-SPC would probably do what I want. >> Coding that is three minutes, but maybe someone did it already?) > > If narrowing to what is currently shown in the window is > what you're looking for, then yes, you can easily code that. > > (If you use library zones.el then you can easily flip among > multiple narrowings, in case that is related to what you want. > https://www.emacswiki.org/emacs/MultipleNarrowings) I heard about it, though I don't really see much use (for me, not in general). OTOH, I use narrowing quite a lot, so maybe I could give it a try. >> Note that it's not the same as keeping a position in a register. >> A simple experiment shows that keeping a /window configurations/ seems >> to do what I want, > > `C-x r w' puts window-config in a register. `C-x r j' restores it. I learned about it today while rereading the manual. Very useful indeed! >> but from reading the manual I'm not sure what >> a "window configuration" really is. What does a "window >> configuration" consist of, exactly? > > What part of (elisp) `Window Configurations' is unclear to you? Well, now I see it... But look at this: ,----[ (emacs) Configuration Registers ] | You can save the window configuration of the selected frame in a | register, or even the configuration of all windows in all frames, and | restore the configuration later. *Note Windows::, for information about | window configurations. `---- ,----[ (emacs) Window Convenience ] | Winner mode is a global minor mode that records the changes in the | window configuration (i.e., how the frames are partitioned into | windows), so that you can undo them. `---- See? Basically nothing in the /Emacs manual/ explains precisely what a "window configuration" is. On the other hand, the /Elisp reference/ is pretty clear. I'd consider this a bug in the docs: a /user/ should not need to consult the Elisp reference. I'll try to come up with a patch for the docs soon. Thanks, -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University