[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 0df9ca4 240/352: julia-mode: Indentation perfor
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 0df9ca4 240/352: julia-mode: Indentation performance improvements |
Date: |
Sun, 29 Aug 2021 11:22:53 -0400 (EDT) |
branch: elpa/julia-mode
commit 0df9ca44c4ba888341801ea00bec6e83ab6b208b
Author: justbur <justin@burkett.cc>
Commit: Yichao Yu <yyc1992@gmail.com>
julia-mode: Indentation performance improvements
These focus on the block indentation algorithm, and basically remove
unnecessary checks.
1. If we jump out of any comments at the beginning of the block
indentation routine we don't need to check later if we are in a
comment because backward-sexp jumps over comment blocks.
2. We also don't need to check if an end keyword is inside of
brackets, because any time we are in brackets indentation is
handled by julia-paren-indent.
For an example of performance improvements, the time to indent lapack.jl
falls from ~9s to ~3s on my machine.
Added an indentation test for the end keyword appearing in brackets.
---
julia-mode-tests.el | 14 ++++++++++++++
julia-mode.el | 18 +++++++++++-------
2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/julia-mode-tests.el b/julia-mode-tests.el
index 239d078..bd57f17 100644
--- a/julia-mode-tests.el
+++ b/julia-mode-tests.el
@@ -270,6 +270,20 @@ bar
end
\"\"\""))
+(ert-deftest julia--test-indent-of-end-in-brackets ()
+ "Ignore end keyword in brackets for the purposes of indenting blocks."
+ (julia--should-indent
+ "begin
+ begin
+ arr[1: end - 1]
+ end
+end"
+ "begin
+ begin
+ arr[1: end - 1]
+ end
+end"))
+
(defun julia--run-tests ()
(interactive)
(if (featurep 'ert)
diff --git a/julia-mode.el b/julia-mode.el
index 9bad399..bf365a4 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -401,12 +401,13 @@ As a result, it is true inside \"foo\", `foo` and 'f'."
(defun julia-at-keyword (kw-list)
"Return the word at point if it matches any keyword in KW-LIST.
KW-LIST is a list of strings. The word at point is not considered
-a keyword if used as a field name, X.word, or quoted, :word."
+a keyword if used as a field name, X.word, or quoted, :word.
+
+Assumes that point is not inside a comment."
(and (or (= (point) 1)
(and (not (equal (char-before (point)) ?.))
(not (equal (char-before (point)) ?:))))
(member (current-word t) kw-list)
- (not (julia-in-comment))
;; 'end' is not a keyword when used for indexing, e.g. foo[end-2]
(or (not (equal (current-word t) "end"))
(not (julia-in-brackets)))))
@@ -426,9 +427,7 @@ Do not move back beyond position MIN."
(setq count
(cond ((julia-at-keyword julia-block-start-keywords)
(+ count 1))
- ;; fixme: breaks on strings
- ((and (equal (current-word t) "end")
- (not (julia-in-comment)) (not (julia-in-brackets)))
+ ((equal (current-word t) "end")
(- count 1))
(t count))))
(if (> count 0)
@@ -547,13 +546,18 @@ meaning always increase indent on TAB and decrease on
S-TAB."
;; note: if this first function returns nil the beginning of the line
;; cannot be in a string
(julia-indent-in-string)
- ;; If we're inside an open paren, indent to line up arguments.
+ ;; If we're inside an open paren, indent to line up arguments. After
this,
+ ;; we cannot be inside parens which includes brackets
(julia-paren-indent)
- ;; indent due to hanging operators or a line ending in =
+ ;; indent due to hanging operators (lines ending in an operator)
(julia-indent-hanging)
;; Indent according to how many nested blocks we are in.
(save-excursion
(beginning-of-line)
+ ;; jump out of any comments
+ (let ((state (syntax-ppss)))
+ (when (nth 4 state)
+ (goto-char (nth 8 state))))
(forward-to-indentation 0)
(let ((endtok (julia-at-keyword julia-block-end-keywords))
(last-open-block (julia-last-open-block (- (point)
julia-max-block-lookback))))
- [nongnu] elpa/julia-mode 65cfc0d 201/352: julia-mode.el: add a bunch of builtin types, (continued)
- [nongnu] elpa/julia-mode 65cfc0d 201/352: julia-mode.el: add a bunch of builtin types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode fabafad 200/352: julia-mode.el: improve matching of function assignment syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4b41b85 207/352: julia-mode.el: `f(x) == something` does not define a function, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode a37d541 214/352: Changed input from TeX mode to use Julia unicode input, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 2e72a0b 213/352: Removed (setq comint-proccess-echoes t) from contrib/julia-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 716d58c 217/352: Added autoload cookie to inferior-julia function in contrib/julia-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode b1e02f1 230/352: rename: FloatingPoint => AbstractFloat, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 0583ee3 232/352: String was renamed to AbstractString, replace everywhere, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4afb7be 229/352: Update mailmap., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e7c8550 228/352: Bind indent offset to its standard value for tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 0df9ca4 240/352: julia-mode: Indentation performance improvements,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 2d860b1 248/352: Merge pull request #18 from JuliaLang/yyc/str-cleanup, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e4b3428 244/352: Remove test branch in travis, add README, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ad6a494 301/352: Merge pull request #78 from tpapp/tp/update-latexsubs, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 109747e 132/352: eliminate StoredArray (fix #6212, #987); UniformScaling is no longer an AbstractArray (#5810), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 84d9a19 147/352: Fix emacs highlighting of symbols that contain keywords., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode fc04731 153/352: Highlight parameter types and subtypes., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 70d6482 160/352: `throw` and `error` are built-in functions that we should highlight., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ba5ba4c 168/352: Highlight function names when defined with the assignment syntax., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode caab4dc 172/352: Respect the active region when indenting., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e5f8145 191/352: Use a separate face for Julia macro invocations., ELPA Syncer, 2021/08/29