emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH] Find a link after point in `org-open-at-point'


From: Samuel Loury
Subject: [O] [PATCH] Find a link after point in `org-open-at-point'
Date: Mon, 26 Jan 2015 09:05:44 +0100
User-agent: Notmuch/0.18.2 (http://notmuchmail.org) Emacs/24.4.1 (x86_64-pc-linux-gnu)

Dear all,

I would like to propose a patch for `org-open-at-point' to find a link
after point when called inside a paragraph. It had this behavior at some
time and I think lost it during the org-element re-factoring. This patch
restores this ancient behavior with the new way the function is coded.

Please find the patch attached in this mail.

Best regards,
From ea1d4d061a74d7797bf5cf78dc2722eb0baaf7be Mon Sep 17 00:00:00 2001
From: Konubinix <address@hidden>
Date: Mon, 26 Jan 2015 08:44:06 +0100
Subject: [PATCH] Find a link after point in `org-open-at-point'

* lisp/org.el (org-open-at-point): Look for a link after point but in the same
line as (point) when called inside a paragraph.

Now, the user doesn't have to move the cursor to the link to call
`org-open-at-point'.
---
 lisp/org.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index 1041c13..5373179 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10694,7 +10694,9 @@ link in a property drawer line."
              (org-element-lineage
               (org-element-context)
               '(comment comment-block footnote-definition footnote-reference
-                        headline inlinetask link node-property timestamp)
+                        headline inlinetask link node-property
+                        timestamp paragraph
+                        )
               t))
             (type (org-element-type context))
             (value (org-element-property :value context)))
@@ -10870,6 +10872,12 @@ link in a property drawer line."
                         (= (org-element-property :post-affiliated context)
                            (line-beginning-position)))))))
          (org-footnote-action))
+        ;; On a paragraph, find a link on the current line after point.
+        ((memq type '(paragraph))
+         (save-excursion
+           (if (re-search-forward org-any-link-re (line-end-position) t)
+               (org-open-at-point)
+             (user-error "No link found"))))
         (t (user-error "No link found")))))
     (move-marker org-open-link-marker nil)
     (run-hook-with-args 'org-follow-link-hook)))
-- 
2.1.4

-- 
Konubinix
GPG Key    : 7439106A
Fingerprint: 5993 BE7A DA65 E2D9 06CE  5C36 75D2 3CED 7439 106A

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]