branch: externals/phps-mode commit 6d834c1cd6809377a5691519ec95e3257ee765f5 Author: Christian Johansson <christ...@cvj.se> Commit: Christian Johansson <christ...@cvj.se>
Added support for (comment-region) and (uncomment-region) --- phps-mode-functions.el | 7 +++++++ phps-mode-test-functions.el | 31 ++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/phps-mode-functions.el b/phps-mode-functions.el index 3f0fb68..ba1ab50 100644 --- a/phps-mode-functions.el +++ b/phps-mode-functions.el @@ -807,6 +807,13 @@ (set (make-local-variable 'phps-mode-functions-imenu) nil) (set (make-local-variable 'phps-mode-functions-processed-buffer) nil) + ;; Make (comment-region) work + (set (make-local-variable 'comment-start) "/* ") + (set (make-local-variable 'comment-end) " */") + + ;; TODO Make (uncomment-region) work + ;; TODO Make selecting region and clicking ' wrap region in single quotes + ;; Support for change detection (add-hook 'after-change-functions #'phps-mode-functions-after-change)) diff --git a/phps-mode-test-functions.el b/phps-mode-test-functions.el index 0cca066..7388a45 100644 --- a/phps-mode-test-functions.el +++ b/phps-mode-test-functions.el @@ -777,6 +777,33 @@ ) +(defun phps-mode-test-functions-quote-region () + "Test double quotes, single quotes, curly bracket, square bracket, round bracket, back-quotes on regions." + + + ;; TODO Implement this + + ) + +(defun phps-mode-test-functions-comment-uncomment-region () + "Test (comment-region) and (uncomment-region)." + + (phps-mode-test-with-buffer + "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements myInterface {\n public function myFunctionA($myArg = null) {}\n protected function myFunctionB($myArg = 'abc') {}\n}\n" + "Comment object-oriented file with bracket-less namespace, class that extends and implements and functions with optional arguments" + (comment-region (point-min) (point-max)) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "/* <?php */\n/* namespace myNamespace; */\n/* class myClass extends myAbstract implements myInterface { */\n/* public function myFunctionA($myArg = null) {} */\n/* protected function myFunctionB($myArg = 'abc') {} */\n/* } */\n")))) + + (phps-mode-test-with-buffer + "/* <?php */\n/* namespace myNamespace; */\n/* class myClass extends myAbstract implements myInterface { */\n/* public function myFunctionA($myArg = null) {} */\n/* protected function myFunctionB($myArg = 'abc') {} */\n/* } */\n" + "Uncomment object-oriented file with bracket-less namespace, class that extends and implements and functions with optional arguments" + (uncomment-region (point-min) (point-max)) + (let ((buffer-contents (buffer-substring-no-properties (point-min) (point-max)))) + (should (equal buffer-contents "<?php\nnamespace myNamespace;\nclass myClass extends myAbstract implements myInterface {\n public function myFunctionA($myArg = null) {}\n protected function myFunctionB($myArg = 'abc') {}\n}\n")))) + + ) + (defun phps-mode-test-functions () "Run test for functions." ;; (setq debug-on-error t) @@ -790,7 +817,9 @@ (phps-mode-test-functions-get-lines-indent) (phps-mode-test-functions-get-lines-indent-psr-2) (phps-mode-test-functions-indent-line) - (phps-mode-test-functions-imenu)) + (phps-mode-test-functions-imenu) + (phps-mode-test-functions-comment-uncomment-region) + (phps-mode-test-functions-quote-region)) (phps-mode-test-functions)