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 12:39:18 +0100 Message-ID: <87wqvtrxcp.fsf@konixwork.incubateur.ens-lyon.fr> References: <87ehjmvxk7.fsf@konixwork.incubateur.ens-lyon.fr> <87bodpdskd.fsf@bzg.ath.cx> 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]:42302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr5du-0006ln-GX for emacs-orgmode@gnu.org; Fri, 04 Jan 2013 06:40:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tr5ds-0001me-O6 for emacs-orgmode@gnu.org; Fri, 04 Jan 2013 06:40:54 -0500 Received: from mail-we0-f180.google.com ([74.125.82.180]:59688) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tr5ds-0001mY-Co for emacs-orgmode@gnu.org; Fri, 04 Jan 2013 06:40:52 -0500 Received: by mail-we0-f180.google.com with SMTP id t57so7518570wey.39 for ; Fri, 04 Jan 2013 03:40:51 -0800 (PST) In-Reply-To: <87bodpdskd.fsf@bzg.ath.cx> 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: Bastien Cc: OrgMode ML --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi and thanks for paying attention to my patch. Bastien writes: > I allowed myself to fix this, with a somewhat smaller patch: > http://orgmode.org/cgit.cgi/org-mode.git/commit/?h=3Dmaint&id=3D14ffe2 This is indeed a good way to fix the uncaught error problem. Nonetheless, the patch I provided was intended to also correct a functional problem (to my mind) about the consistency of the behavior of org-open-at-point relatively to plain links. Let me explain what I mean: * First test: with bracket links Imagine you have the following line (I placed a _ to indicate the position of the cursor) =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 some non r_elevant text [[id:some-id]] =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80 Within that situation, launching org-open-at-point would follow the id:some-id link. In the following situation (with the cursor inside the link) =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 some non relevant text [[id:so_me-id]] =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80 org-open-at-point will also open the link. That one seems obvious but I think it is worth keeping in mind though. * Second test: with plain links Now, imagine the same scenarios with plain links =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 some non relevant text id:so_me-id =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80 With the cursor inside the link, org-open-at-point follows the link. Then with the cursor before the link: =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80 =E2=94=82 some non r_elevant text id:some-id =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80 org-open-at-point results in an error (now caught thanks to Bastien) while I (and I stress it is my personal opinion) think that it should also follow the link, like in the case of a bracket link. As suggested by Nicolas, I provided tests in attachment to show the 4 use cases I just explained. The initial patch I provided was meant to enhance the implementation of org-open-at-point to make those use cases work. What do you think? Should we enhance the function that way. I use the patched version for some time now and I often launch org-open-at-point (C-c C-o) before plain links. Thanks again for your answers. =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-Addition-of-tests-highlighting-the-expected-behavior.patch Content-Transfer-Encoding: quoted-printable Content-Description: test From=20d9df74a72962020c3e695be0ad9a8646a42ee9de Mon Sep 17 00:00:00 2001 From: Samuel Loury Date: Fri, 4 Jan 2013 12:31:01 +0100 Subject: [PATCH] Addition of tests highlighting the expected behavior of org-open-at-point in several circumstances =2D-- testing/examples/open-at-point.org | 8 ++++ testing/lisp/test-org-open-at-point.el | 63 ++++++++++++++++++++++++++++= ++++ 2 files changed, 71 insertions(+) create mode 100644 testing/examples/open-at-point.org create mode 100644 testing/lisp/test-org-open-at-point.el diff --git a/testing/examples/open-at-point.org b/testing/examples/open-at-= point.org new file mode 100644 index 0000000..b3bb92d =2D-- /dev/null +++ b/testing/examples/open-at-point.org @@ -0,0 +1,8 @@ + +* Header 1 + :PROPERTIES: + :ID: header1_with_great_id + :END: +* Header 2 + [[id:header1_with_great_id][Header 1]] + id:header1_with_great_id diff --git a/testing/lisp/test-org-open-at-point.el b/testing/lisp/test-org= -open-at-point.el new file mode 100644 index 0000000..efb70c8 =2D-- /dev/null +++ b/testing/lisp/test-org-open-at-point.el @@ -0,0 +1,63 @@ +;;; test-org-open-at-point.el + +;; Copyright (c) Samuel Loury +;; Authors: Samuel Loury + +;; Released under the GNU General Public License version 3 +;; see: http://www.gnu.org/licenses/gpl-3.0.html + +;;;; Comments: + +;; Test for the org-open-at-point function + +;;; Code: + + +;;; Bracket links + +(save-excursion + (set-buffer (get-buffer-create "test-org-open-at-point.el")) + (setq ly-here + (file-name-directory + (or load-file-name (buffer-file-name))))) + +(defun test-org-open-at-point/goto-fixture () + (find-file-other-window + (concat ly-here "../examples/open-at-point.org")) + (set-buffer "open-at-point.org")) + +(ert-deftest test-org-open-at-point/bracket-link-inside () + "Test `org-open-at-point' from inside a bracket link." + (test-org-open-at-point/goto-fixture) + ;; go inside the bracket link + (goto-char 113) + (org-open-at-point) + ;; should now be in front of the header + (should (equal (point) 2))) + +(ert-deftest test-org-open-at-point/plain-link-inside () + "Test `org-open-at-point' from inside a plain link." + (test-org-open-at-point/goto-fixture) + ;; go inside the plain link + (goto-char 126) + (org-open-at-point) + ;; should now be in front of the header + (should (equal (point) 2))) + +(ert-deftest test-org-open-at-point/bracket-link-before () + "Test `org-open-at-point' from before a bracket link but in the same lin= e." + (test-org-open-at-point/goto-fixture) + ;; go before the bracket link + (goto-char 83) + (org-open-at-point) + ;; should now be in front of the header + (should (equal (point) 2))) + +(ert-deftest test-org-open-at-point/plain-link-before () + "Test `org-open-at-point' from before a plain link but in the same line." + (test-org-open-at-point/goto-fixture) + ;; go before the plain link + (goto-char 124) + (org-open-at-point) + ;; should now be in front of the header + (should (equal (point) 2))) =2D-=20 1.7.10.4 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQEcBAEBAgAGBQJQ5r9mAAoJEHXSPO10ORBqFHMIAJ/s70aG+lLnvDiF/P9WG5iU ZeYOPgOEHnRMNXcccftUzEA+nPp2OO9usuOLGuykeHbCYRz977mhb3eP9YBLx8NA L4EQRI8LGw30yRD6WqQsZy1SqnNm7IVIqVszFi77GnKlty86Bq5K0alVmFzMunMk /m9IRX55ddxXkbjCQvPBekTTN8fXupBv/zER0+TsspWtSw4YX637/HY25gJ/eVoF zFN2PNeYQE31UtN0FwCZD3DtuUGLaWeQX6VVYT3WuqaiokjGuicqIGdiZPZwkRqP qSQaewtezPQfNFsx+gm5nCOvhZ7y0TRpCnBP2JsyByIx6jBz+KG03K/9xz6+qiw= =zbkI -----END PGP SIGNATURE----- --==-=-=--