Function: org-table--to-generic-cell
org-table--to-generic-cell is a byte-compiled function defined in
org-table.el.gz.
Signature
(org-table--to-generic-cell PARAMS)
Documentation
Return custom table cell transcoder according to PARAMS.
PARAMS is a plist. See orgtbl-to-generic for more
information.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
(defun org-table--to-generic-cell (params)
"Return custom table cell transcoder according to PARAMS.
PARAMS is a plist. See `orgtbl-to-generic' for more
information."
(let* ((backend (plist-get params :backend))
(efmt (plist-get params :efmt))
(fmt (plist-get params :fmt))
(hfmt (plist-get params :hfmt))
(sep (plist-get params :sep))
(hsep (plist-get params :hsep)))
`(lambda (cell contents info)
;; Make sure that contents are exported as Org data when :raw
;; parameter is non-nil.
,(when (and backend (plist-get params :raw))
`(setq contents
;; Since we don't know what are the pseudo object
;; types defined in backend, we cannot pass them to
;; `org-element-interpret-data'. As a consequence,
;; they will be treated as pseudo elements, and will
;; have newlines appended instead of spaces.
;; Therefore, we must make sure :post-blank value is
;; really turned into spaces.
(replace-regexp-in-string
"\n" " "
(org-trim
(org-element-interpret-data
(org-element-contents cell))))))
(let ((headerp ,(and (or hfmt hsep)
'(org-export-table-row-in-header-p
(org-element-parent-element cell) info)))
(column
;; Call costly `org-export-table-cell-address' only if
;; absolutely necessary, i.e., if one
;; of :fmt :efmt :hfmt has a "plist type" value.
,(and (cl-some (lambda (v) (integerp (car-safe v)))
(list efmt hfmt fmt))
'(1+ (cdr (org-export-table-cell-address cell info))))))
(when contents
;; Check if we can apply `:efmt' on CONTENTS.
,(when efmt
`(when (string-match orgtbl-exp-regexp contents)
(let ((mantissa (match-string 1 contents))
(exponent (match-string 2 contents)))
(setq contents ,(org-table--generic-apply
efmt ":efmt" t 'mantissa 'exponent)))))
;; Check if we can apply FMT (or HFMT) on CONTENTS.
(cond
,(and hfmt `(headerp (setq contents ,(org-table--generic-apply
hfmt ":hfmt" t 'contents))))
,(and fmt `(t (setq contents ,(org-table--generic-apply
fmt ":fmt" t 'contents))))))
;; If a separator is provided, use it instead of BACKEND's.
;; Separators are ignored when LFMT (or equivalent) is
;; provided.
,(cond
((or hsep sep)
`(if (or ,(and (not sep) '(not headerp))
(plist-get info :orgtbl-ignore-sep)
(not (org-export-get-next-element cell info)))
,(if (not backend) 'contents
`(org-export-with-backend ',backend cell contents info))
(concat contents
,(if (and sep hsep) `(if headerp ,hsep ,sep)
(or hsep sep)))))
(backend `(org-export-with-backend ',backend cell contents info))
(t 'contents))))))