From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jens Lautenbacher Newsgroups: gmane.emacs.devel Subject: problems with scroll-preserve-screen-position and cua-mode Date: Thu, 08 Dec 2005 17:42:29 +0100 Message-ID: <1134060150.20114.5.camel@britten.laudi.ka> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1134066349 16079 80.91.229.2 (8 Dec 2005 18:25:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Dec 2005 18:25:49 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 08 19:25:48 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EkQMO-0007az-Oa for ged-emacs-devel@m.gmane.org; Thu, 08 Dec 2005 19:19:17 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EkQMh-0000NP-7s for ged-emacs-devel@m.gmane.org; Thu, 08 Dec 2005 13:19:35 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EkOrB-0004Xp-1R for emacs-devel@gnu.org; Thu, 08 Dec 2005 11:42:57 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EkOr8-0004X1-9J for emacs-devel@gnu.org; Thu, 08 Dec 2005 11:42:56 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EkOr5-0004W0-Fz for emacs-devel@gnu.org; Thu, 08 Dec 2005 11:42:52 -0500 Original-Received: from [212.227.126.171] (helo=moutng.kundenserver.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EkOs8-0007Br-9y for emacs-devel@gnu.org; Thu, 08 Dec 2005 11:43:56 -0500 Original-Received: from [212.227.125.252] (helo=[172.17.205.186]) by mrelayeu.kundenserver.de (node=mrelayeu4) with ESMTP (Nemesis), id 0ML21M-1EkOqk3PY0-0005CG; Thu, 08 Dec 2005 17:42:30 +0100 Original-To: Emacs-Devel X-Mailer: Evolution 2.2.3 (2.2.3-3.fc4) X-Provags-ID: kundenserver.de abuse@kundenserver.de login:c841b0622166f560aa7ad6ce6c381fb1 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:47236 Archived-At: Hi, using cua mode and it's scroll commands has the annoying problem that the scrolling up to the top or down to the end of the buffer will kill the ability to always have the cursor positioned on the same screenline - but more importantly to have the cursor positioned on the same buffer positions while scrolling through the buffer (what i mean with this is: I have point on a certain line, say the beginning of function "FOO" when I start scrolling up and down with prior/next. The desired behavior is that no matter how much I scroll, I want to be able to hit the original position at the FOO function while scrolling by.) This works more or less (not completely) when not using cua. But with cu, the last thing when the buffer is scrolled up (or to the end) is to move the cursor to point-min or point-max resp. Of course, scrolling into the opposite direction breaks the desired behavior. I have the following snippet in my .emacs, which does what I want. Maybe one could add something similar to the cua scroll commands to always have that behavior. (setq ms-before-down 0) (setq ms-before-up 0) (defun my-scroll-down (&optional arg) (interactive) (if (not (equal ms-before-up 0)) (progn (goto-char ms-before-up) (setq ms-before-up 0)) (if (not (equal (point) (point-min))) (setq ms-before-down (point))) (cua-scroll-down arg) (if (not (equal (point) (point-min))) (setq ms-before-down 0)))) (defun my-scroll-up (&optional arg) (interactive) (if (not (equal ms-before-down 0)) (progn (goto-char ms-before-down) (setq ms-before-down 0)) (if (not (equal (point) (point-max))) (setq ms-before-up (point))) (cua-scroll-up arg) (if (not (equal (point) (point-max))) (setq ms-before-up 0)))) (global-set-key [next] 'my-scroll-up) (global-set-key [prior] 'my-scroll-down)