[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode d3366f4 250/352: Added using, fixed bugs, added
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode d3366f4 250/352: Added using, fixed bugs, added tests. |
Date: |
Sun, 29 Aug 2021 11:22:55 -0400 (EDT) |
branch: elpa/julia-mode
commit d3366f41c58831bd711e4bfb0f2f4fc6389754e7
Author: Tamas K. Papp <tkpapp@gmail.com>
Commit: Tamas K. Papp <tkpapp@gmail.com>
Added using, fixed bugs, added tests.
Handling using suggested by @tkelman.
---
julia-mode-tests.el | 21 +++++++++++++++++++++
julia-mode.el | 28 ++++++++++++++++------------
2 files changed, 37 insertions(+), 12 deletions(-)
diff --git a/julia-mode-tests.el b/julia-mode-tests.el
index 647323b..faeaf66 100644
--- a/julia-mode-tests.el
+++ b/julia-mode-tests.el
@@ -292,6 +292,27 @@ a = 1"
"# if foo
a = 1"))
+(ert-deftest julia--test-indent-import-export-using ()
+ "Toplevel using, export, and import."
+ (julia--should-indent
+ "
+export bar, baz,
+quux"
+ "
+export bar, baz,
+ quux")
+ (julia--should-indent
+ "
+using Foo: bar ,
+baz,
+quux
+notpartofit"
+ "
+using Foo: bar ,
+ baz,
+ quux
+notpartofit"))
+
(defun julia--run-tests ()
(interactive)
(if (featurep 'ert)
diff --git a/julia-mode.el b/julia-mode.el
index 88ca566..a8ab0c6 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -416,25 +416,29 @@ a keyword if used as a field name, X.word, or quoted,
:word."
(if (condition-case nil (backward-sexp) (error t))
(ignore-errors (backward-char))))
-(defun julia-following-import-export ()
+(defun julia-following-import-export-using ()
"If the current line follows an `export` or `import` keyword
with valid syntax, return the position of the keyword, otherwise
`nil`. Works by stepping backwards through comma-separated
symbol, gives up when this is not true."
- (let ((done nil))
+ ;; Implementation accepts a single Module: right after the keyword, and saves
+ ;; the module name for future use, but does not enforce that `export` has no
+ ;; module name.
+ (let ((done nil) ; find keyword or give up
+ (module nil)) ; found "Module:"
(save-excursion
(beginning-of-line)
(while (and (not done) (< 0 (point)))
(julia-safe-backward-sexp)
(cond
- ((looking-at (rx "export"))
+ ((looking-at (rx (or "import" "export" "using")))
(setf done (point)))
- ((looking-at (rx "import"
- (+ space)
- (opt (* (or word (syntax symbol)))
- (0+ space) ":" (0+ space))))
- (setf done (point)))
- ((looking-at (rx (* (or word (syntax symbol))) (0+ space) ",")))
+ ((looking-at (rx (group (* (or word (syntax symbol)))) (0+ space)
":"))
+ (if module
+ (setf done 'broken)
+ (setf module (match-string-no-properties 1))))
+ ((looking-at (rx (* (or word (syntax symbol))) (0+ space) ","))
+ (when module (setf done 'broken)))
(t (setf done 'broken)))))
(if (eq done 'broken)
nil
@@ -560,9 +564,9 @@ meaning always increase indent on TAB and decrease on
S-TAB."
;; indenting inside strings
(current-indentation)))))
-(defun julia-indent-import-export ()
+(defun julia-indent-import-export-using ()
"Indent offset for lines that follow `import` or `export`, otherwise nil."
- (when (julia-following-import-export)
+ (when (julia-following-import-export-using)
julia-indent-offset))
(defun julia-indent-line ()
@@ -580,7 +584,7 @@ meaning always increase indent on TAB and decrease on
S-TAB."
;; indent due to hanging operators (lines ending in an operator)
(julia-indent-hanging)
;; indent for import and export
- (julia-indent-import-export)
+ (julia-indent-import-export-using)
;; Indent according to how many nested blocks we are in.
(save-excursion
(beginning-of-line)
- [nongnu] elpa/julia-mode edaaff2 276/352: Bin op chars (#44), (continued)
- [nongnu] elpa/julia-mode edaaff2 276/352: Bin op chars (#44), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c20a4e5 300/352: generate new LaTeX substitutions using 1.3-pre., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode b194039 302/352: Merge pull request #72 from FelipeLema/unicode-for-in, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode addd3d4 305/352: Merge pull request #81 from JuliaEditorSupport/tp/add-substitution-tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 9df3a7e 307/352: fix variable renaming, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 1b8682b 308/352: fix travis setup, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 43cfc91 109/352: Update mailmap, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7304a4a 166/352: rename None to Union(), and Nothing to Void. fixes #8423, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e22219f 266/352: Added another test., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 2486d1e 247/352: Replace {UTF8, ASCII, Byte}String with String, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d3366f4 250/352: Added using, fixed bugs, added tests.,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 0e3217f 243/352: Enable travis on emacs23, emacs24, emacs-snapshot., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c9d8ca6 265/352: Fix backslash character class., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 46d2469 272/352: Merge pull request #39 from rfourquet/rf/where, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode cb41ae0 303/352: Add unit tests for LaTeX substitution., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode df2ab77 319/352: test on Emacs25, simplify setup code (#95), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 5238f9a 323/352: Increase lookback. (#98), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 7de3b0c 330/352: Remove highlighting for :: and <:. (#112), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 1c122f1 328/352: Fix multiple type face highlighting. Add tests. (#110), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 6e9e60b 327/352: Fix forloop matching on == instead of = (#105), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ac22747 178/352: remove trailing ws from repo, ELPA Syncer, 2021/08/29