From 5cb26db4f6b63a588ad7b8d2ec22ebf0f56f1076 Mon Sep 17 00:00:00 2001 From: Doug Davis Date: Mon, 24 Jul 2023 21:12:33 -0500 Subject: [PATCH] optionally auto fill paragraphs (#16) --- NEWS.md | 9 +++++++-- README.md | 5 +++++ numpydoc.el | 18 ++++++++++++++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index e60b951..8b3db60 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,8 +1,13 @@ # numpydoc.el NEWS -- history of user visible changes -## Unreleased +## 0.9 (July 24, 2023) -... +### Changes + +- Add new `defcustom`: `numpydoc-auto-fill-paragraphs`, which when set + to `t` (the default) will enable automatic paragraph filling for + (somewhat) long descriptions. + ([#16](https://github.com/douglasdavis/numpydoc.el/pull/16)). ## 0.8 (March 20, 2023) diff --git a/README.md b/README.md index 4ca3291..3c2d8f6 100644 --- a/README.md +++ b/README.md @@ -135,6 +135,11 @@ RET numpydoc All function parameters with names listed here will be ignored when generating a docstring. +
numpydoc-auto-fill-paragraphs
+
+ If t text that is inserted in a prompt will be + automatically paragraph-filled. +
## Examples diff --git a/numpydoc.el b/numpydoc.el index 87954b4..caa99ee 100644 --- a/numpydoc.el +++ b/numpydoc.el @@ -6,7 +6,7 @@ ;; Maintainer: Doug Davis ;; URL: https://github.com/douglasdavis/numpydoc.el ;; SPDX-License-Identifier: GPL-3.0-or-later -;; Version: 0.8 +;; Version: 0.9 ;; Package-Requires: ((emacs "25.1") (s "1.12.0") (dash "2.18.0")) ;; Keywords: convenience @@ -133,6 +133,13 @@ when generating a docstring." :group 'numpydoc :type '(repeat string)) +(defcustom numpydoc-auto-fill-paragraphs t + "Flag to control automatic paragraph filling. +If set to t text that is inserted in a prompt will be automatically +paragraph-filled." + :group 'numpydoc + :type 'boolean) + ;;; package implementation code. (cl-defstruct numpydoc--def @@ -391,7 +398,8 @@ This function assumes the cursor to be in the function body." (unless (string-empty-p ld) (insert "\n") (numpydoc--insert indent ld) - (numpydoc--fill-last-insertion) + (when numpydoc-auto-fill-paragraphs + (numpydoc--fill-last-insertion)) (insert "\n"))) (insert "\n") (numpydoc--insert indent tmpl) @@ -429,7 +437,8 @@ This function assumes the cursor to be in the function body." element)) tmpd)))) (numpydoc--insert indent desc) - (numpydoc--fill-last-insertion) + (when numpydoc-auto-fill-paragraphs + (numpydoc--fill-last-insertion)) (insert "\n"))) (defun numpydoc--insert-parameters (indent fnargs) @@ -466,7 +475,8 @@ This function assumes the cursor to be in the function body." (if (numpydoc--prompt-p) (read-string "Description for return: ") tmpr))) - (numpydoc--fill-last-insertion) + (when numpydoc-auto-fill-paragraphs + (numpydoc--fill-last-insertion)) (insert "\n")))) (defun numpydoc--insert-exceptions (indent fnexcepts)