emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Org, Hyperbole, and eev


From: Robert Weiner
Subject: Re: Org, Hyperbole, and eev
Date: Mon, 10 Oct 2022 22:42:36 -0400

Hi Jean:

I know this does not address everything you want but if you leverage 
Hyperbole’s capabilities, you’ll probably be able to get what you want with a 
lot less code.

First, creating an explicit button displays only the button name as you like, 
fontified as you like, and with the button action hidden.  So then you need to 
write a function that adds or removed the button action from the buffer when 
you want to see it, utilizing existing Hyperbole code from the actype or action 
class for manipulating actions.

For your generalized syntax, I think you would be better off using the angle 
brackets of Hyperbole’s action buttons but you could instead use the defil 
macro to create your own link button type and delimiter format with just a few 
lines of code.  Just follow the example in the docstring for that macro.

Org probably has similar capabilities with its link types though not as 
flexible with the syntax.

-- rsw

> On Oct 8, 2022, at 1:00 AM, Jean Louis <bugs@gnu.support> wrote:
> 
> * Eduardo Ochs <eduardoochs@gmail.com> [2022-10-08 03:28]:
>>> On Thu, 29 Sept 2022 at 06:22, Jean Louis <bugs@gnu.support> wrote:
>>> 
>>> I am definitely interested, make prototype please. Just can't answer 
>>> properly on travel.
>> 
>> Hi Jean Louis,
>> 
>> Sorry, I will have to put that on hold until my holidays... I wrote a
>> very primitive prototype, but I never had to write much code that
>> generates text with text properties, my friends are not interested in
>> playing with that together with me, and I don't know where to borrow
>> ideas from, so adding each new small feature by myself is a
>> struggle... and right now writing code "whose inner details don't
>> matter" is exactly the opposite of my notion of fun... =(
> 
> Fine, solution will come up with time. 
> 
> In the sense is similar to Org links, though just universal. With the
> RCD Template Interpolation System for Emacs:
> https://hyperscope.link/3/7/1/3/3/RCD-Template-Interpolation-System-for-Emacs.html
> and this function, I can easily replace such snippets as below to their 
> values:
> 
> ** Hello heading
> 
> ⟦ (format "[[https://www.example.com][Hello there %s]]" user-full-name) ⟧
> 
> (defun rcd-org-interpolate ()
>  "Extrapolate Org buffer before dispatch."
>  (interactive)
> (let ((my-org (buffer-substring (point-min) (point-max))))
> (with-temp-buffer
>   (insert (rcd-template-eval my-org))
>   (org-export-dispatch))))
> 
> (keymap-set org-mode-map "C-c C-e" 'rcd-org-interpolate)
> 
> to get Org hyperlinks. Or any other type of a link?
> 
> (defun hyperscope-hyperlink (id &optional markup)
>  (let ((name (hyperscope-name id))
>    (link (hyperscope-hyperdocument-url id))
>    (markup (or markup (hyperscope-markup-type id))))
>    ;; (unless (or (eq (last-key-binding) 'newline)
>    ;;        (= (last-key) 13))
>    ;;(rcd-button-insert name (lambda (_) (hyperscope id))))
>    (cond ((or (eq major-mode 'markdown-mode)
>           (and (not rcd-current-table-id)
>            (or (= markup 2)
>            (= markup 3)
>            (= markup 6))))
>       (format "[%s](%s \"%s\")" name link name))
>       ((eq major-mode 'adoc-mode) (format "%s[%s]" 
> (hyperscope-hyperdocument-url id) name))
>       ((eq major-mode 'org-mode) (format "[[%s][%s]]" link name)))))
> 
> Same may be used to insert buttons:
> 
> (defun rcd-button-insert (button-text action-function &optional how-many)
>  "Insert button BUTTON-TEXT with ACTION-FUNCTION.
> 
> Optional number HOW-MANY adds superscript digits to BUTTON-TEXT."
>  (insert-text-button button-text
>              'action
>                      action-function
>              'follow-link t)
>  (when how-many
>    (insert (rcd-superscript-digits how-many))))
> 
> (rcd-button-insert "Hello" (lambda (_) (message "I said Hello")))
> 
> now if button can be inserted, it means ⟦ (could insert button as well) ⟧ 
> and make the link invisible part of text. Once toggled, invisible
> part could become visible and saved as such link.
> 
> 
> -- 
> Jean
> 
> Take action in Free Software Foundation campaigns:
> https://www.fsf.org/campaigns
> 
> In support of Richard M. Stallman
> https://stallmansupport.org/



reply via email to

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