From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Loury Subject: [PATCH] Fix uncaught error when trying to open a link at point Date: Thu, 22 Nov 2012 09:42:00 +0100 Message-ID: <87ehjmvxk7.fsf@konixwork.incubateur.ens-lyon.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:45069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbSNT-00036H-VC for emacs-orgmode@gnu.org; Thu, 22 Nov 2012 03:43:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TbSNR-0004So-L3 for emacs-orgmode@gnu.org; Thu, 22 Nov 2012 03:43:19 -0500 Received: from mail-wi0-f169.google.com ([209.85.212.169]:61930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TbSNR-0004QC-9Z for emacs-orgmode@gnu.org; Thu, 22 Nov 2012 03:43:17 -0500 Received: by mail-wi0-f169.google.com with SMTP id hq12so452227wib.0 for ; Thu, 22 Nov 2012 00:43:16 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: OrgMode ML --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-the-uncaught-exception-when-doing-opening-a-link.patch Content-Transfer-Encoding: quoted-printable From=200e31213fa486f7fcfe1c2b7037689df077a39fce Mon Sep 17 00:00:00 2001 From: Samuel Loury 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 =2D-- 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 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -9745,8 +9745,29 @@ application the system uses for this file type." =20 (save-excursion (when (or (org-in-regexp org-angle-link-re) =2D (and (goto-char (car (org-in-regexp org-plain-link-re))) =2D (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))) =2D-=20 1.7.10.4 --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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. =2D-=20 Samuel --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJQreVZAAoJEHXSPO10ORBqtHsH/jB/T8crVxCkyZAsgunndTsG mjN1+6xzKa9svTpyw/qARR7j01ibdzIuOO8sexTGTOJKAaGP2Z3eX4mFJc0hqxU9 OhaZeF9MGhYo7QJbKIuOW/7FwUqcTZ13fEG/bfPJhqBKbqL4hkuGCnSUapDb8Hdi CMAe5EIflUm3gn1tDUc3i8FuKXezQD9uxONAQyH5gTG3gcqfoR7g2YTcwaOzH2y8 1pZ9fvla7/V/sxim7J1xsr5+uXNOjwUzKBAks8XuCGHkuGIuqaqeIhUFjX2jLyQo Jb1iVpOWC5J0n+r8sFBhsShZ2hG0g+Rkl1hqqPSe9AsjXARl3sa5xgfDna1PUhw= =paLE -----END PGP SIGNATURE----- --==-=-=--