emacs-orgmode
[Top][All Lists]
Advanced

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

Re: Org and Hyperbole


From: Eduardo Ochs
Subject: Re: Org and Hyperbole
Date: Thu, 23 Jun 2022 15:48:07 -0300

On Wed, 22 Jun 2022 at 11:36, Bill Burdick <bill.burdick@gmail.com> wrote:
>
> 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


Hi Bill,

can I ask you for help on something that looks easy but that I'm not
being able to do (due to temporary braindeadness)?

How do we reimplement your <recalc> button as a sexp that can be run
with C-e C-x C-e? In eev all "buttons" are simply sexps that can
executed by variants of eval-last-sexp - as explained here:

  http://angg.twu.net/eev-intros/find-eev-quick-intro.html#3

I'm trying to translate your <recalc> to "eev style", but I'm
failing...

  Thanks in advance!
    Eduardo Ochs
    http://angg.twu.net/#eev



reply via email to

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