From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Marco Wahl Newsgroups: gmane.emacs.bugs Subject: bug#36494: 27.0.50; [Proposition] New option to scroll up regardless of eob Date: Thu, 04 Jul 2019 23:07:15 +0200 Organization: Marco Wahl Message-ID: <84zhltzeyk.fsf@gmail.com> References: <84ftnmjc37.fsf@gmail.com> <83d0iqaqvh.fsf@gnu.org> <847e8xkjpp.fsf@gmail.com> <837e8xbw70.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="154894"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Marco Wahl , 36494@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 04 23:08:12 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hj8xe-000e7o-Jk for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jul 2019 23:08:10 +0200 Original-Received: from localhost ([::1]:48826 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj8xd-0000oR-LI for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jul 2019 17:08:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:53898) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hj8xX-0000o9-Pp for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:08:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hj8xW-0007c7-BB for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:08:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43203) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hj8xW-0007bz-5c for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:08:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hj8xV-0003Ru-T6 for bug-gnu-emacs@gnu.org; Thu, 04 Jul 2019 17:08:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Marco Wahl Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jul 2019 21:08:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36494 X-GNU-PR-Package: emacs Original-Received: via spool by 36494-submit@debbugs.gnu.org id=B36494.156227444513206 (code B ref 36494); Thu, 04 Jul 2019 21:08:01 +0000 Original-Received: (at 36494) by debbugs.gnu.org; 4 Jul 2019 21:07:25 +0000 Original-Received: from localhost ([127.0.0.1]:52024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hj8wu-0003Qw-I1 for submit@debbugs.gnu.org; Thu, 04 Jul 2019 17:07:24 -0400 Original-Received: from mail-wr1-f43.google.com ([209.85.221.43]:41732) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hj8ws-0003Qg-Mo for 36494@debbugs.gnu.org; Thu, 04 Jul 2019 17:07:23 -0400 Original-Received: by mail-wr1-f43.google.com with SMTP id c2so7805518wrm.8 for <36494@debbugs.gnu.org>; Thu, 04 Jul 2019 14:07:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:organization:references:date:in-reply-to :message-id:user-agent:mime-version; bh=8Ch/A5cCcFcZfpG7Yk3X+XuYBKIODAWBAjw3rIYgcLw=; b=S7AkFtXnHYS/oym/nj31IqtFmieoJyY5q0VcaIsgaw+kKANpBSapLfYywu70bpb1sQ NIR/UmvZqLm51PGcEH1HGQOEKdT/XJUu9RLoM2OhuAsNpjq5jkwEAXy0yJ+42wU4KNGe Pmm1byLKeF5vSJWWmmk6SDWlhAYEMkD0sU3wI9ftoLAjAtETpGOQr0R2nFEpN1nY0jQu 7vr8em1hiFY5Pf7VQmwoS+VOSqQ4JxJNuECeYJ6GIGKRu1/BR9O6PnzY/Jb1JBBzAdKh CAukDoUTey4uO9lFmDArLd6Iv9xSg6M3LssKrFt08HS07+/hmhhuX5Lhb+LZtd/eNOvN zwTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:organization:references:date :in-reply-to:message-id:user-agent:mime-version; bh=8Ch/A5cCcFcZfpG7Yk3X+XuYBKIODAWBAjw3rIYgcLw=; b=OOfXRGNOdMeM5p8fJdlmWPRvztGg9t1l8ZK36NOsRJ3qby/PIuU7zOuBEIZFT5I9Jn myJQ/g16YyxqJr20Mkd7PWBrPmobW9yJlbhYY/tBAez81QpL8MydUN3YYOmSHj4piyNv p3e15LzZ6vFmmgpG2LAf8yYRnFwaYvAR4diw15trd6Ie+EjAFGZGbLp5QbwNo3PR2q8Z 238HL7Zk66xCySO7g/a+wAmBMBcxRokxvMwdGlE2/EgfX0tQPOyH47Afo22FeQhPWmMw oXyT0qHtJf7GHxG1BoWbFhgv/3C2GmlEgB9E7iG51TzVEGa5rirC2BimxM1v9FItoVM7 8qtw== X-Gm-Message-State: APjAAAUbf66d3KtxLUUN3fhQJ0D52fvz9rinwjAUPyFvysbVfBkMJG6C 6SKZ5QV1+YzL8vjSLdxVGok= X-Google-Smtp-Source: APXvYqz4Zx5E3KUwZYoIKbqE57hh7fKWz2jj+m46BzWZHk/XVmlmKYfviYZQ2NMHy5FynwBvp4aYwg== X-Received: by 2002:adf:f1d1:: with SMTP id z17mr363081wro.190.1562274436864; Thu, 04 Jul 2019 14:07:16 -0700 (PDT) Original-Received: from tm6592 (p200300ECDF02E4260C537504E5DE56DB.dip0.t-ipconnect.de. [2003:ec:df02:e426:c53:7504:e5de:56db]) by smtp.gmail.com with ESMTPSA id y16sm7066174wru.28.2019.07.04.14.07.15 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 04 Jul 2019 14:07:16 -0700 (PDT) In-Reply-To: <837e8xbw70.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 04 Jul 2019 19:28:51 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:162089 Archived-At: --=-=-= Content-Type: text/plain Ok, sorry for the patch missing. Here is the patch. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-New-function-for-scroll-lock-mode-to-always-scroll.patch >From baf7c0cd4c095d283a9d418dda4e6d1e5f565d24 Mon Sep 17 00:00:00 2001 From: Marco Wahl Date: Thu, 4 Jul 2019 22:32:44 +0200 Subject: [PATCH] New function for scroll-lock-mode to always scroll * lisp/scroll-lock.el (scroll-lock-next-line-always-scroll): New function. Opposed to scroll-lock-next-line it does not switch to forward-line at eob. S-down is the default key binding for this function. * test/lisp/scroll-lock-tests.el: A few tests for scroll-lock-next-line-always-scroll. --- lisp/scroll-lock.el | 11 +++++ test/lisp/scroll-lock-tests.el | 73 ++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 test/lisp/scroll-lock-tests.el diff --git a/lisp/scroll-lock.el b/lisp/scroll-lock.el index 8281edb172..5b7a69a17c 100644 --- a/lisp/scroll-lock.el +++ b/lisp/scroll-lock.el @@ -36,6 +36,7 @@ scroll-lock-mode-map (define-key map [remap previous-line] 'scroll-lock-previous-line) (define-key map [remap forward-paragraph] 'scroll-lock-forward-paragraph) (define-key map [remap backward-paragraph] 'scroll-lock-backward-paragraph) + (define-key map [S-down] 'scroll-lock-next-line-always-scroll) map) "Keymap for Scroll Lock mode.") @@ -81,6 +82,16 @@ scroll-lock-move-to-column (move-to-column column) (forward-char (min column (- (line-end-position) (point)))))) +(defun scroll-lock-next-line-always-scroll (&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-up arg) + (end-of-buffer (scroll-up (1- (count-screen-lines (point) (point-max)))))) + (scroll-lock-move-to-column scroll-lock-temporary-goal-column)) + (defun scroll-lock-next-line (&optional arg) "Scroll up ARG lines keeping point fixed." (interactive "p") diff --git a/test/lisp/scroll-lock-tests.el b/test/lisp/scroll-lock-tests.el new file mode 100644 index 0000000000..590ab4518c --- /dev/null +++ b/test/lisp/scroll-lock-tests.el @@ -0,0 +1,73 @@ +;;; scroll-lock-tests.el --- Test suite for scroll-lock -*- lexical-binding: t -*- + +;; Copyright (C) 2019 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Code: + +(require 'ert) +(require 'scroll-lock) + + +(defun point-in-window-line-p (n) + "Return if point is in window line N. Counting starts with 0. +Precondition: the line N must be available." + (save-excursion + (let ((point (progn (beginning-of-line) (point)))) + (let ((moved-to-line (move-to-window-line n))) + (cl-assert (= n moved-to-line) t "precondition violation")) + (= point (progn (beginning-of-line) (point)))))) + + +(ert-deftest scroll-lock-next-line-always-scroll-1 () + (with-temp-buffer + (insert "\n\n\n") + (goto-char (point-min)) + (switch-to-buffer (current-buffer)) + (scroll-lock-next-line-always-scroll) + (should (point-in-window-line-p 0)))) + +(ert-deftest scroll-lock-next-line-always-scroll-2 () + (with-temp-buffer + (scroll-lock-mode) + (insert "\n\n\n") + (goto-char (1+ (point-min))) + (switch-to-buffer (current-buffer)) + (scroll-lock-next-line-always-scroll) + (should (point-in-window-line-p 1)))) + +(ert-deftest scroll-lock-next-line-always-scroll-3 () + (with-temp-buffer + (scroll-lock-mode) + (insert "\n\n\n") + (goto-char (1+ (point-min))) + (switch-to-buffer (current-buffer)) + (scroll-lock-next-line-always-scroll 1234) + (should (point-in-window-line-p 1)))) + +(ert-deftest scroll-lock-next-line-always-scroll-4 () + (with-temp-buffer + (scroll-lock-mode) + (insert (make-string 1000 ?\n)) + (goto-char (1+ (point-min))) + (switch-to-buffer (current-buffer)) + (scroll-lock-next-line-always-scroll 1234) + (should (point-in-window-line-p 1)))) + +(provide 'scroll-lock-tests) + +;;; scroll-lock-tests.el ends here -- 2.22.0 --=-=-=--