From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id CA5qDLcNtGK1twAAbAwnHQ (envelope-from ) for ; Thu, 23 Jun 2022 08:52:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id 2C1sC7cNtGJFXAAAG6o9tA (envelope-from ) for ; Thu, 23 Jun 2022 08:52:39 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9D10316939 for ; Thu, 23 Jun 2022 08:52:38 +0200 (CEST) Received: from localhost ([::1]:50558 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4Ghh-0004qW-N8 for larch@yhetil.org; Thu, 23 Jun 2022 02:52:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4GdP-0004ps-3E for emacs-orgmode@gnu.org; Thu, 23 Jun 2022 02:48:14 -0400 Received: from mail-yw1-x112c.google.com ([2607:f8b0:4864:20::112c]:40727) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4GdE-0005Uh-WA for emacs-orgmode@gnu.org; Thu, 23 Jun 2022 02:48:02 -0400 Received: by mail-yw1-x112c.google.com with SMTP id 00721157ae682-317a66d62dfso124070487b3.7 for ; Wed, 22 Jun 2022 23:48:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mxk2VmkPlz9yPx8fjUkBpSAIO4iz7CzVBpUUtCuFqx0=; b=kWDsP9fjkx7G2kX5L7bWzRipFlWCLpBDvqcqsWohjLqbL/uBsPEGzWsf9sglhwlzGq 6h22YYlyEWMMFsDKujWmN6hGBZK07DXyVNXGLFifbZy4ZPxV23L/GQdsJigqPA/vdt/O zw9/+ap0z8POHe8B1JK2hoSg2kgTihzSvt6cAmi+brobHpbmvkvkYwFzgGkKLGCkGVRH tXfJ+9PQm6nCndFXbkHoeNGx0nn0OwLVrBGpRh14BBSGXboC0zfI3ZooSg3dG6f+6g/B Z7bnCnyF0pjod9zuLimsvr0/zW+6iMfE8Y9zrzO9WEoUvPS69lTVkLxOz0ASzPOWUCTR Adfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Mxk2VmkPlz9yPx8fjUkBpSAIO4iz7CzVBpUUtCuFqx0=; b=pk4sMWR5S4MpM+FSjN2u5FP62L1eqXouzLds50UlYovjJOjkv79Clmh8ErdpuLlwn+ XMDgS4Ix+4RjgWsl65xRut1xcGH4a2oK7PHjL8y468un/wLWZLbCAvjvUCryGYuzDrlf Yis9hrJ9GtSky89wM2drgEH+HFe/YfbmlmMPa9yzq7suEJEkHdsPer1Mi69m8VjL+0WI 0kGKFgwCRIdEkZGXPoUsnjmdgUvdQtqwhEX/0LNrX4J+E7sC1zYlsEHtdgUJWqNjBtOC 6D/rj7uxXCPw8wL3TtFCGOZVOn0n6VQn7hg5I+udfBg2G7HPGxn/g4+2CEl04mnFs9/V eoRQ== X-Gm-Message-State: AJIora/rIJ6Z2ivhIlW2r0pnadW57FBLFRY0wa54wd+IX+ZxAIiHOaQt cE1G7JiJUFhwJlwFTkPSCvf5C1JOmeU4y2SfvXD15oE+dzk= X-Google-Smtp-Source: AGRyM1sE587WJydJoADD7rlnTAGqKxok9v1ilbGBSCebEkp/YhXm7BVwkuJ7kWUPNx3xFyQ8q46S36euA8Ho/8JlqYA= X-Received: by 2002:a0d:df50:0:b0:317:9c40:3b8b with SMTP id i77-20020a0ddf50000000b003179c403b8bmr9208830ywe.332.1655966879438; Wed, 22 Jun 2022 23:47:59 -0700 (PDT) MIME-Version: 1.0 References: <1680266.1655927859@rds059> In-Reply-To: <1680266.1655927859@rds059> From: Bill Burdick Date: Thu, 23 Jun 2022 09:47:48 +0300 Message-ID: Subject: Re: Org and Hyperbole To: linux_hpc_akr@goodyear.com Cc: orgmode Content-Type: multipart/alternative; boundary="0000000000009bdb9005e217d560" Received-SPF: pass client-ip=2607:f8b0:4864:20::112c; envelope-from=bill.burdick@gmail.com; helo=mail-yw1-x112c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1655967158; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=Mxk2VmkPlz9yPx8fjUkBpSAIO4iz7CzVBpUUtCuFqx0=; b=FC93G422+ZK7ESWQbZyrfgoox2tsbI56X4kVobzDzOzbkd9qLdizKRJni56FdBqasFRIqL qTq8g/V2+V5LxMpGQqHrWPoIu3Ip5orz0hP6dkFqWhuYugJdXwBLWuoq5xY9zz+05mPv6D VwJEF8K6V8/aRBPc0I6ExYvJJSiRmhPBMEnK0dgwLmtwJ5dWU0JL2BUFsP/6TDimxVisBw 6dKVnrMCMPrZMEchVNdmmwqDB3hYHmckqZ7dYd97cJO8zrMuyhCk284DyAJo134D8/N10J ZfFGisNjffEycbGVgqG4LVumpVhXqVP1lHmsSyJZHAKjNqqgc2OFtoJSBmLW2A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1655967158; a=rsa-sha256; cv=none; b=P4ssKyjYR72xOecmCy5njfh0Fc/ev+aRFtd3iAnDGmvAWqdlo8+OVFC/VxZHNTn3DyAz3e 9iDEfCPzr1FFRTTp6BAdkpW3LSkzbThnMBAWODtjEWJU6Tt+WWu0G2SrIesM32wbfpXkL+ mrrqSnJa/1CfabWzYfUKsIRGghkTJ66ildjQZchvzD7AGm+CxO8GO7xMUqVrBB3iHQ54Mv rox1od0VklEbvnl0C2/VXbiseLRy/J84rfV0SvS457UgKIQa1gflesjlCrMTikFgSUcWkK l/EQk2ucQUfEcwv2jFtmsolSRl2jqAaJYT1xJztNa1J7aX3RjTtouWWoyglLOw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kWDsP9fj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -3.97 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=kWDsP9fj; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: 9D10316939 X-Spam-Score: -3.97 X-Migadu-Scanner: scn1.migadu.com X-TUID: JfDjdjPkREII --0000000000009bdb9005e217d560 Content-Type: text/plain; charset="UTF-8" In case anyone's interested in writing hyperbole commands that can act on regions but be located in other windows... To write a hyperbole command that restores the previous window and selection, just call bill/hyp-load-state at the start of your code and call bill/hyp-restore at the end (see bill/recalc for an example). This lets recalculate org tables in any buffer with the button in a different (or the same) window. Here's some example text: Here's a table. Click in it and then shift-middle-click recalc, above. "aaa12" should change to "12" and your cursor should stay in the same place. | a | aaa12 | | a | 5 | | | 17 | #+TBLFM: @1$2=3*4::@2$2=2+3::@3$2=vsum(@1..@2) Here's my current definition for recalc (defvar bill/hyp-state nil) (defun bill/hyp-save-state (&rest args) (setq bill/hyp-state (list (selected-window) (point-marker) (and (use-region-p) (copy-marker (mark-marker)))))) (cl-defun bill/hyp-load-state (&optional (state bill/hyp-state)) (let ((window (car state)) (point (cadr state)) (mark (caddr state))) (when window (select-window window) (set-buffer (marker-buffer point)) (and mark (set-mark (marker-position mark))) (goto-char point)))) (defun bill/hyp-restore () (let ((state bill/hyp-state)) (run-at-time 0 nil (lambda () (bill/hyp-load-state state))))) (advice-add 'action-key-depress :before 'bill/hyp-save-state) ;; evaluate this to remove the advice ;;(advice-remove 'action-key-depress 'bill/hyp-save-state) (defun bill/recalc (end) (let ((act-point action-key-depress-prev-point)) (bill/hyp-load-state) (when (org-at-table-p) (org-table-analyze) (org-table-maybe-eval-formula) (call-interactively 'org-table-recalculate) (org-table-align))) (bill/hyp-restore)) (defib recalc () "recalculate the table at point" (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)))) (and start end (string-match " ].*" (buffer-substring start end)) (hact 'bill/recalc end))))) -- Bill --0000000000009bdb9005e217d560 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
In case anyone's interested in writin= g hyperbole commands that can act on regions=C2=A0but be located in other w= indows...

