[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/julia-mode 5e52d81 188/352: Don't error if the first line
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/julia-mode 5e52d81 188/352: Don't error if the first line of the file is empty. |
Date: |
Sun, 29 Aug 2021 11:22:42 -0400 (EDT) |
branch: elpa/julia-mode
commit 5e52d814f0bab15b6476e08581996686a9ee44b1
Author: Wilfred Hughes <me@wilfred.me.uk>
Commit: Yichao Yu <yyc1992@gmail.com>
Don't error if the first line of the file is empty.
We can't go back before (point-min), and Emacs errors if we try.
---
julia-mode.el | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/julia-mode.el b/julia-mode.el
index 7705fdf..0216279 100644
--- a/julia-mode.el
+++ b/julia-mode.el
@@ -234,6 +234,7 @@ Handles both single-line and multi-line comments."
(cond
((julia-in-comment) nil)
((julia-in-string) nil)
+ ((<= (point) (1+ (point-min))) nil)
(:else
(save-excursion
;; See if point is inside a character, e.g. '|x'
@@ -242,17 +243,18 @@ Handles both single-line and multi-line comments."
(backward-char 1)
;; Move back one more character, as julia-char-regex checks
;; for whitespace/paren/etc before the single quote.
- (backward-char 1)
+ (ignore-errors (backward-char 1)) ; ignore error from being at
(point-min)
(if (looking-at julia-char-regex)
t
;; If point was in a \ character (i.e. we started at '\|\'),
;; we need to move back once more.
- (if (looking-at (rx "'\\"))
- (progn
- (backward-char 1)
- (looking-at julia-char-regex))
- nil))))))
+ (ignore-errors
+ (if (looking-at (rx "'\\"))
+ (progn
+ (backward-char 1)
+ (looking-at julia-char-regex))
+ nil)))))))
(defun julia-in-brackets ()
"Return non-nil if point is inside square brackets."
@@ -322,6 +324,12 @@ Do not move back beyond MIN."
(goto-char pos)
(+ julia-basic-offset (current-indentation))))))
+(defsubst julia--safe-backward-char ()
+ "Move back one character, but don't error if we're at the
+beginning of the buffer."
+ (unless (eq (point) (point-min))
+ (backward-char)))
+
(defun julia-paren-indent ()
"Return the column position of the innermost containing paren
before point. Returns nil if we're not within nested parens."
@@ -339,7 +347,7 @@ before point. Returns nil if we're not within nested
parens."
((looking-at (rx (any "]" ")")))
(decf open-count)))))
- (backward-char))
+ (julia--safe-backward-char))
(if (plusp open-count)
(+ (current-column) 2)
@@ -364,14 +372,15 @@ before point. Returns nil if we're not within nested
parens."
(ignore-errors (+ (julia-last-open-block (point-min))
(if endtok (- julia-basic-offset) 0)))))
;; If the previous line ends in =, increase the indent.
- (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))
+ (ignore-errors ; if previous line is (point-min)
+ (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)))
;; Otherwise, use the same indentation as previous line.
(save-excursion (forward-line -1)
(current-indentation))
- [nongnu] elpa/julia-mode 69439e2 055/352: Fix Stephan's last name in .mailmap., (continued)
- [nongnu] elpa/julia-mode 69439e2 055/352: Fix Stephan's last name in .mailmap., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 5762e13 133/352: remove * and div for Char, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 40c5e82 185/352: Fix indentation when we're indenting a line that has an open paren after point., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4f72dfa 246/352: Merge pull request #13 from JuliaLang/keywords_in_comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 344e6c2 283/352: Merge pull request #42 from antoine-levitt/math-insert, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 115d4dc 277/352: Regenerate latex auto completion (#45), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode db84928 299/352: Merge pull request #74 from non-Jedi/emoji, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d21b83d 316/352: Merge pull request #93 from non-Jedi/julia-mode-latexsubs_feature, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 839726a 336/352: Merge pull request #123 from ronisbr/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 2395931 142/352: Since julia-mode.el contains utf-8 chars, mark the file as utf-8., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 5e52d81 188/352: Don't error if the first line of the file is empty.,
ELPA Syncer <=
- [nongnu] elpa/julia-mode b66f8a4 274/352: Insertion of math symbols in julia using auctex's mechanism, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 864e124 311/352: remove newline, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 686bed3 309/352: remove unused lexical args that gave a warning, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 4515765 320/352: add a changelog (#96), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode bfa54b2 331/352: Minor point about preferring the rx macro for regexs., ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 88d7d87 332/352: Merge pull request #121 from JuliaEditorSupport/tp/prefer-rx, ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d91f1d0 324/352: Remove regexp-opt workarounds for Emacs < 24 (#101), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode d69b095 342/352: Removed require statement for auctex that broke prettify. Fixes #99 (#116), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 8ea90c7 347/352: Rec/quoted quote (#143), ELPA Syncer, 2021/08/29
- [nongnu] elpa/julia-mode 5cccdbd 350/352: Fixed installation documentation (#147), ELPA Syncer, 2021/08/29