emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Suvayu Ali <fatkasuvayu+linux@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Adding text properties to all Org mode links
Date: Tue, 10 Sep 2013 01:15:42 +0200	[thread overview]
Message-ID: <20130909231542.GN20690@kuru.dyndns-at-home.com> (raw)
In-Reply-To: <20130714064125.GH11006@kuru.dyndns-at-home.com>

Hello again everyone,

On Sun, Jul 14, 2013 at 08:41:25AM +0200, Suvayu Ali wrote:
> On Sat, Jul 13, 2013 at 11:01:08PM -0400, Nick Dokos wrote:
> > Suvayu Ali <fatkasuvayu+linux@gmail.com> writes:
> > >
> > > How do I add text properties to org elements?  In my particular case, I
> > > want to echo tooltips when I move my cursor over an org link (or other
> > > org elements for that matter).  To do this, I need to add the properties
> > > point-left and point-entered to all org-links.  How do I do that?
> > >
> > > Thanks for any ideas.
> > 
> > Not sure if this is the best method:
> > 
> > o go to (point-min)
> > o loop
> >      (goto-char (cdr (org-element-link-successor (point-max))))
> >      (org-element-link-parser) and extract :begin and :end values from
> >      the returned list
> > 
> > Untested (mostly) - termination, error handling (and who knows what
> > else) left to the interested reader...
> 
> I was afraid of this.  I think the safest way of not screwing up the
> parsing and error handling would be to implement it as a patch to
> org-activate-*-links in org.el.

I was taking a shot at this again.  This is where I stand at the moment:

- I want to add the properties `point-left' and `point-entered' to all
  links where the target is invisible (hidden), so for the moment I'm
  focusing on bracket links.
- I tried to patch `org-activate-bracket-links' to this end; in the let*
  bind I extended the list of properties with like this:

    (let* ((hl (org-match-string-no-properties 1))
           (help (concat "LINK: " (save-match-data (org-link-unescape hl))))
           (ip (org-maybe-intangible
      	  (list 'invisible 'org-link
      		'keymap org-mouse-map 'mouse-face 'highlight
      		'font-lock-multiline t 'help-echo help
      		'point-left sa-echo-tooltip       ; <-- my addition
      		'point-entered sa-echo-tooltip    ; <-- my addition
      		'htmlize-link `(:uri ,hl))))
           (vp (list 'keymap org-mouse-map 'mouse-face 'highlight
      	       'font-lock-multiline t 'help-echo help
      	       'point-left sa-echo-tooltip        ; <-- my addition
      	       'point-entered sa-echo-tooltip     ; <-- my addition
      	       'htmlize-link `(:uri ,hl))))
      ;; rest of the code is unchanged
      )

With this "new" org-activate-bracket-links, when I open an Org file, I
see some bad fontification (e.g. keywords are in default face) and the
invisible parts of backet links are visible.  As in: instead of showing

  this is a link 
  (in org-link face)

I see

  [[http://www.example.com/target][this is a link]]
  (the http part is in org-link face, the rest in default)

I tried to run edebug-defun on org-activate-bracket-links before opening
the org file, but that doesn't trigger the step by step execution of
org-activate-bracket-links I was expecting.  I tested with
`get-text-property' interactively, my properties were not added to the
links.  So I'm wondering what am I doing wrong?  Better yet, is there a
better way to do this?

Thanks for any help or ideas.

Cheers,

-- 
Suvayu

Open source is the future. It sets us free.

  reply	other threads:[~2013-09-09 23:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-13 13:40 Adding text properties to all Org mode links Suvayu Ali
2013-07-14  3:01 ` Nick Dokos
2013-07-14  6:41   ` Suvayu Ali
2013-09-09 23:15     ` Suvayu Ali [this message]
2013-09-10  6:56       ` Jambunathan K
2013-09-10 11:39         ` Suvayu Ali
2013-09-10 12:09           ` Jambunathan K
2013-09-10 12:24             ` Suvayu Ali

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=20130909231542.GN20690@kuru.dyndns-at-home.com \
    --to=fatkasuvayu+linux@gmail.com \
    --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).