[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/phps-mode 287d934 077/405: Updated comments are made un
From: |
Stefan Monnier |
Subject: |
[elpa] externals/phps-mode 287d934 077/405: Updated comments are made un-tested function for moving token positions |
Date: |
Sat, 13 Jul 2019 09:59:47 -0400 (EDT) |
branch: externals/phps-mode
commit 287d9340f9f3c15401f0773925e07259c9d8aec0
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>
Updated comments are made un-tested function for moving token positions
---
phps-functions.el | 34 ++++++++++++++++++++--------------
phps-lexer.el | 20 ++++++++++++++++++++
2 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/phps-functions.el b/phps-functions.el
index 0e84dc5..107b927 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -114,26 +114,32 @@
(setq indent-level (- indent-level (- indent-start
indent-end))))))
+ ;; If this line is part of a doc-comment increase indent with one
unit
(when in-doc-comment
(setq indent-adjust 1))
- (let ((indent-sum (+ (* indent-level tab-width) indent-adjust)))
- (when (not (equal indent-sum (current-indentation)))
- ;; (message "Indenting to %s current column %s" indent-sum
(current-indentation))
- ;; (message "inside scripting, start: %s, end: %s, indenting
to column %s " start end indent-level)
+ (let ((indent-sum (+ (* indent-level tab-width) indent-adjust))
+ current-indentation (current-indentation))
- ;; TODO When indent is changed the trailing tokens just need
to adjust their token positions, this will improve speed of indent-region a lot
- (indent-line-to indent-sum)
+ ;; Only continue if current indentation is wrong
+ (when (not (equal indent-sum current-indentation))
+ (let ((indent-diff (- current-indentation indent-sum)))
+ ;; (message "Indenting to %s current column %s" indent-sum
(current-indentation))
+ ;; (message "inside scripting, start: %s, end: %s, indenting
to column %s " start end indent-level)
- (let ((line-start (line-beginning-position)))
+ (indent-line-to indent-sum)
- ;; Set point of change if it's not set or if it's larger
than current point
- (when (or (not phps-mode/buffer-changes--start)
- (< line-start phps-mode/buffer-changes--start))
- ;; (message "Setting changes start from %s to %s"
phps-mode/buffer-changes--start start)
- (setq phps-mode/buffer-changes--start line-start))
-
- (phps-mode/run-incremental-lex))))))))))
+ ;; TODO When indent is changed the trailing tokens just need
to adjust their token positions, this will improve speed of indent-region a lot
+
+ (let ((line-start (line-beginning-position)))
+
+ ;; Set point of change if it's not set or if it's larger
than current point
+ (when (or (not phps-mode/buffer-changes--start)
+ (< line-start phps-mode/buffer-changes--start))
+ ;; (message "Setting changes start from %s to %s"
phps-mode/buffer-changes--start start)
+ (setq phps-mode/buffer-changes--start line-start))
+
+ (phps-mode/run-incremental-lex)))))))))))
;; TODO Implement this?
(defun phps-mode/indent-region ()
diff --git a/phps-lexer.el b/phps-lexer.el
index 70359c0..8e41347 100644
--- a/phps-lexer.el
+++ b/phps-lexer.el
@@ -1278,6 +1278,26 @@ ANY_CHAR'
(interactive)
(setq phps-mode/lexer-tokens (semantic-lex-buffer)))
+(defun phps-mode/move-lexer-tokens (old-tokens start diff)
+ "Move lexer OLD-TOKENS positions after START with DIFF points."
+ (let ((new-tokens '()))
+ (when old-tokens
+
+ ;; Iterate over all tokens, add those that are to be left unchanged and
+ ;; add modified ones that are to be changed.
+ (catch 'stop-iteration
+ (dolist (token (nreverse old-tokens))
+ (let ((token-symbol (car token))
+ (token-start (car (cdr token)))
+ (token-end (cdr (cdr token))))
+ (if (> token-start start)
+ (let ((new-token-start (+ token-start diff))
+ (new-token-end (+ token-end diff)))
+ (push `(,token-symbol ,new-token-start ,new-token-end)
new-tokens)
+ (push token new-tokens))))))
+
+ new-tokens)))
+
(defun phps-mode/run-incremental-lex ()
"Run incremental lexer based on `phps-mode/buffer-changes--start'."
(when (and (boundp 'phps-mode/buffer-changes--start)
- [elpa] externals/phps-mode bf633d2 061/405: Added test for indent of final line of doc comment block, (continued)
- [elpa] externals/phps-mode bf633d2 061/405: Added test for indent of final line of doc comment block, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode ba8165a 063/405: Fixed bug with brace count not including braces inside double quoted strings, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 99dfc68 067/405: Incremental-lexer deletes affected overlays, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 90d059c 064/405: Fixed bug in incremental lexer logic, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 1be9270 068/405: Updated README, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e57f1e1 075/405: Skipping indentation if it's already correct, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode c57fb5b 073/405: Improved indentation of trailing opening brace, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 5e30a65 076/405: Added TODO items, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 94d4814 078/405: Added test for moving lexer tokens, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a59ef7b 079/405: More unit tests for moving lexer token positions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 287d934 077/405: Updated comments are made un-tested function for moving token positions,
Stefan Monnier <=
- [elpa] externals/phps-mode b3821a1 080/405: Updated TODOs, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f4cd90e 072/405: Updated readme and makefile for running all tests, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f79cf4f 081/405: Started on function for moving lexer states, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e340279 082/405: Added unit tests for moving lexer-state positions, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 89b12ab 084/405: Added autoloads and fixed bug with assigning variable, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode a10cc79 085/405: Debugging a indentation case, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode e30ac0c 083/405: Started implementation of moving lexer and state position when, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 8c919ac 087/405: Added failing indentation test, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode 69ced0d 090/405: Added another unit test for failed indentation, Stefan Monnier, 2019/07/13
- [elpa] externals/phps-mode f2f41a3 088/405: Handles indentation case with } else if (...) {, Stefan Monnier, 2019/07/13