From mboxrd@z Thu Jan 1 00:00:00 1970 From: Toby Cubitt Subject: Re: [PATCH] Make org-[beginning|end]-of-line respect visual-line-mode Date: Tue, 6 Nov 2012 19:46:29 +0100 Message-ID: <20121106184629.GA8539@c3po> References: <87fw4m7hfw.fsf@gmail.com> Reply-To: Toby Cubitt Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="mYCpIKhGyMATD0i+" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:40276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TVoAG-0006wq-Kb for emacs-orgmode@gnu.org; Tue, 06 Nov 2012 13:46:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TVoA8-000555-Cb for emacs-orgmode@gnu.org; Tue, 06 Nov 2012 13:46:20 -0500 Received: from sanddollar.geekisp.com ([216.168.135.167]:46643) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1TVoA8-00054k-6q for emacs-orgmode@gnu.org; Tue, 06 Nov 2012 13:46:12 -0500 Content-Disposition: inline In-Reply-To: <87fw4m7hfw.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Nov 06, 2012 at 06:46:27PM +0100, Nicolas Goaziou wrote: > Toby Cubitt writes: > > > Aha! You may well be right. In which case why is `org-beginning-of-line' > > doing this: > > > > (if (org-bound-and-true-p line-move-visual) > > (beginning-of-visual-line 1) > > (beginning-of-line 1)) > > > > Shouldn't it be doing this instead? > > > > (if (org-bound-and-true-p visual-line-mode) > > (beginning-of-visual-line 1) > > (beginning-of-line 1)) > > Indeed. Do you want to provide a patch (you get bonus points for > regression tests)? I guess you want regression tests for `end-of-line' with `visual-line-mode' enabled? (There aren't any tests for beginning-of-line in test-org.el currently, and the fix to org-beginning-of-line won't actually change the behaviour, just make the code more correct.) I've made an attempt in the attached patch, which also fixes org-beginning-of-line as discussed. Toby -- Dr T. S. Cubitt Mathematics and Quantum Information group Department of Mathematics Complutense University Madrid, Spain email: tsc25@cantab.net web: www.dr-qubit.org --mYCpIKhGyMATD0i+ Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-Bug-fix-in-org-beginning-of-line-visual-line-motion.patch" >From c91b6bee12d27d43e4c2ba90c339c1b86010be67 Mon Sep 17 00:00:00 2001 From: "Toby S. Cubitt" Date: Tue, 6 Nov 2012 19:06:26 +0100 Subject: [PATCH] Bug fix in org-beginning-of-line visual line motion * lisp/org.el (org-beginning-of-line): check `visual-line-mode' instead of `line-visual-mode' to determine whether to move by visual lines. * lisp/org.el (org-kill-line): use of org-bound-and-true-p macro. * testing/lisp/test-org.el (test-org/end-of-line): add regression test for `org-end-of-line' in `visual-line-mode' buffers. --- lisp/org.el | 4 ++-- testing/lisp/test-org.el | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index ad2863b..080b527 100644 --- a/lisp/org.el +++ b/lisp/org.el @@ -21577,7 +21577,7 @@ beyond the end of the headline." (car org-special-ctrl-a/e) org-special-ctrl-a/e)) refpos) - (if (org-bound-and-true-p line-move-visual) + (if (org-bound-and-true-p visual-line-mode) (beginning-of-visual-line 1) (beginning-of-line 1)) (if (and arg (fboundp 'move-beginning-of-line)) @@ -21704,7 +21704,7 @@ depending on context." (not (y-or-n-p "Kill hidden subtree along with headline? "))) (error "C-k aborted - would kill hidden subtree"))) (call-interactively - (if (and (boundp 'visual-line-mode) visual-line-mode) 'kill-visual-line 'kill-line))) + (if (org-bound-and-true-p visual-line-mode) 'kill-visual-line 'kill-line))) ((looking-at (org-re ".*?\\S-\\([ \t]+\\(:[[:alnum:]_@#%:]+:\\)\\)[ \t]*$")) (kill-region (point) (match-beginning 1)) (org-set-tags nil t)) diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index 98957ac..a2115bf 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -477,6 +477,13 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/" (should (org-test-with-temp-text "Some text\nSome other text" (progn (org-end-of-line) (eolp)))) + ;; Standard test with `visual-line-mode'. + (should + (org-test-with-temp-text + "A long line of text\nSome other text" + (progn (forward-char 2) (cl-dotimes (i 1000) (insert "very ")) + (visual-line-mode 1) (goto-char (point-min)) (org-end-of-line) + (thing-at-point-looking-at "very")))) ;; At an headline with special movement. (should (org-test-with-temp-text "* Headline :tag:" -- 1.7.8.6 --mYCpIKhGyMATD0i+--