emacs-devel
[Top][All Lists]
Advanced

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

Re: RFC: locale-sensitive Emacs functions


From: Gdobbins
Subject: Re: RFC: locale-sensitive Emacs functions
Date: Tue, 28 Mar 2017 07:59:25 -0400

>I remember concluding that I was glad I didn't have to write code to support the '
>flag, as it would require messing with the LC_NUMERIC locale setting (currently
>hardwired to "C" for other good reasons) and would make for some work redoing
>carefully-calculated output buffer sizes internal to 'format', not to mention
>the character set conversion that would be required.

The way I've proposed should obviate those problems. Since the variables governing the behavior are set by the user, LC_NUMERIC need not be consulted. If it is deemed necessary a function like set-locale-dependent-vars could be created to set these (and potentially other) variables, and the user could put it in their init if they so choose.

>For what it's worth, the Common Lisp approach cannot handle the Indian numbering
>system, which has a comma every two digits except that the last grouping
>contains three digits (e.g., "12,34,56,789").

The literal CL approach can't handle it, but it can be adapted to do so. The attached patch makes it so the format-digit-grouping variable can be a list. The first element of the list controls the grouping size of the least significant figures etc. until the last element controls all remaining groups. Using your example:

(let ((format-digit-grouping '(3 2)))
  (format "%'d" 123456789)) => "12,34,56,789"

-- Graham Dobbins


Attachment: 0001-src-editfns.c-styled_format-Add-d-format-specifier.patch
Description: Text Data


reply via email to

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