Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions julia-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -452,12 +452,6 @@ 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))
Expand Down Expand Up @@ -674,7 +668,7 @@ only comments."
(defun julia-indent-line ()
"Indent current line of julia code."
(interactive)
(if (julia-in-multiline-string)
(if (save-excursion (beginning-of-line) (julia-in-string))
'noindent
(let* ((point-offset (- (current-column) (current-indentation))))
(indent-line-to
Expand Down Expand Up @@ -705,6 +699,29 @@ only comments."
(when (>= point-offset 0)
(move-to-column (+ (current-indentation) point-offset))))))

(defun julia-fill-paragraph (&optional justify region)
"`fill-paragraph-function' in julia-mode"
(interactive "P")
(let ((fill-paragraph-function nil))
(cond (region (fill-paragraph justify region))
;; in strings, only consider the line containing the first
;; non-whitespace character in the string up until the closing quote
;; (not including it or its indentation).
((julia-in-string)
(let* ((str-start (nth 8 (syntax-ppss)))
(str-fill-start
(save-excursion
(goto-char str-start) (skip-syntax-forward " \"|>")
(beginning-of-line) (point)))
(str-inner-end
(save-excursion
(goto-char str-start) (forward-sexp)
(skip-syntax-backward " \"|") (point))))
(save-restriction (narrow-to-region str-fill-start str-inner-end)
(fill-paragraph justify))))
((julia-in-comment) (fill-comment-paragraph justify))
(t (fill-paragraph justify region)))))


;;; Navigation
;; based off python.el
Expand Down Expand Up @@ -850,6 +867,7 @@ Return nil if point is not in a function, otherwise point."
(setq-local indent-line-function #'julia-indent-line)
(setq-local beginning-of-defun-function #'julia-beginning-of-defun)
(setq-local end-of-defun-function #'julia-end-of-defun)
(setq-local fill-paragraph-function #'julia-fill-paragraph)
;; If completion before point has higher priority than around, \lamb
;; can get completed to \lambdamb
(add-hook 'completion-at-point-functions
Expand Down