You can use a source block with a self-defined major mode.
It is easy to define a customized major mode with helper functions like
Let us name your new major mode
myorg-mode. Then the name of the function executed on C-c C-c is
It is called with two arguments. The first arg is the content of the source block as a string.
The second arg is an association list that maps the keys of the header arguments of the source blocks to their vaules.
The following source code demonstrates the method.
(define-derived-mode myorg-mode org-mode "Org"
"Add special processing to `myorg` source blocks."
(defun org-babel-execute:myorg (body params)
"Processing of `myorg' source blocks.
BODY is the text of the source block
and PARAMS is an alist mapping the keys of the header args
to their vaules."
(let* ((sep (or (cdr (assq :sep params)) "\n")) ;; Example for getting the values of source block header arguments. Here we extract the value for :sep.
;; Beginning of the special action for source blocks of this kind:
;; We split the body into a list of words and collect only every second word from this list.
(words (split-string body nil t "[[:space:]]+")))
(mapconcat ;; Concatenating the collected words to the output string.
(cl-loop for word in words by #'cddr
when (string-match "[[:alpha:]]" word)
A little usage example:
#+BEGIN_SRC myorg :sep "; " :results raw drawer
,* Some text
Lorem *ipsum* dolor /sit/ amet, consectetuer adipiscing elit, ~sed~ diam
text; *ipsum*; /sit/; consectetuer; elit,; diam
Note, if you switch
org-src-fontify-natively on the content of the source block is rendered like the major mode of the source block would do it. In our case Org formatting is applied.