To write a hyper= bole command that restores the previous window and selection, just call bil= l/hyp-load-state at the start of your code and call bill/hyp-restore at the= end (see bill/recalc for an example).

This lets <recalc> recalculate org tables in any buffer = with the button in a different (or the same) window.

Here's some example text:

<recalc>
<= br>Here's a table. Click in it and then shift-middle-click recalc, abov= e. "aaa12" should change to "12" and your cursor should= stay in the same place.
| a | aaa12 |
| a | =C2=A05 |
| =C2=A0 | = 17 |
#+TBLFM: @1$2=3D3*4::@2$2=3D2+3::@3$2=3Dvsum(@1..@2)

Here's my current definition for recalc

(defvar bill/hyp-state nil)

(defun bill/hyp-save-state (&= ;rest args)
=C2=A0 (setq bill/hyp-state
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (= list (selected-window) (point-marker) (and (use-region-p) (copy-marker (mar= k-marker))))))

(cl-defun bill/hyp-load-state (&optional (state b= ill/hyp-state))
=C2=A0 (let ((window (car state))
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 (point (cadr state))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (mark (caddr= state)))
=C2=A0 =C2=A0 (when window
=C2=A0 =C2=A0 =C2=A0 (select-win= dow window)
=C2=A0 =C2=A0 =C2=A0 (set-buffer (marker-buffer point))
= =C2=A0 =C2=A0 =C2=A0 (and mark (set-mark (marker-position mark)))
=C2=A0= =C2=A0 =C2=A0 (goto-char point))))

