[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/bug-44858 4e7c5a6 2/6: Improve filling of generated docstring li
From: |
Stefan Kangas |
Subject: |
scratch/bug-44858 4e7c5a6 2/6: Improve filling of generated docstring lines |
Date: |
Fri, 24 Sep 2021 13:19:52 -0400 (EDT) |
branch: scratch/bug-44858
commit 4e7c5a62d02fa0a170ad86c95a505584c150f377
Author: Stefan Kangas <stefan@marxist.se>
Commit: Stefan Kangas <stefan@marxist.se>
Improve filling of generated docstring lines
* lisp/subr.el (internal--fill-string-single-line): Improve filling to
use full width. Fix bug where line was not wrapped correctly.
---
lisp/subr.el | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lisp/subr.el b/lisp/subr.el
index 2d2794c..2a163b7 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -6418,12 +6418,19 @@ seconds."
This is intended for very simple filling while bootstrapping
Emacs itself, and does not support all the customization options
of fill.el (for example `fill-region')."
- (if (< (string-width str) fill-column)
+ (if (< (length str) fill-column)
str
- (let ((fst (substring str 0 fill-column))
- (lst (substring str fill-column)))
- (if (string-match ".*\\( \\(.+\\)\\)$" fst)
- (setq fst (replace-match "\n\\2" nil nil fst 1)))
+ (let* ((limit (min fill-column (length str)))
+ (fst (substring str 0 limit))
+ (lst (substring str limit)))
+ (cond ((string-match "\\( \\)$" fst)
+ (setq fst (replace-match "\n" nil nil fst 1)))
+ ((string-match "^ \\(.*\\)" lst)
+ (setq fst (concat fst "\n"))
+ (setq lst (match-string 1 lst)))
+ ((string-match ".*\\( \\(.+\\)\\)$" fst)
+ (setq lst (concat (match-string 2 fst) lst))
+ (setq fst (replace-match "\n" nil nil fst 1))))
(concat fst (internal--fill-string-single-line lst)))))
(defun internal--format-docstring-line (string &rest objects)
- branch scratch/bug-44858 created (now 35c459f), Stefan Kangas, 2021/09/24
- scratch/bug-44858 2f59fad 1/6: ; Adjust overly long docstrings to fit 80 characters, Stefan Kangas, 2021/09/24
- scratch/bug-44858 4e7c5a6 2/6: Improve filling of generated docstring lines,
Stefan Kangas <=
- scratch/bug-44858 e491d97 3/6: Avoid false positives in bytecomp docstring width warning, Stefan Kangas, 2021/09/24
- scratch/bug-44858 35c459f 6/6: Warn about overly long docstring in lambda, Stefan Kangas, 2021/09/24
- scratch/bug-44858 e4fd496 4/6: Fill some auto-generated docstring lines, Stefan Kangas, 2021/09/24
- scratch/bug-44858 60edb5d 5/6: Avoid warning about long docstring lines in defcustom, Stefan Kangas, 2021/09/24