From b6b2d74f250935a4f17c34f31274a8eb395c25b6 Mon Sep 17 00:00:00 2001 From: Sunn Yao Date: Sat, 7 Sep 2019 12:27:23 +0800 Subject: [PATCH] lang/plantuml: fix src blocks that start w/ @start (#1746) * Fix advice bug of chinese and japanese * Fix bugs of advice * Update config.el * Fix "@start" prefix execute error on ob-plantuml * replace with 'after!' and rename advice function --- modules/lang/plantuml/config.el | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/lang/plantuml/config.el b/modules/lang/plantuml/config.el index 593ecfead..abc0b8091 100644 --- a/modules/lang/plantuml/config.el +++ b/modules/lang/plantuml/config.el @@ -13,3 +13,26 @@ :when (featurep! :tools flycheck) :after plantuml-mode :config (flycheck-plantuml-setup)) + +;; +;; 1. Add `:cmdline -charset utf-8' to org-src-block:plantuml +;; +;; 2. Fix `@start' prefix execute error +;; When `C-c C-c' is executed in org-src-block:plantuml, if the code starts with +;; `@', execution will go wrong. Must be preceded by `\' or `,' to execute +;; normally. This code is automatically added `\' before `@start' when `C-c C-c' +;; is executed, so that the execution can be carried out normally. +;; +(after! ob-plantuml + (defadvice! +plantuml--fix-atstart-in-org-src-blocks-a (args) + :filter-args #'org-babel-execute:plantuml + (cl-destructuring-bind (body params) args + (let* ((origin-body body) + (fix-body + (replace-regexp-in-string + "^\\w*\\(@start\\)" + "\\\\\\1" + origin-body))) + (list fix-body params)))) + (add-to-list 'org-babel-default-header-args:plantuml + '(:cmdline . "-charset utf-8")))