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 19:12:58 +0300 Message-ID: <87a8ifalf9.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> <87y4609nv5.fsf@gmail.com> <87twgnhohm.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 1466439536 2220 80.91.229.3 (20 Jun 2016 16:18:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 20 Jun 2016 16:18:56 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: lee Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jun 20 18:18:54 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 1bF1uX-00081J-F1 for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Jun 2016 18:18:53 +0200 Original-Received: from localhost ([::1]:44772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF1uW-0000i4-Rs for geh-help-gnu-emacs@m.gmane.org; Mon, 20 Jun 2016 12:18:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57461) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <321942@gmail.com>) id 1bF1os-0003Lp-1M for help-gnu-emacs@gnu.org; Mon, 20 Jun 2016 12:13:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <321942@gmail.com>) id 1bF1oo-00013G-KO for help-gnu-emacs@gnu.org; Mon, 20 Jun 2016 12:13:01 -0400 Original-Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:33198) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <321942@gmail.com>) id 1bF1oo-00013B-86 for help-gnu-emacs@gnu.org; Mon, 20 Jun 2016 12:12:58 -0400 Original-Received: by mail-lf0-x22a.google.com with SMTP id f6so40976128lfg.0 for ; Mon, 20 Jun 2016 09:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version:content-transfer-encoding; bh=wbAwV9g6a74x+waP5upYLgt7+OJuN5U5lgRhqkwKR/A=; b=nCXcgfAYn5I2ho+BtKNcjIsiQbRbxgSdNixGswcBPML0pxxBqYFSxQeo1ysaCQFHTA E/P5DdV7O80WDmx+7R6TwLYNcosFREAM+AumLTw3MaeUI2i7h5PvmalFstrYVl58QHvY L4qZO1FwBHDlMtAWJvFRllH1knojC1tNR/oyuC8Z2wpWCFxxuyT2+ONdwQ/V9OqNKFDS fP9M9iiBRJsOf+XhITb/unJ6EpgBJ3TNWLF8gvMsYLR+w/R08zCgqr249QFsM+reQALh WUDxU1Ixicl4cO8Aeq2w+SSTBNGSmKhnU6phA97+A6rluhgtVy9j6dEUfXFRmujS4C2Z Ka5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version:content-transfer-encoding; bh=wbAwV9g6a74x+waP5upYLgt7+OJuN5U5lgRhqkwKR/A=; b=fNfTFdm3cJhhZJmP8ryODASRtCy/S7+tRxIz3bXuC2H5XyfAMy5XKLuikSZl2V8db8 eL6hiHKozUa5TxSc8q1eclyWRv9OOgBYZMmsOH/BfQhkI8DVlXUaNxHKnbgRvyeSxm+h 3tyBt/jzL/1eKxbGybHlwGRZ/05niOVzt5tguoeTB2yOSKvEx3elLLBzSawU+UiySVvZ SvEE3R240F3flLagpuNDykbN2bJOCJ35PyvXpPZZbWcz3GbybdBRVXQnPp928CmCQEsj TNd0IUImIWvD2P+6pVQW40nJX8/QW+Vl4V9iGMj0u2EfUZ4WpTI6UMp/4hkLRDiVakH2 lLIg== X-Gm-Message-State: ALyK8tKU1ofV+/W4VaL8pB2OC74wwjmAEXXlUjnVNd08RJMMgVbav7aBybeyU5hxRd8wGg== X-Received: by 10.25.30.194 with SMTP id e185mr5188140lfe.202.1466439177301; Mon, 20 Jun 2016 09:12:57 -0700 (PDT) Original-Received: from asus.local ([178.218.27.218]) by smtp.gmail.com with ESMTPSA id ea15sm6398278lbb.1.2016.06.20.09.12.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 09:12:56 -0700 (PDT) In-Reply-To: <87twgnhohm.fsf@heimdali.yagibdah.de> (lee's message of "Mon, 20 Jun 2016 17:24:53 +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::22a 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:110534 Archived-At: lee writes: > Dmitry Alexandrov <321942@gmail.com> writes: > >> 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. > > There is no free space beyond the last line of a buffer, either. Well, by default in GNU Emacs there *is* free space beyond the last line, which is taken in account while scrolling. I have no idea how could you disabled it. Actually I would like to see some day an opposite option in GNU Emacs — to enable empty lines above the top of a buffer. > It doesn't make sense, though, because scroll-lock means that the cursor > does not move when scrolling. Why else would I use scroll-lock-mode? As far as I understand, minor modes for Emacs are generally designed to be used on permanent basis, not to be toggled every several keystrokes. Since the algorithm you described prevents user from accessing to first N lines of buffer, this algorithm would be perceived as broken. >> 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) > > Thank you very much! That does the trick You are welcome. > and I just found out that > I have scroll-preserve-screen-position set to t and forgot about it ages > ago. The result of that is pretty much what scroll-lock-mode is > supposed to do. > > I guess I'm a bit confused because emacs at work and emacs at home are > configured differently. I should be fine when I set > scroll-preserve-screen-position to t at work, too. Or maybe even to ‘always’ (or whatever you want to call it). >> 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) > > The idea was to make use of the ScrollLock key. So I did that and found > that when scroll-lock-mode is enabled, the point does move when it > shouldn't. > > Since what scroll-lock-mode does is achieved by setting > scroll-preserve-screen-position to t, what is the point or purpose of > scroll-lock-mode? That the cursor moves when it shouldn't? First of all, I would not say that there is something wrong even with existence of a minor mode that only toggles single variable. However you might notice that besides toggling ‘scroll-preserve-screen-position’ ‘scroll-lock-mode’ at least re-defines several moving keys: ‘C-n’, ‘C-p’, etc. > BTW, it seems that changing scroll-preserve-screen-position requires > restarting emacs to take effect. No. > Maybe that's what scroll-lock-mode is > for, being able to change the behaviour without restarting? As you already noticed, ‘scroll-lock-mode’ depends on state of ‘scroll-preserve-screen-position’. How then could it evade such a limitation if it existed?