emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix uncaught error when trying to open a link at point
@ 2012-11-22  8:42 Samuel Loury
  2012-11-28 12:53 ` Nicolas Goaziou
  2012-12-20  8:41 ` Bastien
  0 siblings, 2 replies; 12+ messages in thread
From: Samuel Loury @ 2012-11-22  8:42 UTC (permalink / raw)
  To: OrgMode ML


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.1: 0001-Fix-the-uncaught-exception-when-doing-opening-a-link.patch --]
[-- Type: text/x-diff, Size: 2044 bytes --]

From 0e31213fa486f7fcfe1c2b7037689df077a39fce Mon Sep 17 00:00:00 2001
From: Samuel Loury <samuel.loury@cosmo-platform.org>
Date: Thu, 22 Nov 2012 09:31:15 +0100
Subject: [PATCH] Fix the uncaught exception when doing opening a link from
 nowhere

* lisp/org.el (org-open-at-point): Make sure point is on a
org-plain-link-re before trying to go to its beginning

In cases the custor at point did not match anything, the piece of
code (goto-char (car (org-in-regexp org-plain-link-re))) threw an
error.

The inital intention of avoiding matching a org-plain-link-re when
just after a org-bracket-link-regexp, from the commit originating
the error (ad35e2ac6c6decae55dd987be738e07e7c87bd7d) was conserved.

TINYCHANGE
---
 lisp/org.el |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index 080b527..d036c2a 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -9745,8 +9745,29 @@ application the system uses for this file type."
 
 	  (save-excursion
 	    (when (or (org-in-regexp org-angle-link-re)
-		      (and (goto-char (car (org-in-regexp org-plain-link-re)))
-			   (save-match-data (not (looking-back "\\[\\[")))))
+		      (let (
+			    (match (org-in-regexp org-plain-link-re))
+			    )
+			(and
+			 ;; link at point is a plain link
+			 match
+			 ;; check that it is not of the form
+			 ;; [[http://orgmode.org][Org]]Mode. in that
+			 ;; case, if the cursor is on "Mode", then the
+			 ;; string "http://orgmode.org][Org]]Mode" is
+			 ;; recognized as a plain link while it should
+			 ;; not be
+			 (progn
+			   ;; go to the begining of the match, If we
+			   ;; were in the special case, we should now
+			   ;; be in a org-bracket-link-regexp
+			   (goto-char (car match))
+			   (not
+			    (org-in-regexp org-bracket-link-regexp)
+			    )
+			   )
+			 )
+			))
 	      (setq type (match-string 1)
 		    path (org-link-unescape (match-string 2)))
 	      (throw 'match t)))
-- 
1.7.10.4


[-- Attachment #1.2: Type: text/plain, Size: 575 bytes --]

Hi,

        When trying to open a link at point when no link is present, an
error is thrown. Test for instance to call org-open-at-point (C-c C-o)
while in an empty line.

It is in fact a regression coming from
ad35e2ac6c6decae55dd987be738e07e7c87bd7d that tries to go to the result
of a org-in-regexp call without checking whether the result is empty.

Here is a patch that keeps the idea from
ad35e2ac6c6decae55dd987be738e07e7c87bd7d (avoiding matching an
org-plain-link-re while it is in fact a org-bracket-link-regexp) and
fixing the problem.
-- 
Samuel

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

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

end of thread, other threads:[~2013-03-16 19:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-22  8:42 [PATCH] Fix uncaught error when trying to open a link at point Samuel Loury
2012-11-28 12:53 ` Nicolas Goaziou
2012-12-20  8:41 ` Bastien
2013-01-04 11:39   ` Samuel Loury
2013-01-04 13:17     ` Samuel Loury
2013-01-04 16:18       ` Bastien
2013-01-14 10:35         ` Samuel Loury
2013-02-13 15:25       ` Bastien
2013-02-13 16:39         ` Samuel Loury
2013-02-13 16:49           ` Bastien
2013-03-16 19:22             ` Samuel Loury
2013-03-16 19:32               ` Bastien

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