emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [RFC][PATCH] Store links to named elements
@ 2015-03-18 14:19 Jacob Gerlach
  2015-03-26 20:34 ` Nicolas Goaziou
  0 siblings, 1 reply; 2+ messages in thread
From: Jacob Gerlach @ 2015-03-18 14:19 UTC (permalink / raw)
  To: Org-mode

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

In [1], storing links to named elements was discussed. AFAICT, no
patches came from that discussion. The current behavior is that given:

* Headline

#+Name: foo

org-store-link will store a link to `*Headline' rather than `foo'.

Attached is a very rough first attempt at patching org-store-link to
recognize and link to the name.

Is this approach worth fleshing out or are there problems associated
with this type of link? Using the above example, [[foo]] seems to be a
valid link, recognized by both export and org-open-at-point.

If doable, a couple of specific questions:
This attached patch makes no attempt to store the file name as
currently done for headlines. Would it be better to check for a name
in the headline linking code (the final "t" in the org-mode-p `cond'
in org-store-link) or rather reproduce file name code separately.

Does a context string make sense for links to element names?

Regards,
Jake

[1] http://permalink.gmane.org/gmane.emacs.orgmode/91935

[-- Attachment #2: 0001-Add-support-to-link-to-named-elements.patch --]
[-- Type: text/x-patch, Size: 990 bytes --]

From f1166d30ccabdb208b0263d87fd9366fa9a2f325 Mon Sep 17 00:00:00 2001
From: Jacob Gerlach <jacobgerlach@gmail.com>
Date: Wed, 18 Mar 2015 09:58:00 -0400
Subject: [PATCH] Add support to link to named elements

* lisp/org.el (org-store-link): Store links to named elements.

Before falling back to the current headline, check if point is at a
named element, and if so store the element name as the link.

TINYCHANGE
---
 lisp/org.el | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lisp/org.el b/lisp/org.el
index b1999dc..0a37a2f 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9838,6 +9838,11 @@ active region."
 			 (concat "file:"
 				 (abbreviate-file-name
 				  (buffer-file-name (buffer-base-buffer))))))))
+
+	  ((org-element-property :name (org-element-at-point))
+	   ;; At a named element, link to the name
+	   (setq cpltxt (org-element-property :name (org-element-at-point))))
+
 	  (t
 	   ;; Just link to current headline
 	   (setq cpltxt (concat "file:"
-- 
1.9.1


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

end of thread, other threads:[~2015-03-26 20:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-18 14:19 [RFC][PATCH] Store links to named elements Jacob Gerlach
2015-03-26 20:34 ` Nicolas Goaziou

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