[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode c625217 042/405: Added flag for PSR-2 white-s
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode c625217 042/405: Added flag for PSR-2 white-space settings |
Date: |
Sat, 13 Jul 2019 09:59:39 -0400 (EDT) |
branch: externals/phps-mode
commit c625217d81227b31c09cf37fd34758f9c402163b
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Added flag for PSR-2 white-space settings
---
phps-functions.el | 18 ++++++++++++++----
phps-mode.el | 3 +++
phps-syntax-table.el | 10 ++++++----
phps-test-functions.el | 3 ---
4 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/phps-functions.el b/phps-functions.el
index cc2bc7a..9c67d3a 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -47,8 +47,8 @@
;; Are we in scripting?
(if in-scripting
- (let* ((indent-start (* (+ (nth 1 start) (nth 2 start)) 4))
- (indent-end (* (+ (nth 1 end) (nth 2 end)) 4))
+ (let* ((indent-start (* (+ (nth 1 start) (nth 2 start)) tab-width))
+ (indent-end (* (+ (nth 1 end) (nth 2 end)) tab-width))
(indent-diff 0))
(when (and (> indent-start indent-end)
(looking-at-p "^[][ \t)(}{};]+\\($\\|?>\\)"))
@@ -57,7 +57,7 @@
(message "inside scripting, start: %s, end: %s, indenting to
column %s " start end indent-level)
(indent-line-to indent-level))
(progn
- (message "Outside scripting %s" start)
+ ;; (message "Outside scripting %s" start)
;; (indent-relative)
))))))
@@ -69,7 +69,17 @@
"PHP specific init-cleanup routines."
(set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
- (set (make-local-variable 'tab-width) 8)
+
+ (when phps-mode/use-psr-2
+
+ ;; PSR-2 : Code MUST use an indent of 4 spaces
+ (set (make-local-variable 'tab-width) 4)
+
+ ;; PSR-2 : MUST NOT use tabs for indenting
+ (set (make-local-variable 'indent-tabs-mode) nil)
+
+ )
+
;; (set (make-local-variable 'indent-line-function)
#'phps-mode/indent-region)
)
diff --git a/phps-mode.el b/phps-mode.el
index 65542f7..0d5c19d 100644
--- a/phps-mode.el
+++ b/phps-mode.el
@@ -57,6 +57,9 @@
(autoload 'phps-mode/tags-init "phps-tags")
(autoload 'phps-mode/semantic-init "phps-semantic")
+(defvar phps-mode/use-psr-2 t
+ "Whether to use PSR-2 guidelines for white-space or not.")
+
(define-derived-mode phps-mode prog-mode "PHPs"
"Major mode for PHP with Semantic integration."
diff --git a/phps-syntax-table.el b/phps-syntax-table.el
index 6cbdecd..b482143 100644
--- a/phps-syntax-table.el
+++ b/phps-syntax-table.el
@@ -43,12 +43,14 @@
(let ((phps-mode/syntax-table (make-syntax-table)))
;; This is added so entity names with underscores can be more easily
parsed as one word
- (modify-syntax-entry ?_ "w" phps-mode/syntax-table)
+
+ ;; Treat underscore as a punctuation
+ (modify-syntax-entry ?_ "." phps-mode/syntax-table)
;; Improve parsing of <?php and ?> as words
- (modify-syntax-entry ?? "w" phps-mode/syntax-table)
- (modify-syntax-entry ?< "w" phps-mode/syntax-table)
- (modify-syntax-entry ?> "w" phps-mode/syntax-table)
+ ;;(modify-syntax-entry ?? "w" phps-mode/syntax-table)
+ ;;(modify-syntax-entry ?< "w" phps-mode/syntax-table)
+ ;;(modify-syntax-entry ?> "w" phps-mode/syntax-table)
;; (modify-syntax-entry ?_ "w" phps-mode/syntax-table)
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 3f6543e..003ea4d 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -99,9 +99,6 @@
(defun phps-mod/test-functions ()
"Run test for functions."
- (setq-default indent-tabs-mode nil)
- (setq-default tab-width 4)
- (setq-default c-basic-indent 4)
(phps-mode/test-indentation))
(phps-mod/test-functions)
- [elpa] externals/phps-mode d839f8a 029/405: More work on indentation support, (continued)
- [elpa] externals/phps-mode d839f8a 029/405: More work on indentation support, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode efcefde 035/405: Added support for closing parenthesis and braces, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1b891ea 031/405: More work on indentation and related tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c6e5255 038/405: Merge branch 'master' of https://github.com/cjohansson/emacs-phps-mode, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3837d9c 001/405: My initial commit, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 6776468 037/405: Started worked with adding references to tokens from point meta information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode feb5724 039/405: Various debug work, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e36d477 045/405: token-number from point now is the same format as (nth), Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode b437374 040/405: Fixed bug in parsing of object parameters inside double quoted string, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7161184 041/405: Handles stacked states better, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c625217 042/405: Added flag for PSR-2 white-space settings,
Stefan Monnier <=
- [elpa] externals/phps-mode b629c4b 050/405: Updated comments and TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 4b4a375 043/405: Using lexical bindings for all files, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c040358 046/405: Point lexer token information makes more sense, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 94492c4 048/405: Added changes tracking to functions from lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be46d9c 044/405: Added lexer autoload to functions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a259292 047/405: Changed indentation function to work solely on tokens, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 4098f46 049/405: Started with incremental lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode da1d1de 051/405: Temporary lexer after change until other work is ready, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 990d3dd 054/405: Added test for indentation of multiple-line doc comment, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode dd80d27 055/405: Started work on detecting doc comment blocks, Stefan Monnier, 2019/07/13