emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/gnu-indent 3307404581 17/17: New command gnu-indent-defun-


From: ELPA Syncer
Subject: [nongnu] elpa/gnu-indent 3307404581 17/17: New command gnu-indent-defun-or-fill
Date: Sun, 27 Nov 2022 16:00:28 -0500 (EST)

branch: elpa/gnu-indent
commit 3307404581bc954dc4f568b9f118af11a8125c23
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Akib Azmain Turja <akib@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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]