From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: [ISSUE] links navigation not consistent behavior Date: Wed, 03 Apr 2019 12:28:28 -0400 Message-ID: <87r2ajrr2r.fsf@alphaville.usersys.redhat.com> References: <87k1gj3n5q.fsf@gmail.com> <87zhp8i2q9.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:60781) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hBikl-0006P1-W6 for emacs-orgmode@gnu.org; Wed, 03 Apr 2019 12:28:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hBikj-0003we-M8 for emacs-orgmode@gnu.org; Wed, 03 Apr 2019 12:28:42 -0400 Received: from [195.159.176.226] (port=39828 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hBikj-0003H5-BC for emacs-orgmode@gnu.org; Wed, 03 Apr 2019 12:28:41 -0400 Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hBikb-000mDr-UQ for emacs-orgmode@gnu.org; Wed, 03 Apr 2019 18:28:33 +0200 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" To: emacs-orgmode@gnu.org Nicolas Goaziou writes: > Hello, > > stardiviner writes: > >> For example, I have following Org content: >> >> #+begin_src org ,*** TODO Figwheel [0/1] >> >> - [ ] https://www.youtube.com/watch?v=yUTxm29fjT4 :: I built a >> Figwheel-inspired, hot code reloading experience for Clojure, >> with an eye towards #datascience hacking. >> >> ,*** TODO Docker ClojureScript [0/3] >> >> - [ ] https://www.youtube.com/watch?v=yUTxm29fjT4 #+end_src >> >> When my point at beginning of buffer, then press {{{kbd(C-c C-x >> C-n)}}} , it does not jump to first link, it jump to second link >> instead. But when I jump backwards with {{{kbd(C-c C-x C-p)}}} >> works fine. > > I rewrote this functions some weeks ago. Please try again on master. > I can reproduce the problem with very recent org. I did some debugging and here are my notes: ,---- | I can reproduce this and traced it to this code: | | ,---- | | (catch :found | | (while (funcall search-fun org-link-any-re nil t) | | (pcase (org-element-lineage (org-element-context) '(link) t) ;;; <<<<< HERE | | (`nil nil) (link | | (goto-char (org-element-property :begin link)) (when | | (org-invisible-p) (org-show-context)) (throw :found t)))) | `---- | | which is a rewrite of org-next-link in commit 4ff8947ea8. | | There is some asymmetry in how forward and backward searches behave: | | - in the forward case, the search ends up at the end of the first | link where `org-element-lineage' returns nil, so the loop repeats; | we then end up at the end of the second link where | `org-element-lineage' returns the link, we go to the beginning of | the link and return. | | - in the backward case, we end up at the beginning of each link in | turn, in which case `org-element-lineage' returns a link, so both | links are found. | | So it may be that `org-element-context' should return a structure with | the link included when called at the end of the first link or it may | be that the search should back up one char in the forward case, before | calling org-context. `---- This may be wrong but I did not have time to continue with it: I hope it's useful. -- Nick "There are only two hard problems in computer science: cache invalidation, naming things, and off-by-one errors." -Martin Fowler