emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Find a link after point in `org-open-at-point'
@ 2015-01-26  8:05 Samuel Loury
  2015-01-26 15:50 ` Samuel Loury
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Loury @ 2015-01-26  8:05 UTC (permalink / raw)
  To: Org Mode List


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

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,

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Find-a-link-after-point-in-org-open-at-point.patch --]
[-- Type: text/x-diff, Size: 1659 bytes --]

From ea1d4d061a74d7797bf5cf78dc2722eb0baaf7be Mon Sep 17 00:00:00 2001
From: Konubinix <konubinix@gmail.com>
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


[-- Attachment #1.3: Type: text/plain, Size: 104 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [PATCH] Find a link after point in `org-open-at-point'
  2015-01-26  8:05 [PATCH] Find a link after point in `org-open-at-point' Samuel Loury
@ 2015-01-26 15:50 ` Samuel Loury
  2015-01-26 17:58   ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Loury @ 2015-01-26 15:50 UTC (permalink / raw)
  To: Org Mode List


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

Samuel Loury <konubinix@gmail.com> 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,

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-Find-a-link-after-point-in-org-open-at-point.patch --]
[-- Type: text/x-diff, Size: 1671 bytes --]

From e05f1a54af26f2eebc4b33fe961951af65e70195 Mon Sep 17 00:00:00 2001
From: Konubinix <konubinix@gmail.com>
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


[-- Attachment #1.3: Type: text/plain, Size: 104 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

* Re: [PATCH] Find a link after point in `org-open-at-point'
  2015-01-26 15:50 ` Samuel Loury
@ 2015-01-26 17:58   ` Nicolas Goaziou
  2015-01-27  8:27     ` Samuel Loury
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2015-01-26 17:58 UTC (permalink / raw)
  To: Samuel Loury; +Cc: Org Mode List

Hello,

Samuel Loury <konubinix@gmail.com> 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.

Thanks for the patch.

However, I removed this because it is too sloppy. I want
`org-open-at-point' to be predictable. 

If you rely on this, I suggest to defadvice `org-open-at-point' instead.


Regards,

-- 
Nicolas Goaziou

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

* Re: [PATCH] Find a link after point in `org-open-at-point'
  2015-01-26 17:58   ` Nicolas Goaziou
@ 2015-01-27  8:27     ` Samuel Loury
  0 siblings, 0 replies; 4+ messages in thread
From: Samuel Loury @ 2015-01-27  8:27 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Org Mode List

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

Hi,
Nicolas Goaziou <mail@nicolasgoaziou.fr> writes:

> Samuel Loury <konubinix@gmail.com> 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.
>
> Thanks for the patch.
>
> However, I removed this because it is too sloppy. I want
> `org-open-at-point' to be predictable.

Thank you for the answer.

> If you rely on this, I suggest to defadvice `org-open-at-point'
>instead.

I'll do that.

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

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

end of thread, other threads:[~2015-01-27  8:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-26  8:05 [PATCH] Find a link after point in `org-open-at-point' Samuel Loury
2015-01-26 15:50 ` Samuel Loury
2015-01-26 17:58   ` Nicolas Goaziou
2015-01-27  8:27     ` Samuel Loury

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