如何在org-table中的点获取列名和字段名

时间:2017-12-27 07:21:38

标签: emacs org-mode spacemacs

像这样的表:

|  Time | ---AAA ---  | ---BBB ---  |
|-------+-------------+-------------+
|  9:45 |             |             |
| 10:00 |             |             |
| 10:15 |  i am here  |             |
| 10:30 |             |             |
| 10:45 |             |             |
|-------+-------------+-------------+

当我输入“我在这里”的行时,是否有任何内置函数可以执行此操作?

get-current-column-name(),return "AAA"
get-current-line-name(),return "10:15"

1 个答案:

答案 0 :(得分:3)

我找不到任何内置函数,所以我写了它们,希望它有所帮助

(defun dindom/org-table-get-current-colname()
  "get current column name if in org table"
  (if (org-table-p)
      (org-table-get 1 nil)
    (message "not in table!")
    )
  )

(defun dindom/org-table-get-current-linename()
  "get current line name if in org table"
  (if (org-table-p)
      (org-table-get nil 1)
    (message "not in table!")
    )
  )

或使用org-table-get-field:

(defun dindom/org-table-get-current-linename()
  "get current line name if in org table"
  (if (org-table-p)
      (save-excursion
        (org-table-get-field 1)
        )
    (message "not in table!")
    )
  )