From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id KJOUAD7hKWGAzAAAgWs5BA (envelope-from ) for ; Sat, 28 Aug 2021 09:09:50 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id mIKeNz3hKWFdFQAAB5/wlQ (envelope-from ) for ; Sat, 28 Aug 2021 07:09:49 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6BA3A1E5B7 for ; Sat, 28 Aug 2021 09:09:49 +0200 (CEST) Received: from localhost ([::1]:58364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJsTM-0002Mz-FY for larch@yhetil.org; Sat, 28 Aug 2021 03:09:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJsRC-0001Mu-Ir for emacs-orgmode@gnu.org; Sat, 28 Aug 2021 03:07:35 -0400 Received: from ciao.gmane.io ([116.202.254.214]:55146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJsR8-0000Gs-Iq for emacs-orgmode@gnu.org; Sat, 28 Aug 2021 03:07:32 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mJsR6-0004jE-Hz for emacs-orgmode@gnu.org; Sat, 28 Aug 2021 09:07:28 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Jarmo Hurri Subject: Org table: numeric locale Date: Sat, 28 Aug 2021 10:07:19 +0300 Message-ID: <8735qut5co.fsf@iki.fi> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:FcFlg1YRgiB8S63Ty8Pxa/JlV04= Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630134589; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=fDVqjkFSzNFsYctV+BWKVOyPMmE4uLkd5kHFnF6GlCc=; b=HrR0NsdF36lP2m0NFz5rbcj8Sl9cSqnlLGJy0zb5HPhxxSBPFK/XmpMfLVFpyXjKGPhQ5l CWpkxrAejWKo6UxbkwrigfroEpWr63kKgkFORwQ2qblvXW+lUcycRh37MNJJHP1kX/5Vl9 463p3UpRAclLMV8otO3FCh/48LbOx25FU0Vu37vgGvjC8+bw0abUpqAo+M3tGJV3PYG6nl Ft9jKY06PPigYn08GKQPQBVRctEPkswwzX7xY+40k4+vX5QMIrmVsSOyqRBism5UmWDecd 7NiX0+WYuQJa8cPUj0iPMq5KOwieVvrLyTOTa1qGt14GWnPqd7v+B3REYtiSXQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630134589; a=rsa-sha256; cv=none; b=brelbUUUZClS4rA5XLSOgJY8/O0TN8RDfKnwsQpzDJe4WZ6wE0QhEK1YojlaQUbjyhywd4 lU8HuouJAyNUNleOAJbEfcp3MCXDsrzviT9i0+dMISjUT6cls22D5da1FxdQriaQKS2elk ugcMCl1ttC9gpV0EPN9pukdDXEUCH7+OObEs1om0dUsw62S1Ur/BbedhUkWaPzkvP+/v2O Q/1q1YaSnrtIPbaN4AZFQyUV4xf1/8vz6d16fvdskdS81Qnu6wotpE488o7v6Oq1TROiDp emIkx4XV+9WcYAZdr9rKHkejAb1Q6J2TqihF4mmE+lanossFkfLGnaJgsqnAQw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -0.43 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 6BA3A1E5B7 X-Spam-Score: -0.43 X-Migadu-Scanner: scn0.migadu.com X-TUID: RDDuI6GazgsB Greetings. I wonder if it is possible to get org table formulas to respect numeric locale. Emacs documentation says that Emacs uses the value of LC_NUMERIC: https://www.gnu.org/software/emacs/manual/html_node/emacs/General-Variables.html However, even though I have a value of LC_NUMERIC which specifies comma as a decimal separator, I get dot as a decimal separator when formatting a floating point value in both elisp and in org table formula. So yes, I am aware that the source of the issue is likely to be in Emacs, but I only need a solution for org only. The example at the end of this message tries to illustrate all aspects: what my environment variables are, what Emacs sees and does, what org does, and how to force locale in another language (C++). Have fun and stay safe, Jarmo # ------------------------------------------------------------------------- * My relevant locale variables in shell #+begin_src sh echo "LANG: ${LANG}" echo "LC_ALL: ${LC_ALL}" echo "LC_NUMERIC: ${LC_NUMERIC}" #+end_src #+RESULTS: | LANG: | en_GB.UTF-8 | | LC_ALL: | | | LC_NUMERIC: | fi_FI.UTF-8 | * What emacs sees and does Emacs uses dot, not comma, as decimal separator. #+begin_src elisp (let ((env (mapconcat 'getenv (list "LANG" "LC_ALL" "LC_NUMERIC") " ")) (str (format "%.2f" (/ 1.0 3)))) (concat env "\n" str "\n" (emacs-version))) #+end_src #+RESULTS: : en_GB.UTF-8 fi_FI.UTF-8 : 0.33 : GNU Emacs 27.2 (build 1, x86_64-redhat-linux-gnu, GTK+ Version 3.24.30, cairo version 1.17.4) : of 2021-08-07 * What Org table does Org table also uses dot, not comma, as decimal separator. | 0.33 | #+TBLFM: @1$1=1.0/3;%.2f * C++ version (for comparison) #+begin_src C++ :results raw #include #include #include int main (int argc, char* argv[]) { // I have to set locale, it is not obtained automatically from // shell environment setlocale (LC_NUMERIC, getenv ("LC_NUMERIC")); printf ("%.2f", 1.0 / 3); exit (0); } #+end_src #+RESULTS: 0,33 # -------------------------------------------------------------------------