1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

(pp-fill): Fix bug#76715

* lisp/emacs-lisp/pp.el (pp-fill): Don't break before `.` within symbols.
* test/lisp/emacs-lisp/pp-tests.el (pp-tests--bug76715): New test.
This commit is contained in:
Stefan Monnier 2025-03-05 18:35:35 -05:00
parent 70d0da3fe0
commit 25de262bd9
2 changed files with 17 additions and 1 deletions

View file

@ -208,7 +208,14 @@ it inserts and pretty-prints that arg at point."
(while (while
(progn (progn
(funcall avoid-unbreakable) (funcall avoid-unbreakable)
(not (zerop (skip-chars-backward " \t({[',."))))) (let ((pos (point)))
(skip-chars-backward " \t({[',.")
(while (and (memq (char-after) '(?\. ?\{))
(not (memq (char-before)
'(nil ?\n ?\) \" ?\]))))
;; `.' and `{' within symbols? (Bug#76715)
(forward-char 1))
(not (eql pos (point))))))
(if (bolp) (if (bolp)
;; The sexp already starts on its own line. ;; The sexp already starts on its own line.
(progn (goto-char beg) nil) (progn (goto-char beg) nil)

View file

@ -85,4 +85,13 @@
(signal (car err) (cdr err)) (signal (car err) (cdr err))
)))))))) ))))))))
(ert-deftest pp-tests--bug76715 ()
(with-temp-buffer
(let ((pp-default-function #'pp-fill)
(fill-column 8)
(val '(x. y{ z. a{ b. x. y{ z. a{ b.)))
(pp val (current-buffer))
(goto-char (point-min))
(should (equal (read (current-buffer)) val)))))
;;; pp-tests.el ends here. ;;; pp-tests.el ends here.