diff options
| author | Lars Ingebrigtsen | 2021-02-04 16:12:41 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2021-02-04 16:12:41 +0100 |
| commit | 9bf367e18486b8f89ff1e0a4c4f4b5b4da4d9a75 (patch) | |
| tree | 04c40b4df0c7e0e46992d230e8453eb99b644d0c | |
| parent | e1d54bb638dfb017acb778a45092f97bb0d3427c (diff) | |
| download | emacs-9bf367e18486b8f89ff1e0a4c4f4b5b4da4d9a75.tar.gz emacs-9bf367e18486b8f89ff1e0a4c4f4b5b4da4d9a75.zip | |
Improve filling of Emacs Lisp doc strings
* lisp/emacs-lisp/lisp-mode.el (lisp-fill-paragraph): When filling
a Lisp string, try to avoid filling bits that follow it
(bug#28937).
| -rw-r--r-- | lisp/emacs-lisp/lisp-mode.el | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el index 5dda3a8f8e9..f5ce107185a 100644 --- a/lisp/emacs-lisp/lisp-mode.el +++ b/lisp/emacs-lisp/lisp-mode.el | |||
| @@ -1373,7 +1373,24 @@ and initial semicolons." | |||
| 1373 | (derived-mode-p 'emacs-lisp-mode)) | 1373 | (derived-mode-p 'emacs-lisp-mode)) |
| 1374 | emacs-lisp-docstring-fill-column | 1374 | emacs-lisp-docstring-fill-column |
| 1375 | fill-column))) | 1375 | fill-column))) |
| 1376 | (fill-paragraph justify)) | 1376 | (save-restriction |
| 1377 | (save-excursion | ||
| 1378 | (let ((ppss (syntax-ppss))) | ||
| 1379 | ;; If we're in a string, then narrow (roughly) to that | ||
| 1380 | ;; string before filling. This avoids filling Lisp | ||
| 1381 | ;; statements that follow the string. | ||
| 1382 | (when (ppss-string-terminator ppss) | ||
| 1383 | (goto-char (ppss-comment-or-string-start ppss)) | ||
| 1384 | (beginning-of-line) | ||
| 1385 | ;; The string may be unterminated -- in that case, don't | ||
| 1386 | ;; narrow. | ||
| 1387 | (when (ignore-errors | ||
| 1388 | (progn | ||
| 1389 | (forward-sexp 1) | ||
| 1390 | t)) | ||
| 1391 | (narrow-to-region (ppss-comment-or-string-start ppss) | ||
| 1392 | (point)))) | ||
| 1393 | (fill-paragraph justify))))) | ||
| 1377 | ;; Never return nil. | 1394 | ;; Never return nil. |
| 1378 | t)) | 1395 | t)) |
| 1379 | 1396 | ||