I just wrote recalc today as a demo so people can extrapolate what they might do with Hyperbole (calc was handy in my head since I wrote it for Ober, the Java version of the Oberon environment).

WIth buttons that restore the point to where it was when you clicked, you can make them operate on the current selection (it looks like Hyperbole might not save the region though so maybe more function advice is needed for that). This makes reusable "menu bars" possible:

<recalc> <cut> <copy> <paste>

(changing recalc to find the table at point instead of using the location of the button).
Highlight a region and shift-middle-click on cut/copy/paste to do that action on your selection.

This also lets you use button bars in other frames (acting even more like a real menu bar).

Buttons could also parse contextual information in the button buffer (and/or the active buffer), something like org-mode properties, that could influence how the buttons behave. Other buttons could edit this information to give you document-based behavior. For instance, a button-buffer (like the menubar) could have behavioral information like this:

<indent>: 4
<justify>: left

Clicking "left" could toggle it between the different types of justification (left, right, center, full) and clicking on <justify> could justify the current paragraph. Clicking <indent> could change the indentation of the current file (if it's a program, it could analyze for the current indentation and then change it to the desired indentation).

Just thinking out loud here -- this is the sort of thing Ober did and Hyperbole looks like a framework that makes it not too hard to do that for Emacs.


-- Bill


On Wed, Jun 22, 2022 at 10:26 PM Bill Burdick <bill.burdick@gmail.com> wrote:
No idea.


-- Bill


On Wed, Jun 22, 2022 at 10:23 PM David Masterson <dsmasterson@gmail.com> wrote:
Bill Burdick <bill.burdick@gmail.com> writes:

> Here's a hyperbole-org integration that lets you use org-mode tables
> outside of org-mode files. Shift-middle-click a "recalc" button and it
> will recalculate the table right under it (this idea is from an old
> version of the Oberon environment I wrote in Java, by the way).
>
> Here's the code:
>
> (defun bill/calc (end)
>   (goto-char end)
>   (re-search-forward "\n")
>   (when (org-at-table-p)
>     (org-table-analyze)
>     (let* ((table-start (point))
>            (rows (1- (length org-table-dlines)))
>            (table-end (re-search-forward "\n" nil t rows))
>            (inside (<= table-start action-key-depress-prev-point table-end)))
>       (when inside
>         (goto-char action-key-depress-prev-point)
>         (org-table-maybe-eval-formula))
>       (goto-char table-start)
>       (call-interactively 'org-table-recalculate)
>       (org-table-align))))
>
> (defib recalc ()
>   "recalculate a table"
>   (save-excursion
>     (let* ((pos (point))
>            (eol (progn (re-search-forward "\n") (point)))
>            (bol (progn (re-search-backward "\n" nil t 2) (1+ (point))))
>            (start (progn (goto-char pos) (re-search-backward "<" bol t)))
>            (end (progn (goto-char pos) (re-search-forward ">" eol t))))
>       ;;(message "pos: %s, prev: %s" (point) action-key-depress-prev-point)
>       (and start end (string-match "<recalc[> ].*" (buffer-substring start end))
>            (hact 'bill/calc end)))))
>
> Here's an example table you can put anywhere. Just shift-middle-click
> on it to recalculate the org-mode table. Also, if you type a formula
> (and keep the cursor on the same line) and then shift-click recalc,
> it'll handle the formula:
>
> <recalc>
> | a | 12 |
> | a |  5 |
> #+TBLFM: @1$2=3*4::@2$2=2+3

Isn't this the minor mode orgtbl-mode ?

--
David Masterson