From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Alexandrov <321942@gmail.com> Newsgroups: gmane.emacs.help Subject: Re: prevent scroll-lock-mode from scrolling? Date: Mon, 20 Jun 2016 13:05:34 +0300 Message-ID: <87y4609nv5.fsf@gmail.com> References: <871t3waaa8.fsf@heimdali.yagibdah.de> <83eg7wcnwj.fsf@gnu.org> <8760t7l8cg.fsf@heimdali.yagibdah.de> <834m8qc2nb.fsf@gnu.org> <87mvmgpwf9.fsf@heimdali.yagibdah.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1466417207 32032 80.91.229.3 (20 Jun 2016 10:06:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 10:06:47 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jun 20 12:06:41 2016 Return-path: Envelope-to: geh-help-gnu-emacs@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 1bEw61-0003bm-IX for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Jun 2016 12:06:21 +0200 Original-Received: from localhost ([::1]:42422 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEw60-000629-PY for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Jun 2016 06:06:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40275) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <321942@gmail.com>) id 1bEw5N-0005tr-3l for help-gnu-emacs@gnu.org; Mon, 20 Jun 2016 06:05:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <321942@gmail.com>) id 1bEw5G-00073T-Pr for help-gnu-emacs@gnu.org; Mon, 20 Jun 2016 06:05:39 -0400 Original-Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]:34760) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <321942@gmail.com>) id 1bEw5G-00073B-E2 for help-gnu-emacs@gnu.org; Mon, 20 Jun 2016 06:05:34 -0400 Original-Received: by mail-lf0-x230.google.com with SMTP id h129so33544422lfh.1 for ; Mon, 20 Jun 2016 03:05:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:to:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=HWwdkk5XkCvOPxkzuqcgIWw39zl2GYB3beJM3ngiyRo=; b=J+spdKtzy0S/cbN5uD+YCQ/lybUPKtOboLmvAjNUTtvJHa0Xs2CcNONfujxYXrG8au ejl3FZCNRJjnK8UY3pcdP+32GT4ySDGsz38nE9FW3iwMKoa/UPKF///DCP5Qvp6shYTB RuNvfkHw9KF6PUKI00PX/e60qK96hfOYJB4cF4S4fXoc14cgkt0GBndgurys8nD+I8cf Mkfd1c7PtfgS1EK7xjzdO6Ar4mjv8Q7tNoPZheQYbK1KecKui5/qy+vDPce6WyjATKII oduGSUhBDAYG+F3JP7OMdjX7j/VOStKWPSS6GuyU8xn01KaOQGFP0wtA6p6lJv8RIf2n yB8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:to:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=HWwdkk5XkCvOPxkzuqcgIWw39zl2GYB3beJM3ngiyRo=; b=MHFG4VM+x3Rz3Pq6gZpLWye8WX5CpLQ8ZHz45GJtJ7hxB8EhP/vB6NpDGaokRxn4Sm gBejicjXKGL7Xin/kbnk5LTanJeTxbPcmle5RR1IOfrSOAwQi6z147gvrxZF+qQfphGC LhcyWQfsgr7Al5zabtb3tsFlK2SB2wBeNETVfj6QTLibFh5RUIXbjl5Sud8xd1utgovN 3Mr2MIzx4Bu6+Vcs06R6FHxUNsS0BjQnjg4OpNFZXzsZQr38daSSr4330LnFNTZxvQcs axI6c6iJC0yildm9ky8cu5A+YBLAgcvsodLeCDDfxinA+u0/qknmVHfXzvcFQv1+b0Rl qo6Q== X-Gm-Message-State: ALyK8tJGyAYVI586OSmx7SlAezs1T8basgQmA/nZ1cD2PnkhDsOvTzUxvKCgspXp/IBcDg== X-Received: by 10.25.25.79 with SMTP id 76mr2630830lfz.14.1466417133244; Mon, 20 Jun 2016 03:05:33 -0700 (PDT) Original-Received: from asus.local ([178.218.27.218]) by smtp.gmail.com with ESMTPSA id f20sm4774472lji.46.2016.06.20.03.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 03:05:32 -0700 (PDT) Original-To: lee Original-To: help-gnu-emacs@gnu.org In-Reply-To: <87mvmgpwf9.fsf@heimdali.yagibdah.de> (lee's message of "Mon, 20 Jun 2016 01:54:02 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::230 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:110524 Archived-At: lee writes: > Can you explain to me why the cursor remains at its position /on the > screen/ while I'm scrolling with scroll-lock-mode enabled all the time > like it should --- and then suddenly moves when the top or bottom of the > buffer contents come into view? That doesn't make any sense to me; the > cursor still shouldn't move. Given that there is no free space before the first line of a buffer, this does make perfect sense with regard to scrolling backward (to the top of a buffer). The other way we would just get stuck with the point in the middle of a screen not being able to reach first lines. The scrolling forward behaves the same way for sake of coherence, I guess. Anyway, if you look into the code, you’ll see that this behaviour is definetely intentional: (defun scroll-lock-next-line (&optional arg) "Scroll up ARG lines keeping point fixed." (interactive "p") (or arg (setq arg 1)) (scroll-lock-update-goal-column) (if (pos-visible-in-window-p (point-max)) (forward-line arg) (scroll-up arg)) (scroll-lock-move-to-column scroll-lock-temporary-goal-column)) (defun scroll-lock-previous-line (&optional arg) "Scroll up ARG lines keeping point fixed." (interactive "p") (or arg (setq arg 1)) (scroll-lock-update-goal-column) (condition-case nil (scroll-down arg) (beginning-of-buffer (forward-line (- arg)))) (scroll-lock-move-to-column scroll-lock-temporary-goal-column)) However, if you do not like it, just remove the condition: (defun my-scroll-lock-next-line (&optional arg) "Scroll up ARG lines keeping point fixed." (interactive "p") (or arg (setq arg 1)) (scroll-lock-update-goal-column) (scroll-up arg) (scroll-lock-move-to-column scroll-lock-temporary-goal-column)) (defun my-scroll-lock-previous-line (&optional arg) "Scroll up ARG lines keeping point fixed." (interactive "p") (or arg (setq arg 1)) (scroll-lock-update-goal-column) (scroll-down arg) (scroll-lock-move-to-column scroll-lock-temporary-goal-column)) (advice-add 'scroll-lock-next-line :override #'my-scroll-lock-next-line) (advice-add 'scroll-lock-previous-line :override #'my-scroll-lock-previous-line) Also, if you are regularily toggling the ‘scroll-lock-mode’ on and off, you might consider to use approach that, one might say, is more ‘Emacsish’ — another keychord instead of mode: (setq scroll-preserve-screen-position 'always) (global-set-key (kbd "M-n") #'scroll-up-line) (global-set-key (kbd "M-") #'scroll-up-line) (global-set-key (kbd "M-p") #'scroll-down-line) (global-set-key (kbd "M-") #'scroll-down-line)