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 ms11 with LMTPS id kMq1IV7BjV+jOAAA0tVLHw (envelope-from ) for ; Mon, 19 Oct 2020 16:39:58 +0000 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 iHuOHV7BjV9aGQAAB5/wlQ (envelope-from ) for ; Mon, 19 Oct 2020 16:39:58 +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 1DF909402B0 for ; Mon, 19 Oct 2020 16:39:58 +0000 (UTC) Received: from localhost ([::1]:53296 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUXFI-0006hb-Uz for larch@yhetil.org; Mon, 19 Oct 2020 11:38:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47836) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUXEv-0006hR-0m for emacs-orgmode@gnu.org; Mon, 19 Oct 2020 11:38:25 -0400 Received: from grinta.net ([109.74.203.128]:42828) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUXEt-00067t-15 for emacs-orgmode@gnu.org; Mon, 19 Oct 2020 11:38:24 -0400 Received: from black.local (unknown [46.165.233.56]) (Authenticated sender: daniele) by grinta.net (Postfix) with ESMTPSA id 12A47ED187 for ; Mon, 19 Oct 2020 15:38:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=grinta.net; s=2020; t=1603121899; bh=gtQQu/73k8LUSMK8hVNU+Ae0v0wgpx7Y1i0111V0SMo=; h=To:From:Subject:Date:From; b=X9qynQqDUFK+FmyssmLmfcJiA/5YQn+PIen3bRPidOwf/xjGtmMcKcC0YkGUx0gde tHQkrszk4ca3Ooim9C+o5xFIS/XpqD5MhHAhruEtjljtcC/PXxdsgSqWlamNE0nhkh BE24/eR2T7vLSxOtCDmBe4O+eR0tskBdnacAt1v2qSgFMYxViAualpssSbb6Y44dUg xz8HV3ftXZim8HjB4TC38TRbEEL3QOGbw8lsq6Q2zxfSUOCMwfSIkKfPsA9DvQIfAj P927W6oLnFIeFV6i8wiyYSu90MZMneE18ZiKvWwqlY+I1Jz/k2po8dGmhMFUFbnFVJ VGy62AmjFmaBQ== To: Org Mode List From: Daniele Nicolodi Subject: Bug in org-table--set-calc-mode? Message-ID: <6d8c15c2-d1b0-d913-df39-c60381cff70b@grinta.net> Date: Mon, 19 Oct 2020 17:38:17 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=109.74.203.128; envelope-from=daniele@grinta.net; helo=grinta.net X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 11:38:19 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=fail (rsa verify failed) header.d=grinta.net header.s=2020 header.b=X9qynQqD; 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-Spam-Score: 0.99 X-TUID: 1DBXJRzUr4Vo Hello, I am hacking org-table-eval-formula (see thread about monetary values in org-tables) which uses this inline function: (defsubst org-table--set-calc-mode (var &optional value) (if (stringp var) (setq var (assoc var '(("D" calc-angle-mode deg) ("R" calc-angle-mode rad) ("F" calc-prefer-frac t) ("S" calc-symbolic-mode t))) value (nth 2 var) var (nth 1 var))) (if (memq var org-tbl-calc-modes) (setcar (cdr (memq var org-tbl-calc-modes)) value) (cons var (cons value org-tbl-calc-modes))) org-tbl-calc-modes) which I am not able to understand or which is not correct. The first (if ...) does some value substitutions, however, IIUC the second (if ...) sets a new value for an entry in the org-tbl-calc-modes plist if the entry is already present and builds a new plist with the entry prepended if the entry is not there. However, the original plist is returned and not the one with the new entry prepended. It does not seem to be the intended behavior. Shouldn't this be simply: (defsubst org-table--set-calc-mode (var &optional value) (if (stringp var) (setq var (assoc var '(("D" calc-angle-mode deg) ("R" calc-angle-mode rad) ("F" calc-prefer-frac t) ("S" calc-symbolic-mode t))) value (nth 2 var) var (nth 1 var))) (plist-put org-tbl-calc-modes var value)) or, better, the code refactored to do not use this function? Cheers, Dan