Fix newline-and-indent advice forgetting indentation
e.g. in python-mode docstrings. The point-in-string case is no longer handled, because indent-according-to-mode handles it properly already.
This commit is contained in:
parent
5cd1fb2a52
commit
b821bfca1f
2 changed files with 12 additions and 12 deletions
|
@ -109,18 +109,18 @@ If ARG (universal argument), runs `compile' from the current directory."
|
||||||
((error "No kill-ring search backend available. Enable ivy or helm!")))))
|
((error "No kill-ring search backend available. Enable ivy or helm!")))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +default*newline-indent-and-continue-comments (_orig-fn)
|
(defun +default*newline-indent-and-continue-comments ()
|
||||||
"Inserts a newline and possibly indents it. Also continues comments if
|
"A replacement for `newline-and-indent'.
|
||||||
executed from a commented line; handling special cases for certain languages
|
|
||||||
with weak native support."
|
Continues comments if executed from a commented line, with special support for
|
||||||
|
languages with weak native comment continuation support (like C-family
|
||||||
|
languages)."
|
||||||
(interactive)
|
(interactive)
|
||||||
(cond ((sp-point-in-string) (newline))
|
(if (and (sp-point-in-comment)
|
||||||
((and (sp-point-in-comment)
|
|
||||||
comment-line-break-function)
|
comment-line-break-function)
|
||||||
(funcall comment-line-break-function))
|
(funcall comment-line-break-function)
|
||||||
(t
|
|
||||||
(newline nil t)
|
(newline nil t)
|
||||||
(indent-according-to-mode))))
|
(indent-according-to-mode)))
|
||||||
|
|
||||||
(defun doom--backward-delete-whitespace-to-column ()
|
(defun doom--backward-delete-whitespace-to-column ()
|
||||||
"Delete back to the previous column of whitespace, or as much whitespace as
|
"Delete back to the previous column of whitespace, or as much whitespace as
|
||||||
|
|
|
@ -125,7 +125,7 @@
|
||||||
(advice-add #'delete-backward-char :override #'+default*delete-backward-char)
|
(advice-add #'delete-backward-char :override #'+default*delete-backward-char)
|
||||||
|
|
||||||
;; Makes `newline-and-indent' continue comments (and more reliably)
|
;; Makes `newline-and-indent' continue comments (and more reliably)
|
||||||
(advice-add #'newline-and-indent :around #'+default*newline-indent-and-continue-comments)))
|
(advice-add #'newline-and-indent :override #'+default*newline-indent-and-continue-comments)))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue