[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode abcfd01 021/405: Started with function to gat
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode abcfd01 021/405: Started with function to gather current point data |
Date: |
Sat, 13 Jul 2019 09:59:32 -0400 (EDT) |
branch: externals/phps-mode
commit abcfd01b57d7a05896ef699c78db4087c75eea03
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Started with function to gather current point data
---
README.md | 3 ++-
phps-functions.el | 11 ++++-------
phps-lexer.el | 22 +++++++++++++++++++++-
phps-test-lexer.el | 13 ++++++++++---
sample-php-files/class.php | 5 +++++
5 files changed, 42 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index 090c8de..51e9237 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,8 @@ With current progress estimates:
* Flycheck support (100%)
* Lexer based on official PHP re2c lexer (100%)
* Syntax coloring based on lexer tokens (100%)
-* PSR based indentation based on lexer tokens (0%)
+* Incremental lexer and syntax coloring after changes (0%)
+* PSR based indentation based on lexer tokens (20%)
* Wisent LALR parser based on official PHP yacc parser automatically converted
(60%)
* Flymake support (0%)
* Full integration with Emacs Semantic subsystem (0%)
diff --git a/phps-functions.el b/phps-functions.el
index 2366c43..48aac15 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -38,20 +38,17 @@
(defun phps-mode/indent-line ()
"Indent line."
- (save-excursion
- (move-beginning-of-line nil)
- )
)
(defun phps-mode/indent-region ()
- "Indent region.")
+ "Indent region."
+ )
(defun phps-mode/functions-init ()
"PHP specific init-cleanup routines."
- ;; (set (make-local-variable 'indent-line-function) 'phps-mode/indent-line)
- ;; (set (make-local-variable 'indent-line-function) 'phps-mode/indent-region)
-
+ ;; (set (make-local-variable 'indent-line-function) #'phps-mode/indent-line)
+ ;; (set (make-local-variable 'indent-line-function)
#'phps-mode/indent-region)
)
diff --git a/phps-lexer.el b/phps-lexer.el
index 58c704b..d9b6493 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1255,12 +1255,31 @@ ANY_CHAR'
))
+(defun phps-mode/lexer-get-point-data()
+ "Return information about point in tokens."
+ (message "Point: %s in %s" (point) phps-mode/lexer-tokens)
+ (dolist (item phps-mode/lexer-tokens)
+ )
+ )
+
(defun phps-mode/lex--SETUP (start end)
"Just prepare other lexers for lexing region START to END."
(when (eq start 1)
;; (message "SETUP %s %s" start end)
(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")
+ ;; (message "phps-mode/after-change-functions %s %s %s" start stop length)
+ ))
+
+(defun phps-mode/lex--RUN ()
+ "Run lexer."
+ (interactive)
+ (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
(define-lex phps-mode/tags-lexer
"Lexer that handles PHP buffers."
@@ -1284,7 +1303,8 @@ 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)
- (setq phps-mode/lexer-tokens (semantic-lex-buffer)))
+ (add-hook 'after-change-functions #'phps-mode/after-change-functions)
+ (phps-mode/lex--RUN))
(provide 'phps-mode/lexer)
diff --git a/phps-test-lexer.el b/phps-test-lexer.el
index b2744cc..a45db16 100644
--- a/phps-test-lexer.el
+++ b/phps-test-lexer.el
@@ -54,8 +54,6 @@
(kill-buffer test-buffer)
))
-(defun phps-mode/token-stream-to-string (IGNORE))
-
(defun phps-mode/test-lexer--script-boundaries ()
"Run test for lexer."
@@ -239,7 +237,15 @@
(should (equal phps-mode/lexer-tokens
'((T_OPEN_TAG 1 . 7) (T_START_HEREDOC 7 . 16) (T_ERROR 16 .
55)))))
-)
+ )
+
+(defun phps-mode/test-lexer-get-point-data ()
+ "Return information about point in tokens."
+ (phps-mode/with-test-buffer
+ "<?php\nNAMESPACE MyNameSpace;\nCLASS MyClass {\n\tpublic function
__construct() {\n\t\texit;\n\t}\n}\n"
+ (goto-char 30)
+ (phps-mode/lexer-get-point-data))
+ )
(defun phps-mode/test-lexer ()
"Run test for lexer."
@@ -250,6 +256,7 @@
(phps-mode/test-lexer--complex-tokens)
(phps-mode/test-lexer--namespaces)
(phps-mode/test-lexer--errors)
+ (phps-mode/test-lexer-get-point-data)
;; (message "\n-- Ran all tests for lexer. --")
)
diff --git a/sample-php-files/class.php b/sample-php-files/class.php
index 3fa7bf4..fef6bfe 100644
--- a/sample-php-files/class.php
+++ b/sample-php-files/class.php
@@ -28,4 +28,9 @@ class MyClass {
$this->var = '\\';
}
+ public function heres_more_information() {
+ $var = '23ac';
+ $var2 = '123';
+ }
+
}
- [elpa] externals/phps-mode b3a6308 015/405: Added hook for resetting lexer variables, (continued)
- [elpa] externals/phps-mode b3a6308 015/405: Added hook for resetting lexer variables, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ce656a5 006/405: More general cleaning up, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f3205d5 011/405: Fixed lexing of basic tokens, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 31ca9d5 007/405: More cleaning up, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 79040dc 005/405: Some cleaning up, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 394f7ae 017/405: Fixed issue with empty strings before non-empty strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 41c4fbb 009/405: Lexer unit tests now working, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode be078dc 020/405: Updated readme, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c4a8ca5 016/405: Free lexer tokens does not have properties anymore, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8ed0716 022/405: Started with unit tests for getting point lexer data, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode abcfd01 021/405: Started with function to gather current point data,
Stefan Monnier <=
- [elpa] externals/phps-mode 2475734 018/405: Improved logic for single quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 795053b 013/405: Lexer unit tests using start and ends as well, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 95e749e 028/405: Started with indentation function, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3202213 025/405: Added another unit test for lexer, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode bf59f0a 023/405: More unit tests for getting point lex information, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode de771b5 019/405: Added more unit tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e3a060a 026/405: Handles script breaking single-line comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 7fa9fdb 024/405: More unit tests for lexing comments and doc comments, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 64a3ca8 014/405: Modified start and end for single and double quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 3ea8c64 003/405: Added license, Stefan Monnier, 2019/07/13