From: Tomohisa Kuranari <tomohisa.kuranari@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Fix org-[beginning|end]-of-line with arguments
Date: Sun, 8 Oct 2023 23:23:47 +0900 [thread overview]
Message-ID: <CAL-TYF7jnNDyM7MrzYtfdx5uxUPEfZ3pOZBnz-gjiX-Jgh+u6Q@mail.gmail.com> (raw)
In-Reply-To: <87edi9jsft.fsf@localhost>
[-- Attachment #1: Type: text/plain, Size: 3501 bytes --]
Hi, Ihor
Thank you for your feedback.
I found your guidance on writing a clearer message, quoting Elisp symbols,
and the insights about indentation rules to be particularly valuable.
Not using line-number-at-pos is truly a great suggestion.
I've reworked the patch and also revised the commit message.
I kindly request another review. If there are any issues, I will make
further revisions.
Finally, the copyright assignment process was completed on 2023/09/20.
Thank you for letting me know.
On Thu, Oct 5, 2023 at 7:03 PM Ihor Radchenko <yantar92@posteo.net> wrote:
>
> 倉成智久 <tomohisa.kuranari@gmail.com> writes:
>
> > In the current implementation, org-special-ctrl-a/e may not operate as expected.
> > For example, executing (org-beginning-of-line 2) relocates the cursor
> > to the start of the line, rather than after the heading symbols even
> > if org-special-ctrl-a/e is t.
> > (Movements to prior lines, such as (org-beginning-of-line 0), function
> > correctly.)
>
> > This is my first patch submission. If there are any shortcomings or
> > additional requirements needed, please do not hesitate to inform me. I
> > am open to feedback and willing to make any necessary adjustments.
>
> Thanks for the patch, and especially for providing tests!
> See my comments below.
>
> > Subject: [PATCH] lisp/org.el: Fix the issue with argumented function calls
>
> The above message is not very clear. It would be better if you summarize
> the commit purpose more precisely. For example,
> "org-beginning/end-of-line: Fix when moving to different line"
>
> > * lisp/org.el (org-beginning-of-line, org-end-of-line): Fix issue with org-special-ctrl-a/e not working correctly when moving with arguments
>
> Please, quote Elisp symbols like `org-special-ctrl-a/e'. Also, we
> usually limit the line width to default `fill-column'.
>
> > - (when (or (> origin refpos) (= origin bol))
> > + (when (or (> origin refpos)
> > + (= origin bol)
> > + (/= (line-number-at-pos origin) (line-number-at-pos bol)))
>
> This will work, but I am not a big fan of using `line-number-at-pos' -
> it is rather slow. May simply check (< origin bol)
>
> > - (when (or (> origin after-bullet) (= (point) origin))
> > + (when (or (> origin after-bullet)
> > + (= (point) origin)
> > + (/= (line-number-at-pos origin) (line-number-at-pos (point))))
>
> Same here - (< origin (point))
>
> > - (if (or (< origin tags) (= origin (line-end-position)))
> > + (if (or (< origin tags)
> > + (= origin (line-end-position))
> > + (/= (line-number-at-pos origin) (line-number-at-pos (point))))
>
> (> origin (line-end-position))
>
> Finally, your patch is on the edge of legally allowed contribution we are
> allowed to accept without copyright assignment. You may consider signing
> the copyright form as described in
> https://orgmode.org/worg/org-contribute.html#copyright. Or you can add
> "TINYCHANGE" to the commit message (see
> https://orgmode.org/worg/org-contribute.html#first-patch)
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
--
Tomohisa Kuranari
Email: tomohisa.kuranari@gmail.com
[-- Attachment #2: 0001-org-beginning-end-of-line-Fix-when-moving-to-differe.patch --]
[-- Type: application/octet-stream, Size: 6490 bytes --]
From 739c6636cd9e015ed214a6ccaed20cf75301a8d5 Mon Sep 17 00:00:00 2001
From: Tomohisa Kuranari <tomohisa.kuranari@gmail.com>
Date: Fri, 22 Sep 2023 22:38:26 +0900
Subject: [PATCH] org-beginning/end-of-line: Fix when moving to different line
* lisp/org.el (org-beginning-of-line, org-end-of-line): Fix issue with `org-special-ctrl-a/e' not working correctly when moving to different line
* testing/lisp/test-org.el (test-org/beginning-of-line, test-org/end-of-line): Add new tests.
---
lisp/org.el | 6 ++--
testing/lisp/test-org.el | 62 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/lisp/org.el b/lisp/org.el
index d0b2355ea..7cd313c30 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -20331,7 +20331,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
(if (eq special 'reversed)
(when (and (= origin bol) (eq last-command this-command))
(goto-char refpos))
- (when (or (> origin refpos) (= origin bol))
+ (when (or (> origin refpos) (<= origin bol))
(goto-char refpos)))))
((and (looking-at org-list-full-item-re)
(org-element-type-p
@@ -20347,7 +20347,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
(if (eq special 'reversed)
(when (and (= (point) origin) (eq last-command this-command))
(goto-char after-bullet))
- (when (or (> origin after-bullet) (= (point) origin))
+ (when (or (> origin after-bullet) (>= (point) origin))
(goto-char after-bullet)))))
;; No special context. Point is already at beginning of line.
(t nil))))
@@ -20402,7 +20402,7 @@ With argument N not nil or 1, move forward N - 1 lines first."
(goto-char tags)
(end-of-line)))
(t
- (if (or (< origin tags) (= origin (line-end-position)))
+ (if (or (< origin tags) (>= origin (line-end-position)))
(goto-char tags)
(end-of-line))))))
((bound-and-true-p visual-line-mode)
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 8355e2d77..63fd16b40 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -4460,6 +4460,16 @@ asd
(let ((org-special-ctrl-a/e '(nil . nil)))
(org-beginning-of-line)
(looking-at "Headline"))))
+ (should
+ (org-test-with-temp-text "* TODO [#A] Headline\n<point>"
+ (let ((org-special-ctrl-a/e t))
+ (org-beginning-of-line 0)
+ (looking-at-p "Headline"))))
+ (should
+ (org-test-with-temp-text "<point>\n* TODO [#A] Headline"
+ (let ((org-special-ctrl-a/e t))
+ (org-beginning-of-line 2)
+ (looking-at-p "Headline"))))
;; At an headline with reversed movement, first move to beginning of
;; line, then to the beginning of title.
(should
@@ -4480,6 +4490,18 @@ asd
(this-command last-command))
(and (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at-p "Headline"))))))
+ (should
+ (org-test-with-temp-text "* TODO Headline\n<point>"
+ (let ((org-special-ctrl-a/e 'reversed)
+ (this-command last-command))
+ (and (progn (org-beginning-of-line 0) (bolp))
+ (progn (org-beginning-of-line) (looking-at-p "Headline"))))))
+ (should
+ (org-test-with-temp-text "<point>\n* TODO Headline"
+ (let ((org-special-ctrl-a/e 'reversed)
+ (this-command last-command))
+ (and (progn (org-beginning-of-line 2) (bolp))
+ (progn (org-beginning-of-line) (looking-at-p "Headline"))))))
;; At an item with special movement, first move after to beginning
;; of title, then to the beginning of line, rinse, repeat.
(should
@@ -4488,6 +4510,14 @@ asd
(and (progn (org-beginning-of-line) (looking-at-p "Item"))
(progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
+ (should
+ (org-test-with-temp-text "- [ ] Item\n<point>"
+ (let ((org-special-ctrl-a/e t))
+ (org-beginning-of-line 0) (looking-at-p "Item"))))
+ (should
+ (org-test-with-temp-text "<point>\n- [ ] Item"
+ (let ((org-special-ctrl-a/e t))
+ (org-beginning-of-line 2) (looking-at-p "Item"))))
;; At an item with reversed movement, first move to beginning of
;; line, then to the beginning of title.
(should
@@ -4496,6 +4526,18 @@ asd
(this-command last-command))
(and (progn (org-beginning-of-line) (bolp))
(progn (org-beginning-of-line) (looking-at-p "Item"))))))
+ (should
+ (org-test-with-temp-text "- [X] Item\n<point>"
+ (let ((org-special-ctrl-a/e 'reversed)
+ (this-command last-command))
+ (and (progn (org-beginning-of-line 0) (bolp))
+ (progn (org-beginning-of-line) (looking-at-p "Item"))))))
+ (should
+ (org-test-with-temp-text "<point>\n- [X] Item"
+ (let ((org-special-ctrl-a/e 'reversed)
+ (this-command last-command))
+ (and (progn (org-beginning-of-line 2) (bolp))
+ (progn (org-beginning-of-line) (looking-at-p "Item"))))))
;; Leave point before invisible characters at column 0.
(should
(org-test-with-temp-text "[[https://orgmode.org]]<point>"
@@ -4598,6 +4640,14 @@ asd
(and (progn (org-end-of-line) (looking-at-p " :tag:"))
(progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
+ (should
+ (org-test-with-temp-text "* Headline1 :tag:\n<point>"
+ (let ((org-special-ctrl-a/e t))
+ (org-end-of-line 0) (looking-at-p " :tag:"))))
+ (should
+ (org-test-with-temp-text "<point>\n* Headline1 :tag:\n"
+ (let ((org-special-ctrl-a/e t))
+ (org-end-of-line 2) (looking-at-p " :tag:"))))
(should
(org-test-with-temp-text "* Headline2a :tag:\n** Sub"
(org-overview)
@@ -4625,6 +4675,18 @@ asd
(this-command last-command))
(and (progn (org-end-of-line) (eolp))
(progn (org-end-of-line) (looking-at-p " :tag:"))))))
+ (should
+ (org-test-with-temp-text "* Headline3 :tag:\n<point>"
+ (let ((org-special-ctrl-a/e 'reversed)
+ (this-command last-command))
+ (and (progn (org-end-of-line 0) (eolp))
+ (progn (org-end-of-line) (looking-at-p " :tag:"))))))
+ (should
+ (org-test-with-temp-text "<point>\n* Headline3 :tag:\n"
+ (let ((org-special-ctrl-a/e 'reversed)
+ (this-command last-command))
+ (and (progn (org-end-of-line 2) (eolp))
+ (progn (org-end-of-line) (looking-at-p " :tag:"))))))
(should
(org-test-with-temp-text "* Headline2a :tag:\n** Sub"
(org-overview)
--
2.42.0
next prev parent reply other threads:[~2023-10-08 14:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-26 14:38 [PATCH] Fix org-[beginning|end]-of-line with arguments 倉成智久
2023-10-05 10:04 ` Ihor Radchenko
2023-10-08 14:23 ` Tomohisa Kuranari [this message]
2023-11-07 9:50 ` Ihor Radchenko
2023-11-07 10:12 ` Bastien Guerry
2023-11-07 10:56 ` Ihor Radchenko
2023-11-07 14:38 ` Tomohisa Kuranari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAL-TYF7jnNDyM7MrzYtfdx5uxUPEfZ3pOZBnz-gjiX-Jgh+u6Q@mail.gmail.com \
--to=tomohisa.kuranari@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=yantar92@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).