From b931a4223788d01e736a47e442ece33381bccad8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 16 Oct 2016 13:07:01 -0500 Subject: [PATCH 1/4] autoload does not seem to be functioning in latest update --- plantuml-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index f441274..6e1059f 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -330,7 +330,7 @@ Uses prefix (as PREFIX) to choose where to display it: (message "Making completion list...%s" "done"))))) ;;;###autoload -(add-to-list 'auto-mode-alist '("\\.(plantuml|pum|plantuml|plu)$" . plantuml-mode)) +(add-to-list 'auto-mode-alist '("\\.\\(plantuml\\|pum\\|plantuml\\|plu\\)$" . plantuml-mode)) ;;;###autoload (define-derived-mode plantuml-mode prog-mode "plantuml" From 04a2e7d5d9325944342291b9b278a5ebba6e9a10 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 16 Oct 2016 13:37:20 -0500 Subject: [PATCH 2/4] Delay mode variable initialization until mode is loaded. --- plantuml-mode.el | 66 +++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 6e1059f..275e844 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -273,38 +273,39 @@ Uses prefix (as PREFIX) to choose where to display it: (plantuml-preview-region prefix) (plantuml-preview-buffer prefix))) -(unless plantuml-kwdList - (plantuml-init) - (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-keywords-regexp (concat "^\\s *" (regexp-opt plantuml-keywords 'words) "\\|\\(<\\|<|\\|\\*\\|o\\)\\(\\.+\\|-+\\)\\|\\(\\.+\\|-+\\)\\(>\\||>\\|\\*\\|o\\)\\|\\.\\{2,\\}\\|-\\{2,\\}")) - (defvar plantuml-builtins-regexp (regexp-opt plantuml-builtins 'words)) - (defvar plantuml-preprocessors-regexp (concat "^\\s *" (regexp-opt plantuml-preprocessors 'words))) - - (setq plantuml-font-lock-keywords - `( - (,plantuml-types-regexp . font-lock-type-face) - (,plantuml-keywords-regexp . font-lock-keyword-face) - (,plantuml-builtins-regexp . font-lock-builtin-face) - (,plantuml-preprocessors-regexp . font-lock-preprocessor-face) - ;; note: order matters - )) - - (setq plantuml-kwdList (make-hash-table :test 'equal)) - (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-types) - (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-keywords) - (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-builtins) - (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-preprocessors) - (put 'plantuml-kwdList 'risky-local-variable t) - - ;; clear memory - (setq plantuml-types nil) - (setq plantuml-keywords nil) - (setq plantuml-builtins nil) - (setq plantuml-preprocessors nil) - (setq plantuml-types-regexp nil) - (setq plantuml-keywords-regexp nil) - (setq plantuml-builtins-regexp nil) - (setq plantuml-preprocessors-regexp nil)) +(defun plantuml-init-once () + (unless plantuml-kwdList + (plantuml-init) + (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-keywords-regexp (concat "^\\s *" (regexp-opt plantuml-keywords 'words) "\\|\\(<\\|<|\\|\\*\\|o\\)\\(\\.+\\|-+\\)\\|\\(\\.+\\|-+\\)\\(>\\||>\\|\\*\\|o\\)\\|\\.\\{2,\\}\\|-\\{2,\\}")) + (defvar plantuml-builtins-regexp (regexp-opt plantuml-builtins 'words)) + (defvar plantuml-preprocessors-regexp (concat "^\\s *" (regexp-opt plantuml-preprocessors 'words))) + + (setq plantuml-font-lock-keywords + `( + (,plantuml-types-regexp . font-lock-type-face) + (,plantuml-keywords-regexp . font-lock-keyword-face) + (,plantuml-builtins-regexp . font-lock-builtin-face) + (,plantuml-preprocessors-regexp . font-lock-preprocessor-face) + ;; note: order matters + )) + + (setq plantuml-kwdList (make-hash-table :test 'equal)) + (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-types) + (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-keywords) + (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-builtins) + (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-preprocessors) + (put 'plantuml-kwdList 'risky-local-variable t) + + ;; clear memory + (setq plantuml-types nil) + (setq plantuml-keywords nil) + (setq plantuml-builtins nil) + (setq plantuml-preprocessors nil) + (setq plantuml-types-regexp nil) + (setq plantuml-keywords-regexp nil) + (setq plantuml-builtins-regexp nil) + (setq plantuml-preprocessors-regexp nil))) (defun plantuml-complete-symbol () "Perform keyword completion on word before cursor." @@ -338,6 +339,7 @@ Uses prefix (as PREFIX) to choose where to display it: Shortcuts Command Name \\[plantuml-complete-symbol] `plantuml-complete-symbol'" + (plantuml-init-once) (make-local-variable 'plantuml-output-type) (set (make-local-variable 'comment-start-skip) "\\('+\\|/'+\\)\\s *") (set (make-local-variable 'comment-start) "/'") From 40e2ff222c7fba94d73124e495cbc57c6d8812c2 Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Mon, 17 Oct 2016 15:21:00 +0900 Subject: [PATCH 3/4] Fix regexp of auto-mode-alist And use "\'" end of string anchor instead of "$". --- plantuml-mode.el | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index 275e844..f71b3b3 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -280,23 +280,23 @@ Uses prefix (as PREFIX) to choose where to display it: (defvar plantuml-keywords-regexp (concat "^\\s *" (regexp-opt plantuml-keywords 'words) "\\|\\(<\\|<|\\|\\*\\|o\\)\\(\\.+\\|-+\\)\\|\\(\\.+\\|-+\\)\\(>\\||>\\|\\*\\|o\\)\\|\\.\\{2,\\}\\|-\\{2,\\}")) (defvar plantuml-builtins-regexp (regexp-opt plantuml-builtins 'words)) (defvar plantuml-preprocessors-regexp (concat "^\\s *" (regexp-opt plantuml-preprocessors 'words))) - + (setq plantuml-font-lock-keywords - `( - (,plantuml-types-regexp . font-lock-type-face) - (,plantuml-keywords-regexp . font-lock-keyword-face) - (,plantuml-builtins-regexp . font-lock-builtin-face) - (,plantuml-preprocessors-regexp . font-lock-preprocessor-face) - ;; note: order matters - )) - + `( + (,plantuml-types-regexp . font-lock-type-face) + (,plantuml-keywords-regexp . font-lock-keyword-face) + (,plantuml-builtins-regexp . font-lock-builtin-face) + (,plantuml-preprocessors-regexp . font-lock-preprocessor-face) + ;; note: order matters + )) + (setq plantuml-kwdList (make-hash-table :test 'equal)) (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-types) (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-keywords) (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-builtins) (mapc (lambda (x) (puthash x t plantuml-kwdList)) plantuml-preprocessors) (put 'plantuml-kwdList 'risky-local-variable t) - + ;; clear memory (setq plantuml-types nil) (setq plantuml-keywords nil) @@ -331,7 +331,7 @@ Uses prefix (as PREFIX) to choose where to display it: (message "Making completion list...%s" "done"))))) ;;;###autoload -(add-to-list 'auto-mode-alist '("\\.\\(plantuml\\|pum\\|plantuml\\|plu\\)$" . plantuml-mode)) +(add-to-list 'auto-mode-alist '("\\.(plantuml\\|pum\\|plantuml\\|plu)\\'" . plantuml-mode)) ;;;###autoload (define-derived-mode plantuml-mode prog-mode "plantuml" From 314674796f870b2a8edb84dd2201cb9103478dd8 Mon Sep 17 00:00:00 2001 From: Syohei YOSHIDA Date: Mon, 17 Oct 2016 15:39:34 +0900 Subject: [PATCH 4/4] Don't call hook two times define-derived-mode macro puts run-hook code after body so it is not necessary to call it manually. --- plantuml-mode.el | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plantuml-mode.el b/plantuml-mode.el index f71b3b3..4ce603d 100644 --- a/plantuml-mode.el +++ b/plantuml-mode.el @@ -346,10 +346,7 @@ Shortcuts Command Name (set (make-local-variable 'comment-end) "'/") (set (make-local-variable 'comment-multi-line) t) (set (make-local-variable 'comment-style) 'extra-line) - (setq font-lock-defaults '((plantuml-font-lock-keywords) nil t)) - - ; Run hooks: - (run-mode-hooks 'plantuml-mode-hook)) + (setq font-lock-defaults '((plantuml-font-lock-keywords) nil t))) (defun plantuml-deprecation-warning () "Warns the user about the deprecation of the `puml-mode' project."