[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] [Feature Request] Add an dispatcher command (keybinding) for inserti
From: |
stardiviner |
Subject: |
[O] [Feature Request] Add an dispatcher command (keybinding) for inserting dynamic blocks |
Date: |
Fri, 16 Nov 2018 09:15:20 +0800 |
User-agent: |
mu4e 1.1.0; emacs 26.1 |
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"
(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 dynamic
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=1.5, every node/.style={scale=1.5}"
:weekend-style "{draw=blue!10, line width=1pt}"
:workday-style "{draw=blue!5, line width=.75pt}"
:show-progress 'if-value
:progress-source 'cookie-clocksum
:no-date-headlines 'inactive
:parameters "y unit title=.7cm, y unit chart=.9cm"
:tags-group-style '(("test"."group label font=\\color{blue}")
("toast"."group label font=\\color{green}"))
:tags-bar-style '(("test"."bar label font=\\color{blue}")
("toast"."bar label font=\\color{green}")))))
#+end_src
--
[ stardiviner ]
I try to make every word tell the meaning what I want to express.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
- [O] [Feature Request] Add an dispatcher command (keybinding) for inserting dynamic blocks,
stardiviner <=