emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Samuel Loury <konubinix@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: [PATCH] Find a link after point in `org-open-at-point'
Date: Mon, 26 Jan 2015 09:05:44 +0100	[thread overview]
Message-ID: <8761but19j.fsf@konixwork.incubateur.ens-lyon.fr> (raw)


[-- 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 --]

             reply	other threads:[~2015-01-26  8:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-26  8:05 Samuel Loury [this message]
2015-01-26 15:50 ` [PATCH] Find a link after point in `org-open-at-point' Samuel Loury
2015-01-26 17:58   ` Nicolas Goaziou
2015-01-27  8:27     ` Samuel Loury

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8761but19j.fsf@konixwork.incubateur.ens-lyon.fr \
    --to=konubinix@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).