all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Chong Yidong <cyd@stupidchicken.com>
To: emacs-devel@gnu.org
Cc: 3361@emacsbugs.donarmstrong.com, duanpanda@gmail.com
Subject: Re: 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	[thread overview]
Message-ID: <87d49v53ba.fsf@cyd.mit.edu> (raw)

> 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.




             reply	other threads:[~2009-05-26 14:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 14:47 Chong Yidong [this message]
2009-05-26 17:19 ` 23.0.92; View-scroll-page-forward/backward does wrong in text mode after text-scale-increase/decrease Stefan Monnier
2009-05-26 17:19 ` bug#3361: " Stefan Monnier
2009-07-11 20:39 ` Juri Linkov
2009-07-12 16:44   ` Chong Yidong
2009-07-12 21:02     ` Juri Linkov
2009-07-13  0:08 ` Miles Bader
2009-07-13 20:07   ` Juri Linkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d49v53ba.fsf@cyd.mit.edu \
    --to=cyd@stupidchicken.com \
    --cc=3361@emacsbugs.donarmstrong.com \
    --cc=duanpanda@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.