emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master a1b49f3: Fix last change to format-spec


From: Basil L. Contovounesios
Subject: [Emacs-diffs] master a1b49f3: Fix last change to format-spec
Date: Sat, 20 Jul 2019 11:59:59 -0400 (EDT)

branch: master
commit a1b49f3bff5e104581b43ac5a9093a576f87f04b
Author: Basil L. Contovounesios <address@hidden>
Commit: Basil L. Contovounesios <address@hidden>

    Fix last change to format-spec
    
    * doc/lispref/text.texi (Interpolated Strings): Use @result and fix
    typos.
    * lisp/format-spec.el: Avoid loading subr-x at runtime.
    (format-spec--parse-modifiers): Optimize slightly.
---
 doc/lispref/text.texi |  6 +++---
 lisp/format-spec.el   | 11 +++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index df9fce0..e73141f 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -4655,11 +4655,11 @@ Here's a trivial example:
 (format-spec "su - %u %l"
              `((?u . ,(user-login-name))
                (?l . "ls")))
-=> "su - foo ls"
+     @result{} "su - foo ls"
 @end example
 
 In addition to allowing padding/limiting to a certain length, the
-following modifiers are can be used:
+following modifiers can be used:
 
 @table @asis
 @item @samp{0}
@@ -4684,7 +4684,7 @@ If the length needs to limited, remove characters from 
the left.
 Same as previous, but remove characters from the right.
 @end table
 
-If contradictory modifiers are used (for instance, both upper- and
+If contradictory modifiers are used (for instance, both upper and
 lower case), then what happens is undefined.
 
 As an example, @samp{"%<010b"} means ``insert the @samp{b} expansion,
diff --git a/lisp/format-spec.el b/lisp/format-spec.el
index 220cecd..fec93ce 100644
--- a/lisp/format-spec.el
+++ b/lisp/format-spec.el
@@ -24,7 +24,8 @@
 
 ;;; Code:
 
-(require 'subr-x)
+(eval-when-compile
+  (require 'subr-x))
 
 (defun format-spec (format specification &optional only-present)
   "Return a string based on FORMAT and SPECIFICATION.
@@ -118,8 +119,7 @@ where they are, including \"%%\" strings."
         (concat padding text)))))
 
 (defun format-spec--parse-modifiers (modifiers)
-  (let ((elems nil))
-    (mapc (lambda (char)
+  (mapcan (lambda (char)
             (when-let ((modifier
                         (pcase char
                           (?0 :zero-pad)
@@ -129,9 +129,8 @@ where they are, including \"%%\" strings."
                           (?- :right-pad)
                           (?< :chop-left)
                           (?> :chop-right))))
-              (push modifier elems)))
-          modifiers)
-    elems))
+              (list modifier)))
+          modifiers))
 
 (defun format-spec-make (&rest pairs)
   "Return an alist suitable for use in `format-spec' based on PAIRS.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]