emacs-orgmode
[Top][All Lists]
Advanced

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

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


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

Samuel Loury <address@hidden> writes:

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

Actually, I just found out that the behavior could be the same in items.

Please find attached the modified patch.

Best regards,
From e05f1a54af26f2eebc4b33fe961951af65e70195 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 or an item.

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

diff --git a/lisp/org.el b/lisp/org.el
index 1041c13..73ff1fc 100755
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -10694,7 +10694,8 @@ 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 item)
               t))
             (type (org-element-type context))
             (value (org-element-property :value context)))
@@ -10870,6 +10871,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 item))
+         (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]