[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [RFC] Change visibility for bracket links

From: Clément Pit--Claudel
Subject: Re: [O] [RFC] Change visibility for bracket links
Date: Thu, 20 Oct 2016 19:44:46 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0

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 
          (set-marker org-show-link--beg nil)
          (set-marker org-show-link--end nil)))
        (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))
            (remove-text-properties (match-beginning 2) (1+ (match-beginning 
2)) '(invisible))
            (remove-text-properties (1- (match-end 2)) (match-end 2) 
      (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.


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]