all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Samuel Loury <konubinix@gmail.com>
To: Org Mode List <emacs-orgmode@gnu.org>
Subject: Re: [PATCH] Find a link after point in `org-open-at-point'
Date: Mon, 26 Jan 2015 16:50:19 +0100	[thread overview]
Message-ID: <87mw55k0ck.fsf@konixwork.incubateur.ens-lyon.fr> (raw)
In-Reply-To: <8761but19j.fsf@konixwork.incubateur.ens-lyon.fr>


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

  reply	other threads:[~2015-01-26 15:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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

  git send-email \
    --in-reply-to=87mw55k0ck.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.