From: Stefan Monnier Date: Wed, 5 Mar 2025 23:35:35 +0000 (-0500) Subject: (pp-fill): Fix bug#76715 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=33085cfc537cdc618a7390a3609fe5c345e32d2b;p=emacs.git (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. (cherry picked from commit 25de262bd95b587beb757e1a82828ad4fffbf168) --- diff --git a/lisp/emacs-lisp/pp.el b/lisp/emacs-lisp/pp.el index 108dbaae3be..dba95fef455 100644 --- a/lisp/emacs-lisp/pp.el +++ b/lisp/emacs-lisp/pp.el @@ -208,7 +208,14 @@ it inserts and pretty-prints that arg at point." (while (progn (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) ;; The sexp already starts on its own line. (progn (goto-char beg) nil) diff --git a/test/lisp/emacs-lisp/pp-tests.el b/test/lisp/emacs-lisp/pp-tests.el index 68095ea08c8..d964ed38986 100644 --- a/test/lisp/emacs-lisp/pp-tests.el +++ b/test/lisp/emacs-lisp/pp-tests.el @@ -85,4 +85,13 @@ (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.