emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Stig Brautaset <stig@brautaset.org>
To: emacs-orgmode@gnu.org
Subject: Re: [RFC] Change visibility for bracket links
Date: Sat, 22 Oct 2016 03:02:38 +0200	[thread overview]
Message-ID: <m2a8dxgpqp.fsf@Margil.home> (raw)
In-Reply-To: <9e35201e-cc6e-8d3e-e1be-b237034dbfd5@gmail.com> ("Clément Pit--Claudel"'s message of "Thu, 20 Oct 2016 19:44:46 -0400")

Clément Pit--Claudel <clement.pit@gmail.com> 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
>> 
>>   [[http://orgmode.org][Org mode]]
>> 
>> displayed as
>> 
>>   Org mode
>> 
>> into
>> 
>>   [Org mode]
>> 
>> when point is near _any_ of the boundaries and doesn't trigger anything
>> on anything not related to an Org link.
>> 
>> 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 (<= org-show-link--beg (point) org-show-link--end)
>           (save-excursion (font-lock-fontify-region org-show-link--beg org-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-beginning 2)) '(invisible))
>             (remove-text-properties (1- (match-end 2)) (match-end 2) '(invisible)))))
>       (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 — 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

  reply	other threads:[~2016-10-22  1:02 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-05 15:40 [RFC] Change visibility for bracket links Nicolas Goaziou
2016-10-05 15:46 ` Rainer M Krug
2016-10-05 16:46 ` Marco Wahl
2016-10-05 21:13   ` Nicolas Goaziou
2016-10-05 19:21 ` Detlef Steuer
     [not found] ` <520C9DD6-7764-4B07-8E7A-FB42CC0CDF8A@dagertech.net>
2016-10-05 21:30   ` David A. Gershman
2016-10-05 22:26     ` Nicolas Goaziou
2016-10-06  0:16       ` David A. Gershman
2016-10-06  0:27         ` Clément Pit--Claudel
2016-10-07  6:13           ` Nicolas Goaziou
2016-10-12  9:27             ` Rasmus
     [not found]         ` <e78992df838c44419e7893671dbe2adb@HE1PR01MB1898.eurprd01.prod.exchangelabs.com>
2016-10-06  7:38           ` Eric S Fraga
2016-10-06 14:53             ` William Denton
2016-10-08  2:38 ` Adam Porter
2016-10-08  3:50   ` Clément Pit--Claudel
2016-10-08  4:00     ` Adam Porter
2016-10-10 14:17     ` Nick Dokos
2016-10-10 14:56       ` Clément Pit--Claudel
2016-10-10 16:28         ` Nick Dokos
2016-10-14 20:00         ` Joost Kremers
2016-10-14 21:24           ` Thomas S. Dye
2016-10-12  7:10 ` Daniele Nicolodi
2016-10-12 10:37   ` Nicolas Goaziou
2016-10-12 10:40     ` Nicolas Goaziou
2016-10-12 17:36     ` Daniele Nicolodi
2016-10-13 12:07       ` Nicolas Goaziou
2016-10-13 12:28         ` Aaron Ecay
2016-10-13 12:35           ` Nicolas Goaziou
2016-10-13 13:20             ` Michael Brand
2016-10-13 18:23               ` Nicolas Goaziou
2016-10-13 17:46             ` Gregor Zattler
2016-10-13 22:05             ` [RFC] " Aaron Ecay
2016-10-13 17:31         ` Daniele Nicolodi
2016-10-13 18:33           ` Nicolas Goaziou
2016-10-13 19:11           ` William Denton
2016-10-12  9:23 ` Rasmus
2016-10-12 10:32   ` Nicolas Goaziou
2016-10-12 11:08     ` Rasmus
2016-10-12 12:21       ` Nicolas Goaziou
2016-10-12 12:47         ` Rasmus
2016-10-13 12:30           ` Nicolas Goaziou
2016-10-20 23:44             ` Clément Pit--Claudel
2016-10-22  1:02               ` Stig Brautaset [this message]
2016-10-13 12:19 ` Rasmus
2016-10-13 16:13   ` Nick Dokos
2016-10-13 16:24     ` Rasmus
2016-10-13 16:43     ` Clément Pit--Claudel
2016-10-13 17:18       ` Nick Dokos
2016-10-13 12:19 ` Rasmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2a8dxgpqp.fsf@Margil.home \
    --to=stig@brautaset.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).