diff options
| author | Stefan Monnier | 2024-03-22 16:46:28 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2024-03-22 16:46:28 -0400 |
| commit | 7269a2f1586733bd03b569608bd77112b2e6487f (patch) | |
| tree | 9acfc5c656863bf6ce482f32e1ca273929e83a59 /test | |
| parent | accd79c93935b50dddfcd6fe7fb6912c80bcddb1 (diff) | |
| download | emacs-7269a2f1586733bd03b569608bd77112b2e6487f.tar.gz emacs-7269a2f1586733bd03b569608bd77112b2e6487f.zip | |
(pp-fill): Cut before parens and dots
The `pp-fill` code sometimes end up generating things like:
(foo .
bar)
instead of
(foo
. bar)
so make sure we cut before rather than after the dot (and open
parens while we're at it).
* lisp/emacs-lisp/pp.el (pp-fill): Cut before parens and dots.
* test/lisp/emacs-lisp/pp-tests.el (pp-tests--dimensions): New function.
(pp-tests--cut-before): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/pp-tests.el | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/pp-tests.el b/test/lisp/emacs-lisp/pp-tests.el index b663fb365a8..7f7c798cde8 100644 --- a/test/lisp/emacs-lisp/pp-tests.el +++ b/test/lisp/emacs-lisp/pp-tests.el | |||
| @@ -36,4 +36,34 @@ | |||
| 36 | (ert-deftest test-indentation () | 36 | (ert-deftest test-indentation () |
| 37 | (ert-test-erts-file (ert-resource-file "code-formats.erts"))) | 37 | (ert-test-erts-file (ert-resource-file "code-formats.erts"))) |
| 38 | 38 | ||
| 39 | (defun pp-tests--dimensions () | ||
| 40 | (save-excursion | ||
| 41 | (let ((width 0) | ||
| 42 | (height 0)) | ||
| 43 | (goto-char (point-min)) | ||
| 44 | (while (not (eobp)) | ||
| 45 | (end-of-line) | ||
| 46 | (setq height (1+ height)) | ||
| 47 | (setq width (max width (current-column))) | ||
| 48 | (forward-char 1)) | ||
| 49 | (cons width height)))) | ||
| 50 | |||
| 51 | (ert-deftest pp-tests--cut-before () | ||
| 52 | (with-temp-buffer | ||
| 53 | (lisp-data-mode) | ||
| 54 | (pp '(1 (quite-a-long-package-name | ||
| 55 | . [(0 10 0) ((avy (0 5 0))) "Quickly switch windows." tar | ||
| 56 | ((:url . "https://github.com/abo-abo/ace-window") | ||
| 57 | (:maintainer "Oleh Krehel" . "ohwoeowho@gmail.com") | ||
| 58 | (:authors ("Oleh Krehel" . "ohwoeowho@gmail.com")) | ||
| 59 | (:keywords "window" "location"))])) | ||
| 60 | (current-buffer)) | ||
| 61 | ;; (message "Filled:\n%s" (buffer-string)) | ||
| 62 | (let ((dimensions (pp-tests--dimensions))) | ||
| 63 | (should (< (car dimensions) 80)) | ||
| 64 | (should (< (cdr dimensions) 8))) | ||
| 65 | (goto-char (point-min)) | ||
| 66 | (while (search-forward "." nil t) | ||
| 67 | (should (not (eolp)))))) | ||
| 68 | |||
| 39 | ;;; pp-tests.el ends here. | 69 | ;;; pp-tests.el ends here. |