all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Matt Lundin <mdl@imapmail.org>, Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Fix moving cursor in org-set-tags-command
Date: Fri, 08 May 2020 02:42:42 +0000	[thread overview]
Message-ID: <878si3du59.fsf@kyleam.com> (raw)
In-Reply-To: <871rnvi8g6.fsf@fastmail.fm>

Matt Lundin writes:

> Commit 44ec473c199262d89b372d8a6cd35bed7672164d from Feb. 23 causes
> org-set-tags-command to move the cursor forward 1 char when situated on
> headline asterisks.
[...]
> This commit modified a previous change on Feb. 21
> (450452de4b790706d187291f9f71a286f8f62004). But that commit also had
> problems, since it would move the cursor one asterisk forward on
> headlines > 1, thus also interfering with org-speed-keys. In my view
> org-set-tags-command should not move the cursor except to fix the very
> specific thing that commit 450452de4b was meant to fix: namely the
> cursor moving when on a blank headline: i.e., from here...

Thanks for the nice description of the problem.  I wouldn't mind if at
least a condensed version made its way into the commit message :)

> I've attached a patch that corrects the problem, but it would be ideal
> if we figured out why the cursor is moving in the first place.

I looked quickly at org-set-tags (and the functions it calls).  Based on
commenting bits out, I think there are at least a couple of parts that
modify the buffer in a way that prevent save-excursion from restoring
the intended location.  While not ideal, this after-the-fact adjustment
is probably the simplest way to deal with the issue.

> Subject: [PATCH 1/1] Fix bug that placed cursor incorrectly when setting tags
>
> * lisp/org.el: (org-set-tags-command) Only fix cursor position in very

nitpick: The colon should follow (org-set-tags-command).

> diff --git a/lisp/org.el b/lisp/org.el
> index dd017e662..0e4fd7be1 100644
> --- a/lisp/org.el
> +++ b/lisp/org.el
> @@ -11846,8 +11846,9 @@ in Lisp code use `org-set-tags' instead."
>  	  (org-set-tags tags)))))
>      ;; `save-excursion' may not replace the point at the right
>      ;; position.
> -    (when (save-excursion (skip-chars-backward "*") (bolp))
> -      (forward-char))))
> +    (and (looking-at " ")
> +	 (string-match "\\*+" (buffer-substring (point-at-bol) (point)))
> +	 (forward-char))))

Looks fine to me, with the minor nit that I think looking-at-p and
string-match-p would be preferable here.

Would you mind adding a regression test?


  reply	other threads:[~2020-05-08  2:43 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-08  0:20 [PATCH] Fix moving cursor in org-set-tags-command Matt Lundin
2020-05-08  2:42 ` Kyle Meyer [this message]
2020-05-08  7:53 ` Nicolas Goaziou
2020-05-09  1:44   ` Kyle Meyer
2020-05-09  8:12     ` Nicolas Goaziou
2020-05-09 20:01       ` Kyle Meyer
2020-05-10 17:39   ` Matthew Lundin

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878si3du59.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=mdl@imapmail.org \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.