From 273448455d9fe53bff49153480eeffd24bc88521 Mon Sep 17 00:00:00 2001 From: Robert Burnett Date: Wed, 24 Jun 2026 19:21:51 -0500 Subject: [PATCH 1/2] refactor tab command --- src/ext/language-mode.lisp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/ext/language-mode.lisp b/src/ext/language-mode.lisp index 573a6bd11..ccfecbf45 100644 --- a/src/ext/language-mode.lisp +++ b/src/ext/language-mode.lisp @@ -469,16 +469,26 @@ (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 ident 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)) + (with-point ((start (region-beginning (current-buffer))) + (end (region-end (current-buffer)))) + (indent-points start end))) + + ;; 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))) From 651cd2a8c9a4fb8373e2d28a8a8c023796cda125 Mon Sep 17 00:00:00 2001 From: Robert Wess Burnett Date: Wed, 8 Jul 2026 12:39:26 -0500 Subject: [PATCH 2/2] delegate indentation work to indent-region command --- src/ext/language-mode.lisp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/ext/language-mode.lisp b/src/ext/language-mode.lisp index ccfecbf45..7e2639726 100644 --- a/src/ext/language-mode.lisp +++ b/src/ext/language-mode.lisp @@ -470,15 +470,13 @@ (define-command indent-line-and-complete-symbol () () (cond - ;; If no ident function is defined then just complete-symbol + ;; 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)) - (with-point ((start (region-beginning (current-buffer))) - (end (region-end (current-buffer)))) - (indent-points start end))) + (call-command 'indent-region nil)) ;; Else indent the line and complete-symbol if the cursor doesn't move (t (let* ((p (current-point))