branch: elpa/gnu-indent commit 3307404581bc954dc4f568b9f118af11a8125c23 Author: Philip Kaludercic <phil...@posteo.net> Commit: Akib Azmain Turja <a...@disroot.org>
New command gnu-indent-defun-or-fill --- gnu-indent.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gnu-indent.el b/gnu-indent.el index 989cebd71c..590e2d9b2f 100644 --- a/gnu-indent.el +++ b/gnu-indent.el @@ -99,6 +99,20 @@ When called non-interactively, indent text between BEG and END." (when (called-interactively-p 'interactive) (message "Indenting...done")))) +;;;###autoload +(defun gnu-indent-defun-or-fill (arg) + "Indent current function with GNU Indent. +If point is in a comment, call `fill-paragraph' instead. A +prefix argument ARG is passed to `fill-paragraph'." + (interactive "P") + (if (nth 8 (syntax-ppss)) ; If in a comment. + (fill-paragraph arg) + (let ((bounds (bounds-of-thing-at-point 'defun))) + (if (consp bounds) + (gnu-indent-region (car bounds) (cdr bounds)) + (user-error "No defun at point"))))) + + ;;;###autoload (defun gnu-indent-buffer () "Indent current buffer with GNU Indent."