From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thierry Banel Subject: Re: [Feature Request] Add an dispatcher command (keybinding) for inserting dynamic blocks Date: Fri, 16 Nov 2018 18:59:42 +0100 Message-ID: <3332dc93-afb1-0854-6298-06e0939aff3a@free.fr> References: <871s7lvn4n.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35635) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gNiPC-00077p-H4 for emacs-orgmode@gnu.org; Fri, 16 Nov 2018 12:59:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gNiPB-0007P3-OM for emacs-orgmode@gnu.org; Fri, 16 Nov 2018 12:59:46 -0500 Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]:49259) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gNiPB-0007OW-H4 for emacs-orgmode@gnu.org; Fri, 16 Nov 2018 12:59:45 -0500 Received: from [IPv6:2a01:e35:2e21:def0:2cbc:733f:37bb:d0ad] (unknown [IPv6:2a01:e35:2e21:def0:2cbc:733f:37bb:d0ad]) by smtp2-g21.free.fr (Postfix) with ESMTPS id A3C742003CA for ; Fri, 16 Nov 2018 18:59:43 +0100 (CET) In-Reply-To: <871s7lvn4n.fsf@gmail.com> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org

On 16/11/2018 02:15, stardiviner wrote:
In package `orgtbl-aggregate=
` has bellowing command to insert different dynamic blocks.

#+begin_src emacs-lisp
(defun org-insert-dblock ()
  "Inserts an org table dynamic block.
This is a dispatching function which prompts for the type
of dynamic block to insert. It dispatches to functions
which names matches the pattern `org-insert-dblock:*'"
  (interactive)
  (let ((fun
	 (intern
	  (format
	   "org-insert-dblock:%s"=20
	   (org-icompleting-read
	    "Kind of dynamic block: "
	    (mapcar (lambda (x)
		      (replace-regexp-in-string
		       "^org-insert-dblock:"
		       ""
		       (symbol-name x)))
		    (apropos-internal "^org-insert-dblock:")))))))
    (if (functionp fun)
	(funcall fun)
      (message "No such dynamic block: %s" fun))))
#+end_src

This command matches Org Mode API style.

I hope Org Mode can have this built-in. Because there are some other dyna=
mic blocks. They can use this dispatcher function.

For example org-gantt dynamic block, I write a function manually:

#+begin_src emacs-lisp
(defun org-insert-dblock:org-gantt ()
  "Insert org-gantt dynamic block."
  (interactive)
  (org-create-dblock
   (list :name "org-gantt"
         :file "data/images/project-gantt-chart.png"
         :imagemagick t
         :tikz-options "scale=3D1.5, every node/.style=3D{scale=3D1.5}"
         :weekend-style "{draw=3Dblue!10, line width=3D1pt}"
         :workday-style "{draw=3Dblue!5, line width=3D.75pt}"
         :show-progress 'if-value
         :progress-source 'cookie-clocksum
         :no-date-headlines 'inactive
         :parameters "y unit title=3D.7cm, y unit chart=3D.9cm"
         :tags-group-style '(("test"."group label font=3D\\color{blue}")
                             ("toast"."group label font=3D\\color{green}"=
))
         :tags-bar-style '(("test"."bar label font=3D\\color{blue}")
                           ("toast"."bar label font=3D\\color{green}"))))=
)
#+end_src


+1


Org defines C-c C-x i as org-insert-columns-dblock= . Instead, it could call the org-insert-dblock dispatcher shown here. The original org-insert-columns-dblock<= /tt> would be one among other dblock inserters.

Possible dblocks:
=C2=A0 org-insert-columns-dblock
=C2=A0 org-clock-report
=C2=A0 propview
=C2=A0 invoice
=C2=A0 org-insert-dblock:aggregate
=C2=A0 org-insert-dblock:join
=C2=A0 org-insert-dblock:transpose

Any future dblock inserter would be taken into account by the dispatcher just by providing an autoloadable org-insert-dblock:s= omething function.