Subject: bug#36941: Want programmable parameterized link buttons: (Was: Please include option to link to maildir files)

From: Robert Weiner <[email-masked]>
Date: Sat, 24 Aug 2019 01:11:47 -0400

On Wed, Aug 7, 2019 at 3:21 AM Jean Louis <[email-masked]> wrote:

> * Robert Weiner <[email-masked]> [2019-08-07 04:33]:
> > On Tue, Aug 6, 2019 at 4:29 AM Jean Louis <[email-masked]> wrote:
> >
> > >
> > > That is why I suggested making customization group for buttons. As
> > > that would easy everything. One can add Elisp function and link type is
> > > added.
>
> Request is for simple customization option so that new links and
> button types can easily be customized and created.
>
> For example I could add a new link with protocol "SMS" and Value Menu
> Format: SMS:%s
>
> Or maybe new protocOl "gpatent" meaning Google Patent with value
> "https://www.google.com/patents/US%s"
>
> Then if I make this link in Org:
>
> [[gpatent:481550][Ore washer and concentrator, by Arthur L. Dana]]
>
> It will be shown as "Ore washer and concentrator, by Arthur L. Dana"
> and if I click on this link, I can see the Google Patent online.
>
> However, web search is not as important: More important is elisp
> functions. Than I would not need to work with Hyperbole intervals.
>
> But functions are not well implemented in Org. They allow only
> function without parameter.
>
> What we need is link that allows parameters, which can be customized
> to run on such parameter.
>
> Synonym is <[Media]>: "~/Media"
>
> However, that implementation does not look well.
>
> As Hyperbola us using special file outside of the text to define
> links, I see no reason why such links, even parameters could not be
> defined in that separate file.
>
> Even simple words could be defined in that separate file to be links
> for something. Isn't it?
>
> I could define word GNU in the directory, to be the link in the file
> about-gnu.txt to https://www.gnu.org
>
> Then for example, I could define word "notes" to be link to the action
> "notes" with parameter ID: 123.
>

Hi Jean:

FYI, the following behavior is implemented in my working copy of Hyperbole
but not yet released anywhere.  It will be in the next test release.  Using
what is described below together with globally labeled/named implicit
buttons, you can create in-buffer, parameterized Action Buttons that you
can invoke from anywhere by name or by pressing the Action Key on them.  I
hope this will meet the bulk of your needs and be easy to use.

------
>From the DEMO file:

** Action Buttons

A new feature of Hyperbole is a universal syntax for creating implicit
buttons of any existing type, known as Action Buttons.  Such buttons are
delimited by angle brackets, < > and come in three forms:

  1. action type invocations - these begin with an action type name (from
the
     list displayed by {C-h h d t a RET}) and are followed by any needed
     arguments to form the action, e.g.

          <link-to-file-line "${hyperb:dir}/hact.el" 40>

  2. function calls - these are similar to action type invocations but begin
     with an Elisp function name rather than an action type name, e.g.

          <find-file-other-window "/tmp">

  3. variable displays - these consist of just an Elisp variable name and
     display a message with the variable name and value, e.g.

          <fill-column>

Since implicit buttons can be labeled with a name and placed in the global
button file for invocation by name, you can give short names to any such
buttons you want to invoke frequently.

An Action Button is recognized only if the first name within the angle
brackets is an existing action type or Elisp symbol.  Otherwise, other
implicit button types will be tested and may activate instead.

With Action Buttons you need not remember any special syntax for each type
of
implicit button.  You can freely embed them in any type of text and use the
Action and Assist keys on them as you do with any other type of implicit
button.

Bob