From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi 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 11:25:01 +0000 Message-ID: References: <87zioutd4v.fsf@mbork.pl> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1470224159 20734 195.159.176.226 (3 Aug 2016 11:35:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Aug 2016 11:35:59 +0000 (UTC) To: Marcin Borkowski , Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 03 13:35:54 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 1bUuSi-0004Rn-PZ for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Aug 2016 13:35:49 +0200 Original-Received: from localhost ([::1]:33669 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUuSf-0005WT-AB for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Aug 2016 07:35:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUuIV-0004dn-Tf for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 07:25:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUuIT-0006sY-91 for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 07:25:14 -0400 Original-Received: from mail-oi0-x236.google.com ([2607:f8b0:4003:c06::236]:35650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUuIT-0006sU-2i for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 07:25:13 -0400 Original-Received: by mail-oi0-x236.google.com with SMTP id 4so65964525oih.2 for ; Wed, 03 Aug 2016 04:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=A2AzQ9DTBKN6ScHdi5qw2Z0cdDtdLSYB0+wuhbugi94=; b=es+MKnTNVTlrKbdUKma0I7NzhJ66tpPkSnVtrN0hWTozYZTZjsHHzJTg+bKO7ZEfUA 2IEB5FCCYmBjLsC4KGlyhPt93WS4hwQ7nk3/vZO6HluEWVGvcFWwP6gLdmSWa9iBBRP8 UtyeZjzLzdsOiEoL3Hfr6DNSRlAwHvK7d6pKRcemHuW2Mhfh31CCWyDRnAmV+HN2E9n1 8tNFafJicqJAI/SNLYjN1yIgqd0YETtHnySo1RSq8+6QqEDr2s2kxhO2AVZleOzYy5D9 nUPw6SnYeZQEneNY8WW9al7bQDnkZKu2b/+DW3/z2J0x104saRRlF2JGbJiQHrs06pQa AY9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=A2AzQ9DTBKN6ScHdi5qw2Z0cdDtdLSYB0+wuhbugi94=; b=QPy8Ba91zxtRAJ9v9/wSEwsf/KxloMMRCkzUky0bmOVldhtzfZ1hafrIf5Fy1L2Qrr K/V2qkJKHcvj4eyEwOL0Skn7+xq3oodSS4UD6+N8FUR8e5qhoYlZff8wg81041xm0T2t dcfKEqN9zQ/kykBzzdkeagPo+ey8F6J21vL4BJRVKzD3dbJo7Tct6bD99MF+bA5RakSd zoStMzlnriIajB2txSvx+5NqFC30Gvh1+KE6A107hnBlrOyYiUM6AqycqbXWasQdDPok D/0Ev4R960A+SLf+vAnKTHccfYb3E9+ocz2afGrwlnFaS1DJUJSam1NQCX8lAMHOASVT VynA== X-Gm-Message-State: AEkooutqoqhbNctlFFYFF4Wg44TJwwkCqZaXKzNkESF5tI5j7Y1A4CQO8XLeoDs8C92db00uv3YP+M7j4eMBtQ== X-Received: by 10.157.17.169 with SMTP id v38mr38962739otf.11.1470223512339; Wed, 03 Aug 2016 04:25:12 -0700 (PDT) In-Reply-To: <87zioutd4v.fsf@mbork.pl> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::236 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:111052 Archived-At: Here are a couple of things that might help you: (1) Setting scroll-preserve-screen-position to a non-nil value. If you happen to C-c/M-v so that the point changes its position, but if the above is set to t and you reverse the scroll direction, you will find the cursor at the exact same position where you last left it. https://www.gnu.org/software/emacs/manual/html_node/emacs/Scrolling.html (2) Use C-u C-SPC When you do large vertical positions, emacs auto-saves the previous marks to the mark-ring. It is very convenient to jump back to those older marks by hitting C-u C-SPC. https://www.gnu.org/software/emacs/manual/html_node/emacs/Mark-Ring.html (3) Use winner-mode This is a golden mode, used to conveniently jump back and forth window configurations. The awesome thing is that you do not need to manually save those configurations. All window configuration changes are auto-saved. https://www.gnu.org/software/emacs/manual/html_node/emacs/Window-Convenience.html (4) Create mini wrapper functions to scroll current/other window without moving the cursor position. I have the below in my config. ;;; Scrolling ;; Keep point at its screen position if the scroll command moved it vertically ;; out of the window, e.g. when scrolling by full screens using C-v. (setq scroll-preserve-screen-position t) ;; Scroll without moving the point/cursor (defun modi/scroll-up (ln) "Scroll up by LN lines without moving the point. If LN is nil, defaults to 1 line." (interactive "p") (scroll-up ln)) (defun modi/scroll-down (ln) "Scroll down by LN lines without moving the point. If LN is nil, defaults to 1 line." (interactive "p") (scroll-down ln)) (defun modi/scroll-other-window-up (ln) "Scroll other window up by LN lines without moving the point. If LN is nil, defaults to 1 line." (interactive "p") (scroll-other-window ln)) (defun modi/scroll-other-window-down (ln) "Scroll other window down by LN lines without moving the point. If LN is nil, defaults to 1 line." (interactive "p") (scroll-other-window (- ln))) ;; Below bindings are made in global map and not in my minor mode as I want ;; other modes to override those bindings. (bind-keys ("" . modi/scroll-down) ("" . modi/scroll-up) ("" . modi/scroll-other-window-down) ("" . modi/scroll-other-window-up)) On Wed, Aug 3, 2016, 5:32 AM Marcin Borkowski wrote: > Hi all, > > sometimes I work on a particular place in some buffer, and Emacs for > some reason scrolls me out of that place. I want then to get back to > it. 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. > (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?) > > 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, but from reading the manual I'm not sure what > a "window configuration" really is. What does a "window configuration" > consist of, exactly? > > TIA, > > -- > Marcin Borkowski > http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski > Faculty of Mathematics and Computer Science > Adam Mickiewicz University > > -- Kaushal Modi