(defun bill/hyp-restore ()
= =C2=A0 (let ((state bill/hyp-state))
=C2=A0 =C2=A0 (run-at-time 0 nil (l= ambda () (bill/hyp-load-state state)))))

(advice-add 'action-key= -depress :before 'bill/hyp-save-state)
;; evaluate this to remove th= e advice
;;(advice-remove 'action-key-depress 'bill/hyp-save-sta= te)

(defun bill/recalc (end)
=C2=A0 (let ((act-point action-key-d= epress-prev-point))
=C2=A0 =C2=A0 (bill/hyp-load-state)
=C2=A0 =C2=A0= (when (org-at-table-p)
=C2=A0 =C2=A0 =C2=A0 (org-table-analyze)
=C2= =A0 =C2=A0 =C2=A0 (org-table-maybe-eval-formula)
=C2=A0 =C2=A0 =C2=A0 (c= all-interactively 'org-table-recalculate)
=C2=A0 =C2=A0 =C2=A0 (org-= table-align)))
=C2=A0 (bill/hyp-restore))

(defib recalc ()
=C2= =A0 "recalculate the table at point"
=C2=A0 (save-excursion=C2=A0 =C2=A0 (let* ((pos (point))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(eol (progn (re-search-forward "\n") (point)))
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(bol (progn (re-search-backward "\n&= quot; nil t 2) (1+ (point))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(= start (progn (goto-char pos) (re-search-backward "<" bol t)))<= br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(end (progn (goto-char pos) (re= -search-forward ">" eol t))))
=C2=A0 =C2=A0 =C2=A0 (and sta= rt end (string-match "<recalc[> ].*" (buffer-substring star= t end))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(hact 'bill/recalc = end)))))


-- Bill
--0000000000009bdb9005e217d560--