Skip to content

Commit aadf295

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master'
2 parents 5551061 + 125c81b commit aadf295

1 file changed

Lines changed: 25 additions & 7 deletions

File tree

julia-mode.el

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -452,12 +452,6 @@ As a result, it is true inside \"foo\", \\=`foo\\=` and \\='f\\='."
452452
;; of overlapping triple-quotes with first escaped
453453
((backward-char 2)))))
454454

455-
(defun julia-in-multiline-string (&optional syntax-pps)
456-
"Return non-nil if point is inside multi-line string using SYNTAX-PPS."
457-
(and (julia-in-string syntax-pps)
458-
(save-excursion (beginning-of-line)
459-
(julia-in-string syntax-pps))))
460-
461455
(defun julia-in-brackets ()
462456
"Return non-nil if point is inside square brackets."
463457
(let ((start-pos (point))
@@ -674,7 +668,7 @@ only comments."
674668
(defun julia-indent-line ()
675669
"Indent current line of julia code."
676670
(interactive)
677-
(if (julia-in-multiline-string)
671+
(if (save-excursion (beginning-of-line) (julia-in-string))
678672
'noindent
679673
(let* ((point-offset (- (current-column) (current-indentation))))
680674
(indent-line-to
@@ -705,6 +699,29 @@ only comments."
705699
(when (>= point-offset 0)
706700
(move-to-column (+ (current-indentation) point-offset))))))
707701

702+
(defun julia-fill-paragraph (&optional justify region)
703+
"`fill-paragraph-function' in julia-mode"
704+
(interactive "P")
705+
(let ((fill-paragraph-function nil))
706+
(cond (region (fill-paragraph justify region))
707+
;; in strings, only consider the line containing the first
708+
;; non-whitespace character in the string up until the closing quote
709+
;; (not including it or its indentation).
710+
((julia-in-string)
711+
(let* ((str-start (nth 8 (syntax-ppss)))
712+
(str-fill-start
713+
(save-excursion
714+
(goto-char str-start) (skip-syntax-forward " \"|>")
715+
(beginning-of-line) (point)))
716+
(str-inner-end
717+
(save-excursion
718+
(goto-char str-start) (forward-sexp)
719+
(skip-syntax-backward " \"|") (point))))
720+
(save-restriction (narrow-to-region str-fill-start str-inner-end)
721+
(fill-paragraph justify))))
722+
((julia-in-comment) (fill-comment-paragraph justify))
723+
(t (fill-paragraph justify region)))))
724+
708725

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

0 commit comments

Comments
 (0)