all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [QUESTION] Mouse click on an text-property object displayed as image not working
@ 2021-01-13  2:40 Christopher Miles
  2021-01-14 11:12 ` Michael Heerdegen
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Miles @ 2021-01-13  2:40 UTC (permalink / raw)
  To: Emacs Help

[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]


Here is my Emacs package https://github.com/stardiviner/org-link-beautify

I got an problem on defining keybinding mouse left click on text-property object
which is display as image. The following code can't work when click on the
preview image. But it works fine if the text-property object is not image.

#+begin_src emacs-lisp
(defun org-link-beautify--add-keymap (start end)
  "Add keymap on link text-property. between START and END."
  (put-text-property start end 'keymap org-link-beautify-keymap))

(define-key org-link-beautify-keymap (kbd "RET") 'org-open-at-point)
(define-key org-link-beautify-keymap [mouse-1] 'org-open-at-point)
(define-key org-link-beautify-keymap (kbd "<mouse-1>") 'org-open-at-point)
#+end_src

The code of displaying image in text-property is here:

https://github.com/stardiviner/org-link-beautify/blob/master/org-link-beautify.el#L291

And here is background info of the user submitted issue, there is a gif showing this case.

https://github.com/stardiviner/org-link-beautify/issues/7

-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [QUESTION] Mouse click on an text-property object displayed as image not working
  2021-01-13  2:40 [QUESTION] Mouse click on an text-property object displayed as image not working Christopher Miles
@ 2021-01-14 11:12 ` Michael Heerdegen
  2021-01-14 15:03   ` Christopher Miles
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2021-01-14 11:12 UTC (permalink / raw)
  To: Christopher Miles; +Cc: Emacs Help

Christopher Miles <numbchild@gmail.com> writes:

> Here is my Emacs package https://github.com/stardiviner/org-link-beautify

Without having looked at the code: is the reason of your problem that
the keymap character property at the location of the image points to
something like `image-map' instead of what you expect when you click
there (C-u C-x = should tell you)?

Michael.



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

* Re: [QUESTION] Mouse click on an text-property object displayed as image not working
  2021-01-14 11:12 ` Michael Heerdegen
@ 2021-01-14 15:03   ` Christopher Miles
  2021-01-14 17:18     ` Michael Heerdegen
  0 siblings, 1 reply; 5+ messages in thread
From: Christopher Miles @ 2021-01-14 15:03 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: Emacs Help

[-- Attachment #1: Type: text/plain, Size: 2753 bytes --]


Michael Heerdegen <michael_heerdegen@web.de> writes:

> Christopher Miles <numbchild@gmail.com> writes:
>
>> Here is my Emacs package https://github.com/stardiviner/org-link-beautify
>
> Without having looked at the code: is the reason of your problem that
> the keymap character property at the location of the image points to
> something like `image-map' instead of what you expect when you click
> there (C-u C-x = should tell you)?
>
> Michael.

Aha, I understand now. Because displaying as inline image, so text-property
keymap not working. Thanks for hint.

Here is the output of [C-u C-x =]

#+begin_example
             position: 377333 of 458088 (82%), column: 0
            character: [ (displayed as [) (codepoint 91, #o133, #x5b)
              charset: ascii (ASCII (ISO646 IRV))
code point in charset: 0x5B
               script: latin
               syntax: (]	which means: open, matches ]
             category: .:Base, <:Not at eol, a:ASCII, l:Latin, r:Roman
             to input: type "C-x 8 RET 5b" or "C-x 8 RET LEFT SQUARE BRACKET"
          buffer code: #x5B
            file code: #x5B (encoded by coding system utf-8-unix)
              display: by this font (glyph code)
    ftcrhb:-PfEd-DejaVu Sans Mono-normal-normal-normal-*-24-*-*-*-m-0-iso10646-1 (#x3E)

Character code properties: customize what to show
  name: LEFT SQUARE BRACKET
  old-name: OPENING SQUARE BRACKET
  general-category: Ps (Punctuation, Open)
  decomposition: (91) ('[')

There are 2 overlays here:
 From 377333 to 377379
  face                 hl-line
  priority             -50
  window               #<window 32 on Clojure.org>
 From 377333 to 377378
  display              [Show]
  face                 default
  keymap               [Show]
  modification-hooks   (org-display-inline-remove-overlay)
  org-image-overlay    t


There are text properties here:
  display              [Show]
  font-lock-multiline  t
  fontified            t
  help-echo            "LINK: file:Data/Books/mmexport1532255776028.jpg"
  htmlize-link         (:uri "file:Data/Books/mmexport1532255776028.jpg")
  invisible            org-link
  keymap               [Show]
  mouse-face           highlight
  type                 org-link-beautify
#+end_example

So I should define keymap on ~image-map~. But this is global. Is there any other
good solution to get around this adding keybinding on global map? Maybe make
this ~image-map~ buffer locally?

-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [QUESTION] Mouse click on an text-property object displayed as image not working
  2021-01-14 15:03   ` Christopher Miles
@ 2021-01-14 17:18     ` Michael Heerdegen
  2021-01-16  4:35       ` [SOLVED] " Christopher Miles
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Heerdegen @ 2021-01-14 17:18 UTC (permalink / raw)
  To: help-gnu-emacs

Christopher Miles <numbchild@gmail.com> writes:

>   keymap               [Show]

That button is clickable btw.

> So I should define keymap on ~image-map~. But this is global. Is there
> any other good solution to get around this adding keybinding on global
> map? Maybe make this ~image-map~ buffer locally?

This is the harder part of the question.  Seems in your case
`org-display-inline-images' is attaching the keymap property.  You could
try to override the property, depending on when your code is run.  The
overlays seem to be collected in `org-inline-image-overlays'.  If a
changed buffer-local binding of `image-map' does not make sense in your
case you could also advice `org-display-inline-images'.

Regards,

Michael.




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

* [SOLVED] Re: [QUESTION] Mouse click on an text-property object displayed as image not working
  2021-01-14 17:18     ` Michael Heerdegen
@ 2021-01-16  4:35       ` Christopher Miles
  0 siblings, 0 replies; 5+ messages in thread
From: Christopher Miles @ 2021-01-16  4:35 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: help-gnu-emacs@gnu.org

[-- Attachment #1: Type: text/plain, Size: 1234 bytes --]


Michael Heerdegen <michael_heerdegen@web.de> writes:

> Christopher Miles <numbchild@gmail.com> writes:
>
>>   keymap               [Show]
>
> That button is clickable btw.

Thanks for hint, I checked it out.

>
>> So I should define keymap on ~image-map~. But this is global. Is there
>> any other good solution to get around this adding keybinding on global
>> map? Maybe make this ~image-map~ buffer locally?
>
> This is the harder part of the question.  Seems in your case
> `org-display-inline-images' is attaching the keymap property.  You could
> try to override the property, depending on when your code is run.  The
> overlays seem to be collected in `org-inline-image-overlays'.  If a
> changed buffer-local binding of `image-map' does not make sense in your
> case you could also advice `org-display-inline-images'.
>

Yes, I tested with setting buffer-local `image-map', now it works fine.

> Regards,
>
> Michael.

Thanks, Michael.


-- 
[ stardiviner ]
       I try to make every word tell the meaning that I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2021-01-16  4:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-13  2:40 [QUESTION] Mouse click on an text-property object displayed as image not working Christopher Miles
2021-01-14 11:12 ` Michael Heerdegen
2021-01-14 15:03   ` Christopher Miles
2021-01-14 17:18     ` Michael Heerdegen
2021-01-16  4:35       ` [SOLVED] " Christopher Miles

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.