From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Justin Burkett Newsgroups: gmane.emacs.devel Subject: Patch for beginning-of-visual-line and end-of-visual-line Date: Fri, 11 Aug 2017 13:24:54 -0400 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1502472348 24178 195.159.176.226 (11 Aug 2017 17:25:48 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 11 Aug 2017 17:25:48 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Aug 11 19:25:41 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dgDgj-0005NX-Ps for ged-emacs-devel@m.gmane.org; Fri, 11 Aug 2017 19:25:33 +0200 Original-Received: from localhost ([::1]:58985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgDgp-0007DD-Ub for ged-emacs-devel@m.gmane.org; Fri, 11 Aug 2017 13:25:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58845) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dgDgh-0007CO-I0 for emacs-devel@gnu.org; Fri, 11 Aug 2017 13:25:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dgDge-0002jW-Bm for emacs-devel@gnu.org; Fri, 11 Aug 2017 13:25:31 -0400 Original-Received: from mail-qt0-x22a.google.com ([2607:f8b0:400d:c0d::22a]:33121) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dgDge-0002iA-53 for emacs-devel@gnu.org; Fri, 11 Aug 2017 13:25:28 -0400 Original-Received: by mail-qt0-x22a.google.com with SMTP id a18so24872220qta.0 for ; Fri, 11 Aug 2017 10:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burkett-cc.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=fYYcCJ7WAeZXryyAghRhht27BpA9oTtQpbBqvv1H9Ko=; b=SAxnv9hxI4BcZkXjh3hE+sm2gk0RP8Z6Cmd8nZghegiNHYMOJRMSZjuShhin5OTcdv kDBtyZvnruzrpSgNXjT08xNZeKvKOErchRxTWYd+QvLtHxQBxKjxJtrEwNR1lrytQg8G Tft6txP/XzECnieIV52Uuzffu1ZxnRR3klvJ27Ybm9O41AgWOatoHzFdOorG8WfrLIgo T1rpkhDaXPwNMtCP6C+GHDfUOfoxJ8RshCiLNJPDBarqg/veTDZZbX7D7of2nX9s4X3L HKMhFBqV7KyDrtuEsWX/xM6N67iBZ7cIkwvnGss7aOgMztJVJmS0+O4OqKHW0l6nH98F 6DDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=fYYcCJ7WAeZXryyAghRhht27BpA9oTtQpbBqvv1H9Ko=; b=bWdf7tclNZuJFb1C09WfT3VdkHsXGzLmegOHlRn+aIbztxCrQaQ/cy3CrqwzXcG6Hx Pwg7vxgYgUzJNv8NNxsfHxTqoRmw6eSmVjFDoXiGNllWnrym0jKenDeuKxLZv9XgM4O6 vg2/wISEnhcpko0bOOMyLCtODvYJeyDMQMAXDJhigY8+V6/rN/vzI6cSK1hFz3FzTkyM +UtKwKmShRMkPdhcYwUr4+WQi7XH4+1Yg5Jibm6pgfVGFRPl3esaArfc9rJ2Kbyie4Cn Bxid3GMVtFQY8Uj1o324kPcemnBLKions29GYIXmttdSKYwvTITbf4jWju2pKDG/Rdf6 f5fA== X-Gm-Message-State: AHYfb5gsftcJgl7lHKKbBx2wmjDDEnFHSQIERwIrw0XmbwNX3sOgTzwg JF+xFgnWpKKkd8azFos7mA== X-Received: by 10.200.53.251 with SMTP id l56mr21531379qtb.82.1502472326634; Fri, 11 Aug 2017 10:25:26 -0700 (PDT) Original-Received: from mail-qk0-f177.google.com (mail-qk0-f177.google.com. [209.85.220.177]) by smtp.gmail.com with ESMTPSA id v64sm812593qkd.96.2017.08.11.10.25.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Aug 2017 10:25:25 -0700 (PDT) Original-Received: by mail-qk0-f177.google.com with SMTP id z18so23890162qka.4 for ; Fri, 11 Aug 2017 10:25:25 -0700 (PDT) X-Received: by 10.55.164.17 with SMTP id n17mr20423159qke.325.1502472325040; Fri, 11 Aug 2017 10:25:25 -0700 (PDT) Original-Received: by 10.140.30.139 with HTTP; Fri, 11 Aug 2017 10:24:54 -0700 (PDT) X-Gmail-Original-Message-ID: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22a X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217443 Archived-At: Hi, I found (what seems like) a bug in these two functions. The docstrings advertise that they should stop if they reach the beginning or end of buffer and they don't. As a test cast, try (beginning-of-visual-line 2) in a buffer with one line. According to the docstring, point should be at the end of the buffer, but it ends up at the beginning for me in Emacs 25.2.1. Here's a patch that works for me. Justin diff --git a/lisp/simple.el b/lisp/simple.el index 3d23fc3..04d8030 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6682,9 +6682,10 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t." (if (/= n 1) (let ((line-move-visual t)) (line-move (1- n) t))) - ;; Unlike `move-beginning-of-line', `move-end-of-line' doesn't - ;; constrain to field boundaries, so we don't either. - (vertical-motion (cons (window-width) 0))) + (unless (or (bobp) (eobp)) + ;; Unlike `move-beginning-of-line', `move-end-of-line' doesn't + ;; constrain to field boundaries, so we don't either. + (vertical-motion (cons (window-width) 0)))) (defun beginning-of-visual-line (&optional n) "Move point to beginning of current visual line. @@ -6697,9 +6698,10 @@ To ignore intangibility, bind `inhibit-point-motion-hooks' to t." (if (/= n 1) (let ((line-move-visual t)) (line-move (1- n) t))) - (vertical-motion 0) - ;; Constrain to field boundaries, like `move-beginning-of-line'. - (goto-char (constrain-to-field (point) opoint (/= n 1))))) + (unless (or (bobp) (eobp)) + (vertical-motion 0) + ;; Constrain to field boundaries, like `move-beginning-of-line'. + (goto-char (constrain-to-field (point) opoint (/= n 1)))))) (defun kill-visual-line (&optional arg) "Kill the rest of the visual line.