thx thats perfect

Z

On Sat, Oct 21, 2017 at 2:59 PM, Marco Wahl <marcowahls...@gmail.com> wrote:

> The following message is a courtesy copy of an article
> that has been posted to gmane.emacs.orgmode as well.
>
> Hi!
>
> 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
> them.
>
> 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
>   '("SRC" "EXAMPLE" "QUOTE" "VERSE" "VERBATIM" "CENTER" "COMMENT" "EXPORT")
>   "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
> block."
>   (interactive)
>   (setq type (or type (completing-read "Block type: "
>                                        org-structure-predefined-blocks)))
>   (unless (use-region-p)
>     (when (org-element-at-point)
>       (org-mark-element)))
>   (let ((s (if (use-region-p)
>                (region-beginning)
>              (point)))
>         (e (copy-marker (if (use-region-p)
>                             (region-end)
>                           (point))
>                         t))
>         column)
>     (when (string-equal (downcase type) "example")
>       (org-escape-code-in-region s e))
>     (goto-char s)
>     (setq column (current-indentation))
>     (beginning-of-line)
>     (indent-to column)
>     (insert (format "#+BEGIN_%s\n" type))
>     (goto-char e)
>     (if (bolp)
>         (progn
>           (skip-chars-backward " \n\t")
>           (forward-line))
>       (end-of-line)
>       (insert "\n"))
>     (indent-to column)
>     (insert (format "#+END_%s\n"
>                     type))
>     (set-marker e nil)))
>
> (org-defkey org-mode-map "\C-c\C-xw"    'org-insert-structure-template)
> #+END_SRC
>
> 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
>             Marco
>

Reply via email to