[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode c3d3e3a 182/352: Don't call parse-partial-sexp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode c3d3e3a 182/352: Don't call parse-partial-sexp to find the last opening paren. |
Date: |
Sun, 29 Aug 2021 11:22:41 -0400 (EDT) |
branch: elpa/julia-mode
commit c3d3e3ac37842b3bc33e0697d45b85e22e65cca2
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>
Don't call parse-partial-sexp to find the last opening paren.
This doesn't work because Julia's character syntax cannot simply be
expressed with an Emacs syntax table. However, parse-partial-sexp
is depending on the syntax table to avoid strings and characters.
Instead, just move backwards until we find a paren that isn't in a
string, character or comment.
Fixes https://github.com/JuliaLang/julia/issues/8924
---
julia-mode.el | 37 ++++++++++++++++++++++---------------
1 file changed, 22 insertions(+), 15 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index 89216a9..7419cfe 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -325,20 +325,27 @@ Do not move back beyond MIN."
(+ julia-basic-offset (current-indentation))))))
(defun julia-paren-indent ()
- "Return indent amount of the last opening paren."
- (let* ((p (parse-partial-sexp
- (save-excursion
- ;; only indent by paren if the last open
- ;; paren is closer than the last open
- ;; block
- (or (julia-last-open-block-pos (point-min))
- (point-min)))
- (progn (beginning-of-line)
- (point))))
- (pos (cadr p)))
- (if (or (= 0 (car p)) (null pos))
- nil
- (progn (goto-char pos) (+ 1 (current-column))))))
+ "Return the column position of the innermost containing paren
+before point. Returns nil if we're not within nested parens."
+ (save-excursion
+ (let ((min-pos (or (julia-last-open-block-pos (point-min))
+ (point-min)))
+ (open-count 0))
+ (while (and (> (point) min-pos)
+ (not (plusp open-count)))
+
+ (when (looking-at (rx (any "[" "]" "(" ")")))
+ (unless (or (julia-in-string) (julia-in-char) (julia-in-comment))
+ (cond ((looking-at (rx (any "[" "(")))
+ (incf open-count))
+ ((looking-at (rx (any "]" ")")))
+ (decf open-count)))))
+
+ (backward-char))
+
+ (if (plusp open-count)
+ (+ (current-column) 2)
+ nil))))
(defun julia-indent-line ()
"Indent current line of julia code."
@@ -348,7 +355,7 @@ Do not move back beyond MIN."
(indent-line-to
(or
;; If we're inside an open paren, indent to line up arguments.
- (save-excursion (ignore-errors (julia-paren-indent)))
+ (ignore-errors (julia-paren-indent))
;; If we're on a block end keyword, unindent.
(save-excursion
(beginning-of-line)
- [nongnu] elpa/julia-mode 0e3217f 243/352: Enable travis on emacs23, emacs24, emacs-snapshot., (continued)
- [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
- [nongnu] elpa/julia-mode c3d3e3a 182/352: Don't call parse-partial-sexp to find the last opening paren.,
ELPA Syncer <=
- [nongnu] elpa/julia-mode c45c786 335/352: Add more tests, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 549a7b4 341/352: Remove C_NULL from constants and add Cvoid, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 13a3c53 344/352: Merge branch 'master' into triple-quote-cmd, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ac7431c 174/352: Mark @ and ! as a symbol constituents, as suggested by @Clemens-H., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ac55340 175/352: Factoring out a types regex., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d96a08c 180/352: Refactoring julia-char-regex as an rx form., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 76d5d75 183/352: Optimising julia-at-keyword., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 9cdad57 187/352: Make julia-char-regex stricter., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ff5fc36 202/352: julia-mode.el: allow space or no space after :: and <:, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 05f002c 203/352: When indenting code, limit how far back we search., ELPA Syncer, 2021/08/29