From mboxrd@z Thu Jan 1 00:00:00 1970 From: Samuel Loury Subject: Re: [PATCH] Fix uncaught error when trying to open a link at point Date: Fri, 04 Jan 2013 14:17:42 +0100 Message-ID: <87pq1lrssp.fsf@konixwork.incubateur.ens-lyon.fr> References: <87ehjmvxk7.fsf@konixwork.incubateur.ens-lyon.fr> <87bodpdskd.fsf@bzg.ath.cx> <87wqvtrxcp.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]:35010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr7B8-0006ha-9V for emacs-orgmode@gnu.org; Fri, 04 Jan 2013 08:19:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tr7B4-00052c-Qs for emacs-orgmode@gnu.org; Fri, 04 Jan 2013 08:19:18 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:46769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr7B4-00052H-HO for emacs-orgmode@gnu.org; Fri, 04 Jan 2013 08:19:14 -0500 Received: by mail-wg0-f45.google.com with SMTP id dq12so7723703wgb.12 for ; Fri, 04 Jan 2013 05:19:13 -0800 (PST) In-Reply-To: <87wqvtrxcp.fsf@konixwork.incubateur.ens-lyon.fr> 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/plain Content-Transfer-Encoding: quoted-printable In attachment is a patch making tests of the previous mail (id:"87wqvtrxcp.fsf@konixwork.incubateur.ens-lyon.fr") pass. It adjusts org-open-at-point to have plain links handled the same way bracket links are. It allows plain links to be followed if the cursor is before the link while still on the same line. I also got rid of dangling parenthesis as suggested by Nicolas. Personally, I think it is easier to read with dangling parens. Could you explain what is wrong with them? Thanks for your attention. =2D-=20 Konubinix GPG Key : 7439106A Fingerprint: 5993 BE7A DA65 E2D9 06CE 5C36 75D2 3CED 7439 106A --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Make-org-open-at-point-behave-the-same-with-plain-li.patch Content-Transfer-Encoding: quoted-printable Content-Description: patch From=20cd52bef7715ed551972ad5331fce50260cfcda50 Mon Sep 17 00:00:00 2001 From: Samuel Loury Date: Fri, 4 Jan 2013 14:01:43 +0100 Subject: [PATCH] Make org-open-at-point behave the same with plain links and with bracket links. * lisp/org.el (org-open-at-point): make org-open-at-point handle a plai= n link even if the cursor is before it TINYCHANGE =2D-- lisp/org.el | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/lisp/org.el b/lisp/org.el index b0fcb58..5d75055 100644 =2D-- a/lisp/org.el +++ b/lisp/org.el @@ -9911,12 +9911,36 @@ application the system uses for this file type." (throw 'match t)) =20 (save-excursion =2D (let ((plinkpos (org-in-regexp org-plain-link-re))) =2D (when (or (org-in-regexp org-angle-link-re) =2D (and plinkpos (goto-char (car plinkpos)) =2D (save-match-data (not (looking-back "\\[\\["))))) =2D (setq type (match-string 1) =2D path (org-link-unescape (match-string 2))) + (when (or (org-in-regexp org-angle-link-re) + (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 + (save-excursion + (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)))))) + (let ((line_ending (save-excursion (end-of-line) + (point)))) + ;; if in a line before a plain link or a + ;; bracket link + (or + (re-search-forward org-plain-link-re + line_ending t) + (re-search-forward org-bracket-link-regexp + line_ending t)))) + (setq type (match-string 1) + path (org-link-unescape (match-string 2))) (throw 'match t)))) (save-excursion (when (org-in-regexp (org-re "\\(:[[:alnum:]_@#%:]+\\):[ \t]*$")) =2D-=20 1.7.10.4 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJQ5tZ2AAoJEHXSPO10ORBqUGQH/0zp+I2e+UonrXWtWwXWo5Q5 FpElG7fyFU/zLpRMWOEnLMcFBuixLWVJHPQfWadGfLp/qVCiCm3u41HysMuMFZ3J LyyWHsrcPfolG/Y4RFa9IwSRX7VN7QTB8fwHfExm2fRH00gMNxUubfFRDhHUEeSF wnSqW8VSDn81c0yIxhPxc5D8AoEZcbBvY0BDMumHKCF/7ihg6nlJEMpGgGjIxOVN WeB8E8YrpS87oIsVsxZAHxyMaHH4M3ZrcUocOqlz3qz5i09oqLfwaDuZaUtiAKp1 6/a1cPSwjFUD+LLBP7VP9mE/+QLgWJywU2vl5UXYkcXOnaKLZCMkzH8QQKENbUE= =ikM+ -----END PGP SIGNATURE----- --==-=-=--