emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: bug#47885: [PATCH] org-table-import: Make it more smarter for interactive use
Date: Tue, 18 May 2021 19:31:16 +0700	[thread overview]
Message-ID: <s80c2n$fkd$1@ciao.gmane.io> (raw)
In-Reply-To: <87a6osfig3.fsf@gmail.com>

It seems, there is no reliable way to work with numbers in a 
locale-aware way in emacs.  I am still against hard-coded list of 
locales. Requirement to customize a variable is rather inconvenient. 
Considering such properties as a part of translation is a little better 
but I prefer to avoid it.

The question may be risen in emacs-devel but I am unsure if I will 
participate in discussion.

On 18/05/2021 17:24, Utkarsh Singh wrote:
> On 2021-05-16, 23:24 +0700, Maxim Nikulin wrote:
> 
>> On 14/05/2021 21:54, Utkarsh Singh wrote:
>>> On 2021-05-13, 00:08 +0700, Maxim Nikulin wrote:
>>>
>>>> Comma is decimal separator for es_ES, de_DE, ru_RU, etc. The point is
>>>> that order in which separator candidates are tried should depend on
>>>> active locale.
>>>>
>>> I am willing to work on this problem but before this can you identify
>>> any other locale with similar problem or a resource from where I can
>>> information's about locale.
>>
>> I do not think list of locales should be hard coded. I am not familiar
>> with elisp enough to tell you if locale properties such as decimal
>> separator are exposed through some function. I expect, it is quite
>> probable. As a last measure, some number, e.g. 0.5 or 1.5 could be
>> formatted using a locale-aware function and result string could be
>> checked if it contains ",".
> 
> Can you test this function:
> 
> (defun org-table--comma-as-decimal-sep ()
>    "Return nil or 2 if separator is dot or comma respectively."
>    (string-search "," (format "%f" 10)))

No, it does not work. `format' always uses dot. It is reasonable when 
e.g. during writing a config file or during data exchange when locales 
must be ignored.

I was too optimistic. I did not expect that support of locales are so 
poor in Emcacs. I do not see any traces of localeconv(3) in sources that 
would allow to get value of decimal_point directly.

Numbers are forced to use "C" locale and I have not noticed any way to 
override it. Initial settings:

http://git.savannah.gnu.org/cgit/emacs.git/tree/src/emacs.c#n1490

http://git.savannah.gnu.org/cgit/emacs.git/tree/src/emacs.c#n2861

setlocale (LC_NUMERIC, "C");

> To test I am using:
> $ LANG=de_DE.UTF-8 emacs -Q
> 
> But I am getting this as warning:
> (process:1787): Gtk-WARNING **: 15:40:49.375: Locale not supported by C library.
> 	Using the fallback 'C' locale.

You get this error due to you have not generated this locale. On debian 
& ubuntu

dpkg-reconfigure locales

allows to select desired locales and performs all necessary actions.



  reply	other threads:[~2021-05-18 12:41 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19  4:43 [PATCH] org-table-import: Make it more smarter for interactive use Utkarsh Singh
2021-04-19  8:19 ` Nicolas Goaziou
2021-04-19 14:23   ` Utkarsh Singh
2021-04-20 13:40     ` Nicolas Goaziou
2021-04-20 17:15       ` Utkarsh Singh
2021-04-23  4:58       ` Utkarsh Singh
2021-04-27 20:21         ` bug#47885: " Nicolas Goaziou
2021-04-28  8:37           ` Utkarsh Singh
2021-04-28 16:38             ` Maxim Nikulin
2021-05-10 18:36               ` Utkarsh Singh
2021-05-12 17:08                 ` Maxim Nikulin
2021-05-14 14:54                   ` Utkarsh Singh
2021-05-15  9:13                     ` Bastien
2021-05-15 10:10                       ` Utkarsh Singh
2021-05-15 10:30                         ` Bastien
2021-05-15 11:09                           ` Utkarsh Singh
2021-05-17  5:29                         ` Bastien
2021-05-17 16:27                           ` Utkarsh Singh
2021-06-01 16:23                           ` Maxim Nikulin
2021-06-01 17:46                             ` Utkarsh Singh
2021-06-02 12:06                               ` Maxim Nikulin
2021-06-02 15:08                                 ` Utkarsh Singh
2021-06-02 16:44                                   ` Maxim Nikulin
2021-06-04  4:04                                     ` Utkarsh Singh
2021-06-05 12:40                                       ` Maxim Nikulin
2021-06-05 17:50                                         ` Utkarsh Singh
2021-06-09 12:15                                           ` Maxim Nikulin
2021-09-26  8:40                                           ` Bastien
2021-05-16 16:24                     ` Maxim Nikulin
2021-05-17 16:30                       ` Utkarsh Singh
2021-05-18 10:24                       ` Utkarsh Singh
2021-05-18 12:31                         ` Maxim Nikulin [this message]
2021-05-18 15:05                           ` Utkarsh Singh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='s80c2n$fkd$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).