diff --git a/lisp/startup.el b/lisp/startup.el index c1e56fcdff3..4eb71abaacf 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -2534,9 +2534,9 @@ nil default-directory" name) ((eq initial-buffer-choice t) (get-buffer-create "*scratch*")) (t - (error "initial-buffer-choice must be a string, a function, or t."))))) + (error "`initial-buffer-choice' must be a string, a function, or t"))))) (unless (buffer-live-p buf) - (error "initial-buffer-choice is not a live buffer.")) + (error "Value returned by `initial-buffer-choice' is not a live buffer: %S" buf)) (setq displayable-buffers (cons buf (delq buf displayable-buffers))))) ;; Display the first two buffers in `displayable-buffers'. If diff --git a/src/editfns.c b/src/editfns.c index 0fbc5aad8c3..a4cff595bd0 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -4268,6 +4268,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) /* The start and end bytepos in the output string. */ ptrdiff_t start, end; + /* The start of the spec in the format string. */ + ptrdiff_t fbeg; + /* Whether the argument is a string with intervals. */ bool_bf intervals : 1; } *info; @@ -4421,6 +4424,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) char conversion = *format++; memset (&discarded[format0 - format_start], 1, format - format0 - (conversion == '%')); + info[ispec].fbeg = format0 - format_start; if (conversion == '%') { new_result = true; @@ -5011,7 +5015,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) else if (discarded[bytepos] == 1) { position++; - if (fieldn < nspec && translated == info[fieldn].start) + if (fieldn < nspec + && position > info[fieldn].fbeg + && translated == info[fieldn].start) { translated += info[fieldn].end - info[fieldn].start; fieldn++; @@ -5031,7 +5037,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) else if (discarded[bytepos] == 1) { position++; - if (fieldn < nspec && translated == info[fieldn].start) + if (fieldn < nspec + && position > info[fieldn].fbeg + && translated == info[fieldn].start) { translated += info[fieldn].end - info[fieldn].start; fieldn++; diff --git a/test/lisp/wdired-tests.el b/test/lisp/wdired-tests.el index b4ef4ab2486..f1ec4afb6c5 100644 --- a/test/lisp/wdired-tests.el +++ b/test/lisp/wdired-tests.el @@ -116,13 +116,13 @@ wdired-mode." (kill-region (point) (progn (search-forward ".") (forward-char -1) (point))) (insert replace) - (should (equal (dired-get-filename) new-file)))) + (should (equal (dired-get-filename) new-file))) (when buf (with-current-buffer buf ;; Prevent kill-buffer-query-functions from chiming in. (set-buffer-modified-p nil) (kill-buffer buf))) - (delete-directory test-dir t)))) + (delete-directory test-dir t))))) (provide 'wdired-tests) diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 2951270dbf7..aa896b06499 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el @@ -88,7 +88,21 @@ (format "%-10s" (concat (propertize "01" 'face 'bold) (propertize "23" 'face 'underline) (propertize "45" 'face 'italic))) - #("012345 " 0 2 (face bold) 2 4 (face underline) 4 10 (face italic))))) + #("012345 " + 0 2 (face bold) 2 4 (face underline) 4 10 (face italic)))) + ;; Bug #32404 + (should (ert-equal-including-properties + (format (concat (propertize "%s" 'face 'bold) + "" + (propertize "%s" 'face 'error)) + "foo" "bar") + #("foobar" 0 3 (face bold) 3 6 (face error)))) + (should (ert-equal-including-properties + (format (concat "%s" (propertize "%s" 'face 'error)) "foo" "bar") + #("foobar" 3 6 (face error)))) + (should (ert-equal-including-properties + (format (concat "%s " (propertize "%s" 'face 'error)) "foo" "bar") + #("foo bar" 4 7 (face error))))) ;; Tests for bug#5131. (defun transpose-test-reverse-word (start end)