aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2013-05-20 00:45:58 -0700
committerGlenn Morris2013-05-20 00:45:58 -0700
commit33c0f65b6f763969923c4c03c7d97724fc56545c (patch)
tree21e9c90951117e2a5d24af8deda4760470828470
parentd6635ba23031c9ceb430d5bec5dbb8ee4c75ad12 (diff)
downloademacs-33c0f65b6f763969923c4c03c7d97724fc56545c.tar.gz
emacs-33c0f65b6f763969923c4c03c7d97724fc56545c.zip
* lisp/format-spec.el (format-spec): Allow spec chars with nil values.
Fixes: debbugs:14420
-rw-r--r--lisp/ChangeLog4
-rw-r--r--lisp/format-spec.el9
2 files changed, 9 insertions, 4 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8cc4a8876de..8fcd7424401 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,7 @@
12013-05-20 Glenn Morris <rgm@gnu.org>
2
3 * format-spec.el (format-spec): Allow spec chars with nil. (Bug#14420)
4
12013-05-19 Dmitry Gutov <dgutov@yandex.ru> 52013-05-19 Dmitry Gutov <dgutov@yandex.ru>
2 6
3 * progmodes/ruby-mode.el (ruby-expression-expansion-re): Allow to 7 * progmodes/ruby-mode.el (ruby-expression-expansion-re): Allow to
diff --git a/lisp/format-spec.el b/lisp/format-spec.el
index 1280966d737..6bb0fe9178a 100644
--- a/lisp/format-spec.el
+++ b/lisp/format-spec.el
@@ -44,14 +44,15 @@ the text that it generates."
44 ((looking-at "\\([-0-9.]*\\)\\([a-zA-Z]\\)") 44 ((looking-at "\\([-0-9.]*\\)\\([a-zA-Z]\\)")
45 (let* ((num (match-string 1)) 45 (let* ((num (match-string 1))
46 (spec (string-to-char (match-string 2))) 46 (spec (string-to-char (match-string 2)))
47 (val (cdr (assq spec specification)))) 47 (val (assq spec specification)))
48 (unless val 48 (unless val
49 (error "Invalid format character: `%%%c'" spec)) 49 (error "Invalid format character: `%%%c'" spec))
50 (setq val (cdr val))
50 ;; Pad result to desired length. 51 ;; Pad result to desired length.
51 (let ((text (format (concat "%" num "s") val))) 52 (let ((text (format (concat "%" num "s") val)))
52 ;; Insert first, to preserve text properties. 53 ;; Insert first, to preserve text properties.
53 (insert-and-inherit text) 54 (insert-and-inherit text)
54 ;; Delete the specifier body. 55 ;; Delete the specifier body.
55 (delete-region (+ (match-beginning 0) (length text)) 56 (delete-region (+ (match-beginning 0) (length text))
56 (+ (match-end 0) (length text))) 57 (+ (match-end 0) (length text)))
57 ;; Delete the percent sign. 58 ;; Delete the percent sign.