[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode d76f89a 155/352: Preserve point position when i
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode d76f89a 155/352: Preserve point position when indenting. |
Date: |
Sun, 29 Aug 2021 11:22:35 -0400 (EDT) |
branch: elpa/julia-mode
commit d76f89aeedd237912d62594d7185f9d80cb3176b
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>
Preserve point position when indenting.
Fixes #7966.
The new logic is as follows:
If point is in the leading whitespace, jump to the first non-whitespace
character.
Before:
| foo
After <tab>:
|foo
If point is on non-whitespace character, preserve its offset after
indentation.
Before:
fo|o
After <tab>:
fo|o
Finally, if point is on an end keyword (see `julia-block-end-keywords`),
then skip to the end. This allows repeated <tab> to navigate out of
blocks.
Before:
| end
end
<tab> once:
end|
end
<tab> again:
end
end|
---
julia-mode.el | 34 +++++++++++++++++++---------------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index 9361406..8121aea 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -259,7 +259,7 @@ Do not move back beyond MIN."
(defun julia-indent-line ()
"Indent current line of julia code."
(interactive)
-; (save-excursion
+ (let* ((point-offset (- (current-column) (current-indentation))))
(end-of-line)
(indent-line-to
(or (save-excursion (ignore-errors (julia-paren-indent)))
@@ -269,22 +269,26 @@ Do not move back beyond MIN."
(forward-to-indentation 0)
(julia-at-keyword julia-block-end-keywords))))
(ignore-errors (+ (julia-last-open-block (point-min))
- (if endtok (- julia-basic-offset) 0)))))
- ;; previous line ends in =
- (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)) ?=)))
- (+ julia-basic-offset (current-indentation))
- nil))
- ;; take same indentation as previous line
- (save-excursion (forward-line -1)
- (current-indentation))
+ (if endtok (- julia-basic-offset) 0)))))
+ ;; previous line ends in =
+ (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)) ?=)))
+ (+ julia-basic-offset (current-indentation))
+ nil))
+ ;; take same indentation as previous line
+ (save-excursion (forward-line -1)
+ (current-indentation))
0))
+ ;; Point is now at the beginning of indentation, restore it
+ ;; to its original position (relative to indentation).
+ (when (>= point-offset 0)
+ (move-to-column (+ (current-indentation) point-offset)))
(when (julia-at-keyword julia-block-end-keywords)
- (forward-word 1)))
+ (forward-word 1))))
(defalias 'julia-mode-prog-mode
(if (fboundp 'prog-mode)
- [nongnu] elpa/julia-mode 6ae7fab 043/352: improvements to julia-mode indenting:, (continued)
- [nongnu] elpa/julia-mode 6ae7fab 043/352: improvements to julia-mode indenting:, ELPA Syncer, 2021/08/29
- [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 <=
- [nongnu] elpa/julia-mode 7eb9038 161/352: Highlight the function name, not the module name, in declarations., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 9795a7c 021/352: Mailmap file to normalize commit names and emails., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 116a9f9 013/352: disabling automatic conversion, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 1f9a1a7 014/352: redesign of type system and its syntax:, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode de2a2a3 016/352: Rename: Double => Float64, double => float64., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode ecc3f0c 017/352: parsing chains of * or + into single calls, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 16969b1 018/352: removing special syntax of quote(), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8603d3b 019/352: making array dims an ntuple, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 52efd2a 020/352: small tweaks to viral's script and its build process, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 232e758 022/352: starting some basic pretty-printing of Exprs, ELPA Syncer, 2021/08/29