Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: treat as selecting current line if no region is selected for comments. #1663

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
11 changes: 11 additions & 0 deletions src/ext/language-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,18 @@
(uncomment-region)
(comment-region)))

(defun select-current-line-if-no-region-is-selected (start end)
(when (point= start end)
(setf start (line-start start))
(setf end (line-end end))))

(defun commented-region-p ()
(alexandria:when-let ((line-comment (variable-value 'line-comment :buffer)))
(with-point ((start (current-point))
(end (current-point)))
(set-region-point-using-global-mode (current-global-mode) start end)
(select-current-line-if-no-region-is-selected start end)

(loop
(skip-whitespace-forward start)
(when (point>= start end)
Expand All @@ -176,6 +183,8 @@
(with-point ((start (current-point) :right-inserting)
(end (current-point) :left-inserting))
(set-region-point-using-global-mode (current-global-mode) start end)
(select-current-line-if-no-region-is-selected start end)

(skip-whitespace-forward start)
(when (point>= start end)
(insert-string (current-point) line-comment)
Expand Down Expand Up @@ -203,6 +212,8 @@
(with-point ((start (current-point) :right-inserting)
(end (current-point) :right-inserting))
(set-region-point-using-global-mode (current-global-mode) start end)
(select-current-line-if-no-region-is-selected start end)

(let ((p start))
(loop
(parse-partial-sexp p end nil t)
Expand Down
Loading