From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: visual-line-mode Date: Sun, 29 Jun 2008 10:01:22 -0400 Message-ID: References: <87zlp4raab.fsf@catnip.gol.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1214748105 31344 80.91.229.12 (29 Jun 2008 14:01:45 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 29 Jun 2008 14:01:45 +0000 (UTC) Cc: David Reitter , Chong Yidong , "Lennart Borgman \(gmail\)" , Emacs-Devel devel To: Miles Bader Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jun 29 16:02:29 2008 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.50) id 1KCxU3-0007Gw-GC for ged-emacs-devel@m.gmane.org; Sun, 29 Jun 2008 16:02:27 +0200 Original-Received: from localhost ([127.0.0.1]:57684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCxTD-0007cU-Di for ged-emacs-devel@m.gmane.org; Sun, 29 Jun 2008 10:01:35 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KCxT7-0007b0-Db for emacs-devel@gnu.org; Sun, 29 Jun 2008 10:01:29 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KCxT6-0007a8-32 for emacs-devel@gnu.org; Sun, 29 Jun 2008 10:01:29 -0400 Original-Received: from [199.232.76.173] (port=46309 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KCxT5-0007a1-QO for emacs-devel@gnu.org; Sun, 29 Jun 2008 10:01:27 -0400 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]:41431 helo=ironport2-out.teksavvy.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KCxT2-0002Su-EJ; Sun, 29 Jun 2008 10:01:24 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjsFALcyZ0hFxIdG/2dsb2JhbACBW6x5gXo X-IronPort-AV: E=Sophos;i="4.27,722,1204520400"; d="scan'208";a="23735957" Original-Received: from 69-196-135-70.dsl.teksavvy.com (HELO pastel.home) ([69.196.135.70]) by ironport2-out.teksavvy.com with ESMTP; 29 Jun 2008 10:01:22 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 96B9B835A; Sun, 29 Jun 2008 10:01:22 -0400 (EDT) In-Reply-To: <87zlp4raab.fsf@catnip.gol.com> (Miles Bader's message of "Sun, 29 Jun 2008 16:05:16 +0900") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. 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:100133 Archived-At: > I expect emacs primitives will need improvement to work for the > word-wrapping case (and display-time line-prefixes which I've hacked up > locally), so perhaps they can be improved to work better in general too. After looking a bit more at the various visual line movement packages, and remembering that I've just added a `cols' arg to vertical-motion, I believe the patch below provides basically the behavior we want. As it turns out, it doesn't work right with word-wrapping because posn-at-point returns funny X positions. Probably the same underlying bug causes sometimes mouse-clicks to place point elsewhere than under the mouse. Stefan === modified file 'lisp/simple.el' --- lisp/simple.el 2008-06-21 02:48:08 +0000 +++ lisp/simple.el 2008-06-29 13:36:08 +0000 @@ -4030,6 +4030,16 @@ (t (set-window-vscroll nil (frame-char-height) t))))))) +(defvar line-move-visual t) + +(defun line-move-visual (arg) + (unless (and (floatp temporary-goal-column) + (or (memq last-command '(next-line previous-line)) + ;; In case we're called from some other command. + (eq last-command this-command))) + (setq temporary-goal-column + (/ (car (nth 2 (posn-at-point))) 1.0 (frame-char-width)))) + (vertical-motion (cons (truncate temporary-goal-column) arg))) ;; This is like line-move-1 except that it also performs ;; vertical scrolling of tall images if appropriate. @@ -4046,7 +4056,9 @@ (not executing-kbd-macro) (line-move-partial arg noerror to-end)) (set-window-vscroll nil 0 t) - (line-move-1 arg noerror to-end))) + (if line-move-visual + (line-move-visual arg) + (line-move-1 arg noerror to-end)))) ;; This is the guts of next-line and previous-line. ;; Arg says how many lines to move.