emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Incorrect link is stored (org-elements?)
Date: Tue, 09 Nov 2021 19:46:11 +0800	[thread overview]
Message-ID: <871r3po8l8.fsf@localhost> (raw)
In-Reply-To: <smbl59$qjm$1@ciao.gmane.io>

[-- Attachment #1: Type: text/plain, Size: 249 bytes --]

Max Nikulin <manikulin@gmail.com> writes:

> `org-store-link' under some conditions may pick a link to wrong heading. 
> Emacs-26.3, Org main~1.

I can reproduce, though not exactly following your steps.
Can you try the attached patch?

Best,
Ihor


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-element-at-point-Fix-breakage-when-called-at-the.patch --]
[-- Type: text/x-diff, Size: 1650 bytes --]

From 6465741dff757af23b10d1f0a412eb41d05f4c75 Mon Sep 17 00:00:00 2001
Message-Id: <6465741dff757af23b10d1f0a412eb41d05f4c75.1636458311.git.yantar92@gmail.com>
From: Ihor Radchenko <yantar92@gmail.com>
Date: Tue, 9 Nov 2021 19:42:14 +0800
Subject: [PATCH] org-element-at-point: Fix breakage when called at the end of
 section

* lisp/org-element.el (org-element-at-point): Do no unconditionally
return first matching cached element when point is within blank lines
after section element and CACHED-ONLY is non-nil.

Fixes https://list.orgmode.org/smbl59$qjm$1@ciao.gmane.io/T/#u
---
 lisp/org-element.el | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lisp/org-element.el b/lisp/org-element.el
index 9ea13db9c..ad5c2bbd0 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -7510,9 +7510,6 @@ (defun org-element-at-point (&optional pom cached-only)
                                (and (org-element-property :contents-begin element)
                                     (>= pom (org-element-property :begin element))
                                     (< pom (org-element-property :contents-begin element)))
-                               (and (org-element-property :contents-end element)
-                                    (< pom (org-element-property :end element))
-                                    (>= pom (org-element-property :contents-end element)))
                                (and (not (org-element-property :contents-end element))
                                     (>= pom (org-element-property :begin element))
                                     (< pom (org-element-property :end element)))))))
-- 
2.32.0


  reply	other threads:[~2021-11-09 11:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-08 17:01 Incorrect link is stored (org-elements?) Max Nikulin
2021-11-09 11:46 ` Ihor Radchenko [this message]
2021-11-10 12:52   ` Max Nikulin
2021-11-10 13:48     ` Ihor Radchenko
2021-11-11 14:45       ` Max Nikulin

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=871r3po8l8.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /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).