[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 6ae7fab 043/352: improvements to julia-mode ind
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 6ae7fab 043/352: improvements to julia-mode indenting: |
Date: |
Sun, 29 Aug 2021 11:22:12 -0400 (EDT) |
branch: elpa/julia-mode
commit 6ae7fab5bf165acb55107a1140af963ac8152dda
Author: Jeff Bezanson <bezanson@post.harvard.edu>
Commit: Yichao Yu <yyc1992@gmail.com>
improvements to julia-mode indenting:
. skip keywords inside comments
. skip quoted keywords
. fix stack overflow in last-open-block; elisp not tail recursive
. pick same indent as previous line if unsure
pfor macro
---
julia-mode.el | 58 +++++++++++++++++++++++++++++++++-------------------------
1 file changed, 33 insertions(+), 25 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index 99c1bf0..85ae25d 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -70,24 +70,34 @@
(or (equal item (car lst))
(member item (cdr lst)))))
-; TODO: skip keywords inside strings and comments
+; TODO: skip keywords inside strings
+
+(defun in-comment ()
+ (equal (char-after (+ (line-beginning-position) (current-indentation)))
+ ?#))
(defun at-keyword (kw-list)
- ; not a keyword if used as a field name, X.word
+ ; not a keyword if used as a field name, X.word, or quoted, :word
(and (or (= (point) 1)
- (not (equal (char-before (point)) ?.)))
+ (and (not (equal (char-before (point)) ?.))
+ (not (equal (char-before (point)) ?:))))
+ (not (in-comment))
(member (current-word) kw-list)))
; get the column of the last open block
-(defun last-open-block (min count)
- (cond ((> count 0) (+ 4 (current-indentation)))
- ((<= (point) min) nil)
- (t (backward-word 1)
- (cond ((at-keyword julia-block-start-keywords)
- (last-open-block min (+ count 1)))
- ((equal (current-word) "end")
- (last-open-block min (- count 1)))
- (t (last-open-block min count))))))
+(defun last-open-block (min)
+ (do ((count 0
+ (cond ((at-keyword julia-block-start-keywords)
+ (+ count 1))
+ ((and (equal (current-word) "end")
+ (not (in-comment)))
+ (- count 1))
+ (t count))))
+ ((or (> count 0) (<= (point) min))
+ (if (> count 0)
+ (+ 4 (current-indentation))
+ nil))
+ (backward-word 1)))
; return indent implied by a special form opening on the previous line, if any
(defun form-indent ()
@@ -139,20 +149,18 @@
(beginning-of-line)
(forward-to-indentation 0)
(at-keyword julia-block-end-keywords))))
- (error2nil (+ (last-open-block (point-min) 0)
+ (error2nil (+ (last-open-block (point-min))
(if endtok -4 0)))))
-; take same indentation as previous line
-; (save-excursion (beginning-of-line)
-; (forward-line -1)
-; (forward-to-indentation 0)
-; (current-column))
- (save-excursion
- (if (and (not (equal (point-min) (line-beginning-position)))
- (progn
- (forward-line -1)
- (end-of-line) (backward-char 1)
- (equal (char-after (point)) ?=)))
- 4 nil))
+ ;; take same indentation as previous line
+ (save-excursion (forward-line -1)
+ (current-indentation))
+ ;(save-excursion
+ ; (if (and (not (equal (point-min) (line-beginning-position)))
+ ; (progn
+ ; (forward-line -1)
+ ; (end-of-line) (backward-char 1)
+ ; (equal (char-after (point)) ?=)))
+ ; 4 nil))
0))
(when (at-keyword julia-block-end-keywords)
(forward-word 1)))
- [nongnu] elpa/julia-mode 89e42a4 023/352: Minor updates to julia-mode for Ptr and eval., (continued)
- [nongnu] elpa/julia-mode 89e42a4 023/352: Minor updates to julia-mode for Ptr and eval., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode fc44ae6 026/352: more work on type inference; adding isbound(), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 06ff69e 027/352: type does not use block syntax, fix emacs mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 02d443b 034/352: fixing type inference for builtin cases of convert(), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c01429b 044/352: fixing some integer sizes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 3ae6315 046/352: improving indenting of block syntax inside parens, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode dbe56c0 050/352: Work on sparse binary operators, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 0bd625b 028/352: misc. stuff:, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode efce160 032/352: adding bitstype syntax, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 29c7950 033/352: adding boot.j, allowing us to move more primitive definitions to julia, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 6ae7fab 043/352: improvements to julia-mode indenting:,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 2f7441b 058/352: AbstractArray, AbstractVector, AbstractMatrix highlighting in julia-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 1312fa7 062/352: removing Tensor from list of syntax highlighted types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode b35dd82 088/352: more | -> for conversion, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode e225b48 098/352: Update mailmap, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 2ee8be9 089/352: fix #828, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 3fe9882 114/352: Add emacs mode usage, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 3913d39 117/352: Add BigInt and BigFloat to julia-mode.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 3cb85b4 141/352: Fixing some byte-compilation warnings., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode c47ccdc 150/352: Highlight parent types in type declarations., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d76f89a 155/352: Preserve point position when indenting., ELPA Syncer, 2021/08/29