make comment-dwim in source code blocks more DWIM-ish
[org-mode/org-tableheadings.git] / contrib / lisp / ox-groff.el
blob245b67d7f478952fd1fdb25a1833ebce5f642df6
1 ;;; ox-groff.el --- Groff Back-End for Org Export Engine
3 ;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
5 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
6 ;; Author: Luis R Anaya <papoanaya aroba hot mail punto com>
7 ;; Keywords: outlines, hypermedia, calendar, wp
9 ;; This file is not part of GNU Emacs.
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; This library implements a Groff Memorandum Macro back-end for Org
26 ;; generic exporter.
28 ;; To test it, run
30 ;; M-: (org-export-to-buffer 'groff "*Test Groff*") RET
32 ;; in an org-mode buffer then switch to the buffer to see the Groff
33 ;; export. See ox.el for more details on how this exporter works.
35 ;; It introduces two new buffer keywords: "GROFF_CLASS" and
36 ;; "GROFF_CLASS_OPTIONS".
38 ;;; Code:
40 (eval-when-compile (require 'cl))
41 (require 'ox)
43 (defvar orgtbl-exp-regexp)
46 ;;; Define Back-End
48 (org-export-define-backend 'groff
49 '((bold . org-groff-bold)
50 (center-block . org-groff-center-block)
51 (clock . org-groff-clock)
52 (code . org-groff-code)
53 (comment . (lambda (&rest args) ""))
54 (comment-block . (lambda (&rest args) ""))
55 (drawer . org-groff-drawer)
56 (dynamic-block . org-groff-dynamic-block)
57 (entity . org-groff-entity)
58 (example-block . org-groff-example-block)
59 (export-block . org-groff-export-block)
60 (export-snippet . org-groff-export-snippet)
61 (fixed-width . org-groff-fixed-width)
62 (footnote-definition . org-groff-footnote-definition)
63 (footnote-reference . org-groff-footnote-reference)
64 (headline . org-groff-headline)
65 (horizontal-rule . org-groff-horizontal-rule)
66 (inline-src-block . org-groff-inline-src-block)
67 (inlinetask . org-groff-inlinetask)
68 (italic . org-groff-italic)
69 (item . org-groff-item)
70 (keyword . org-groff-keyword)
71 (line-break . org-groff-line-break)
72 (link . org-groff-link)
73 (node-property . org-groff-node-property)
74 (paragraph . org-groff-paragraph)
75 (plain-list . org-groff-plain-list)
76 (plain-text . org-groff-plain-text)
77 (planning . org-groff-planning)
78 (property-drawer . org-groff-property-drawer)
79 (quote-block . org-groff-quote-block)
80 (quote-section . org-groff-quote-section)
81 (radio-target . org-groff-radio-target)
82 (section . org-groff-section)
83 (special-block . org-groff-special-block)
84 (src-block . org-groff-src-block)
85 (statistics-cookie . org-groff-statistics-cookie)
86 (strike-through . org-groff-strike-through)
87 (subscript . org-groff-subscript)
88 (superscript . org-groff-superscript)
89 (table . org-groff-table)
90 (table-cell . org-groff-table-cell)
91 (table-row . org-groff-table-row)
92 (target . org-groff-target)
93 (template . org-groff-template)
94 (timestamp . org-groff-timestamp)
95 (underline . org-groff-underline)
96 (verbatim . org-groff-verbatim)
97 (verse-block . org-groff-verse-block))
98 :export-block "GROFF"
99 :menu-entry
100 '(?g "Export to GROFF"
101 ((?g "As GROFF file" org-groff-export-to-groff)
102 (?p "As PDF file" org-groff-export-to-pdf)
103 (?o "As PDF file and open"
104 (lambda (a s v b)
105 (if a (org-groff-export-to-pdf t s v b)
106 (org-open-file (org-groff-export-to-pdf nil s v b)))))))
107 :options-alist
108 '((:groff-class "GROFF_CLASS" nil org-groff-default-class t)
109 (:groff-class-options "GROFF_CLASS_OPTIONS" nil nil t)
110 (:groff-header-extra "GROFF_HEADER" nil nil newline)))
114 ;;; User Configurable Variables
116 (defgroup org-export-groff nil
117 "Options for exporting Org mode files to Groff."
118 :tag "Org Export Groff"
119 :group 'org-export)
121 ;;; Preamble
123 (defcustom org-groff-default-class "internal"
124 "The default Groff class."
125 :group 'org-export-groff
126 :type '(string :tag "Groff class"))
128 (defcustom org-groff-classes
129 '(("file" ".MT 1"
130 (:heading 'default :type "memo" :last-section "toc"))
131 ("internal" ".MT 0"
132 (:heading 'default :type "memo" :last-section "toc"))
133 ("programmer" ".MT 2"
134 (:heading 'default :type "memo" :last-section "toc"))
135 ("engineer" ".MT 3"
136 (:heading 'default :type "memo" :last-section "toc"))
137 ("external" ".MT 4"
138 (:heading 'default :type "memo" :last-section "toc"))
139 ("letter" ".MT 5"
140 (:heading 'default :type "memo" :last-section "sign"))
141 ("custom" ".so file"
142 (:heading custom-function :type "custom" :last-section "toc"))
143 ("dummy" ""
144 (:heading 'default :type "memo"))
145 ("ms" "ms"
146 (:heading 'default :type "cover" :last-section "toc"))
147 ("se_ms" "se_ms"
148 (:heading 'default :type "cover" :last-section "toc"))
149 ("block" "BL"
150 (:heading 'default :type "letter" :last-section "sign"))
151 ("semiblock" "SB"
152 (:heading 'default :type "letter" :last-section "sign"))
153 ("fullblock" "FB"
154 (:heading 'default :type "letter" :last-section "sign"))
155 ("simplified" "SP"
156 (:heading 'default :type "letter" :last-section "sign"))
157 ("none" "" (:heading 'default :type "custom")))
159 ;; none means, no Cover or Memorandum Type and no calls to AU, AT, ND and TL
160 ;; This is to facilitate the creation of custom pages.
162 ;; dummy means, no Cover or Memorandum Type but calls to AU, AT, ND and TL
163 ;; are made. This is to facilitate Abstract Insertion.
165 "This list describes the attributes for the documents being created.
166 It allows for the creation of new "
167 :group 'org-export-groff
168 :type '(repeat
169 (list (string :tag "Document Type")
170 (string :tag "Header")
171 (repeat :tag "Options" :inline t
172 (choice
173 (list :tag "Heading")
174 (function :tag "Hook computing sectioning"))))))
176 ;;; Headline
178 (defconst org-groff-special-tags
179 '("FROM" "TO" "ABSTRACT" "APPENDIX" "BODY" "NS"))
181 (defcustom org-groff-format-headline-function nil
182 "Function to format headline text.
184 This function will be called with 5 arguments:
185 TODO the todo keyword (string or nil).
186 TODO-TYPE the type of todo (symbol: `todo', `done', nil)
187 PRIORITY the priority of the headline (integer or nil)
188 TEXT the main headline text (string).
189 TAGS the tags as a list of strings (list of strings or nil).
191 The function result will be used in the section format string.
193 As an example, one could set the variable to the following, in
194 order to reproduce the default set-up:
196 \(defun org-groff-format-headline (todo todo-type priority text tags)
197 \"Default format function for a headline.\"
198 \(concat (when todo
199 \(format \"\\fB%s\\fP \" todo))
200 \(when priority
201 \(format \"[\\#%c] \" priority))
202 text
203 \(when tags
204 \(format \" %s \"
205 \(mapconcat 'identity tags \":\"))))"
206 :group 'org-export-groff
207 :type 'function)
209 ;;; Timestamps
211 (defcustom org-groff-active-timestamp-format "\\fI%s\\fP"
212 "A printf format string to be applied to active timestamps."
213 :group 'org-export-groff
214 :type 'string)
216 (defcustom org-groff-inactive-timestamp-format "\\fI%s\\fP"
217 "A printf format string to be applied to inactive timestamps."
218 :group 'org-export-groff
219 :type 'string)
221 (defcustom org-groff-diary-timestamp-format "\\fI%s\\fP"
222 "A printf format string to be applied to diary timestamps."
223 :group 'org-export-groff
224 :type 'string)
226 ;;; Links
228 (defcustom org-groff-inline-image-rules
229 '(("file" . "\\.\\(jpg\\|png\\|pdf\\|ps\\|eps\\|pic\\)\\'")
230 ("fuzzy" . "\\.\\(jpg\\|png\\|pdf\\|ps\\|eps\\|pic\\)\\'"))
231 "Rules characterizing image files that can be inlined into Groff.
233 A rule consists in an association whose key is the type of link
234 to consider, and value is a regexp that will be matched against
235 link's path.
237 Note that, by default, the image extensions actually allowed
238 depend on the way the Groff file is processed. When used with
239 pdfgroff, pdf, jpg and png images are OK. When processing
240 through dvi to Postscript, only ps and eps are allowed. The
241 default we use here encompasses both."
242 :group 'org-export-groff
243 :type '(alist :key-type (string :tag "Type")
244 :value-type (regexp :tag "Path")))
246 (defcustom org-groff-link-with-unknown-path-format "\\fI%s\\fP"
247 "Format string for links with unknown path type."
248 :group 'org-export-groff
249 :type 'string)
251 ;;; Tables
253 (defcustom org-groff-tables-centered t
254 "When non-nil, tables are exported in a center environment."
255 :group 'org-export-groff
256 :type 'boolean)
258 (defcustom org-groff-tables-verbatim nil
259 "When non-nil, tables are exported verbatim."
260 :group 'org-export-groff
261 :type 'boolean)
263 (defcustom org-groff-table-scientific-notation "%sE%s"
264 "Format string to display numbers in scientific notation.
265 The format should have \"%s\" twice, for mantissa and exponent
266 \(i.e. \"%s\\\\times10^{%s}\").
268 When nil, no transformation is made."
269 :group 'org-export-groff
270 :type '(choice
271 (string :tag "Format string")
272 (const :tag "No formatting")))
274 ;;; Text markup
276 (defcustom org-groff-text-markup-alist
277 '((bold . "\\fB%s\\fP")
278 (code . "\\fC%s\\fP")
279 (italic . "\\fI%s\\fP")
280 (strike-through . "\\fC%s\\fP") ; Strike through and underline
281 (underline . "\\fI%s\\fP") ; need to be revised.
282 (verbatim . "protectedtexttt"))
283 "Alist of Groff expressions to convert text markup.
285 The key must be a symbol among `bold', `code', `italic',
286 `strike-through', `underline' and `verbatim'. The value is
287 a formatting string to wrap fontified text with it.
289 If no association can be found for a given markup, text will be
290 returned as-is."
291 :group 'org-export-groff
292 :type 'alist
293 :options '(bold code italic strike-through underline verbatim))
295 ;;; Drawers
297 (defcustom org-groff-format-drawer-function nil
298 "Function called to format a drawer in Groff code.
300 The function must accept two parameters:
301 NAME the drawer name, like \"LOGBOOK\"
302 CONTENTS the contents of the drawer.
304 The function should return the string to be exported.
306 For example, the variable could be set to the following function
307 in order to mimic default behaviour:
309 \(defun org-groff-format-drawer-default \(name contents\)
310 \"Format a drawer element for Groff export.\"
311 contents\)"
312 :group 'org-export-groff
313 :type 'function)
315 ;;; Inlinetasks
317 (defcustom org-groff-format-inlinetask-function nil
318 "Function called to format an inlinetask in Groff code.
320 The function must accept six parameters:
321 TODO the todo keyword, as a string
322 TODO-TYPE the todo type, a symbol among `todo', `done' and nil.
323 PRIORITY the inlinetask priority, as a string
324 NAME the inlinetask name, as a string.
325 TAGS the inlinetask tags, as a list of strings.
326 CONTENTS the contents of the inlinetask, as a string.
328 The function should return the string to be exported.
330 For example, the variable could be set to the following function
331 in order to mimic default behaviour:
333 \(defun org-groff-format-inlinetask \(todo type priority name tags contents\)
334 \"Format an inline task element for Groff export.\"
335 \(let ((full-title
336 \(concat
337 \(when todo
338 \(format \"\\fB%s\\fP \" todo))
339 \(when priority (format \"[\\#%c] \" priority))
340 title
341 \(when tags
342 \(format \":%s:\"
343 \(mapconcat 'identity tags \":\")))))
344 \(format (concat \".DS L\\n\"
345 \"%s\\n\\n\"
346 \"%s\"
347 \".DE\")
348 full-title contents))"
349 :group 'org-export-groff
350 :type 'function)
352 ;; Src blocks
354 (defcustom org-groff-source-highlight nil
355 "Use GNU source highlight to embellish source blocks "
356 :group 'org-export-groff
357 :type 'boolean)
359 (defcustom org-groff-source-highlight-langs
360 '((emacs-lisp "lisp") (lisp "lisp") (clojure "lisp")
361 (scheme "scheme")
362 (c "c") (cc "cpp") (csharp "csharp") (d "d")
363 (fortran "fortran") (cobol "cobol") (pascal "pascal")
364 (ada "ada") (asm "asm")
365 (perl "perl") (cperl "perl")
366 (python "python") (ruby "ruby") (tcl "tcl") (lua "lua")
367 (java "java") (javascript "javascript")
368 (tex "latex")
369 (shell-script "sh") (awk "awk") (diff "diff") (m4 "m4")
370 (ocaml "caml") (caml "caml")
371 (sql "sql") (sqlite "sql")
372 (html "html") (css "css") (xml "xml")
373 (bat "bat") (bison "bison") (clipper "clipper")
374 (ldap "ldap") (opa "opa")
375 (php "php") (postscript "postscript") (prolog "prolog")
376 (properties "properties") (makefile "makefile")
377 (tml "tml") (vala "vala") (vbscript "vbscript") (xorg "xorg"))
378 "Alist mapping languages to their listing language counterpart.
379 The key is a symbol, the major mode symbol without the \"-mode\".
380 The value is the string that should be inserted as the language
381 parameter for the listings package. If the mode name and the
382 listings name are the same, the language does not need an entry
383 in this list - but it does not hurt if it is present."
384 :group 'org-export-groff
385 :type '(repeat
386 (list
387 (symbol :tag "Major mode ")
388 (string :tag "Listings language"))))
390 (defcustom org-groff-source-highlight-options nil
391 "Association list of options for the groff listings package.
393 These options are supplied as a comma-separated list to the
394 \\lstset command. Each element of the association list should be
395 a list containing two strings: the name of the option, and the
396 value. For example,
398 (setq org-groff-source-highlight-options
399 '((\"basicstyle\" \"\\small\")
400 (\"keywordstyle\" \"\\color{black}\\bfseries\\underbar\")))
402 will typeset the code in a small size font with underlined, bold
403 black keywords.
405 Note that the same options will be applied to blocks of all
406 languages."
407 :group 'org-export-groff
408 :type '(repeat
409 (list
410 (string :tag "Listings option name ")
411 (string :tag "Listings option value"))))
413 (defvar org-groff-custom-lang-environments nil
414 "Alist mapping languages to language-specific Groff environments.
416 It is used during export of src blocks by the listings and
417 groff packages. For example,
419 \(setq org-groff-custom-lang-environments
420 '\(\(python \"pythoncode\"\)\)\)
422 would have the effect that if org encounters begin_src python
423 during groff export it will use pythoncode as the source-highlight
424 language.")
426 ;;; Plain text
428 (defcustom org-groff-special-char
429 '(("(c)" . "\\\\(co")
430 ("(tm)" . "\\\\(tm")
431 ("(rg)" . "\\\\(rg"))
432 "CONS list in which the value of the car
433 is replace on the value of the CDR. "
434 :group 'org-export-groff
435 :type '(list
436 (cons :tag "Character Subtitute"
437 (string :tag "Original Character Group")
438 (string :tag "Replacement Character"))))
440 ;;; Compilation
442 (defcustom org-groff-pdf-process
443 '("pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf"
444 "pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf"
445 "pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf")
447 "Commands to process a Groff file to a PDF file.
448 This is a list of strings, each of them will be given to the
449 shell as a command. %f in the command will be replaced by the
450 full file name, %b by the file base name \(i.e. without
451 extension) and %o by the base directory of the file."
452 :group 'org-export-pdf
453 :type '(choice
454 (repeat :tag "Shell command sequence"
455 (string :tag "Shell command"))
456 (const :tag "2 runs of pdfgroff"
457 ("pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf"
458 "pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf"))
459 (const :tag "3 runs of pdfgroff"
460 ("pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf"
461 "pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf"
462 "pic %f | tbl | eqn | groff -mm | ps2pdf - > %b.pdf"))
463 (function)))
465 (defcustom org-groff-logfiles-extensions
466 '("aux" "idx" "log" "out" "toc" "nav" "snm" "vrb")
467 "The list of file extensions to consider as Groff logfiles."
468 :group 'org-export-groff
469 :type '(repeat (string :tag "Extension")))
471 (defcustom org-groff-remove-logfiles t
472 "Non-nil means remove the logfiles produced by PDF production.
473 These are the .aux, .log, .out, and .toc files."
474 :group 'org-export-groff
475 :type 'boolean)
477 (defcustom org-groff-organization "Org User"
478 "Name of the organization used to populate the .AF command."
479 :group 'org-export-groff
480 :type 'string)
482 (defcustom org-groff-raster-to-ps nil
483 "Command used to convert raster to EPS. Nil for no conversion. Make sure that
484 `org-groff-inline-image-rules' is adjusted accordingly if not conversion is being
485 done. In this case, remove the entries for jpg and png in the file and fuzzy lists."
486 :group 'org-export-groff
487 :type '(choice
488 (repeat :tag "Shell Command Sequence" (string :tag "Shell Command"))
489 (const :tag "sam2p" "a=%s;b=%s;sam2p ${a} ${b} ;grep -v BeginData ${b} > b_${b};mv b_${b} ${b}" )
490 (const :tag "NetPNM" "a=%s;b=%s;pngtopnm ${a} | pnmtops -noturn > ${b}" )
491 (const :tag "None" nil)))
493 (defvar org-groff-registered-references nil)
494 (defvar org-groff-special-content nil)
498 ;;; Internal Functions
500 (defun org-groff--caption/label-string (element info)
501 "Return caption and label Groff string for ELEMENT.
503 INFO is a plist holding contextual information. If there's no
504 caption nor label, return the empty string.
506 For non-floats, see `org-groff--wrap-label'."
507 (let ((main (org-export-get-caption element))
508 (short (org-export-get-caption element t))
509 (label (org-element-property :name element)))
510 (cond ((and (not main) (not label)) "")
511 ((not main) (format "\\fI%s\\fP" label))
512 ;; Option caption format with short name.
513 (short (format "%s\n.br\n - %s\n"
514 (org-export-data short info)
515 (org-export-data main info)))
516 ;; Standard caption format.
517 (t (format "\\fR%s\\fP" (org-export-data main info))))))
519 (defun org-groff--wrap-label (element output)
520 "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
521 This function shouldn't be used for floats. See
522 `org-groff--caption/label-string'."
523 (let ((label (org-element-property :name element)))
524 (if (or (not output) (not label) (string= output "") (string= label ""))
525 output
526 (concat (format "%s\n.br\n" label) output))))
528 (defun org-groff--text-markup (text markup)
529 "Format TEXT depending on MARKUP text markup.
530 See `org-groff-text-markup-alist' for details."
531 (let ((fmt (cdr (assq markup org-groff-text-markup-alist))))
532 (cond
533 ;; No format string: Return raw text.
534 ((not fmt) text)
535 ((string= "protectedtexttt" fmt)
536 (let ((start 0)
537 (trans '(("\\" . "\\")))
538 (rtn "")
539 char)
540 (while (string-match "[\\{}$%&_#~^]" text)
541 (setq char (match-string 0 text))
542 (if (> (match-beginning 0) 0)
543 (setq rtn (concat rtn (substring text 0 (match-beginning 0)))))
544 (setq text (substring text (1+ (match-beginning 0))))
545 (setq char (or (cdr (assoc char trans)) (concat "\\" char))
546 rtn (concat rtn char)))
547 (setq text (concat rtn text))
548 (format "\\fC%s\\fP" text)))
549 ;; Else use format string.
550 (t (format fmt text)))))
553 (defun org-groff--get-tagged-content (tag info)
554 (cdr (assoc tag org-groff-special-content)))
556 (defun org-groff--mt-head (title contents attr info)
557 (concat
559 ;; 1. Insert Organization
560 (let ((firm-option (plist-get attr :firm)))
561 (cond
562 ((stringp firm-option)
563 (format ".AF \"%s\" \n" firm-option))
564 (t (format ".AF \"%s\" \n" (or org-groff-organization "")))))
566 ;; 2. Title
567 (let ((subtitle1 (plist-get attr :subtitle1))
568 (subtitle2 (plist-get attr :subtitle2)))
570 (cond
571 ((string= "" title)
572 (format ".TL \"%s\" \"%s\" \n%s\n"
573 (or subtitle1 "")
574 (or subtitle2 "") " "))
576 ((not (or subtitle1 subtitle2))
577 (format ".TL\n%s\n"
578 (or title "")))
580 (format ".TL \"%s\" \"%s \" \n%s\n"
581 (or subtitle1 "")
582 (or subtitle2 "") title))))
584 ;; 3. Author.
585 ;; In Groff, .AU *MUST* be placed after .TL
586 ;; If From, populate with data from From else
588 (let ((author (and (plist-get info :with-author)
589 (let ((auth (plist-get info :author)))
590 (and auth (org-export-data auth info)))))
591 (email (and (plist-get info :with-email)
592 (org-export-data (plist-get info :email) info)))
593 (from-data (org-groff--get-tagged-content "FROM" info))
595 (to-data (org-groff--get-tagged-content "TO" info)))
597 (cond
598 ((and author from-data)
599 (let ((au-line
600 (mapconcat
601 (lambda (from-line)
602 (format " \"%s\" " from-line))
603 (split-string
604 (setq from-data
605 (replace-regexp-in-string "\\.P\n" "" from-data)) "\n") "")))
607 (concat
608 (format ".AU \"%s\" " author) au-line "\n")))
610 ((and author email (not (string= "" email)))
611 (format ".AU \"%s\" \"%s\"\n" author email))
613 (author (format ".AU \"%s\"\n" author))
615 (t ".AU \"\" \n")))
618 ;; 4. Author Title, if present
619 (let ((at-item (plist-get attr :author-title)))
620 (if (and at-item (stringp at-item))
621 (format ".AT \"%s\" \n" at-item)
622 ""))
624 ;; 5. Date.
625 (when (plist-get info :with-date)
626 (let ((date (org-export-data (org-export-get-date info) info)))
627 (and (org-string-nw-p date) (format ".ND \"%s\"\n" date))))
630 ;; If Abstract, then Populate Abstract
633 (let ((abstract-data (org-groff--get-tagged-content "ABSTRACT" info))
634 (to-data (org-groff--get-tagged-content "TO" info)))
635 (cond
636 (abstract-data
637 (format ".AS\n%s\n.AE\n" abstract-data))
638 (to-data
639 (format ".AS\n%s\n.AE\n" to-data))))))
641 (defun org-groff--letter-head (title contents attr info)
642 (let ((author (and (plist-get info :with-author)
643 (let ((auth (plist-get info :author)))
644 (and auth (org-export-data auth info)))))
645 (email (and (plist-get info :with-email)
646 (org-export-data (plist-get info :email) info)))
647 (from-data (org-groff--get-tagged-content "FROM" info))
648 (at-item (plist-get attr :author-title))
649 (to-data (org-groff--get-tagged-content "TO" info)))
652 ;; If FROM then get data from FROM
653 (if from-data
654 (setq from-data
655 (replace-regexp-in-string "\\.P\n" "" from-data))
656 (setq from-data ""))
658 (if to-data
659 (setq to-data
660 (replace-regexp-in-string "\\.P\n" "" to-data))
661 (setq from-data ""))
663 (concat
664 (cond
665 (from-data
666 (format ".WA \"%s\" \"%s\" \n%s\n.WE\n" author (or at-item "") from-data))
667 ((and author email (not (string= "" email)))
668 (format ".WA \"%s\"\n \"%s\"\n.WE\n" author email))
669 (author (format ".WA \"%s\"\n.WE\n" author))
670 (t ".WA \"\" \n.WE\n"))
672 ;; If TO then get data from TO
674 (when to-data
675 (format ".IA \n%s\n.IE\n" to-data)))))
678 ;;; Template
680 (defun org-groff-template (contents info)
681 "Return complete document string after Groff conversion.
682 CONTENTS is the transcoded contents string. INFO is a plist
683 holding export options."
684 (let* ((title (org-export-data (plist-get info :title) info))
685 (attr (read
686 (format "(%s)"
687 (mapconcat
688 #'identity
689 (list (plist-get info :groff-class-options))
690 " "))))
691 (class (plist-get info :groff-class))
692 (class-options (plist-get info :groff-class-options))
693 (classes (assoc class org-groff-classes))
694 (classes-options (car (last classes)))
695 (heading-option (plist-get classes-options :heading))
696 (type-option (plist-get classes-options :type))
697 (last-option (plist-get classes-options :last-section))
698 (hyphenate (plist-get attr :hyphenate))
699 (justify-right (plist-get attr :justify-right))
701 (document-class-string
702 (progn
703 (org-element-normalize-string
704 (let* ((header (nth 1 (assoc class org-groff-classes)))
705 (document-class-item (if (stringp header) header "")))
706 document-class-item)))))
709 (concat
710 (if justify-right
711 (case justify-right
712 ('yes ".SA 1 \n")
713 ('no ".SA 0 \n")
714 (t ""))
717 (if hyphenate
718 (case hyphenate
719 ('yes ".nr Hy 1 \n")
720 ('no ".nr Hy 0 \n")
721 (t ""))
724 (cond
725 ((string= type-option "custom") "")
727 ((and (stringp document-class-string)
728 (string= type-option "cover"))
730 (concat
731 (format ".COVER %s\n" document-class-string)
732 (org-groff--mt-head title contents attr info)
733 ".COVEND\n"))
735 ((string= type-option "memo")
736 (concat
737 (org-groff--mt-head title contents attr info)
738 document-class-string))
739 ((string= type-option "letter")
740 (concat
741 (org-groff--letter-head title contents attr info)
742 (let ((sa-item (plist-get attr :salutation))
743 (cn-item (plist-get attr :confidential))
744 (sj-item (plist-get attr :subject))
745 (rn-item (plist-get attr :reference))
746 (at-item (plist-get attr :attention)))
748 (concat
750 (if (stringp sa-item)
751 (format ".LO SA \"%s\" \n" sa-item)
752 ".LO SA\n")
754 (when cn-item
755 (if (stringp cn-item)
756 (format ".LO CN \"%s\"\n" cn-item)
757 ".LO CN\n"))
759 (when (and at-item (stringp at-item))
760 (format ".LO AT \"%s\" \n" at-item))
761 (when (and title rn-item)
762 (format ".LO RN \"%s\"\n" title))
764 (when (and sj-item (stringp sj-item))
765 (format ".LO SJ \"%s\" \n" sj-item))
768 ".LT " document-class-string "\n"))))
770 (t ""))
772 contents
774 (cond
775 ((string= last-option "toc")
776 ".TC")
777 ((string= last-option "sign")
778 (let ((fc-item (plist-get attr :closing)))
779 (concat (if (stringp fc-item)
780 (format ".FC \"%s\" \n" fc-item)
781 ".FC\n")
782 ".SG\n")))
783 (t ""))
785 (progn
786 (mapconcat
787 (lambda (item)
788 (when (string= (car item) "NS")
789 (replace-regexp-in-string
790 "\\.P\n" "" (cdr item))))
791 (reverse org-groff-special-content) "\n")))))
795 ;;; Transcode Functions
797 ;;; Babel Call
799 ;; Babel Calls are ignored.
802 ;;; Bold
804 (defun org-groff-bold (bold contents info)
805 "Transcode BOLD from Org to Groff.
806 CONTENTS is the text with bold markup. INFO is a plist holding
807 contextual information."
808 (org-groff--text-markup contents 'bold))
810 ;;; Center Block
812 (defun org-groff-center-block (center-block contents info)
813 "Transcode a CENTER-BLOCK element from Org to Groff.
814 CONTENTS holds the contents of the center block. INFO is a plist
815 holding contextual information."
816 (org-groff--wrap-label
817 center-block
818 (format ".DS C \n%s\n.DE" contents)))
820 ;;; Clock
822 (defun org-groff-clock (clock contents info)
823 "Transcode a CLOCK element from Org to Groff.
824 CONTENTS is nil. INFO is a plist holding contextual
825 information."
826 (concat
827 (format "\\fB%s\\fP " org-clock-string)
828 (format org-groff-inactive-timestamp-format
829 (concat (org-translate-time
830 (org-element-property :raw-value
831 (org-element-property :value clock)))
832 (let ((time (org-element-property :duration clock)))
833 (and time (format " (%s)" time)))))))
835 ;;; Code
837 (defun org-groff-code (code contents info)
838 "Transcode a CODE object from Org to Groff.
839 CONTENTS is nil. INFO is a plist used as a communication
840 channel."
841 (org-groff--text-markup (org-element-property :value code) 'code))
843 ;;; Comments and Comment Blocks are ignored.
845 ;;; Drawer
847 (defun org-groff-drawer (drawer contents info)
848 "Transcode a DRAWER element from Org to Groff.
849 CONTENTS holds the contents of the block. INFO is a plist
850 holding contextual information."
851 (let* ((name (org-element-property :drawer-name drawer))
852 (output (if (functionp org-groff-format-drawer-function)
853 (funcall org-groff-format-drawer-function
854 name contents)
855 ;; If there's no user defined function: simply
856 ;; display contents of the drawer.
857 contents)))
858 (org-groff--wrap-label drawer output)))
860 ;;; Dynamic Block
862 (defun org-groff-dynamic-block (dynamic-block contents info)
863 "Transcode a DYNAMIC-BLOCK element from Org to Groff.
864 CONTENTS holds the contents of the block. INFO is a plist
865 holding contextual information. See `org-export-data'."
866 (org-groff--wrap-label dynamic-block contents))
868 ;;; Entity
870 (defun org-groff-entity (entity contents info)
871 "Transcode an ENTITY object from Org to Groff.
872 CONTENTS are the definition itself. INFO is a plist holding
873 contextual information."
874 (org-element-property :utf-8 entity))
876 ;;; Example Block
878 (defun org-groff-example-block (example-block contents info)
879 "Transcode an EXAMPLE-BLOCK element from Org to Groff.
880 CONTENTS is nil. INFO is a plist holding contextual
881 information."
882 (org-groff--wrap-label
883 example-block
884 (format ".DS L\n%s\n.DE"
885 (org-export-format-code-default example-block info))))
887 ;;; Export Block
889 (defun org-groff-export-block (export-block contents info)
890 "Transcode a EXPORT-BLOCK element from Org to Groff.
891 CONTENTS is nil. INFO is a plist holding contextual information."
892 (when (string= (org-element-property :type export-block) "GROFF")
893 (org-remove-indentation (org-element-property :value export-block))))
895 ;;; Export Snippet
897 (defun org-groff-export-snippet (export-snippet contents info)
898 "Transcode a EXPORT-SNIPPET object from Org to Groff.
899 CONTENTS is nil. INFO is a plist holding contextual information."
900 (when (eq (org-export-snippet-backend export-snippet) 'groff)
901 (org-element-property :value export-snippet)))
903 ;;; Fixed Width
905 (defun org-groff-fixed-width (fixed-width contents info)
906 "Transcode a FIXED-WIDTH element from Org to Groff.
907 CONTENTS is nil. INFO is a plist holding contextual information."
908 (org-groff--wrap-label
909 fixed-width
910 (format "\\fC\n%s\\fP"
911 (org-remove-indentation
912 (org-element-property :value fixed-width)))))
914 ;;; Footnote Definition
916 ;; Footnote Definitions are ignored.
918 ;; Footnotes are handled automatically in GROFF. Although manual
919 ;; references can be added, not really required.
921 (defun org-groff-footnote-reference (footnote-reference contents info)
922 ;; Changing from info to footnote-reference
923 (let* ((raw (org-export-get-footnote-definition footnote-reference info))
924 (n (org-export-get-footnote-number footnote-reference info))
925 (data (org-trim (org-export-data raw info)))
926 (ref-id (plist-get (nth 1 footnote-reference) :label)))
927 ;; It is a reference
928 (if (string-match "fn:rl" ref-id)
929 (if (member ref-id org-groff-registered-references)
930 (format "\\*[%s]" ref-id)
931 (progn
932 (push ref-id org-groff-registered-references)
933 (format "\\*(Rf\n.RS \"%s\" \n%s\n.RF\n" ref-id data)))
934 ;; else it is a footnote
935 (format "\\u\\s-2%s\\d\\s+2\n.FS %s\n%s\n.FE\n" n n data))))
937 ;;; Headline
939 (defun org-groff-headline (headline contents info)
940 "Transcode a HEADLINE element from Org to Groff.
941 CONTENTS holds the contents of the headline. INFO is a plist
942 holding contextual information."
943 (let* ((class (plist-get info :groff-class))
944 (level (org-export-get-relative-level headline info))
945 (numberedp (org-export-numbered-headline-p headline info))
946 ;; Section formatting will set two placeholders: one for the
947 ;; title and the other for the contents.
948 (classes (assoc class org-groff-classes))
949 (classes-options (car (last classes)))
950 (heading-option (plist-get classes-options :heading))
951 (section-fmt
952 (progn
953 (cond
954 ((and (symbolp heading-option)
955 (fboundp heading-option))
956 (funcall heading-option level numberedp))
957 ((> level 7) nil)
958 (t (if numberedp
959 (concat ".H " (number-to-string level) " \"%s\"\n%s")
960 ".HU \"%s\"\n%s")))))
961 ;; End of section-fmt
962 (text (org-export-data (org-element-property :title headline) info))
963 (todo
964 (and (plist-get info :with-todo-keywords)
965 (let ((todo (org-element-property :todo-keyword headline)))
966 (and todo (org-export-data todo info)))))
967 (todo-type (and todo (org-element-property :todo-type headline)))
968 (tags (and (plist-get info :with-tags)
969 (org-export-get-tags headline info)))
970 (priority (and (plist-get info :with-priority)
971 (org-element-property :priority headline)))
972 ;; Create the headline text along with a no-tag version. The
973 ;; latter is required to remove tags from table of contents.
974 (full-text (if (functionp org-groff-format-headline-function)
975 ;; User-defined formatting function.
976 (funcall org-groff-format-headline-function
977 todo todo-type priority text tags)
978 ;; Default formatting.
979 (concat
980 (when todo
981 (format "\\fB%s\\fP " todo))
982 (when priority (format " [\\#%c] " priority))
983 text
984 (when tags
985 (format " \\fC:%s:\\fP "
986 (mapconcat 'identity tags ":"))))))
987 (full-text-no-tag
988 (if (functionp org-groff-format-headline-function)
989 ;; User-defined formatting function.
990 (funcall org-groff-format-headline-function
991 todo todo-type priority text nil)
992 ;; Default formatting.
993 (concat
994 (when todo (format "\\fB%s\\fP " todo))
995 (when priority (format " [\\#%c] " priority))
996 text)))
997 ;; Associate some \label to the headline for internal links.
998 ;; (headline-label
999 ;; (format "\\label{sec-%s}\n"
1000 ;; (mapconcat 'number-to-string
1001 ;; (org-export-get-headline-number headline info)
1002 ;; "-")))
1003 (headline-label "")
1004 (pre-blanks
1005 (make-string (org-element-property :pre-blank headline) 10)))
1007 (cond
1008 ;; Case 1: Special Tag
1009 ((member (car tags) org-groff-special-tags)
1010 (cond
1011 ((string= (car tags) "BODY") contents)
1013 ((string= (car tags) "NS")
1014 (progn
1015 (push (cons (car tags)
1016 (format ".NS \"%s\" 1 \n%s"
1017 (car (org-element-property :title headline))
1018 (or contents " ")))
1019 org-groff-special-content) nil))
1022 (progn
1023 (push (cons (car tags) contents) org-groff-special-content)
1024 nil))))
1026 ;; Case 2: This is a footnote section: ignore it.
1027 ((org-element-property :footnote-section-p headline) nil)
1029 ;; Case 3: This is a deep sub-tree: export it as a list item.
1030 ;; Also export as items headlines for which no section
1031 ;; format has been found.
1032 ((or (not section-fmt) (org-export-low-level-p headline info))
1033 ;; Build the real contents of the sub-tree.
1034 (let ((low-level-body
1035 (concat
1036 ;; If the headline is the first sibling, start a list.
1037 (when (org-export-first-sibling-p headline info)
1038 (format "%s\n" (if numberedp ".AL 1\n" ".DL \n")))
1039 ;; Itemize headline
1040 ".LI\n" full-text "\n" headline-label pre-blanks contents)))
1041 ;; If headline is not the last sibling simply return
1042 ;; LOW-LEVEL-BODY. Otherwise, also close the list, before any
1043 ;; blank line.
1044 (if (not (org-export-last-sibling-p headline info)) low-level-body
1045 (replace-regexp-in-string
1046 "[ \t\n]*\\'"
1047 (concat "\n.LE")
1048 low-level-body))))
1050 ;; Case 4. Standard headline. Export it as a section.
1052 (format section-fmt full-text
1053 (concat headline-label pre-blanks contents))))))
1055 ;;; Horizontal Rule
1056 ;; Not supported
1058 ;;; Inline Babel Call
1060 ;; Inline Babel Calls are ignored.
1062 ;;; Inline Src Block
1064 (defun org-groff-inline-src-block (inline-src-block contents info)
1065 "Transcode an INLINE-SRC-BLOCK element from Org to Groff.
1066 CONTENTS holds the contents of the item. INFO is a plist holding
1067 contextual information."
1068 (let* ((code (org-element-property :value inline-src-block)))
1069 (cond
1070 (org-groff-source-highlight
1071 (let* ((tmpdir (if (featurep 'xemacs)
1072 temp-directory
1073 temporary-file-directory))
1074 (in-file (make-temp-name
1075 (expand-file-name "srchilite" tmpdir)))
1076 (out-file (make-temp-name
1077 (expand-file-name "reshilite" tmpdir)))
1078 (org-lang (org-element-property :language inline-src-block))
1079 (lst-lang (cadr (assq (intern org-lang)
1080 org-groff-source-highlight-langs)))
1082 (cmd (concat (expand-file-name "source-highlight")
1083 " -s " lst-lang
1084 " -f groff_mm_color "
1085 " -i " in-file
1086 " -o " out-file)))
1087 (if lst-lang
1088 (let ((code-block ""))
1089 (with-temp-file in-file (insert code))
1090 (shell-command cmd)
1091 (setq code-block (org-file-contents out-file))
1092 (delete-file in-file)
1093 (delete-file out-file)
1094 code-block)
1095 (format ".DS I\n\\fC\\m[black]%s\\m[]\\fP\n.DE\n"
1096 code))))
1098 ;; Do not use a special package: transcode it verbatim.
1100 (concat ".DS I\n" "\\fC" code "\\fP\n.DE\n")))))
1102 ;;; Inlinetask
1104 (defun org-groff-inlinetask (inlinetask contents info)
1105 "Transcode an INLINETASK element from Org to Groff.
1106 CONTENTS holds the contents of the block. INFO is a plist
1107 holding contextual information."
1108 (let ((title (org-export-data (org-element-property :title inlinetask) info))
1109 (todo (and (plist-get info :with-todo-keywords)
1110 (let ((todo (org-element-property :todo-keyword inlinetask)))
1111 (and todo (org-export-data todo info)))))
1112 (todo-type (org-element-property :todo-type inlinetask))
1113 (tags (and (plist-get info :with-tags)
1114 (org-export-get-tags inlinetask info)))
1115 (priority (and (plist-get info :with-priority)
1116 (org-element-property :priority inlinetask))))
1117 ;; If `org-groff-format-inlinetask-function' is provided, call it
1118 ;; with appropriate arguments.
1119 (if (functionp org-groff-format-inlinetask-function)
1120 (funcall org-groff-format-inlinetask-function
1121 todo todo-type priority title tags contents)
1122 ;; Otherwise, use a default template.
1123 (org-groff--wrap-label
1124 inlinetask
1125 (let ((full-title
1126 (concat
1127 (when todo (format "\\fB%s\\fP " todo))
1128 (when priority (format " [\\#%c] " priority))
1129 title
1130 (when tags (format " \\fC:%s:\\fP "
1131 (mapconcat 'identity tags ":"))))))
1132 (format (concat "\n.DS I\n"
1133 "%s\n"
1134 ".sp"
1135 "%s\n"
1136 ".DE")
1137 full-title contents))))))
1139 ;;; Italic
1141 (defun org-groff-italic (italic contents info)
1142 "Transcode ITALIC from Org to Groff.
1143 CONTENTS is the text with italic markup. INFO is a plist holding
1144 contextual information."
1145 (org-groff--text-markup contents 'italic))
1147 ;;; Item
1149 (defun org-groff-item (item contents info)
1150 "Transcode an ITEM element from Org to Groff.
1151 CONTENTS holds the contents of the item. INFO is a plist holding
1152 contextual information."
1153 (let* ((bullet (org-element-property :bullet item))
1154 (type (org-element-property
1155 :type (org-element-property :parent item)))
1156 (checkbox (case (org-element-property :checkbox item)
1157 (on "\\o'\\(sq\\(mu'")
1158 (off "\\(sq")
1159 (trans "\\o'\\(sq\\(mi'")))
1160 (tag (let ((tag (org-element-property :tag item)))
1161 ;; Check-boxes must belong to the tag.
1162 (and tag (format "%s"
1163 (concat checkbox
1164 (org-export-data tag info)))))))
1166 (cond
1167 ((or checkbox tag)
1168 (concat ".LI ""\"" (or tag (concat "\\ " checkbox)) "\""
1169 "\n"
1170 (org-trim (or contents " "))))
1171 ((eq type 'ordered)
1172 (concat ".LI"
1173 "\n"
1174 (org-trim (or contents " "))))
1176 (let* ((bullet (org-trim bullet))
1177 (marker (cond ((string= "-" bullet) "\\(em")
1178 ((string= "*" bullet) "\\(bu")
1179 (t "\\(dg"))))
1180 (concat ".LI " marker "\n"
1181 (org-trim (or contents " "))))))))
1183 ;;; Keyword
1185 (defun org-groff-keyword (keyword contents info)
1186 "Transcode a KEYWORD element from Org to Groff.
1187 CONTENTS is nil. INFO is a plist holding contextual information."
1188 (let ((key (org-element-property :key keyword))
1189 (value (org-element-property :value keyword)))
1190 (cond
1191 ((string= key "GROFF") value)
1192 (t nil))))
1194 ;;; Line Break
1196 (defun org-groff-line-break (line-break contents info)
1197 "Transcode a LINE-BREAK object from Org to Groff.
1198 CONTENTS is nil. INFO is a plist holding contextual information."
1199 ".br\n")
1201 ;;; Link
1202 ;; Inline images just place a call to .PSPIC or .PS/.PE
1203 ;; and load the graph.
1205 (defun org-groff-link--inline-image (link info)
1206 "Return Groff code for an inline image.
1207 LINK is the link pointing to the inline image. INFO is a plist
1208 used as a communication channel."
1209 (let* ((parent (org-export-get-parent-element link))
1210 (path (let ((raw-path (org-element-property :path link)))
1211 (if (not (file-name-absolute-p raw-path)) raw-path
1212 (expand-file-name raw-path))))
1213 (attr (org-export-read-attribute :attr_groff link))
1214 (placement
1215 (let ((pos (plist-get attr :position)))
1216 (cond ((string= pos 'center) "")
1217 ((string= pos 'left) "-L")
1218 ((string= pos 'right) "-R")
1219 (t ""))))
1220 (width (or (plist-get attr :width) ""))
1221 (height (or (plist-get attr :height) ""))
1222 (caption (and (not (plist-get attr :disable-caption))
1223 (org-groff--caption/label-string parent info))))
1224 ;; Now clear ATTR from any special keyword and set a default value
1225 ;; if nothing is left. Return proper string.
1226 (concat
1227 (cond
1228 ((and org-groff-raster-to-ps
1229 (or (string-match ".\.png$" path)
1230 (string-match ".\.jpg$" path)))
1231 (let ((eps-path (concat path ".eps")))
1232 (shell-command (format org-groff-raster-to-ps path eps-path))
1233 (format "\n.DS L F\n.PSPIC %s \"%s\" %s %s\n.DE "
1234 placement eps-path width height)))
1235 ((string-match ".\.pic$" path)
1236 (format "\n.PS\ncopy \"%s\"\n.PE" path))
1237 (t (format "\n.DS L F\n.PSPIC %s \"%s\" %s %s\n.DE "
1238 placement path width height)))
1239 (and caption (format "\n.FG \"%s\"" caption)))))
1241 (defun org-groff-link (link desc info)
1242 "Transcode a LINK object from Org to Groff.
1244 DESC is the description part of the link, or the empty string.
1245 INFO is a plist holding contextual information. See
1246 `org-export-data'."
1248 (let* ((type (org-element-property :type link))
1249 (raw-path (org-element-property :path link))
1250 ;; Ensure DESC really exists, or set it to nil.
1251 (desc (and (not (string= desc "")) desc))
1252 (imagep (org-export-inline-image-p
1253 link org-groff-inline-image-rules))
1254 (path (cond
1255 ((member type '("http" "https" "ftp" "mailto"))
1256 (concat type ":" raw-path))
1257 ((string= type "file")
1258 (when (string-match "\\(.+\\)::.+" raw-path)
1259 (setq raw-path (match-string 1 raw-path)))
1260 (if (file-name-absolute-p raw-path)
1261 (concat "file://" (expand-file-name raw-path))
1262 (concat "file://" raw-path)))
1263 (t raw-path)))
1264 protocol)
1265 (cond
1266 ;; Image file.
1267 (imagep (org-groff-link--inline-image link info))
1268 ;; import groff files
1269 ((and (string= type "file")
1270 (string-match ".\.groff$" raw-path))
1271 (concat ".so " raw-path "\n"))
1272 ;; Radio link: transcode target's contents and use them as link's
1273 ;; description.
1274 ((string= type "radio")
1275 (let ((destination (org-export-resolve-radio-link link info)))
1276 (when destination
1277 (format "\\fI [%s] \\fP"
1278 (org-export-solidify-link-text path)))))
1280 ;; Links pointing to a headline: find destination and build
1281 ;; appropriate referencing command.
1282 ((member type '("custom-id" "fuzzy" "id"))
1283 (let ((destination (if (string= type "fuzzy")
1284 (org-export-resolve-fuzzy-link link info)
1285 (org-export-resolve-id-link link info))))
1286 (case (org-element-type destination)
1287 ;; Id link points to an external file.
1288 (plain-text
1289 (if desc (format "%s \\fBat\\fP \\fIfile://%s\\fP" desc destination)
1290 (format "\\fI file://%s \\fP" destination)))
1291 ;; Fuzzy link points nowhere.
1292 ('nil
1293 (format org-groff-link-with-unknown-path-format
1294 (or desc
1295 (org-export-data
1296 (org-element-property :raw-link link) info))))
1297 ;; LINK points to a headline. If headlines are numbered and
1298 ;; the link has no description, display headline's number.
1299 ;; Otherwise, display description or headline's title.
1300 (headline
1301 (let ((label ""))
1302 (if (and (plist-get info :section-numbers) (not desc))
1303 (format "\\fI%s\\fP" label)
1304 (format "\\fI%s\\fP"
1305 (or desc
1306 (org-export-data
1307 (org-element-property :title destination) info))))))
1308 ;; Fuzzy link points to a target. Do as above.
1309 (otherwise
1310 (let ((path (org-export-solidify-link-text path)))
1311 (if (not desc) (format "\\fI%s\\fP" path)
1312 (format "%s \\fBat\\fP \\fI%s\\fP" desc path)))))))
1313 ;; External link with a description part.
1314 ((and path desc) (format "%s \\fBat\\fP \\fI%s\\fP" path desc))
1315 ;; External link without a description part.
1316 (path (format "\\fI%s\\fP" path))
1317 ;; No path, only description. Try to do something useful.
1318 (t (format org-groff-link-with-unknown-path-format desc)))))
1320 ;;; Node Property
1322 (defun org-groff-node-property (node-property contents info)
1323 "Transcode a NODE-PROPERTY element from Org to Groff.
1324 CONTENTS is nil. INFO is a plist holding contextual
1325 information."
1326 (format "%s:%s"
1327 (org-element-property :key node-property)
1328 (let ((value (org-element-property :value node-property)))
1329 (if value (concat " " value) ""))))
1331 ;;; Paragraph
1333 (defun org-groff-paragraph (paragraph contents info)
1334 "Transcode a PARAGRAPH element from Org to Groff.
1335 CONTENTS is the contents of the paragraph, as a string. INFO is
1336 the plist used as a communication channel."
1337 (let ((parent (plist-get (nth 1 paragraph) :parent)))
1338 (when parent
1339 (let* ((parent-type (car parent))
1340 (fixed-paragraph "")
1341 (class (plist-get info :groff-class))
1342 (class-options (plist-get info :groff-class-options))
1343 (classes (assoc class org-groff-classes))
1344 (classes-options (car (last classes)))
1345 (paragraph-option (plist-get classes-options :paragraph)))
1346 (cond
1347 ((and (symbolp paragraph-option)
1348 (fboundp paragraph-option))
1349 (funcall paragraph-option parent-type parent contents))
1350 ((and (eq parent-type 'item)
1351 (plist-get (nth 1 parent) :bullet))
1352 (setq fixed-paragraph (concat "" contents)))
1353 ((eq parent-type 'section)
1354 (setq fixed-paragraph (concat ".P\n" contents)))
1355 ((eq parent-type 'footnote-definition)
1356 (setq fixed-paragraph (concat "" contents)))
1357 (t (setq fixed-paragraph (concat "" contents))))
1358 fixed-paragraph))))
1360 ;;; Plain List
1362 (defun org-groff-plain-list (plain-list contents info)
1363 "Transcode a PLAIN-LIST element from Org to Groff.
1364 CONTENTS is the contents of the list. INFO is a plist holding
1365 contextual information."
1366 (let* ((type (org-element-property :type plain-list))
1367 (attr (mapconcat #'identity
1368 (org-element-property :attr_groff plain-list)
1369 " "))
1370 (groff-type (cond
1371 ((eq type 'ordered) ".AL")
1372 ((eq type 'unordered) ".BL")
1373 ((eq type 'descriptive) ".VL 2.0i"))))
1374 (org-groff--wrap-label
1375 plain-list
1376 (format "%s\n%s\n.LE" groff-type contents))))
1378 ;;; Plain Text
1380 (defun org-groff-plain-text (text info)
1381 "Transcode a TEXT string from Org to Groff.
1382 TEXT is the string to transcode. INFO is a plist holding
1383 contextual information."
1384 (let ((output text))
1385 ;; Protect various characters.
1386 (setq output (replace-regexp-in-string
1387 "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
1388 "$\\" output nil t 1))
1389 ;; Activate smart quotes. Be sure to provide original TEXT string
1390 ;; since OUTPUT may have been modified.
1391 (when (plist-get info :with-smart-quotes)
1392 (setq output (org-export-activate-smart-quotes output :utf-8 info text)))
1393 ;; Handle Special Characters
1394 (if org-groff-special-char
1395 (dolist (special-char-list org-groff-special-char)
1396 (setq output
1397 (replace-regexp-in-string (car special-char-list)
1398 (cdr special-char-list) output))))
1399 ;; Handle break preservation if required.
1400 (when (plist-get info :preserve-breaks)
1401 (setq output (replace-regexp-in-string
1402 "\\(\\\\\\\\\\)?[ \t]*\n" ".br\n" output)))
1403 ;; Return value.
1404 output))
1406 ;;; Planning
1408 (defun org-groff-planning (planning contents info)
1409 "Transcode a PLANNING element from Org to Groff.
1410 CONTENTS is nil. INFO is a plist holding contextual
1411 information."
1412 (concat
1413 (mapconcat
1414 'identity
1415 (delq nil
1416 (list
1417 (let ((closed (org-element-property :closed planning)))
1418 (when closed
1419 (concat
1420 (format "\\fR %s \\fP" org-closed-string)
1421 (format org-groff-inactive-timestamp-format
1422 (org-translate-time
1423 (org-element-property :raw-value closed))))))
1424 (let ((deadline (org-element-property :deadline planning)))
1425 (when deadline
1426 (concat
1427 (format "\\fB %s \\fP" org-deadline-string)
1428 (format org-groff-active-timestamp-format
1429 (org-translate-time
1430 (org-element-property :raw-value deadline))))))
1431 (let ((scheduled (org-element-property :scheduled planning)))
1432 (when scheduled
1433 (concat
1434 (format "\\fR %s \\fP" org-scheduled-string)
1435 (format org-groff-active-timestamp-format
1436 (org-translate-time
1437 (org-element-property :raw-value scheduled))))))))
1439 ""))
1441 ;;;; Property Drawer
1443 (defun org-groff-property-drawer (property-drawer contents info)
1444 "Transcode a PROPERTY-DRAWER element from Org to Groff.
1445 CONTENTS holds the contents of the drawer. INFO is a plist
1446 holding contextual information."
1447 (and (org-string-nw-p contents)
1448 (format "\\fC\n%s\\fP" contents)))
1450 ;;; Quote Block
1452 (defun org-groff-quote-block (quote-block contents info)
1453 "Transcode a QUOTE-BLOCK element from Org to Groff.
1454 CONTENTS holds the contents of the block. INFO is a plist
1455 holding contextual information."
1456 (org-groff--wrap-label
1457 quote-block
1458 (format ".DS I\n.I\n%s\n.R\n.DE" contents)))
1460 ;;; Quote Section
1462 (defun org-groff-quote-section (quote-section contents info)
1463 "Transcode a QUOTE-SECTION element from Org to Groff.
1464 CONTENTS is nil. INFO is a plist holding contextual information."
1465 (let ((value (org-remove-indentation
1466 (org-element-property :value quote-section))))
1467 (when value (format ".DS L\n\\fI%s\\fP\n.DE\n" value))))
1469 ;;; Radio Target
1471 (defun org-groff-radio-target (radio-target text info)
1472 "Transcode a RADIO-TARGET object from Org to Groff.
1473 TEXT is the text of the target. INFO is a plist holding
1474 contextual information."
1475 (format "%s - %s"
1476 (org-export-solidify-link-text
1477 (org-element-property :value radio-target))
1478 text))
1480 ;;; Section
1482 (defun org-groff-section (section contents info)
1483 "Transcode a SECTION element from Org to Groff.
1484 CONTENTS holds the contents of the section. INFO is a plist
1485 holding contextual information."
1486 contents)
1488 ;;; Special Block
1490 (defun org-groff-special-block (special-block contents info)
1491 "Transcode a SPECIAL-BLOCK element from Org to Groff.
1492 CONTENTS holds the contents of the block. INFO is a plist
1493 holding contextual information."
1494 (let ((type (downcase (org-element-property :type special-block))))
1495 (org-groff--wrap-label
1496 special-block
1497 (format "%s\n" contents))))
1499 ;;; Src Block
1501 (defun org-groff-src-block (src-block contents info)
1502 "Transcode a SRC-BLOCK element from Org to Groff.
1503 CONTENTS holds the contents of the item. INFO is a plist holding
1504 contextual information."
1505 (let* ((lang (org-element-property :language src-block))
1506 (label (org-element-property :name src-block))
1507 (code (org-element-property :value src-block))
1508 (custom-env (and lang
1509 (cadr (assq (intern lang)
1510 org-groff-custom-lang-environments))))
1511 (num-start (case (org-element-property :number-lines src-block)
1512 (continued (org-export-get-loc src-block info))
1513 (new 0)))
1514 (retain-labels (org-element-property :retain-labels src-block))
1515 (caption (and (not (org-export-read-attribute
1516 :attr_groff src-block :disable-caption))
1517 (org-groff--caption/label-string src-block info))))
1519 (cond
1520 ;; Case 1. No source fontification.
1521 ((not org-groff-source-highlight)
1522 (concat
1523 (format ".DS I\n\\fC%s\\fP\n.DE\n"
1524 (org-export-format-code-default src-block info))
1525 (and caption (format ".EX \"%s\" " caption))))
1527 ;; Case 2. Source fontification.
1528 (org-groff-source-highlight
1529 (let* ((tmpdir (if (featurep 'xemacs)
1530 temp-directory
1531 temporary-file-directory))
1532 (in-file (make-temp-name
1533 (expand-file-name "srchilite" tmpdir)))
1534 (out-file (make-temp-name
1535 (expand-file-name "reshilite" tmpdir)))
1537 (org-lang (org-element-property :language src-block))
1538 (lst-lang (cadr (assq (intern org-lang)
1539 org-groff-source-highlight-langs)))
1541 (cmd (concat "source-highlight"
1542 " -s " lst-lang
1543 " -f groff_mm_color "
1544 " -i " in-file
1545 " -o " out-file)))
1547 (concat
1548 (if lst-lang
1549 (let ((code-block ""))
1550 (with-temp-file in-file (insert code))
1551 (shell-command cmd)
1552 (setq code-block (org-file-contents out-file))
1553 (delete-file in-file)
1554 (delete-file out-file)
1555 (format "%s\n" code-block))
1556 (format ".DS I\n\\fC\\m[black]%s\\m[]\\fP\n.DE\n"
1557 code))
1558 (and caption (format ".EX \"%s\" " caption))))))))
1561 ;;; Statistics Cookie
1563 (defun org-groff-statistics-cookie (statistics-cookie contents info)
1564 "Transcode a STATISTICS-COOKIE object from Org to Groff.
1565 CONTENTS is nil. INFO is a plist holding contextual information."
1566 (org-element-property :value statistics-cookie))
1569 ;;; Strike-Through
1571 (defun org-groff-strike-through (strike-through contents info)
1572 "Transcode STRIKE-THROUGH from Org to Groff.
1573 CONTENTS is the text with strike-through markup. INFO is a plist
1574 holding contextual information."
1575 (org-groff--text-markup contents 'strike-through))
1577 ;;; Subscript
1579 (defun org-groff-subscript (subscript contents info)
1580 "Transcode a SUBSCRIPT object from Org to Groff.
1581 CONTENTS is the contents of the object. INFO is a plist holding
1582 contextual information."
1583 (format "\\d\\s-2%s\\s+2\\u" contents))
1585 ;;; Superscript "^_%s$
1587 (defun org-groff-superscript (superscript contents info)
1588 "Transcode a SUPERSCRIPT object from Org to Groff.
1589 CONTENTS is the contents of the object. INFO is a plist holding
1590 contextual information."
1591 (format "\\u\\s-2%s\\s+2\\d" contents))
1594 ;;; Table
1596 ;; `org-groff-table' is the entry point for table transcoding. It
1597 ;; takes care of tables with a "verbatim" attribute. Otherwise, it
1598 ;; delegates the job to `org-groff-table--org-table' function,
1599 ;; depending of the type of the table.
1601 ;; `org-groff-table--align-string' is a subroutine used to build
1602 ;; alignment string for Org tables.
1604 (defun org-groff-table (table contents info)
1605 "Transcode a TABLE element from Org to Groff.
1606 CONTENTS is the contents of the table. INFO is a plist holding
1607 contextual information."
1608 (cond
1609 ;; Case 1: verbatim table.
1610 ((or org-groff-tables-verbatim
1611 (let ((attr (read (format "(%s)"
1612 (mapconcat
1613 #'identity
1614 (org-element-property :attr_groff table) " ")))))
1615 (and attr (plist-get attr :verbatim))))
1617 (format ".DS L\n\\fC%s\\fP\n.DE"
1618 ;; Re-create table, without affiliated keywords.
1619 (org-trim
1620 (org-element-interpret-data
1621 `(table nil ,@(org-element-contents table))))))
1623 ;; Case 2: Standard table.
1624 (t (org-groff-table--org-table table contents info))))
1626 (defun org-groff-table--align-string (divider table info)
1627 "Return an appropriate Groff alignment string.
1628 TABLE is the considered table. INFO is a plist used as
1629 a communication channel."
1630 (let (alignment)
1631 ;; Extract column groups and alignment from first (non-rule) row.
1632 (org-element-map
1633 (org-element-map table 'table-row
1634 (lambda (row)
1635 (and (eq (org-element-property :type row) 'standard) row))
1636 info 'first-match)
1637 'table-cell
1638 (lambda (cell)
1639 (let* ((borders (org-export-table-cell-borders cell info))
1640 (raw-width (org-export-table-cell-width cell info))
1641 (width-cm (when raw-width (/ raw-width 5)))
1642 (width (if raw-width (format "w(%dc)"
1643 (if (< width-cm 1) 1 width-cm)) "")))
1644 ;; Check left border for the first cell only.
1645 ;; Alignment is nil on assignment
1647 (when (and (memq 'left borders) (not alignment))
1648 (push "|" alignment))
1649 (push
1650 (case (org-export-table-cell-alignment cell info)
1651 (left (concat "l" width divider))
1652 (right (concat "r" width divider))
1653 (center (concat "c" width divider)))
1654 alignment)
1655 (when (memq 'right borders) (push "|" alignment))))
1656 info)
1657 (apply 'concat (reverse alignment))))
1659 (defun org-groff-table--org-table (table contents info)
1660 "Return appropriate Groff code for an Org table.
1662 TABLE is the table type element to transcode. CONTENTS is its
1663 contents, as a string. INFO is a plist used as a communication
1664 channel.
1666 This function assumes TABLE has `org' as its `:type' attribute."
1667 (let* ((attr (org-export-read-attribute :attr_groff table))
1668 (label (org-element-property :name table))
1669 (caption (and (not (plist-get attr :disable-caption))
1670 (org-groff--caption/label-string table info)))
1671 (divider (if (plist-get attr :divider) "|" " "))
1673 ;; Determine alignment string.
1674 (alignment (org-groff-table--align-string divider table info))
1676 ;; Extract others display options.
1678 (lines (org-split-string contents "\n"))
1680 (attr-list
1681 (delq nil
1682 (list (and (plist-get attr :expand) "expand")
1683 (let ((placement (plist-get attr :placement)))
1684 (cond ((string= placement 'center) "center")
1685 ((string= placement 'left) nil)
1686 (t (if org-groff-tables-centered "center" ""))))
1687 (or (plist-get attr :boxtype) "box"))))
1689 (title-line (plist-get attr :title-line))
1690 (long-cells (plist-get attr :long-cells))
1692 (table-format
1693 (concat
1694 (or (car attr-list) "")
1696 (let (output-list)
1697 (when (cdr attr-list)
1698 (dolist (attr-item (cdr attr-list))
1699 (setq output-list (concat output-list
1700 (format ",%s" attr-item)))))
1701 output-list) "")))
1702 (first-line
1703 (when lines (org-split-string (car lines) "\t"))))
1704 ;; Prepare the final format string for the table.
1707 (cond
1708 ;; Others.
1709 (lines
1710 (concat ".TS\n " table-format ";\n"
1711 (format "%s.\n"
1712 (let ((final-line ""))
1713 (when title-line
1714 (dotimes (i (length first-line))
1715 (setq final-line (concat final-line "cb" divider))))
1717 (setq final-line (concat final-line "\n"))
1719 (if alignment
1720 (setq final-line (concat final-line alignment))
1721 (dotimes (i (length first-line))
1722 (setq final-line (concat final-line "c" divider))))
1723 final-line))
1725 (format "%s.TE\n"
1726 (let ((final-line "")
1727 (long-line "")
1728 (lines (org-split-string contents "\n")))
1730 (dolist (line-item lines)
1731 (setq long-line "")
1733 (if long-cells
1734 (progn
1735 (if (string= line-item "_")
1736 (setq long-line (format "%s\n" line-item))
1737 ;; else string =
1738 (let ((cell-item-list (org-split-string line-item "\t")))
1739 (dolist (cell-item cell-item-list)
1741 (cond ((eq cell-item (car (last cell-item-list)))
1742 (setq long-line (concat long-line
1743 (format "T{\n%s\nT}\t\n" cell-item))))
1745 (setq long-line (concat long-line
1746 (format "T{\n%s\nT}\t" cell-item))))))
1747 long-line))
1748 ;; else long cells
1749 (setq final-line (concat final-line long-line)))
1751 (setq final-line (concat final-line line-item "\n"))))
1752 final-line))
1754 (if caption (format ".TB \"%s\"" caption) ""))))))
1756 ;;; Table Cell
1758 (defun org-groff-table-cell (table-cell contents info)
1759 "Transcode a TABLE-CELL element from Org to Groff
1760 CONTENTS is the cell contents. INFO is a plist used as
1761 a communication channel."
1762 (progn
1763 (concat (if (and contents
1764 org-groff-table-scientific-notation
1765 (string-match orgtbl-exp-regexp contents))
1766 ;; Use appropriate format string for scientific
1767 ;; notation.
1768 (format org-groff-table-scientific-notation
1769 (match-string 1 contents)
1770 (match-string 2 contents))
1771 contents)
1772 (when (org-export-get-next-element table-cell info) "\t"))))
1775 ;;; Table Row
1777 (defun org-groff-table-row (table-row contents info)
1778 "Transcode a TABLE-ROW element from Org to Groff
1779 CONTENTS is the contents of the row. INFO is a plist used as
1780 a communication channel."
1781 ;; Rules are ignored since table separators are deduced from
1782 ;; borders of the current row.
1783 (when (eq (org-element-property :type table-row) 'standard)
1784 (let* ((attr (mapconcat 'identity
1785 (org-element-property
1786 :attr_groff (org-export-get-parent table-row))
1787 " "))
1788 ;; TABLE-ROW's borders are extracted from its first cell.
1789 (borders
1790 (org-export-table-cell-borders
1791 (car (org-element-contents table-row)) info)))
1792 (concat
1793 ;; Mark horizontal lines
1794 (cond ((and (memq 'top borders) (memq 'above borders)) "_\n"))
1795 contents
1796 (cond
1797 ;; When BOOKTABS are activated enforce bottom rule even when
1798 ;; no hline was specifically marked.
1799 ((and (memq 'bottom borders) (memq 'below borders)) "\n_")
1800 ((memq 'below borders) "\n_"))))))
1802 ;;; Target
1804 (defun org-groff-target (target contents info)
1805 "Transcode a TARGET object from Org to Groff.
1806 CONTENTS is nil. INFO is a plist holding contextual
1807 information."
1808 (format "\\fI%s\\fP"
1809 (org-export-solidify-link-text (org-element-property :value target))))
1811 ;;; Timestamp
1813 (defun org-groff-timestamp (timestamp contents info)
1814 "Transcode a TIMESTAMP object from Org to Groff.
1815 CONTENTS is nil. INFO is a plist holding contextual
1816 information."
1817 (let ((value (org-groff-plain-text
1818 (org-timestamp-translate timestamp) info)))
1819 (case (org-element-property :type timestamp)
1820 ((active active-range)
1821 (format org-groff-active-timestamp-format value))
1822 ((inactive inactive-range)
1823 (format org-groff-inactive-timestamp-format value))
1824 (t (format org-groff-diary-timestamp-format value)))))
1826 ;;; Underline
1828 (defun org-groff-underline (underline contents info)
1829 "Transcode UNDERLINE from Org to Groff.
1830 CONTENTS is the text with underline markup. INFO is a plist
1831 holding contextual information."
1832 (org-groff--text-markup contents 'underline))
1834 ;;; Verbatim
1836 (defun org-groff-verbatim (verbatim contents info)
1837 "Transcode a VERBATIM object from Org to Groff.
1838 CONTENTS is nil. INFO is a plist used as a communication
1839 channel."
1840 (org-groff--text-markup (org-element-property :value verbatim) 'verbatim))
1842 ;;; Verse Block
1844 (defun org-groff-verse-block (verse-block contents info)
1845 "Transcode a VERSE-BLOCK element from Org to Groff.
1846 CONTENTS is verse block contents. INFO is a plist holding
1847 contextual information."
1848 (format ".DS C\n.ft HI\n%s\n.ft\n.DE" contents))
1851 ;;; Interactive functions
1853 (defun org-groff-export-to-groff
1854 (&optional async subtreep visible-only body-only ext-plist)
1855 "Export current buffer to a Groff file.
1857 If narrowing is active in the current buffer, only export its
1858 narrowed part.
1860 If a region is active, export that region.
1862 A non-nil optional argument ASYNC means the process should happen
1863 asynchronously. The resulting file should be accessible through
1864 the `org-export-stack' interface.
1866 When optional argument SUBTREEP is non-nil, export the sub-tree
1867 at point, extracting information from the headline properties
1868 first.
1870 When optional argument VISIBLE-ONLY is non-nil, don't export
1871 contents of hidden elements.
1873 EXT-PLIST, when provided, is a property list with external
1874 parameters overriding Org default settings, but still inferior to
1875 file-local settings.
1877 Return output file's name."
1878 (interactive)
1879 (let ((outfile (org-export-output-file-name ".groff" subtreep))
1880 (org-groff-registered-references nil)
1881 (org-groff-special-content nil))
1882 (org-export-to-file 'groff outfile
1883 async subtreep visible-only body-only ext-plist)))
1885 (defun org-groff-export-to-pdf
1886 (&optional async subtreep visible-only body-only ext-plist)
1887 "Export current buffer to Groff then process through to PDF.
1889 If narrowing is active in the current buffer, only export its
1890 narrowed part.
1892 If a region is active, export that region.
1894 A non-nil optional argument ASYNC means the process should happen
1895 asynchronously. The resulting file should be accessible through
1896 the `org-export-stack' interface.
1898 When optional argument SUBTREEP is non-nil, export the sub-tree
1899 at point, extracting information from the headline properties
1900 first.
1902 When optional argument VISIBLE-ONLY is non-nil, don't export
1903 contents of hidden elements.
1905 EXT-PLIST, when provided, is a property list with external
1906 parameters overriding Org default settings, but still inferior to
1907 file-local settings.
1909 Return PDF file's name."
1910 (interactive)
1911 (let ((outfile (org-export-output-file-name ".groff" subtreep)))
1912 (org-export-to-file 'groff outfile
1913 async subtreep visible-only body-only ext-plist
1914 (lambda (file) (org-groff-compile file)))))
1916 (defun org-groff-compile (file)
1917 "Compile a Groff file.
1919 FILE is the name of the file being compiled. Processing is done
1920 through the command specified in `org-groff-pdf-process'.
1922 Return PDF file name or an error if it couldn't be produced."
1923 (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
1924 (full-name (file-truename file))
1925 (out-dir (file-name-directory file))
1926 ;; Properly set working directory for compilation.
1927 (default-directory (if (file-name-absolute-p file)
1928 (file-name-directory full-name)
1929 default-directory))
1930 errors)
1931 (message (format "Processing Groff file %s ..." file))
1932 (save-window-excursion
1933 (cond
1934 ;; A function is provided: Apply it.
1935 ((functionp org-groff-pdf-process)
1936 (funcall org-groff-pdf-process (shell-quote-argument file)))
1937 ;; A list is provided: Replace %b, %f and %o with appropriate
1938 ;; values in each command before applying it. Output is
1939 ;; redirected to "*Org PDF Groff Output*" buffer.
1940 ((consp org-groff-pdf-process)
1941 (let ((outbuf (get-buffer-create "*Org PDF Groff Output*")))
1942 (mapc
1943 (lambda (command)
1944 (shell-command
1945 (replace-regexp-in-string
1946 "%b" (shell-quote-argument base-name)
1947 (replace-regexp-in-string
1948 "%f" (shell-quote-argument full-name)
1949 (replace-regexp-in-string
1950 "%o" (shell-quote-argument out-dir) command t t)
1951 t t) t t)
1952 outbuf))
1953 org-groff-pdf-process)
1954 ;; Collect standard errors from output buffer.
1955 (setq errors (org-groff-collect-errors outbuf))))
1956 (t (error "No valid command to process to PDF")))
1957 (let ((pdffile (concat out-dir base-name ".pdf")))
1958 ;; Check for process failure. Provide collected errors if
1959 ;; possible.
1960 (if (not (file-exists-p pdffile))
1961 (error (concat (format "PDF file %s wasn't produced" pdffile)
1962 (when errors (concat ": " errors))))
1963 ;; Else remove log files, when specified, and signal end of
1964 ;; process to user, along with any error encountered.
1965 (when org-groff-remove-logfiles
1966 (dolist (ext org-groff-logfiles-extensions)
1967 (let ((file (concat out-dir base-name "." ext)))
1968 (when (file-exists-p file) (delete-file file)))))
1969 (message (concat "Process completed"
1970 (if (not errors) "."
1971 (concat " with errors: " errors)))))
1972 ;; Return output file name.
1973 pdffile))))
1975 (defun org-groff-collect-errors (buffer)
1976 "Collect some kind of errors from \"groff\" output
1977 BUFFER is the buffer containing output.
1978 Return collected error types as a string, or nil if there was
1979 none."
1980 (with-current-buffer buffer
1981 (save-excursion
1982 (goto-char (point-max))
1983 ;; Find final run
1984 nil)))
1987 (provide 'ox-groff)
1988 ;;; ox-groff.el ends here