From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] /srv/bzr/emacs/trunk r99831: Scrolling commands which does not signal errors at top/bottom. Date: Tue, 06 Apr 2010 23:19:16 +0300 Organization: JURTA Message-ID: <87ljd0wcw3.fsf@mail.jurta.org> References: <877hol5qso.fsf@mail.jurta.org> <874ojozp27.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1270585458 4161 80.91.229.12 (6 Apr 2010 20:24:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 6 Apr 2010 20:24:18 +0000 (UTC) Cc: Emacs developers To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 06 22:24:16 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NzFJn-0006uD-Nh for ged-emacs-devel@m.gmane.org; Tue, 06 Apr 2010 22:24:16 +0200 Original-Received: from localhost ([127.0.0.1]:42811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzFJm-0004WO-Uf for ged-emacs-devel@m.gmane.org; Tue, 06 Apr 2010 16:24:14 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NzFJh-0004Vt-1Q for emacs-devel@gnu.org; Tue, 06 Apr 2010 16:24:09 -0400 Original-Received: from [140.186.70.92] (port=32893 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzFJf-0004Vc-OZ for emacs-devel@gnu.org; Tue, 06 Apr 2010 16:24:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NzFJd-0001dJ-PX for emacs-devel@gnu.org; Tue, 06 Apr 2010 16:24:07 -0400 Original-Received: from smtp-out2.starman.ee ([85.253.0.4]:44506 helo=mx2.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzFJd-0001d7-Ep for emacs-devel@gnu.org; Tue, 06 Apr 2010 16:24:05 -0400 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (85.253.49.244.cable.starman.ee [85.253.49.244]) by mx2.starman.ee (Postfix) with ESMTP id BDDD33F40ED; Tue, 6 Apr 2010 23:23:57 +0300 (EEST) In-Reply-To: (Juanma Barranquero's message of "Tue, 6 Apr 2010 20:26:43 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:123280 Archived-At: > This fixes one problem, but not the other: scroll-(up|down)-command do > not preserve the column. I see now what do you mean. This patch takes care of that: === modified file 'lisp/simple.el' --- lisp/simple.el 2010-04-05 19:08:58 +0000 +++ lisp/simple.el 2010-04-06 20:18:23 +0000 @@ -4877,6 +4877,16 @@ (define-globalized-minor-mode global-vis ;;; of buffer at first key-press (instead moves to top/bottom ;;; of buffer). +(defcustom scroll-error-top-bottom nil + "Move point to top/bottom of buffer before signalling a scrolling error. +A value of nil means just signal an error if no more scrolling possible. +A value of t means point moves to the beginning or the end of the buffer +\(depending on scrolling direction) when no more scrolling possible. +When point is already on that position, then signal an error." + :type 'boolean + :group 'scrolling + :version "24.1") + (defun scroll-up-command (&optional arg) "Scroll text of selected window upward ARG lines; or near full screen if no ARG. If `scroll-up' cannot scroll window further, move cursor to the bottom line. @@ -4886,6 +4896,8 @@ (defun scroll-up-command (&optional arg) If ARG is the atom `-', scroll downward by nearly full screen." (interactive "^P") (cond + ((null scroll-error-top-bottom) + (scroll-up arg)) ((eq arg '-) (scroll-down-command nil)) ((< (prefix-numeric-value arg) 0) (scroll-down-command (- (prefix-numeric-value arg)))) @@ -4893,7 +4905,14 @@ (defun scroll-up-command (&optional arg) (scroll-up arg)) ; signal error (t (condition-case nil - (scroll-up arg) + (progn + (when (and scroll-preserve-screen-position + (not (eq scroll-preserve-screen-position t))) + (setq temporary-goal-column + (if (and track-eol (eolp) (not (bolp))) + most-positive-fixnum + (current-column)))) + (scroll-up arg)) (end-of-buffer (if arg ;; When scrolling by ARG lines can't be done, @@ -4901,7 +4920,10 @@ (defun scroll-up-command (&optional arg) (forward-line arg) ;; When ARG is nil for full-screen scrolling, ;; move to the bottom of the buffer. - (goto-char (point-max)))))))) + (goto-char (point-max)) + (when (and scroll-preserve-screen-position + (not (eq scroll-preserve-screen-position t))) + (line-move-to-column (truncate temporary-goal-column))))))))) (put 'scroll-up-command 'isearch-scroll t) @@ -4914,6 +4936,8 @@ (defun scroll-down-command (&optional ar If ARG is the atom `-', scroll upward by nearly full screen." (interactive "^P") (cond + ((null scroll-error-top-bottom) + (scroll-down arg)) ((eq arg '-) (scroll-up-command nil)) ((< (prefix-numeric-value arg) 0) (scroll-up-command (- (prefix-numeric-value arg)))) @@ -4921,7 +4945,14 @@ (defun scroll-down-command (&optional ar (scroll-down arg)) ; signal error (t (condition-case nil - (scroll-down arg) + (progn + (when (and scroll-preserve-screen-position + (not (eq scroll-preserve-screen-position t))) + (setq temporary-goal-column + (if (and track-eol (eolp) (not (bolp))) + most-positive-fixnum + (current-column)))) + (scroll-down arg)) (beginning-of-buffer (if arg ;; When scrolling by ARG lines can't be done, @@ -4929,7 +4960,10 @@ (defun scroll-down-command (&optional ar (forward-line (- arg)) ;; When ARG is nil for full-screen scrolling, ;; move to the top of the buffer. - (goto-char (point-min)))))))) + (goto-char (point-min)) + (when (and scroll-preserve-screen-position + (not (eq scroll-preserve-screen-position t))) + (line-move-to-column (truncate temporary-goal-column))))))))) (put 'scroll-down-command 'isearch-scroll t) -- Juri Linkov http://www.jurta.org/emacs/