Fix switching between modes (#104)
Giving a default value to `plantuml-exec-mode` local var at startup time is wrong. This change keeps the local var to `nil` and resorts to the customizable `plantuml-default-exec-mode`. The local var can be set by users at will on a buffer local level, but without such an explicit opt-in then the default value is always used
This commit is contained in:
parent
d11bd57f31
commit
1e5f8beedd
1 changed files with 10 additions and 5 deletions
|
@ -159,8 +159,8 @@
|
||||||
(defvar plantuml-kwdList nil "The plantuml keywords.")
|
(defvar plantuml-kwdList nil "The plantuml keywords.")
|
||||||
|
|
||||||
;; PlantUML execution mode
|
;; PlantUML execution mode
|
||||||
(defvar-local plantuml-exec-mode plantuml-default-exec-mode
|
(defvar-local plantuml-exec-mode nil
|
||||||
"The Plantuml execution mode. See `plantuml-default-exec-mode' for acceptable values.")
|
"The Plantuml execution mode override. See `plantuml-default-exec-mode' for acceptable values.")
|
||||||
|
|
||||||
(defun plantuml-set-exec-mode (mode)
|
(defun plantuml-set-exec-mode (mode)
|
||||||
"Set the execution mode MODE for PlantUML."
|
"Set the execution mode MODE for PlantUML."
|
||||||
|
@ -177,6 +177,11 @@
|
||||||
(setq plantuml-exec-mode (intern mode))
|
(setq plantuml-exec-mode (intern mode))
|
||||||
(error (concat "Unsupported mode:" mode))))
|
(error (concat "Unsupported mode:" mode))))
|
||||||
|
|
||||||
|
(defun plantuml-get-exec-mode ()
|
||||||
|
"Retrieves the currently active PlantUML exec mode."
|
||||||
|
(or plantuml-exec-mode
|
||||||
|
plantuml-default-exec-mode))
|
||||||
|
|
||||||
(defun plantuml-enable-debug ()
|
(defun plantuml-enable-debug ()
|
||||||
"Enables debug messages into the *PLANTUML Messages* buffer."
|
"Enables debug messages into the *PLANTUML Messages* buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
@ -418,7 +423,7 @@ to choose where to display it."
|
||||||
(buf (get-buffer-create plantuml-preview-buffer))
|
(buf (get-buffer-create plantuml-preview-buffer))
|
||||||
(coding-system-for-read (and imagep 'binary))
|
(coding-system-for-read (and imagep 'binary))
|
||||||
(coding-system-for-write (and imagep 'binary)))
|
(coding-system-for-write (and imagep 'binary)))
|
||||||
(plantuml-exec-mode-preview-string prefix plantuml-exec-mode string buf)))
|
(plantuml-exec-mode-preview-string prefix (plantuml-get-exec-mode) string buf)))
|
||||||
|
|
||||||
(defun plantuml-preview-buffer (prefix)
|
(defun plantuml-preview-buffer (prefix)
|
||||||
"Preview diagram from the PlantUML sources in the current buffer.
|
"Preview diagram from the PlantUML sources in the current buffer.
|
||||||
|
@ -467,8 +472,8 @@ Uses prefix (as PREFIX) to choose where to display it:
|
||||||
(plantuml-preview-buffer prefix)))
|
(plantuml-preview-buffer prefix)))
|
||||||
|
|
||||||
(defun plantuml-init-once (&optional mode)
|
(defun plantuml-init-once (&optional mode)
|
||||||
"Ensure initialization only happens once. Use exec mode MODE to load the language details, which defaults to `plantuml-exec-mode'."
|
"Ensure initialization only happens once. Use exec mode MODE to load the language details or by first querying `plantuml-get-exec-mode'."
|
||||||
(let ((mode (or mode plantuml-exec-mode)))
|
(let ((mode (or mode (plantuml-get-exec-mode))))
|
||||||
(unless plantuml-kwdList
|
(unless plantuml-kwdList
|
||||||
(plantuml-init mode)
|
(plantuml-init mode)
|
||||||
(defvar plantuml-types-regexp (concat "^\\s *\\(" (regexp-opt plantuml-types 'words) "\\|\\<\\(note\\s +over\\|note\\s +\\(left\\|right\\|bottom\\|top\\)\\s +\\(of\\)?\\)\\>\\|\\<\\(\\(left\\|center\\|right\\)\\s +\\(header\\|footer\\)\\)\\>\\)"))
|
(defvar plantuml-types-regexp (concat "^\\s *\\(" (regexp-opt plantuml-types 'words) "\\|\\<\\(note\\s +over\\|note\\s +\\(left\\|right\\|bottom\\|top\\)\\s +\\(of\\)?\\)\\>\\|\\<\\(\\(left\\|center\\|right\\)\\s +\\(header\\|footer\\)\\)\\>\\)"))
|
||||||
|
|
Loading…
Reference in a new issue