emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: clickable text in org-mode not working (Sebastien Vauban)
@ 2012-11-13 18:24 John Kitchin
  2012-11-14 15:14 ` Sebastien Vauban
  0 siblings, 1 reply; 2+ messages in thread
From: John Kitchin @ 2012-11-13 18:24 UTC (permalink / raw)
  To: emacs-orgmode

I was just learning about programming interactive features into emacs
buffers, and something that worked in one major mode did not work in
org-mode. I have narrowed it down to an effect of font-lock-mode. When
that is off, the mouse-clicking works fine, when it is on, the font
syntax highlighting works fine, but not the clicking in org-mode.

In terms of usage, I could see this as a way to automatically make
"links" out of different words, or in a related application to overlay
tooltips on specific words without having to markup the org-file. In
essence, moving some markup to a lisp file that is run before opening
the org-file.

I am familiar with `org-add-link-type' and have used that to do some
pretty cool things, as well as the elisp and shell links. With the
clickable text code I described, you can actually do different things
with different mouse clicks, including different mouse buttons, and
presumably on mouse button up events. It is not obvious that can be
done with `org-add-link-type'; you get the same behavior with any
mouse button click. I havent advanced to a point where I could get
emacs-lisp to tell me which mouse event occurred on clicking on a
link. That seems possible though.

j

> Message: 34
> Date: Tue, 13 Nov 2012 09:50:19 +0100
> From: "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com>
> To: emacs-orgmode@gnu.org
> Subject: Re: [O] clickable text in org-mode not working
> Message-ID: <80haot999w.fsf@somewhere.org>
> Content-Type: text/plain
>
> Hello John,
>
> John Kitchin wrote:
>> It appears that one cannot define "clickable" text in org-mode. I was
>> trying to make some text in an org-file respond to different types of
>> clicking. I know that links provide some functionality for this, but
>> out of curiosity I wanted to see what else I could do.
>>
>> If I run the following code on a buffer in text-mode, the first four
>> characters in the buffer turn blue with a white background, they turn
>> a light green when the mouse is over them, and finally a message box
>> pops up when I click on the characters.
>>
>> (let ((map (make-sparse-keymap)))
>>      (define-key map (kbd "<down-mouse-1>")
>>             '(lambda() (interactive) (message-box "it works!")))
>>      (add-text-properties 1 5 `(keymap, map
>>                                 font-lock-face (:foreground "blue"
>>                                                 :background "white")
>>                                 mouse-face highlight)))
>>
>> If I switch to org-mode, the clickability and mouse highlighting go
>> away. They also do not appear when I run the function in an
>> org-buffer.
>>
>> Does anyone know if there is a feature in org-mode that turns this
>> off, or if there is a way to get the clickability to work? Is it
>> related to having links that are clickable?
>
> I'm not sure to understand your use case -- why do you want clickable text in
> the first place (other than links)?
>
> But, did you look at `org-add-link-type' which does allow some kind of
> powerful stuff (mainly for export, but can maybe be diverted from its original
> purpose)?
>
> I guess you also are aware of the elisp and shell links you can already put in
> any Org file, as clickable "buttons"?
>
> Best regards,
>   Seb
>
> --
> Sebastien Vauban
>
>
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: clickable text in org-mode not working (Sebastien Vauban)
  2012-11-13 18:24 clickable text in org-mode not working (Sebastien Vauban) John Kitchin
@ 2012-11-14 15:14 ` Sebastien Vauban
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastien Vauban @ 2012-11-14 15:14 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi John,

John Kitchin wrote:
> Sebastien Vauban wrote:
>> John Kitchin wrote:
>>> It appears that one cannot define "clickable" text in org-mode. I was
>>> trying to make some text in an org-file respond to different types of
>>> clicking. I know that links provide some functionality for this, but
>>> out of curiosity I wanted to see what else I could do.
>>>
>>> If I run the following code on a buffer in text-mode, the first four
>>> characters in the buffer turn blue with a white background, they turn
>>> a light green when the mouse is over them, and finally a message box
>>> pops up when I click on the characters.
>>>
>>> (let ((map (make-sparse-keymap)))
>>>      (define-key map (kbd "<down-mouse-1>")
>>>             '(lambda() (interactive) (message-box "it works!")))
>>>      (add-text-properties 1 5 `(keymap, map
>>>                                 font-lock-face (:foreground "blue"
>>>                                                 :background "white")
>>>                                 mouse-face highlight)))
>>>
>>> If I switch to org-mode, the clickability and mouse highlighting go
>>> away. They also do not appear when I run the function in an
>>> org-buffer.
>>>
>>> Does anyone know if there is a feature in org-mode that turns this
>>> off, or if there is a way to get the clickability to work? Is it
>>> related to having links that are clickable?
>>
>> I'm not sure to understand your use case -- why do you want clickable text in
>> the first place (other than links)?
>>
>> But, did you look at `org-add-link-type' which does allow some kind of
>> powerful stuff (mainly for export, but can maybe be diverted from its original
>> purpose)?
>>
>> I guess you also are aware of the elisp and shell links you can already put in
>> any Org file, as clickable "buttons"?
>
> I was just learning about programming interactive features into emacs
> buffers, and something that worked in one major mode did not work in
> org-mode. I have narrowed it down to an effect of font-lock-mode. When that
> is off, the mouse-clicking works fine, when it is on, the font syntax
> highlighting works fine, but not the clicking in org-mode.
>
> In terms of usage, I could see this as a way to automatically make "links"
> out of different words, or in a related application to overlay tooltips on
> specific words without having to markup the org-file. In essence, moving
> some markup to a lisp file that is run before opening the org-file.
>
> I am familiar with `org-add-link-type' and have used that to do some pretty
> cool things, as well as the elisp and shell links. With the clickable text
> code I described, you can actually do different things with different mouse
> clicks, including different mouse buttons, and presumably on mouse button up
> events. It is not obvious that can be done with `org-add-link-type'; you get
> the same behavior with any mouse button click. I havent advanced to a point
> where I could get emacs-lisp to tell me which mouse event occurred on
> clicking on a link. That seems possible though.

Thanks for giving more information about what you're looking for.

However, I must admit having no experience in that. Sorry. But, if I had to
try and understand why your above code does not work, I would first give a
deep look at some agenda commands: I know they *do* use "text properties" (for
handling the clicks on the agenda line, in particular). These could help you
achieving your goal, maybe?

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-14 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-13 18:24 clickable text in org-mode not working (Sebastien Vauban) John Kitchin
2012-11-14 15:14 ` Sebastien Vauban

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).