From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.bugs Subject: bug#3361: 23.0.92; View-scroll-page-forward/backward does wrong in text mode after text-scale-increase/decrease Date: Tue, 26 May 2009 10:47:21 -0400 Message-ID: <87d49v53ba.fsf__33288.7057717473$1243350626$gmane$org@cyd.mit.edu> Reply-To: Chong Yidong , 3361@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1243350626 6147 80.91.229.12 (26 May 2009 15:10:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 26 May 2009 15:10:26 +0000 (UTC) Cc: 3361@emacsbugs.donarmstrong.com, duanpanda@gmail.com To: emacs-devel@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 26 17:10:19 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M8yIC-0005cX-Jl for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 May 2009 17:10:17 +0200 Original-Received: from localhost ([127.0.0.1]:54367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8yIB-0005eM-Tv for geb-bug-gnu-emacs@m.gmane.org; Tue, 26 May 2009 11:10:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8yHI-0005Fl-ES for bug-gnu-emacs@gnu.org; Tue, 26 May 2009 11:09:20 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8yHD-0005D1-AX for bug-gnu-emacs@gnu.org; Tue, 26 May 2009 11:09:19 -0400 Original-Received: from [199.232.76.173] (port=54590 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8yHC-0005Cl-Tw for bug-gnu-emacs@gnu.org; Tue, 26 May 2009 11:09:14 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:35016) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1M8yHC-0001sb-8z for bug-gnu-emacs@gnu.org; Tue, 26 May 2009 11:09:14 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n4QF9BiN019423; Tue, 26 May 2009 08:09:12 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n4QEt5UU016756; Tue, 26 May 2009 07:55:05 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Chong Yidong Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Tue, 26 May 2009 14:55:05 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 3361 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 3361-submit@emacsbugs.donarmstrong.com id=B3361.124334922416011 (code B ref 3361); Tue, 26 May 2009 14:55:05 +0000 Original-Received: (at 3361) by emacsbugs.donarmstrong.com; 26 May 2009 14:47:04 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from cyd.mit.edu (CYD.MIT.EDU [18.115.2.24]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n4QEkx6l016006 for <3361@emacsbugs.donarmstrong.com>; Tue, 26 May 2009 07:47:00 -0700 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id 0524757E25C; Tue, 26 May 2009 10:47:22 -0400 (EDT) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Tue, 26 May 2009 11:09:19 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:28192 Archived-At: > Open a normal text file with the text mode, do > (view-mode) > (text-scale-increase) or (text-scale-decrease) > (View-scroll-page-forward) or (View-scroll-page-backward) > The View-scroll-page-* command does wrong. It cannot scroll "page > size" as expected like it does when the text-scale minor mode is off. View-mode, written in the dawn of time, assumes that all lines have the default height. The following patch changes it so that scroll-up/scroll-down are passed nil arguments where possible; then Emacs will automatically determine how to scroll by one page, taking variable-height lines and text-scaling into account. It's not good to make this kind of change at this stage in the release, but this bug would be pretty annoying if you happen to come across it, and that's much more likely now we've introduced the text-scaling commands. Could someone on emacs-devel help review the patch? *** trunk/lisp/view.el.~1.102.~ 2009-05-26 10:34:04.000000000 -0400 --- trunk/lisp/view.el 2009-05-26 10:39:03.000000000 -0400 *************** *** 740,747 **** ;;; Some help routines. (defun view-window-size () ! ;; Window height excluding mode line. ! (1- (window-height))) ;; (defun view-last-command (&optional who what) ;; (setq view-last-command-entry this-command) --- 740,754 ---- ;;; Some help routines. (defun view-window-size () ! ;; Return the number of lines in the current window, excluding the ! ;; mode line. Using `window-line-height' accounts for ! ;; variable-height fonts. ! (let ((h (window-line-height -1))) ! (if h ! (1+ (nth 1 h)) ! ;; This should not happen, but if `window-line-height' returns ! ;; nil, fall back on `window-height'. ! (1- (window-height))))) ;; (defun view-last-command (&optional who what) ;; (setq view-last-command-entry this-command) *************** *** 761,771 **** (recenter '(1))) (defun view-page-size-default (lines) ! ;; Get page size. ! (let ((default (- (view-window-size) next-screen-context-lines))) ! (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines)))) ! default ! (min (abs lines) default)))) (defun view-set-half-page-size-default (lines) ;; Get and maybe set half page size. --- 768,780 ---- (recenter '(1))) (defun view-page-size-default (lines) ! ;; Return nil if LINES is nil, 0, or larger than ! ;; `view-window-size'. Otherwise, return LINES. ! (and lines ! (not (zerop (setq lines (prefix-numeric-value lines)))) ! (<= (abs lines) ! (abs (- (view-window-size) next-screen-context-lines))) ! lines)) (defun view-set-half-page-size-default (lines) ;; Get and maybe set half page size. *************** *** 827,854 **** ;; This function does the job for all the scrolling commands. ;; Scroll forward LINES lines. If BACKWARD is true scroll backwards. ;; If LINES is negative scroll in the other direction. If LINES is 0 or nil, ! ;; scroll DEFAULT lines. If MAXDEFAULT is true then scroll no more than a ! ;; window full. (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines)))) (setq lines default)) ! (when (< lines 0) ! (setq backward (not backward)) (setq lines (- lines))) ! (setq default (view-page-size-default nil)) ; Max scrolled at a time. ! (if maxdefault (setq lines (min lines default))) ! (cond ! (backward (scroll-down lines)) ! ((view-really-at-end) ! (if view-scroll-auto-exit (View-quit) ! (ding) ! (view-end-message))) ! (t (while (> lines default) ! (scroll-up default) ! (setq lines (- lines default)) ! (if (view-really-at-end) (setq lines 0))) ! (scroll-up lines) ! (if (view-really-at-end) (view-end-message)) ! (move-to-window-line -1) ! (beginning-of-line)))) (defun view-really-at-end () ;; Return true if buffer end visible. Maybe revert buffer and test. --- 836,857 ---- ;; This function does the job for all the scrolling commands. ;; Scroll forward LINES lines. If BACKWARD is true scroll backwards. ;; If LINES is negative scroll in the other direction. If LINES is 0 or nil, ! ;; scroll DEFAULT lines (if DEFAULT is nil, scroll by one page). If ! ;; MAXDEFAULT is true then scroll no more than a window full. (if (or (null lines) (zerop (setq lines (prefix-numeric-value lines)))) (setq lines default)) ! (when (and lines (< lines 0)) ! (setq backward (not backward) lines (- lines))) ! (when (and maxdefault lines (> lines (view-window-size))) ! (setq lines nil)) ! (cond (backward (scroll-down lines)) ! ((view-really-at-end) ! (if view-scroll-auto-exit ! (View-quit) ! (ding) ! (view-end-message))) ! (t (scroll-up lines) ! (if (view-really-at-end) (view-end-message))))) (defun view-really-at-end () ;; Return true if buffer end visible. Maybe revert buffer and test.