[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode c87949315f 02/22: Remove hack for indentation i
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode c87949315f 02/22: Remove hack for indentation in strings |
Date: |
Thu, 4 May 2023 11:00:51 -0400 (EDT) |
branch: elpa/julia-mode
commit c87949315f81f8744d4ddef821a92bc56b61224b
Author: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>
Commit: Adam Beckmeyer <adam_gpg@thebeckmeyers.xyz>
Remove hack for indentation in strings
---
julia-mode.el | 78 +++++++++++++++++++++++++++--------------------------------
1 file changed, 35 insertions(+), 43 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index cbd6f39112..b15b182486 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -365,6 +365,12 @@ As a result, it is true inside \"foo\", `foo` and 'f'."
;; of overlapping triple-quotes with first escaped
((backward-char 2)))))
+(defun julia-in-multiline-string (&optional syntax-pps)
+ "Return non-nil if point is inside multi-line string using SYNTAX-PPS."
+ (and (julia-in-string syntax-pps)
+ (save-excursion (beginning-of-line)
+ (julia-in-string syntax-pps))))
+
(defun julia-in-brackets ()
"Return non-nil if point is inside square brackets."
(let ((start-pos (point))
@@ -573,19 +579,6 @@ only comments."
;; above
(+ julia-indent-offset prev-indent)))))))
-(defun julia-indent-in-string ()
- "Indentation inside strings with newlines is \"manual\",
-meaning always increase indent on TAB and decrease on S-TAB."
- (save-excursion
- (beginning-of-line)
- (when (julia-in-string)
- (if (member this-command '(julia-latexsub-or-indent
- ess-indent-or-complete))
- (+ julia-indent-offset (current-indentation))
- ;; return the current indentation to prevent other functions from
- ;; indenting inside strings
- (current-indentation)))))
-
(defun julia-indent-import-export-using ()
"Indent offset for lines that follow `import` or `export`, otherwise nil."
(when (julia-following-import-export-using)
@@ -594,37 +587,36 @@ meaning always increase indent on TAB and decrease on
S-TAB."
(defun julia-indent-line ()
"Indent current line of julia code."
(interactive)
- (let* ((point-offset (- (current-column) (current-indentation))))
- (indent-line-to
- (or
- ;; note: if this first function returns nil the beginning of the line
- ;; cannot be in a string
- (julia-indent-in-string)
- ;; indent due to hanging operators (lines ending in an operator)
- (julia-indent-hanging)
- ;; indent for import and export
- (julia-indent-import-export-using)
- ;; use julia-paren-indent along with block indentation
- (let ((paren-indent (or (julia-paren-indent) 0)))
- ;; 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))
+ (if (julia-in-multiline-string)
+ 'noindent
+ (let* ((point-offset (- (current-column) (current-indentation))))
+ (indent-line-to
+ (or
+ ;; indent due to hanging operators (lines ending in an operator)
+ (julia-indent-hanging)
+ ;; indent for import and export
+ (julia-indent-import-export-using)
+ ;; use julia-paren-indent along with block indentation
+ (let ((paren-indent (or (julia-paren-indent) 0)))
+ ;; 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))))
- (max paren-indent (- (or last-open-block paren-indent)
- ;; subtract indentation if we're at the end
of a block
- (if (or endtok
- (julia-at-keyword
julia-block-start-keywords-no-indent))
- julia-indent-offset 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)))))
+ (max paren-indent (- (or last-open-block paren-indent)
+ ;; subtract indentation if we're at the end
of a block
+ (if (or endtok
+ (julia-at-keyword
julia-block-start-keywords-no-indent))
+ julia-indent-offset 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))))))
;;; Navigation
- [nongnu] elpa/julia-mode updated (a20367f282 -> 7e301f4414), ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 8078bb9d88 01/22: Add completion-at-point functions for completing LaTeX strings, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 307b4afa9a 03/22: Create julia-mode-abbrev-table filled with latexsub abbrevs, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode d52cb3e885 10/22: Provide alternative to indent-for-tab-command for use with company, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 77ff4f1146 15/22: comment code, fix docstring width, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode d684bf172a 17/22: further byte compilation docstring warning fixes, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 759e8a8e57 18/22: Merge branch 'master' into tp/find-latexsub-end, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode c87949315f 02/22: Remove hack for indentation in strings,
ELPA Syncer <=
- [nongnu] elpa/julia-mode 4d2047666f 04/22: Remove old latexsub implementation, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 0160fecf90 05/22: Override TAB to do completion in julia-mode buffers, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode f92227a87f 09/22: Fix whitespace, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode f359fd01c5 12/22: Add predicate to "around" latex symbol completion, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 347c5c11c5 14/22: cleanup tests, bit more verbose to compare matched string, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 74e13dc460 16/22: use cl-flet, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 15326d6992 08/22: Remove extraneous -mode suffix from julia-- functions, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 016721004c 19/22: Merge pull request #185 from JuliaEditorSupport/tp/find-latexsub-end, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode 8f3afcb99e 21/22: ignore warnings on snaphot, ELPA Syncer, 2023/05/04
- [nongnu] elpa/julia-mode f854352d76 11/22: Fix byte-compilation warnings for company-integration code, ELPA Syncer, 2023/05/04