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


-- Bill


On Wed, Jun 22, 2022 at 1:38 PM Juan Manuel Macías <maciasch...@posteo.net>
wrote:

> Hi David,
>
> David Masterson writes:
>
> > I haven't touched Hyperbole in ...decades...?  Even then, it was
> > complicated and full-featured (but I still keep it in my .emacs file).
> > My discussions with Bob Weiner were interesting at the time and I really
> > wanted to make use of it.
> >
> > As you've discovered, it integrates a lot of what Org has in, perhaps, a
> > tighter fashion (which makes it more complicated, but the pain might be
> > useful). The Smart Keys and Buttons are very similar to Org.  The
> > outliner (KOutline) is more powerful than Org, but not integrated with
> > export capabilities to other formats (I think there is a way of
> > exporting an outline to Org).  Something that Org does not have is
> > browsing capabilities for Object Oriented languages.  This is an add-on
> > (for C++ ?) in Hyperbole (search for OO-Browser).  Since I retired, I
> > don't do much programming, so Org's project management has been more
> > interesting to me.
> >
> > It's nice to see that it's actually still being developed by Bob.
>
> Thanks for all the interesting facts about hyperbole. I hadn't looked at
> the package source code info yet, and didn't know that this is all the
> work of one person. I also thought hyperbole was more recent...
>
> It certainly has some interesting stuff. In what way is KOutline more
> powerful than Org? Do you think there is any useful feature of KOutline
> that could be incorporated into Org?
>
> So far I've been able to find a couple of practical uses for this
> package in my workflow. The whole window control system is very
> powerful, although it would have been better if it had been a single
> separate package, IMHO.
>
> Implicit links have a lot of potential. For example, I've managed to
> define some buttons for LaTeX, which recognize LaTeX commands and
> environments and lead to the local TeX live documentation or
> tex.stackexchange.org. It's like giving a LaTeX document a sort of hover
> help. This could also be done in Org, by defining some patterns as
> implicit buttons to lead to Org info pages.
>
> Best regards,
>
> Juan Manuel
>
>

Reply via email to