]> git.eshelyaron.com Git - emacs.git/commitdiff
(pp-fill): Fix bug#76715
authorStefan Monnier <monnier@iro.umontreal.ca>
Wed, 5 Mar 2025 23:35:35 +0000 (18:35 -0500)
committerEshel Yaron <me@eshelyaron.com>
Sun, 9 Mar 2025 07:05:54 +0000 (08:05 +0100)
* 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)

lisp/emacs-lisp/pp.el
test/lisp/emacs-lisp/pp-tests.el

index 108dbaae3be7d7a6a580b54886b81cfb1ef1d5d7..dba95fef4559e238c67a014628a0a1265ba84308 100644 (file)
@@ -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)
index 68095ea08c8c44ba1c844126ce185194d895d2fb..d964ed389863140237ba3606cad9e6c357e04019 100644 (file)
              (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.