[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode c8c5b62 337/405: Made custom functions for (c
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode c8c5b62 337/405: Made custom functions for (comment-region) and (uncomment-region) |
Date: |
Sat, 13 Jul 2019 10:00:44 -0400 (EDT) |
branch: externals/phps-mode
commit c8c5b6264847282400e9d4b1cee4b4dbbcc9b607
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Made custom functions for (comment-region) and (uncomment-region)
---
README.md | 4 ++--
phps-mode-functions.el | 45 ++++++++++++++++++++++++++++++++-------------
phps-mode-test-functions.el | 4 ++--
3 files changed, 36 insertions(+), 17 deletions(-)
diff --git a/README.md b/README.md
index 25df1e9..0e9551c 100644
--- a/README.md
+++ b/README.md
@@ -14,10 +14,10 @@ This mode does not require PHP installed on computer
because it has a elisp base
* Syntax coloring based on lexer tokens (100%)
* PSR-1 and PSR-2 indentation based on lexer tokens (100%)
* Imenu support (100%)
-* Integration with (electric-pair) (100%)
+* Integration with `(electric-pair)` (100%)
* Incremental lexer and syntax coloring after buffer changes (100%)
* Incremental indentation and imenu calculation after buffer changes (100%)
-* Supports `(comment-region)` and `(uncomment-region)` (50%)
+* Supports `(comment-region)` and `(uncomment-region)` (100%)
* Wisent LALR parser based on official PHP yacc parser automatically converted
grammar (50%)
* Approach flycheck about including support for this module by default (0%)
* Full integration with Emacs Semantic subsystem (30%)
diff --git a/phps-mode-functions.el b/phps-mode-functions.el
index 507e236..0de3711 100644
--- a/phps-mode-functions.el
+++ b/phps-mode-functions.el
@@ -789,7 +789,6 @@
(defun phps-mode-functions-comment-region (beg end &optional _arg)
"Comment region from BEG to END with optional ARG."
- (message "phps-mode-functions-comment-region %s %s %s" beg end _arg)
(save-excursion
;; Go to start of region
(goto-char beg)
@@ -799,26 +798,46 @@
;; Do this for every line in region
(while (< current-line-number end-line-number)
- (back-to-indentation)
+ (move-beginning-of-line nil)
;; Does this line contain something other than white-space?
(unless (eq (point) (line-end-position))
(insert comment-start)
- (end-of-line)
+ (move-end-of-line nil)
(insert comment-end))
(line-move 1)
- (setq current-line-number (line-number-at-pos))))
+ (setq current-line-number (line-number-at-pos))))))
-
- ))
-
-(defun phps-mode-functions-uncomment-region (beg end &optional arg)
+(defun phps-mode-functions-uncomment-region (beg end &optional _arg)
"Comment region from BEG to END with optional ARG."
(save-excursion
- (message "phps-mode-functions-uncomment-region %s %s %s" beg end arg)
- )
- )
+
+ ;; Go to start of region
+ (goto-char beg)
+
+ (let ((end-line-number (line-number-at-pos end t))
+ (current-line-number (line-number-at-pos)))
+
+ ;; Do this for every line in region
+ (while (< current-line-number end-line-number)
+ (move-beginning-of-line nil)
+
+ ;; Does this line contain something other than white-space?
+ (unless (>= (+ (point) 3) (line-end-position))
+ (when (looking-at-p "\/\/ ")
+ (delete-char 3))
+ (when (looking-at-p "\/\\* ")
+ (delete-char 3))
+
+ (move-end-of-line nil)
+
+ (backward-char 3)
+ (when (looking-at-p " \\*\/")
+ (delete-char 3)))
+
+ (line-move 1)
+ (setq current-line-number (line-number-at-pos))))))
(defun phps-mode-functions-init ()
@@ -850,8 +869,8 @@
;; Make (comment-region) and (uncomment-region) work
(set (make-local-variable 'comment-region-function)
#'phps-mode-functions-comment-region)
(set (make-local-variable 'uncomment-region-function)
#'phps-mode-functions-uncomment-region)
- (set (make-local-variable 'comment-start) "/* ")
- (set (make-local-variable 'comment-end) " */")
+ (set (make-local-variable 'comment-start) "// ")
+ (set (make-local-variable 'comment-end) "")
;; 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 dda9bfd..e146b73 100644
--- a/phps-mode-test-functions.el
+++ b/phps-mode-test-functions.el
@@ -790,10 +790,10 @@
"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"))))
+ (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"
+ "// <?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))))
- [elpa] externals/phps-mode 7e755e1 303/405: Fixed indentation for argument assignments, (continued)
- [elpa] externals/phps-mode 7e755e1 303/405: Fixed indentation for argument assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a852669 320/405: Fix bug in syntax colouring, added debug outputs for incremental lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ad94b0b 319/405: Removed some fixed TODO itemsc, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 2427c7e 318/405: Improved README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6d834c1 312/405: Added support for (comment-region) and (uncomment-region), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b1d2820 309/405: Fixed issue with indentation of square bracket arrays in assignments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3bc2411 317/405: Moved syntax-table tests to own file, using local electric-pair-mode in PHPs buffers, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c2b8a16 335/405: Passes new test for concatenated string inside function arguments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b4e416a 336/405: (comment-region) tests working with custom function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ad53b6c 330/405: Fixed warning when expected integer was nil, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c8c5b62 337/405: Made custom functions for (comment-region) and (uncomment-region),
Stefan Monnier <=
- [elpa] externals/phps-mode 7e22fdb 323/405: Added failing incremental indentation test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a45b39a 339/405: Added two failing indentation tests for concatenated equal assignment and double arrow multi-line array declaration, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3e1ff06 332/405: Added integration-tests for syntax colouring and update goals, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ced201d 322/405: Updated syntax colouring for namespace, class, function and constant names, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8298a6a 325/405: Colorized strings after namespace separator, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a30e5ff 331/405: Run incremental lexer when processing file if buffer change, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e9475f7 321/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 55b3087 333/405: Optimized lexer calling, do not call when using (indent-line), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a309998 326/405: Integration tests passes with new function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c37b234 334/405: Added failing test for indent in concatenated string inside function arguments, Stefan Monnier, 2019/07/13