From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id 4OvnMhdIzWUoawEAqHPOHw:P1 (envelope-from ) for ; Thu, 15 Feb 2024 00:09:12 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id 4OvnMhdIzWUoawEAqHPOHw (envelope-from ) for ; Thu, 15 Feb 2024 00:09:11 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SEJPuqMN; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707952151; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=PlHsN32hF5Iiyi0oJRj4v8J1kUi8q9jyW9AY1sccvmc=; b=oukPXYV/9Xrxd+YJ6y5BCXZucrcSVQGmOchIRfLfyF8jMvJLkPVjfmxWYOPvHLEqIYuFVy g74e0YRv5tVmGQm9ekC4CIh9ORiFn1f9kHg1Qp51xTExi6Bpzi2knJGaFViA5LdHKgmXg7 HFRxLnKjkRx67snLzMrcu9zUg/y50vuep/eYY3MOf6nFtJks4zAMYvwUjCA3rbwUxvWb7A sxzxLt1r2ZYWmrCDmZvxFmavDWyaOhuIh2rR8x0XfpqyxkqecCk9en74oaIdIkZ6OZZKcc /Bg4ZAIcI371sL1H3Ha+clIWDd3XHxpxE/W/U1pgpKIRSh3lppvZldRqvrc7qg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=SEJPuqMN; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707952151; a=rsa-sha256; cv=none; b=OKJKPVNaq7gWs2LxtfRfsYF6o8CyT0Di/NTkOgbpuHyFzxsT5S7sVrXjSI0okyhh2wZ2sS OrkcX6PvwoaFqGpASt1lgCaGeGuKMeFXuppNXMLbfwgVyf0//cxGdD+ofm/LAOb0cgJ0eU 2KQtJpL4IPHI3jISlUt3/jr7qRSfhqOuKXfe+l98++A+6VsQlcZCkF5CZQXYyny7NeWyxX 5tEqBuI+/0FQ0rGaNG6J0o41Lyg/nflmpRgEHB/84nLRBPRVuXvvvM0RezLt+vuFL/PNWT 7uJrbyA9Ue7Oz4dFb42JAF7NbgdPgaqk8km1EutlOgnssjHOR0FV+nefO36rWQ== 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 7ABD75BD15 for ; Thu, 15 Feb 2024 00:09:11 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1raOMl-0000HG-40; Wed, 14 Feb 2024 18:08:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1raOMd-0008Ul-Kv for emacs-orgmode@gnu.org; Wed, 14 Feb 2024 18:08:32 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1raOMa-0001sc-RM for emacs-orgmode@gnu.org; Wed, 14 Feb 2024 18:08:26 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-33cf6374e58so90663f8f.3 for ; Wed, 14 Feb 2024 15:08:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707952101; x=1708556901; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=PlHsN32hF5Iiyi0oJRj4v8J1kUi8q9jyW9AY1sccvmc=; b=SEJPuqMN2iyxDI0FtAKxQBGrEgwdobRr4RpVn+yPjuOV/69lVHiKwHkV5y97jYxbJ0 +/bhB1zosu2WuEf4/lAMpEiNuDgYlpbvrpxTLm+xmqiJ/HqAPZYAk652UE6sGxVHkxVD 53SkPnyN76CcWQI1ZGgcQON/khEcsgE5JIq23r6viqw9/JGzz7p9PJjZOPS/8jjfJFFm 2+7/BY1sowL9N12h61HGunIIo9ZmcVyvQ6+isz1E3fwMUCNHLq/EWd73871FcjtXj3Kg lsU0B618aQBCrycjRTiaVRBdxWeHobcktiO3A8n17UESne30ETR79H+6T7jEvq2GJT1h 4DYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707952101; x=1708556901; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=PlHsN32hF5Iiyi0oJRj4v8J1kUi8q9jyW9AY1sccvmc=; b=f3zqDqbETsnSyp7wt6BoIMVoIKZpct1tBeKntgMDziOG40jGpk3N9KZCtcOM6L8xgP NdKBjT0hNO3fFkTM97puaPe1GIrBSy7GDyRjZi/7LEjwVEZlW+sCnrEzUGQQVlL2Nizl /PK5+xmNiDxyRpukUZp2OZQaE6/JXgv/sjLRqs9+MHDXp3dTiLrAHji655V/vnL/1cYb c4B3iOo4DHBLBdYLPoS7SE5hbYmaD8BX+N5DcaNSEEHka/sGn6J3OpAJkgCBNEVs0E98 SICCVFQNYFqpe24oR8UmJtAAt/hWN4ioeHbuPv3E6i3OZHbZismBbFYhLFpxpWgj9IgV +mVg== X-Gm-Message-State: AOJu0YzI+jBd0UiXMoXiy39B5J0qgWiUn2OyLjB5RnJWOH+ZG/QqBFoj mhOR9JJyI9/wSHkfjD7zwa7RvEBSWetMOmMIioyBIds08z+fatQ93xn+TEh2 X-Google-Smtp-Source: AGHT+IGg1J1HhgvVxixzd/9kJDgvBGgWwAvTtEN+wVkg83zFw9diCGg1zkFetsTDtCCDV99wjFPHiA== X-Received: by 2002:a5d:4b11:0:b0:33c:f34c:b755 with SMTP id v17-20020a5d4b11000000b0033cf34cb755mr61116wrq.19.1707952100958; Wed, 14 Feb 2024 15:08:20 -0800 (PST) Received: from nixos.localnet (alagny-155-1-32-83.w83-200.abo.wanadoo.fr. [83.200.85.83]) by smtp.gmail.com with ESMTPSA id ce9-20020a5d5e09000000b0033b8808355fsm7878535wrb.28.2024.02.14.15.08.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 15:08:20 -0800 (PST) From: chris To: emacs-orgmode@gnu.org Subject: dynamic blocks orgmode manpage Date: Wed, 14 Feb 2024 23:08:18 +0000 Message-ID: <5790810.DvuYhMxLoT@nixos> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=inkbottle007@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=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-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -8.78 X-Spam-Score: -8.78 X-Migadu-Queue-Id: 7ABD75BD15 X-Migadu-Scanner: mx11.migadu.com X-TUID: W6dZ6hI8L/hF Hi all, #+title: dynamic blocks orgmode manpage * Example from the manual Concerned page: [[https://orgmode.org/manual/Dynamic-Blocks.html][Dynamic Blocks (The Org Manual)]] Below is an elisp snippet from the manual. You can execute it with =C-c C-c=. #+begin_src emacs-lisp (defun org-dblock-write:block-update-time (params) (let ((fmt (or (plist-get params :format) "%d. %m. %Y"))) (insert "Last block update at: " (format-time-string fmt)))) #+end_src #+RESULTS: : org-dblock-write:block-update-time Below is another snippet from the manual. You can update it with =M-x org- dblock-update=. #+BEGIN: block-update-time :format "on %m/%d/%Y at %H:%M" Last block update at: on 02/14/2024 at 21:33 #+END: Now, after running =C-c C-c= on the line below, trying =M-x org-dynamic-block- insert-dblock= will result in the error: =funcall-interactively: Wrong type argument: commandp, org-dblock-write:block-update-time=. #+begin_src emacs-lisp (org-dynamic-block-define "block update time" #'org-dblock-write:block- update-time) #+end_src #+RESULTS: : ((block update time . org-dblock-write:block-update-time) (abstracts-index . org-dblock-write:abstracts-index) (columnview . org-columns-insert-dblock) (clocktable . org-clock-report)) * Alternative construction Given the circumstances described above, the following snippet works with both =M-x org-dblock-update= and =M-x org-dynamic-block-insert-dblock=. #+begin_src emacs-lisp (defun cool-hello () (string-join '("cool" "hello") " ")) (defun org-dblock-write:hello-dblock (&optional arg) (interactive) (let* ((a (if (called-interactively-p 'any) (format "#+BEGIN: hello-dblock\n%s\n#+END:\n" (cool-hello)) (format "%s" (cool-hello))))) (insert a))) (org-dynamic-block-define "hello dblock" #'org-dblock-write:hello-dblock) #+end_src #+RESULTS: : org-dblock-write:hello-dblock #+BEGIN: hello-dblock cool hello #+END: * Notes In the above snippet, for it to work in both cases, after numerous experiments, I found that both the =(interactive)= part and the =(&optional arg)= part are necessary. If memory serves, depending on whether it is used with =M-x org-dblock-update= or =M-x org-dynamic-block-insert-dblock=, one of them might not require the =interactive= part, while it's a requirement for the other one. Similarly, one scenario requires no arguments, while the other demands that arguments are present. Cheers, Chris