emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Org and Hyperbole


From: Bill Burdick
Subject: Re: Org and Hyperbole
Date: Wed, 22 Jun 2022 22:26:25 +0300

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

reply via email to

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