From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stig Brautaset Subject: Re: [RFC] Change visibility for bracket links Date: Sat, 22 Oct 2016 03:02:38 +0200 Message-ID: References: <87bmyyold3.fsf@nicolasgoaziou.fr> <871szlrkdh.fsf@gmx.us> <87zim9oo2m.fsf@nicolasgoaziou.fr> <87twchomel.fsf@gmx.us> <87h98hoj0m.fsf@nicolasgoaziou.fr> <877f9dohsi.fsf@gmx.us> <87d1j45t41.fsf@nicolasgoaziou.fr> <9e35201e-cc6e-8d3e-e1be-b237034dbfd5@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55039) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxkhy-0004uf-VG for emacs-orgmode@gnu.org; Fri, 21 Oct 2016 21:02:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxkhv-0007WC-RE for emacs-orgmode@gnu.org; Fri, 21 Oct 2016 21:02:46 -0400 Received: from relay5-d.mail.gandi.net ([217.70.183.197]:37077) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1bxkhv-0007Uo-LI for emacs-orgmode@gnu.org; Fri, 21 Oct 2016 21:02:43 -0400 Received: from mfilter25-d.gandi.net (mfilter25-d.gandi.net [217.70.178.153]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 0468D41C04C for ; Sat, 22 Oct 2016 03:02:41 +0200 (CEST) Received: from relay5-d.mail.gandi.net ([IPv6:::ffff:217.70.183.197]) by mfilter25-d.gandi.net (mfilter25-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id hpU6o8WDVWUH for ; Sat, 22 Oct 2016 03:02:39 +0200 (CEST) Received: from Margil.home (host86-165-46-164.range86-165.btcentralplus.com [86.165.46.164]) (Authenticated sender: mailbox@brautaset.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 4DC0A41C07E for ; Sat, 22 Oct 2016 03:02:39 +0200 (CEST) In-Reply-To: <9e35201e-cc6e-8d3e-e1be-b237034dbfd5@gmail.com> (=?utf-8?Q?=22Cl=C3=A9ment?= Pit--Claudel"'s message of "Thu, 20 Oct 2016 19:44:46 -0400") 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" To: emacs-orgmode@gnu.org Cl=C3=A9ment Pit--Claudel writes: > On 2016-10-13 08:30, Nicolas Goaziou wrote: >> I understand what `prettify-symbols-mode' is. My real problem is >> understanding how it can help with links in Org. In particular, I'd like >> to see it, or any other mechanism, turn >>=20 >> [[http://orgmode.org][Org mode]] >>=20 >> displayed as >>=20 >> Org mode >>=20 >> into >>=20 >> [Org mode] >>=20 >> when point is near _any_ of the boundaries and doesn't trigger anything >> on anything not related to an Org link. >>=20 >> I don't know if that would be sufficient to make it useful, but it needs >> to be as subtle as possible. We already have a not-so-subtle solution >> with visible square brackets. > > Hey Nicolas, > > Something like this? > > (defvar-local org-show-link--beg nil) > (defvar-local org-show-link--end nil) > > (defun org-show-link--reveal-at-point (&rest _) > "Possibly reveal link markup around point." > (unless (and org-show-link--beg org-show-link--end) > (setq org-show-link--beg (make-marker) > org-show-link--end (make-marker))) > (when (and (marker-position org-show-link--beg) > (marker-position org-show-link--end)) > (unless (<=3D org-show-link--beg (point) org-show-link--end) > (save-excursion (font-lock-fontify-region org-show-link--beg or= g-show-link--end)) > (set-marker org-show-link--beg nil) > (set-marker org-show-link--end nil))) > (save-excursion > (when (org-in-regexp org-bracket-link-regexp 1) > (set-marker org-show-link--beg (match-beginning 0)) > (set-marker org-show-link--end (match-end 0)) > (with-silent-modifications > (remove-text-properties (match-beginning 2) (1+ (match-beginn= ing 2)) '(invisible)) > (remove-text-properties (1- (match-end 2)) (match-end 2) '(in= visible))))) > (message "%S" org-show-link--end)) > > (defun org-show-link-setup () > (add-hook 'post-command-hook #'org-show-link--reveal-at-point t t)) > > (add-hook 'org-mode-hook #'org-show-link-setup) > > Running it before opening an Org buffer with links should be enough to > make it work (links brackets will be hidden until point is next to or > inside the link). It's a quick draft, of course =E2=80=94 there are still > small issues. But it should give an idea of what my original proposal > was about. I love this! I have had problems with editing links at the start of lines etc, and this seems to solve it. I would love something similar for *bold* and /italics/ too. Stig