Skip to content
Merged
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
28 changes: 18 additions & 10 deletions src/ext/language-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,24 @@
(lem/completion-mode:run-completion completion)))

(define-command indent-line-and-complete-symbol () ()
(if (variable-value 'calc-indent-function :buffer)
(let* ((p (current-point))
(old (point-charpos p)))
(let ((charpos (point-charpos p)))
(handler-case (indent-line p)
(editor-condition ()
(line-offset p 0 charpos))))
(when (= old (point-charpos p))
(complete-symbol)))
(complete-symbol)))
(cond
;; If no indent function is defined then just complete-symbol
((null (variable-value 'calc-indent-function :buffer))
(complete-symbol))

;; Else if there is a highlighted region indent the region
((buffer-mark-p (current-buffer))
(call-command 'indent-region nil))

;; Else indent the line and complete-symbol if the cursor doesn't move
(t (let* ((p (current-point))
(old (point-charpos p))
(charpos (point-charpos p)))
(handler-case (indent-line p)
(editor-condition ()
(line-offset p 0 charpos)))
(when (= old (point-charpos p))
(complete-symbol))))))

(define-command (insert-\(\)-or-wrap (:advice-classes editable-advice)) () ()
(if (mark-active-p (cursor-mark (current-point)))
Expand Down
Loading