emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] ol: Fix org-link-search
@ 2022-04-20 16:10 tony aldon
  2022-04-21  5:39 ` Ihor Radchenko
  2022-04-21 13:00 ` Ihor Radchenko
  0 siblings, 2 replies; 4+ messages in thread
From: tony aldon @ 2022-04-20 16:10 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 304 bytes --]

Hey everyone,

If I'm not wrong, name defined after #+NAME: should be match first
before trying a fuzzy search in the function `org-link-search`.

You can find the patch in attachment (hope it feat in Tiny changes
[though I also sent a request today for the FSF agreement]).

Have a nice day.
Tony Aldon

[-- Attachment #1.2: Type: text/html, Size: 357 bytes --]

[-- Attachment #2: 0001-ol-Fix-org-link-search.patch --]
[-- Type: text/x-patch, Size: 1647 bytes --]

From ba4028e71fb41b6e4367d3e85846526dd7577d52 Mon Sep 17 00:00:00 2001
From: tony <tony.aldon.adm@gmail.com>
Date: Wed, 20 Apr 2022 17:58:34 +0200
Subject: [PATCH] ol: Fix org-link-search

* lisp/ol.el (org-link-search):  Replace wrong property :name by
  :value.  Name defined after #+NAME: should be match first before
  trying a fuzzy search.
* testing/lisp/test-ol.el (test-ol/search):  New test.

TINYCHANGE
---
 lisp/ol.el              |  2 +-
 testing/lisp/test-ol.el | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/ol.el b/lisp/ol.el
index 1b2bb9a9a..4554941b6 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -1189,7 +1189,7 @@ of matched result, which is either `dedicated' or `fuzzy'."
 	       (goto-char (point-min))
 	       (while (re-search-forward name nil t)
 		 (let* ((element (org-element-at-point))
-			(name (org-element-property :name element)))
+			(name (org-element-property :value element)))
 		   (when (and name (equal words (split-string name)))
 		     (setq type 'dedicated)
 		     (beginning-of-line)
diff --git a/testing/lisp/test-ol.el b/testing/lisp/test-ol.el
index ddcc570b3..3e5b9c7cd 100644
--- a/testing/lisp/test-ol.el
+++ b/testing/lisp/test-ol.el
@@ -492,6 +492,18 @@
 	    (buffer-substring (point) (line-end-position))))))
 
 \f
+;;; Search
+
+(ert-deftest test-ol/search ()
+  "Test `org-link-search'."
+  ;; Look for name defined after #+NAME:
+  (should
+   (equal 'dedicated
+      (org-test-with-temp-text "foo\n#+NAME: foo"
+	(let ((org-link-search-must-match-exact-headline nil))
+          (org-link-search "foo"))))))
+
+\f
 ;;; Link regexps
 
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-21 13:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-20 16:10 [PATCH] ol: Fix org-link-search tony aldon
2022-04-21  5:39 ` Ihor Radchenko
     [not found]   ` <CACWitSA6eYp68L3u3HFxA-U-EE=s9ZDQxKaHmaFPdL+UxXVEOw@mail.gmail.com>
2022-04-21 10:25     ` tony aldon
2022-04-21 13:00 ` Ihor Radchenko

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).