branch: externals/phps-mode
commit 94492c4780ec9df2b678569b2292bf4518e867f4
Author: Christian Johansson <christ...@cvj.se>
Commit: Christian Johansson <christ...@cvj.se>

    Added changes tracking to functions from lexer
---
 phps-functions.el      | 16 ++++++++++++++++
 phps-lexer.el          | 13 -------------
 phps-test-functions.el |  6 ++++--
 3 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 54e021c..bcd50ce 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -36,6 +36,9 @@
 ;;; Code:
 
 
+(defvar phps-mode/buffer-changes--start nil
+  "Start of buffer changes, nil if none.")
+
 (autoload 'phps-mode/lexer-get-point-data "phps-lexer")
 
 (defun phps-mode/indent-line ()
@@ -93,6 +96,15 @@
   "Indent region."
   )
 
+;; TODO This function should track between what min and max region a specific 
buffer has been modified and then re-run lexer for that region when editor is 
idle, maybe use (buffer-name))
+;; maybe use 'auto-save-hook for this
+(defun phps-mode/after-change-functions (start stop length)
+  "Track buffer change from START to STOP with length LENGTH."
+  (when (string= major-mode "phps-mode")
+    (setq phps-mode/buffer-changes--start start)
+    (message "phps-mode/after-change-functions %s %s %s" start stop length)
+  ))
+
 (defun phps-mode/functions-init ()
   "PHP specific init-cleanup routines."
 
@@ -109,6 +121,10 @@
 
     )
 
+  (set (make-local-variable 'phps-mode/buffer-changes--start) nil)
+
+  (add-hook 'after-change-functions #'phps-mode/after-change-functions)
+
   ;; (set (make-local-variable 'indent-line-function) 
#'phps-mode/indent-region)
   )
 
diff --git a/phps-lexer.el b/phps-lexer.el
index 42ab914..37e1c56 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -47,9 +47,6 @@
 (defvar phps-mode/lexer-tokens nil
   "Last lexer tokens.")
 
-(defvar phps-mode/buffer-changes--start nil
-  "Start of buffer changes, nil if none.")
-
 
 ;; SETTINGS
 
@@ -1335,15 +1332,6 @@ ANY_CHAR'
     (setq phps-mode/buffer-changes--start nil)
     (phps-mode/BEGIN phps-mode/ST_INITIAL)))
 
-;; TODO This function should track between what min and max region a specific 
buffer has been modified and then re-run lexer for that region when editor is 
idle, maybe use (buffer-name))
-;; maybe use 'auto-save-hook for this
-(defun phps-mode/after-change-functions (start stop length)
-  "Track buffer change from START to STOP with length LENGTH."
-  (when (string= major-mode "phps-mode")
-    (setq phps-mode/buffer-changes--start start)
-    (message "phps-mode/after-change-functions %s %s %s" start stop length)
-  ))
-
 (defun phps-mode/lex--RUN ()
   "Run lexer."
   (interactive)
@@ -1371,7 +1359,6 @@ ANY_CHAR'
     (setq semantic-lex-syntax-table phps-mode/syntax-table))
   (setq semantic-lex-analyzer #'phps-mode/tags-lexer)
   (add-hook 'semantic-lex-reset-functions #'phps-mode/lex--SETUP)
-  (add-hook 'after-change-functions #'phps-mode/after-change-functions)
   (phps-mode/lex--RUN))
 
 (provide 'phps-mode/lexer)
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 644f916..9635bc0 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -40,7 +40,7 @@
 (autoload 'phps-mode/with-test-buffer "phps-test")
 (autoload 'should "ert")
 
-(defun phps-mode/test-indentation ()
+(defun phps-mode/test-indent-line ()
   "Test for indentation."
 
   (phps-mode/with-test-buffer
@@ -99,9 +99,11 @@
 
   )
 
+;; TODO Add tests for all examples here: https://www.php-fig.org/psr/psr-2/
+
 (defun phps-mod/test-functions ()
   "Run test for functions."
-  (phps-mode/test-indentation))
+  (phps-mode/test-indent-line))
 
 (phps-mod/test-functions)
 

Reply via email to