diff options
| -rw-r--r-- | lisp/startup.el | 4 | ||||
| -rw-r--r-- | src/editfns.c | 12 | ||||
| -rw-r--r-- | test/lisp/wdired-tests.el | 4 | ||||
| -rw-r--r-- | test/src/editfns-tests.el | 16 |
4 files changed, 29 insertions, 7 deletions
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) | |||
| 2534 | ((eq initial-buffer-choice t) | 2534 | ((eq initial-buffer-choice t) |
| 2535 | (get-buffer-create "*scratch*")) | 2535 | (get-buffer-create "*scratch*")) |
| 2536 | (t | 2536 | (t |
| 2537 | (error "initial-buffer-choice must be a string, a function, or t."))))) | 2537 | (error "`initial-buffer-choice' must be a string, a function, or t"))))) |
| 2538 | (unless (buffer-live-p buf) | 2538 | (unless (buffer-live-p buf) |
| 2539 | (error "initial-buffer-choice is not a live buffer.")) | 2539 | (error "Value returned by `initial-buffer-choice' is not a live buffer: %S" buf)) |
| 2540 | (setq displayable-buffers (cons buf (delq buf displayable-buffers))))) | 2540 | (setq displayable-buffers (cons buf (delq buf displayable-buffers))))) |
| 2541 | 2541 | ||
| 2542 | ;; Display the first two buffers in `displayable-buffers'. If | 2542 | ;; 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) | |||
| 4268 | /* The start and end bytepos in the output string. */ | 4268 | /* The start and end bytepos in the output string. */ |
| 4269 | ptrdiff_t start, end; | 4269 | ptrdiff_t start, end; |
| 4270 | 4270 | ||
| 4271 | /* The start of the spec in the format string. */ | ||
| 4272 | ptrdiff_t fbeg; | ||
| 4273 | |||
| 4271 | /* Whether the argument is a string with intervals. */ | 4274 | /* Whether the argument is a string with intervals. */ |
| 4272 | bool_bf intervals : 1; | 4275 | bool_bf intervals : 1; |
| 4273 | } *info; | 4276 | } *info; |
| @@ -4421,6 +4424,7 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) | |||
| 4421 | char conversion = *format++; | 4424 | char conversion = *format++; |
| 4422 | memset (&discarded[format0 - format_start], 1, | 4425 | memset (&discarded[format0 - format_start], 1, |
| 4423 | format - format0 - (conversion == '%')); | 4426 | format - format0 - (conversion == '%')); |
| 4427 | info[ispec].fbeg = format0 - format_start; | ||
| 4424 | if (conversion == '%') | 4428 | if (conversion == '%') |
| 4425 | { | 4429 | { |
| 4426 | new_result = true; | 4430 | new_result = true; |
| @@ -5011,7 +5015,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) | |||
| 5011 | else if (discarded[bytepos] == 1) | 5015 | else if (discarded[bytepos] == 1) |
| 5012 | { | 5016 | { |
| 5013 | position++; | 5017 | position++; |
| 5014 | if (fieldn < nspec && translated == info[fieldn].start) | 5018 | if (fieldn < nspec |
| 5019 | && position > info[fieldn].fbeg | ||
| 5020 | && translated == info[fieldn].start) | ||
| 5015 | { | 5021 | { |
| 5016 | translated += info[fieldn].end - info[fieldn].start; | 5022 | translated += info[fieldn].end - info[fieldn].start; |
| 5017 | fieldn++; | 5023 | fieldn++; |
| @@ -5031,7 +5037,9 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) | |||
| 5031 | else if (discarded[bytepos] == 1) | 5037 | else if (discarded[bytepos] == 1) |
| 5032 | { | 5038 | { |
| 5033 | position++; | 5039 | position++; |
| 5034 | if (fieldn < nspec && translated == info[fieldn].start) | 5040 | if (fieldn < nspec |
| 5041 | && position > info[fieldn].fbeg | ||
| 5042 | && translated == info[fieldn].start) | ||
| 5035 | { | 5043 | { |
| 5036 | translated += info[fieldn].end - info[fieldn].start; | 5044 | translated += info[fieldn].end - info[fieldn].start; |
| 5037 | fieldn++; | 5045 | 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." | |||
| 116 | (kill-region (point) (progn (search-forward ".") | 116 | (kill-region (point) (progn (search-forward ".") |
| 117 | (forward-char -1) (point))) | 117 | (forward-char -1) (point))) |
| 118 | (insert replace) | 118 | (insert replace) |
| 119 | (should (equal (dired-get-filename) new-file)))) | 119 | (should (equal (dired-get-filename) new-file))) |
| 120 | (when buf | 120 | (when buf |
| 121 | (with-current-buffer buf | 121 | (with-current-buffer buf |
| 122 | ;; Prevent kill-buffer-query-functions from chiming in. | 122 | ;; Prevent kill-buffer-query-functions from chiming in. |
| 123 | (set-buffer-modified-p nil) | 123 | (set-buffer-modified-p nil) |
| 124 | (kill-buffer buf))) | 124 | (kill-buffer buf))) |
| 125 | (delete-directory test-dir t)))) | 125 | (delete-directory test-dir t))))) |
| 126 | 126 | ||
| 127 | 127 | ||
| 128 | (provide 'wdired-tests) | 128 | (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 @@ | |||
| 88 | (format "%-10s" (concat (propertize "01" 'face 'bold) | 88 | (format "%-10s" (concat (propertize "01" 'face 'bold) |
| 89 | (propertize "23" 'face 'underline) | 89 | (propertize "23" 'face 'underline) |
| 90 | (propertize "45" 'face 'italic))) | 90 | (propertize "45" 'face 'italic))) |
| 91 | #("012345 " 0 2 (face bold) 2 4 (face underline) 4 10 (face italic))))) | 91 | #("012345 " |
| 92 | 0 2 (face bold) 2 4 (face underline) 4 10 (face italic)))) | ||
| 93 | ;; Bug #32404 | ||
| 94 | (should (ert-equal-including-properties | ||
| 95 | (format (concat (propertize "%s" 'face 'bold) | ||
| 96 | "" | ||
| 97 | (propertize "%s" 'face 'error)) | ||
| 98 | "foo" "bar") | ||
| 99 | #("foobar" 0 3 (face bold) 3 6 (face error)))) | ||
| 100 | (should (ert-equal-including-properties | ||
| 101 | (format (concat "%s" (propertize "%s" 'face 'error)) "foo" "bar") | ||
| 102 | #("foobar" 3 6 (face error)))) | ||
| 103 | (should (ert-equal-including-properties | ||
| 104 | (format (concat "%s " (propertize "%s" 'face 'error)) "foo" "bar") | ||
| 105 | #("foo bar" 4 7 (face error))))) | ||
| 92 | 106 | ||
| 93 | ;; Tests for bug#5131. | 107 | ;; Tests for bug#5131. |
| 94 | (defun transpose-test-reverse-word (start end) | 108 | (defun transpose-test-reverse-word (start end) |