From: Gerd Möllmann Date: Sat, 22 Oct 2022 07:26:07 +0000 (+0200) Subject: Fix priting of :1 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=647046687a3217cf002353bc9b53691701ce7785;p=emacs.git Fix priting of :1 * src/print.c (print_symbol_name, print_symbol): Don't check for symbol names looking like a number when we have already printed a package prefix. * test/src/editfns-tests.el (format-%s-keywords): Test for :1. --- diff --git a/src/print.c b/src/print.c index 7cb7165cb08..0bae167c00e 100644 --- a/src/print.c +++ b/src/print.c @@ -2196,9 +2196,11 @@ looks_like_number_p (Lisp_Object name) static void print_symbol_name (Lisp_Object name, Lisp_Object printcharfun, - bool escape) + bool escape, bool check_number) { - bool like_number_p = looks_like_number_p (name); + /* Don't check if the name looks like a number if we already know it + doesn't. For example, for keywords. */ + bool like_number_p = check_number ? looks_like_number_p (name) : false; for (ptrdiff_t ibyte = 0, ichar = 0; ibyte < SBYTES (name);) { const int c = fetch_string_char_advance (name, &ichar, &ibyte); @@ -2221,9 +2223,13 @@ print_symbol (Lisp_Object symbol, Lisp_Object printcharfun, { const Lisp_Object name = SYMBOL_NAME (symbol); const Lisp_Object package = SYMBOL_PACKAGE (symbol); + bool check_number_p = true; if (EQ (package, Vkeyword_package)) - print_c_string (":", printcharfun); + { + print_c_string (":", printcharfun); + check_number_p = false; + } else if (EQ (package, Vearmuffs_package)) ; else if (NILP (package)) @@ -2239,13 +2245,14 @@ print_symbol (Lisp_Object symbol, Lisp_Object printcharfun, const bool accessible = !EQ (found, Qunbound); if (!accessible || !EQ (found, symbol)) { - print_symbol_name (PACKAGE_NAMEX (package), printcharfun, escape); + print_symbol_name (PACKAGE_NAMEX (package), printcharfun, escape, true); const Lisp_Object found = pkg_find_symbol (name, package, &status); eassert (!EQ (found, Qunbound)); if (EQ (status, QCexternal)) print_c_string (":", printcharfun); else print_c_string ("::", printcharfun); + check_number_p = false; } } @@ -2255,7 +2262,7 @@ print_symbol (Lisp_Object symbol, Lisp_Object printcharfun, if (SBYTES (name) == 0 && !EQ (package, Vkeyword_package)) print_c_string ("##", printcharfun); else - print_symbol_name (name, printcharfun, escape); + print_symbol_name (name, printcharfun, escape, check_number_p); } diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index bffa7865d52..74327fcb32d 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -427,7 +427,7 @@ (should (= (field-end) (point-max))))) (ert-deftest format-%s-keywords () - (should (string-equal (format "%s" :hansi) ":hansi"))) - + (should (string-equal (format "%s" :hansi) ":hansi")) + (should (string-equal (format "%s" :1) ":1"))) ;;; editfns-tests.el ends here