From e65f201e72740df530c75aaa9c148687ee253c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Schmelzer?= Date: Sat, 16 Mar 2019 15:31:25 +0100 Subject: [PATCH] intro of customisable plantuml-tab-width Default is still the global tab-width. For diagrams I usually like to have a smaller indentation (2 spaces) as I use in programming (4 spaces). Is tested implicitly, as the variable is setq-local in test prepartions. --- plantuml-mode.el | 7 ++++++- test/plantuml-indentation-basics-test.el | 2 +- test/test-helper.el | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 69dcbec..cdd15bb 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -108,6 +108,11 @@ :type '(repeat string) :group 'plantuml) +(defcustom plantuml-tab-width tab-width + "The number of spaces used for indentation." + :type 'integer + :group 'plantuml) + (defcustom plantuml-suppress-deprecation-warning t "To silence the deprecation warning when `puml-mode' is found upon loading." :type 'boolean @@ -460,7 +465,7 @@ Restore point to same position in text of the line as before indentation." (let ((original-position-eol (- (line-end-position) (point)))) (save-excursion (beginning-of-line) - (indent-line-to (* tab-width (plantuml-current-block-depth)))) + (indent-line-to (* plantuml-tab-width (plantuml-current-block-depth)))) ;; restore position in text of line (goto-char (- (line-end-position) original-position-eol)))) diff --git a/test/plantuml-indentation-basics-test.el b/test/plantuml-indentation-basics-test.el index 23b9e43..88aa05d 100644 --- a/test/plantuml-indentation-basics-test.el +++ b/test/plantuml-indentation-basics-test.el @@ -166,7 +166,7 @@ the position of | in AFTER." ;; use 2 spaces instead of one tab for indentation (setq-local indent-tabs-mode nil) - (setq-local tab-width 2) + (setq-local plantuml-tab-width 2) (indent-according-to-mode) (should (equal expected-state (buffer-string))) diff --git a/test/test-helper.el b/test/test-helper.el index bbba7b4..609b401 100644 --- a/test/test-helper.el +++ b/test/test-helper.el @@ -61,7 +61,7 @@ Finally, the indented text in the buffer will be compared with AFTER." (plantuml-mode) ;; use 2 spaces instead of one tab for indentation (setq-local indent-tabs-mode nil) - (setq-local tab-width 2) + (setq-local plantuml-tab-width 2) (indent-region (point-min) (point-max)) (should (equal (buffer-string) after))))