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:31:49 +0200 Message-ID: <87shulu2ju.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 1470249152 30491 195.159.176.226 (3 Aug 2016 18:32:32 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Aug 2016 18:32:32 +0000 (UTC) User-Agent: mu4e 0.9.16; emacs 25.1.50.6 Cc: Help Gnu Emacs mailing list To: Kaushal Modi Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 03 20:32:27 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 1bV0xu-0007GX-1b for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Aug 2016 20:32:26 +0200 Original-Received: from localhost ([::1]:36179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV0xq-0003Vd-LE for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Aug 2016 14:32:22 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV0xN-0003VL-7n for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 14:31:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bV0xI-0005eo-9c for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 14:31:52 -0400 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:60022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bV0xH-0005eT-UL for help-gnu-emacs@gnu.org; Wed, 03 Aug 2016 14:31:48 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id CEAEB1D6005; Wed, 3 Aug 2016 20:31:45 +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 56D5RNxVUHnK; Wed, 3 Aug 2016 20:31:43 +0200 (CEST) Original-Received: from localhost (static-dwadziewiec-jedenpiec7.echostar.pl [109.232.29.157]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 2F0D81D6004; Wed, 3 Aug 2016 20:31:43 +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:111054 Archived-At: On 2016-08-03, at 13:25, Kaushal Modi wrote: > 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 I know that, and I set scroll-preserve-screen-position to t in my init.el a long time ago. But thanks anyway, it is not very well known! > (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 I know that, too, and I use it often. But point position is not what I'm asking for; I also want the point to get in the same place onthe screen, IOW, I want to preserve the first visible line. > (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 I've heard about it, now that you recommend it, I'll try it out some day, probably sooner than later, thanks! > (4) Create mini wrapper functions to scroll current/other window without > moving the cursor position. I have the below in my config. I also had such functions some time ago, I must have deleted them from my config. OTOH, C-v/M-v with prefix arg seem to do the same, so hey seem a bit redundant to me. > ;;; 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)) Thanks a lot! -- Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University