From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suvayu Ali Subject: Re: Adding text properties to all Org mode links Date: Tue, 10 Sep 2013 01:15:42 +0200 Message-ID: <20130909231542.GN20690@kuru.dyndns-at-home.com> References: <20130713134027.GC11006@kuru.dyndns-at-home.com> <878v19j157.fsf@gmail.com> <20130714064125.GH11006@kuru.dyndns-at-home.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJAgX-00031X-Np for emacs-orgmode@gnu.org; Mon, 09 Sep 2013 19:16:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJAgP-0004cI-50 for emacs-orgmode@gnu.org; Mon, 09 Sep 2013 19:15:57 -0400 Received: from mail-ee0-x232.google.com ([2a00:1450:4013:c00::232]:57936) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJAgO-0004c3-TN for emacs-orgmode@gnu.org; Mon, 09 Sep 2013 19:15:49 -0400 Received: by mail-ee0-f50.google.com with SMTP id d51so3503635eek.37 for ; Mon, 09 Sep 2013 16:15:47 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20130714064125.GH11006@kuru.dyndns-at-home.com> 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: emacs-orgmode@gnu.org 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 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.