Xebar Saram <zelt...@gmail.com> writes:

> this looks really cool and would love to try. as a non technical user, how
> does one use the patch to get the functionality? is there a way to create a
> clean function only version from the patch i can try?

You could simply pick the relevant parts from the patch and evaluate

Concretely you could do:

1. Copy Eric's code to empty buffer *scratch*.  The relevant code is

#+BEGIN_SRC elisp
(defcustom org-structure-predefined-blocks
  "Block structure completion names."
  :group 'org-completion
  :type '(repeat string)
  :package-version '(Org . "9.1.3"))

(defun org-insert-structure-template (&optional type)
  "Insert a block structure of the type #+BEGIN_FOO/#+END_FOO.
Prompts for a block type, and inserts the block.  With an active
region, wrap the region in the block.  With an element under
point, wrap the element in the block.  Otherwise, insert an empty
  (setq type (or type (completing-read "Block type: "
  (unless (use-region-p)
    (when (org-element-at-point)
  (let ((s (if (use-region-p)
        (e (copy-marker (if (use-region-p)
    (when (string-equal (downcase type) "example")
      (org-escape-code-in-region s e))
    (goto-char s)
    (setq column (current-indentation))
    (indent-to column)
    (insert (format "#+BEGIN_%s\n" type))
    (goto-char e)
    (if (bolp)
          (skip-chars-backward " \n\t")
      (insert "\n"))
    (indent-to column)
    (insert (format "#+END_%s\n"
    (set-marker e nil)))

(org-defkey org-mode-map "\C-c\C-xw"    'org-insert-structure-template)

2. In buffer *scratch* do

    M-x eval-buffer

3. Voila!  Check out C-c C-x w in an org mode buffer.

Best regards

Reply via email to