在组织模式电子表格中显示千位分隔符

jac*_*soe 5 emacs org-mode

有没有一种方法可以配置组织模式电子表格以显示数千个分隔符?我希望将1000显示为1000。

Jef*_*Leo 1

这是一个解决方案。首先定义函数组号

(defun group-number (num &optional size char)
    "Format NUM as string grouped to SIZE with CHAR."
    ;; Based on code for `math-group-float' in calc-ext.el
    (let* ((size (or size 3))
           (char (or char ","))
           (str (if (stringp num)
                    num
                  (number-to-string num)))
            ;; omitting any trailing non-digit chars
            ;; NOTE: Calc supports BASE up to 36 (26 letters and 10 digits ;)
           (pt (or (string-match "[^0-9a-zA-Z]" str) (length str))))
      (while (> pt size)
        (setq str (concat (substring str 0 (- pt size))
                          char
                          (substring str (- pt size)))
              pt (- pt size)))
      str))
Run Code Online (Sandbox Code Playgroud)

来自:Emacs Cookbook - 在数字中添加逗号

Next, use it in your formula:
|           |       |             |
|-----------+-------+-------------|
|      2000 |  3100 |       5,100 |
|        11 |    22 |          33 |
| 111221212 | 29996 | 111,251,208 |
|           |       |           0 |
#+TBLFM: $3='(group-number (+ $1 $2));N
Run Code Online (Sandbox Code Playgroud)

这里我们使用group-number函数来格式化 emacs lisp 表单的结果 - 而不是使用计算公式语法。