org-e-man.el 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. ;; org-e-man.el --- Man Back-End For Org Export Engine
  2. ;; Copyright (C) 2011-2012 Free Software Foundation, Inc.
  3. ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
  4. ;; Author: Luis R Anaya <papoanaya aroba hot mail punto com>
  5. ;; Keywords: outlines, hypermedia, calendar, wp
  6. ;;
  7. ;; This program is free software; you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; This program is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;;
  19. ;; This library implements a Man back-end for Org generic exporter.
  20. ;;
  21. ;; To test it, run
  22. ;;
  23. ;; M-: (org-export-to-buffer 'e-man "*Test e-Man*") RET
  24. ;;
  25. ;; in an org-mode buffer then switch to the buffer to see the Man
  26. ;; export. See contrib/lisp/org-export.el for more details on how
  27. ;; this exporter works.
  28. ;;
  29. ;; It introduces one new buffer keywords:
  30. ;; "MAN_CLASS_OPTIONS".
  31. ;;; Code:
  32. (require 'org-export)
  33. (eval-when-compile (require 'cl))
  34. (defvar org-export-man-default-packages-alist)
  35. (defvar org-export-man-packages-alist)
  36. (defvar orgtbl-exp-regexp)
  37. ;;; Define Back-End
  38. (org-export-define-backend e-man
  39. ((babel-call . org-e-man-babel-call)
  40. (bold . org-e-man-bold)
  41. (center-block . org-e-man-center-block)
  42. (clock . org-e-man-clock)
  43. (code . org-e-man-code)
  44. (comment . org-e-man-comment)
  45. (comment-block . org-e-man-comment-block)
  46. (drawer . org-e-man-drawer)
  47. (dynamic-block . org-e-man-dynamic-block)
  48. (entity . org-e-man-entity)
  49. (example-block . org-e-man-example-block)
  50. (export-block . org-e-man-export-block)
  51. (export-snippet . org-e-man-export-snippet)
  52. (fixed-width . org-e-man-fixed-width)
  53. (footnote-definition . org-e-man-footnote-definition)
  54. (footnote-reference . org-e-man-footnote-reference)
  55. (headline . org-e-man-headline)
  56. (horizontal-rule . org-e-man-horizontal-rule)
  57. (inline-babel-call . org-e-man-inline-babel-call)
  58. (inline-src-block . org-e-man-inline-src-block)
  59. (inlinetask . org-e-man-inlinetask)
  60. (italic . org-e-man-italic)
  61. (item . org-e-man-item)
  62. (keyword . org-e-man-keyword)
  63. (man-environment . org-e-man-man-environment)
  64. (man-fragment . org-e-man-man-fragment)
  65. (line-break . org-e-man-line-break)
  66. (link . org-e-man-link)
  67. (paragraph . org-e-man-paragraph)
  68. (plain-list . org-e-man-plain-list)
  69. (plain-text . org-e-man-plain-text)
  70. (planning . org-e-man-planning)
  71. (property-drawer . org-e-man-property-drawer)
  72. (quote-block . org-e-man-quote-block)
  73. (quote-section . org-e-man-quote-section)
  74. (radio-target . org-e-man-radio-target)
  75. (section . org-e-man-section)
  76. (special-block . org-e-man-special-block)
  77. (src-block . org-e-man-src-block)
  78. (statistics-cookie . org-e-man-statistics-cookie)
  79. (strike-through . org-e-man-strike-through)
  80. (subscript . org-e-man-subscript)
  81. (superscript . org-e-man-superscript)
  82. (table . org-e-man-table)
  83. (table-cell . org-e-man-table-cell)
  84. (table-row . org-e-man-table-row)
  85. (target . org-e-man-target)
  86. (template . org-e-man-template)
  87. (timestamp . org-e-man-timestamp)
  88. (underline . org-e-man-underline)
  89. (verbatim . org-e-man-verbatim)
  90. (verse-block . org-e-man-verse-block))
  91. :export-block "MAN"
  92. :menu-entry
  93. (?m "Export to MAN"
  94. ((?m "As MAN file" org-e-man-export-to-man)
  95. (?p "As PDF file" org-e-man-export-to-pdf)
  96. (?o "As PDF file and open"
  97. (lambda (s v b) (org-open-file (org-e-man-export-to-pdf s v b))))))
  98. :options-alist
  99. ((:date "DATE" nil nil t)
  100. (:man-class "MAN_CLASS" nil nil t)
  101. (:man-class-options "MAN_CLASS_OPTIONS" nil nil t)
  102. (:man-header-extra "MAN_HEADER" nil nil newline)))
  103. ;;; User Configurable Variables
  104. (defgroup org-export-e-man nil
  105. "Options for exporting Org mode files to Man."
  106. :tag "Org Export Man"
  107. :group 'org-export)
  108. ;;; Tables
  109. (defcustom org-e-man-tables-centered t
  110. "When non-nil, tables are exported in a center environment."
  111. :group 'org-export-e-man
  112. :type 'boolean)
  113. (defcustom org-e-man-tables-verbatim nil
  114. "When non-nil, tables are exported verbatim."
  115. :group 'org-export-e-man
  116. :type 'boolean)
  117. (defcustom org-e-man-table-scientific-notation "%sE%s"
  118. "Format string to display numbers in scientific notation.
  119. The format should have \"%s\" twice, for mantissa and exponent
  120. \(i.e. \"%s\\\\times10^{%s}\").
  121. When nil, no transformation is made."
  122. :group 'org-export-e-man
  123. :type '(choice
  124. (string :tag "Format string")
  125. (const :tag "No formatting")))
  126. ;;; Inlinetasks
  127. ;; Src blocks
  128. (defcustom org-e-man-source-highlight nil
  129. "Use GNU source highlight to embellish source blocks "
  130. :group 'org-export-e-man
  131. :type 'boolean)
  132. (defcustom org-e-man-source-highlight-langs
  133. '((emacs-lisp "lisp") (lisp "lisp") (clojure "lisp")
  134. (scheme "scheme")
  135. (c "c") (cc "cpp") (csharp "csharp") (d "d")
  136. (fortran "fortran") (cobol "cobol") (pascal "pascal")
  137. (ada "ada") (asm "asm")
  138. (perl "perl") (cperl "perl")
  139. (python "python") (ruby "ruby") (tcl "tcl") (lua "lua")
  140. (java "java") (javascript "javascript")
  141. (tex "latex")
  142. (shell-script "sh") (awk "awk") (diff "diff") (m4 "m4")
  143. (ocaml "caml") (caml "caml")
  144. (sql "sql") (sqlite "sql")
  145. (html "html") (css "css") (xml "xml")
  146. (bat "bat") (bison "bison") (clipper "clipper")
  147. (ldap "ldap") (opa "opa")
  148. (php "php") (postscript "postscript") (prolog "prolog")
  149. (properties "properties") (makefile "makefile")
  150. (tml "tml") (vala "vala") (vbscript "vbscript") (xorg "xorg"))
  151. "Alist mapping languages to their listing language counterpart.
  152. The key is a symbol, the major mode symbol without the \"-mode\".
  153. The value is the string that should be inserted as the language
  154. parameter for the listings package. If the mode name and the
  155. listings name are the same, the language does not need an entry
  156. in this list - but it does not hurt if it is present."
  157. :group 'org-export-e-man
  158. :type '(repeat
  159. (list
  160. (symbol :tag "Major mode ")
  161. (string :tag "Listings language"))))
  162. (defvar org-e-man-custom-lang-environments nil
  163. "Alist mapping languages to language-specific Man environments.
  164. It is used during export of src blocks by the listings and
  165. man packages. For example,
  166. \(setq org-e-man-custom-lang-environments
  167. '\(\(python \"pythoncode\"\)\)\)
  168. would have the effect that if org encounters begin_src python
  169. during man export."
  170. )
  171. ;;; Compilation
  172. (defcustom org-e-man-pdf-process
  173. '("tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
  174. "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
  175. "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf")
  176. "Commands to process a Man file to a PDF file.
  177. This is a list of strings, each of them will be given to the
  178. shell as a command. %f in the command will be replaced by the
  179. full file name, %b by the file base name (i.e. without directory
  180. and extension parts) and %o by the base directory of the file.
  181. By default, Org uses 3 runs of to do the processing.
  182. Alternatively, this may be a Lisp function that does the
  183. processing. This function should accept the file name as
  184. its single argument."
  185. :group 'org-export-pdf
  186. :type '(choice
  187. (repeat :tag "Shell command sequence"
  188. (string :tag "Shell command"))
  189. (const :tag "2 runs of pdfgroff"
  190. ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
  191. "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf" ))
  192. (const :tag "3 runs of pdfgroff"
  193. ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
  194. "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
  195. "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"))
  196. (function)))
  197. (defcustom org-e-man-logfiles-extensions
  198. '("log" "out" "toc")
  199. "The list of file extensions to consider as Man logfiles."
  200. :group 'org-export-e-man
  201. :type '(repeat (string :tag "Extension")))
  202. (defcustom org-e-man-remove-logfiles t
  203. "Non-nil means remove the logfiles produced by PDF production.
  204. These are the .aux, .log, .out, and .toc files."
  205. :group 'org-export-e-man
  206. :type 'boolean)
  207. ;;; Internal Functions
  208. (defun org-e-man--caption/label-string (element info)
  209. "Return caption and label Man string for ELEMENT.
  210. INFO is a plist holding contextual information. If there's no
  211. caption nor label, return the empty string.
  212. For non-floats, see `org-e-man--wrap-label'."
  213. (let ((label (org-element-property :label element))
  214. (main (org-export-get-caption element))
  215. (short (org-export-get-caption element t)))
  216. (cond ((and (not main) (not label)) "")
  217. ((not main) (format "\\fI%s\\fP" label))
  218. ;; Option caption format with short name.
  219. (short (format "\\fR%s\\fP - \\fI\\P - %s\n"
  220. (org-export-data short info)
  221. (org-export-data main info)))
  222. ;; Standard caption format.
  223. (t (format "\\fR%s\\fP" (org-export-data main info))))))
  224. (defun org-e-man--wrap-label (element output)
  225. "Wrap label associated to ELEMENT around OUTPUT, if appropriate.
  226. This function shouldn't be used for floats. See
  227. `org-e-man--caption/label-string'."
  228. (let ((label (org-element-property :name element)))
  229. (if (or (not output) (not label) (string= output "") (string= label ""))
  230. output
  231. (concat (format "%s\n.br\n" label) output))))
  232. ;;; Template
  233. (defun org-e-man-template (contents info)
  234. "Return complete document string after Man conversion.
  235. CONTENTS is the transcoded contents string. INFO is a plist
  236. holding export options."
  237. (let* ((title (org-export-data (plist-get info :title) info))
  238. (attr (read (format "(%s)"
  239. (mapconcat
  240. #'identity
  241. (list (plist-get info :man-class-options))
  242. " "))))
  243. (section-item (plist-get attr :section-id)))
  244. (concat
  245. (cond
  246. ((and title (stringp section-item))
  247. (format ".TH \"%s\" \"%s\" \n" title section-item))
  248. ((and (string= "" title) (stringp section-item))
  249. (format ".TH \"%s\" \"%s\" \n" " " section-item))
  250. (title
  251. (format ".TH \"%s\" \"1\" \n" title))
  252. (t
  253. ".TH \" \" \"1\" "))
  254. contents)))
  255. ;;; Transcode Functions
  256. ;;; Babel Call
  257. ;;
  258. ;; Babel Calls are ignored.
  259. ;;; Bold
  260. (defun org-e-man-bold (bold contents info)
  261. "Transcode BOLD from Org to Man.
  262. CONTENTS is the text with bold markup. INFO is a plist holding
  263. contextual information."
  264. (format "\\fB%s\\fP" contents))
  265. ;;; Center Block
  266. (defun org-e-man-center-block (center-block contents info)
  267. "Transcode a CENTER-BLOCK element from Org to Man.
  268. CONTENTS holds the contents of the center block. INFO is a plist
  269. holding contextual information."
  270. (org-e-man--wrap-label
  271. center-block
  272. (format ".ce %d\n.nf\n%s\n.fi"
  273. (- (length (split-string contents "\n")) 1 )
  274. contents)))
  275. ;;; Clock
  276. (defun org-e-man-clock (clock contents info)
  277. "Transcode a CLOCK element from Org to Man.
  278. CONTENTS is nil. INFO is a plist holding contextual
  279. information."
  280. "" )
  281. ;;; Code
  282. (defun org-e-man-code (code contents info)
  283. "Transcode a CODE object from Org to Man.
  284. CONTENTS is nil. INFO is a plist used as a communication
  285. channel."
  286. (format "\\fC%s\\fP" code))
  287. ;;; Comment
  288. ;;
  289. ;; Comments are ignored.
  290. ;;; Comment Block
  291. ;;
  292. ;; Comment Blocks are ignored.
  293. ;;; Drawer
  294. (defun org-e-man-drawer (drawer contents info)
  295. "Transcode a DRAWER element from Org to Man.
  296. DRAWER holds the drawer information
  297. CONTENTS holds the contents of the block.
  298. INFO is a plist holding contextual information. "
  299. contents)
  300. ;;; Dynamic Block
  301. (defun org-e-man-dynamic-block (dynamic-block contents info)
  302. "Transcode a DYNAMIC-BLOCK element from Org to Man.
  303. CONTENTS holds the contents of the block. INFO is a plist
  304. holding contextual information. See `org-export-data'."
  305. (org-e-man--wrap-label dynamic-block contents))
  306. ;;; Entity
  307. (defun org-e-man-entity (entity contents info)
  308. "Transcode an ENTITY object from Org to Man.
  309. CONTENTS are the definition itself. INFO is a plist holding
  310. contextual information."
  311. (org-element-property :utf-8 entity))
  312. ;;; Example Block
  313. (defun org-e-man-example-block (example-block contents info)
  314. "Transcode an EXAMPLE-BLOCK element from Org to Man.
  315. CONTENTS is nil. INFO is a plist holding contextual
  316. information."
  317. (org-e-man--wrap-label
  318. example-block
  319. (format ".RS\n.nf\n%s\n.fi\n.RE"
  320. (org-export-format-code-default example-block info))))
  321. ;;; Export Block
  322. (defun org-e-man-export-block (export-block contents info)
  323. "Transcode a EXPORT-BLOCK element from Org to Man.
  324. CONTENTS is nil. INFO is a plist holding contextual information."
  325. (when (string= (org-element-property :type export-block) "MAN")
  326. (org-remove-indentation (org-element-property :value export-block))))
  327. ;;; Export Snippet
  328. (defun org-e-man-export-snippet (export-snippet contents info)
  329. "Transcode a EXPORT-SNIPPET object from Org to Man.
  330. CONTENTS is nil. INFO is a plist holding contextual information."
  331. (when (eq (org-export-snippet-backend export-snippet) 'e-man)
  332. (org-element-property :value export-snippet)))
  333. ;;; Fixed Width
  334. (defun org-e-man-fixed-width (fixed-width contents info)
  335. "Transcode a FIXED-WIDTH element from Org to Man.
  336. CONTENTS is nil. INFO is a plist holding contextual information."
  337. (org-e-man--wrap-label
  338. fixed-width
  339. (format "\\fC\n%s\\fP"
  340. (org-remove-indentation
  341. (org-element-property :value fixed-width)))))
  342. ;;; Footnote Definition
  343. ;;
  344. ;; Footnote Definitions are ignored.
  345. ;;; Footnote References
  346. ;;
  347. ;; Footnote References are Ignored
  348. ;;; Headline
  349. (defun org-e-man-headline (headline contents info)
  350. "Transcode an HEADLINE element from Org to Man.
  351. CONTENTS holds the contents of the headline. INFO is a plist
  352. holding contextual information."
  353. (let* ((level (org-export-get-relative-level headline info))
  354. (numberedp (org-export-numbered-headline-p headline info))
  355. ;; Section formatting will set two placeholders: one for the
  356. ;; title and the other for the contents.
  357. (section-fmt
  358. (case level
  359. (1 ".SH \"%s\"\n%s")
  360. (2 ".SS \"%s\"\n%s")
  361. (3 ".SS \"%s\"\n%s")
  362. (t nil)))
  363. (text (org-export-data (org-element-property :title headline) info)))
  364. (cond
  365. ;; Case 1: This is a footnote section: ignore it.
  366. ((org-element-property :footnote-section-p headline) nil)
  367. ;; Case 2. This is a deep sub-tree: export it as a list item.
  368. ;; Also export as items headlines for which no section
  369. ;; format has been found.
  370. ((or (not section-fmt) (org-export-low-level-p headline info))
  371. ;; Build the real contents of the sub-tree.
  372. (let ((low-level-body
  373. (concat
  374. ;; If the headline is the first sibling, start a list.
  375. (when (org-export-first-sibling-p headline info)
  376. (format "%s\n" ".RS"))
  377. ;; Itemize headline
  378. ".TP\n.ft I\n" text "\n.ft\n"
  379. contents ".RE")))
  380. ;; If headline is not the last sibling simply return
  381. ;; LOW-LEVEL-BODY. Otherwise, also close the list, before any
  382. ;; blank line.
  383. (if (not (org-export-last-sibling-p headline info)) low-level-body
  384. (replace-regexp-in-string
  385. "[ \t\n]*\\'" ""
  386. low-level-body))))
  387. ;; Case 3. Standard headline. Export it as a section.
  388. (t (format section-fmt text contents )))))
  389. ;;; Horizontal Rule
  390. ;; Not supported
  391. ;;; Inline Babel Call
  392. ;;
  393. ;; Inline Babel Calls are ignored.
  394. ;;; Inline Src Block
  395. (defun org-e-man-inline-src-block (inline-src-block contents info)
  396. "Transcode an INLINE-SRC-BLOCK element from Org to Man.
  397. CONTENTS holds the contents of the item. INFO is a plist holding
  398. contextual information."
  399. (let* ((code (org-element-property :value inline-src-block)))
  400. (cond
  401. (org-e-man-source-highlight
  402. (let* ((tmpdir (if (featurep 'xemacs)
  403. temp-directory
  404. temporary-file-directory ))
  405. (in-file (make-temp-name
  406. (expand-file-name "srchilite" tmpdir)))
  407. (out-file (make-temp-name
  408. (expand-file-name "reshilite" tmpdir)))
  409. (org-lang (org-element-property :language inline-src-block))
  410. (lst-lang (cadr (assq (intern org-lang)
  411. org-e-man-source-highlight-langs)))
  412. (cmd (concat (expand-file-name "source-highlight")
  413. " -s " lst-lang
  414. " -f groff_man"
  415. " -i " in-file
  416. " -o " out-file )))
  417. (if lst-lang
  418. (let ((code-block "" ))
  419. (with-temp-file in-file (insert code))
  420. (shell-command cmd)
  421. (setq code-block (org-file-contents out-file))
  422. (delete-file in-file)
  423. (delete-file out-file)
  424. code-block)
  425. (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE\n"
  426. code))))
  427. ;; Do not use a special package: transcode it verbatim.
  428. (t
  429. (concat ".RS\n.nf\n" "\\fC" "\n" code "\n"
  430. "\\fP\n.fi\n.RE\n")))))
  431. ;;; Inlinetask
  432. ;;; Italic
  433. (defun org-e-man-italic (italic contents info)
  434. "Transcode ITALIC from Org to Man.
  435. CONTENTS is the text with italic markup. INFO is a plist holding
  436. contextual information."
  437. (format "\\fI%s\\fP" contents))
  438. ;;; Item
  439. (defun org-e-man-item (item contents info)
  440. "Transcode an ITEM element from Org to Man.
  441. CONTENTS holds the contents of the item. INFO is a plist holding
  442. contextual information."
  443. (let* ((bullet (org-element-property :bullet item))
  444. (type (org-element-property :type (org-element-property :parent item)))
  445. (checkbox (case (org-element-property :checkbox item)
  446. (on "\\o'\\(sq\\(mu'") ;;
  447. (off "\\(sq ") ;;
  448. (trans "\\o'\\(sq\\(mi'" ))) ;;
  449. (tag (let ((tag (org-element-property :tag item)))
  450. ;; Check-boxes must belong to the tag.
  451. (and tag (format "\\fB%s\\fP"
  452. (concat checkbox
  453. (org-export-data tag info)))))))
  454. (if (and (null tag )
  455. (null checkbox))
  456. (let* ((bullet (org-trim bullet))
  457. (marker (cond ((string= "-" bullet) "\\(em")
  458. ((string= "*" bullet) "\\(bu")
  459. ((eq type 'ordered)
  460. (format "%s " (org-trim bullet)))
  461. (t "\\(dg"))))
  462. (concat ".IP " marker " 4\n"
  463. (org-trim (or contents " " ))))
  464. ; else
  465. (concat ".TP\n" (or tag (concat " " checkbox)) "\n"
  466. (org-trim (or contents " " ))))))
  467. ;;; Keyword
  468. (defun org-e-man-keyword (keyword contents info)
  469. "Transcode a KEYWORD element from Org to Man.
  470. CONTENTS is nil. INFO is a plist holding contextual information."
  471. (let ((key (org-element-property :key keyword))
  472. (value (org-element-property :value keyword)))
  473. (cond
  474. ((string= key "MAN") value)
  475. ((string= key "INDEX") nil)
  476. ;; Invisible targets.
  477. ((string= key "TARGET") nil)
  478. ((string= key "TOC" ) nil))))
  479. ;;; Man Environment
  480. (defun org-e-man-man-environment (man-environment contents info)
  481. "Transcode a MAN-ENVIRONMENT element from Org to Man.
  482. CONTENTS is nil. INFO is a plist holding contextual information."
  483. (let ((label (org-element-property :name man-environment))
  484. (value (org-remove-indentation
  485. (org-element-property :value man-environment))))
  486. (if (not (org-string-nw-p label)) value
  487. ;; Environment is labelled: label must be within the environment
  488. ;; (otherwise, a reference pointing to that element will count
  489. ;; the section instead).
  490. (with-temp-buffer
  491. (insert value)
  492. (goto-char (point-min))
  493. (forward-line)
  494. (insert (format "%s\n" label))
  495. (buffer-string)))))
  496. ;;; Man Fragment
  497. (defun org-e-man-man-fragment (man-fragment contents info)
  498. "Transcode a MAN-FRAGMENT object from Org to Man.
  499. CONTENTS is nil. INFO is a plist holding contextual information."
  500. (org-element-property :value man-fragment))
  501. ;;; Line Break
  502. (defun org-e-man-line-break (line-break contents info)
  503. "Transcode a LINE-BREAK object from Org to Man.
  504. CONTENTS is nil. INFO is a plist holding contextual information."
  505. ".br\n")
  506. ;;; Link
  507. (defun org-e-man-link (link desc info)
  508. "Transcode a LINK object from Org to Man.
  509. DESC is the description part of the link, or the empty string.
  510. INFO is a plist holding contextual information. See
  511. `org-export-data'."
  512. (let* ((type (org-element-property :type link))
  513. (raw-path (org-element-property :path link))
  514. ;; Ensure DESC really exists, or set it to nil.
  515. (desc (and (not (string= desc "")) desc))
  516. (path (cond
  517. ((member type '("http" "https" "ftp" "mailto"))
  518. (concat type ":" raw-path))
  519. ((string= type "file")
  520. (when (string-match "\\(.+\\)::.+" raw-path)
  521. (setq raw-path (match-string 1 raw-path)))
  522. (if (file-name-absolute-p raw-path)
  523. (concat "file://" (expand-file-name raw-path))
  524. (concat "file://" raw-path)))
  525. (t raw-path)))
  526. protocol)
  527. (cond
  528. ;; External link with a description part.
  529. ((and path desc) (format "%s \\fBat\\fP \\fI%s\\fP" path desc))
  530. ;; External link without a description part.
  531. (path (format "\\fI%s\\fP" path))
  532. ;; No path, only description. Try to do something useful.
  533. (t (format "\\fI%s\\fP" desc)))))
  534. ;;; Paragraph
  535. (defun org-e-man-paragraph (paragraph contents info)
  536. "Transcode a PARAGRAPH element from Org to Man.
  537. CONTENTS is the contents of the paragraph, as a string. INFO is
  538. the plist used as a communication channel."
  539. (let ((parent (plist-get (nth 1 paragraph) :parent)))
  540. (when parent
  541. (let ((parent-type (car parent))
  542. (fixed-paragraph ""))
  543. (cond ((and (eq parent-type 'item)
  544. (plist-get (nth 1 parent) :bullet ))
  545. (setq fixed-paragraph (concat "" contents)))
  546. ((eq parent-type 'section)
  547. (setq fixed-paragraph (concat ".PP\n" contents)))
  548. ((eq parent-type 'footnote-definition)
  549. (setq fixed-paragraph contents))
  550. (t (setq fixed-paragraph (concat "" contents))))
  551. fixed-paragraph ))))
  552. ;;; Plain List
  553. (defun org-e-man-plain-list (plain-list contents info)
  554. "Transcode a PLAIN-LIST element from Org to Man.
  555. CONTENTS is the contents of the list. INFO is a plist holding
  556. contextual information."
  557. contents)
  558. ;;; Plain Text
  559. (defun org-e-man-plain-text (text info)
  560. "Transcode a TEXT string from Org to Man.
  561. TEXT is the string to transcode. INFO is a plist holding
  562. contextual information."
  563. (let ((output text))
  564. ;; Protect various chars.
  565. (setq output (replace-regexp-in-string
  566. "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
  567. "$\\" output nil t 1))
  568. ;; Activate smart quotes. Be sure to provide original TEXT string
  569. ;; since OUTPUT may have been modified.
  570. (when (plist-get info :with-smart-quotes)
  571. (setq output (org-export-activate-smart-quotes output :utf-8 info text)))
  572. ;; Handle break preservation if required.
  573. (when (plist-get info :preserve-breaks)
  574. (setq output (replace-regexp-in-string "\\(\\\\\\\\\\)?[ \t]*\n" ".br\n"
  575. output)))
  576. ;; Return value.
  577. output))
  578. ;;; Planning
  579. ;;; Property Drawer
  580. ;;; Quote Block
  581. (defun org-e-man-quote-block (quote-block contents info)
  582. "Transcode a QUOTE-BLOCK element from Org to Man.
  583. CONTENTS holds the contents of the block. INFO is a plist
  584. holding contextual information."
  585. (org-e-man--wrap-label
  586. quote-block
  587. (format ".RS\n%s\n.RE" contents)))
  588. ;;; Quote Section
  589. (defun org-e-man-quote-section (quote-section contents info)
  590. "Transcode a QUOTE-SECTION element from Org to Man.
  591. CONTENTS is nil. INFO is a plist holding contextual information."
  592. (let ((value (org-remove-indentation
  593. (org-element-property :value quote-section))))
  594. (when value (format ".RS\\fI%s\\fP\n.RE\n" value))))
  595. ;;; Radio Target
  596. (defun org-e-man-radio-target (radio-target text info)
  597. "Transcode a RADIO-TARGET object from Org to Man.
  598. TEXT is the text of the target. INFO is a plist holding
  599. contextual information."
  600. text )
  601. ;;; Section
  602. (defun org-e-man-section (section contents info)
  603. "Transcode a SECTION element from Org to Man.
  604. CONTENTS holds the contents of the section. INFO is a plist
  605. holding contextual information."
  606. contents)
  607. ;;; Special Block
  608. (defun org-e-man-special-block (special-block contents info)
  609. "Transcode a SPECIAL-BLOCK element from Org to Man.
  610. CONTENTS holds the contents of the block. INFO is a plist
  611. holding contextual information."
  612. (let ((type (downcase (org-element-property :type special-block))))
  613. (org-e-man--wrap-label
  614. special-block
  615. (format "%s\n" contents))))
  616. ;;; Src Block
  617. (defun org-e-man-src-block (src-block contents info)
  618. "Transcode a SRC-BLOCK element from Org to Man.
  619. CONTENTS holds the contents of the item. INFO is a plist holding
  620. contextual information."
  621. (let* ((lang (org-element-property :language src-block))
  622. (code (org-element-property :value src-block))
  623. (custom-env (and lang
  624. (cadr (assq (intern lang)
  625. org-e-man-custom-lang-environments))))
  626. (num-start (case (org-element-property :number-lines src-block)
  627. (continued (org-export-get-loc src-block info))
  628. (new 0)))
  629. (retain-labels (org-element-property :retain-labels src-block)))
  630. (cond
  631. ;; Case 1. No source fontification.
  632. ((not org-e-man-source-highlight)
  633. (format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n"
  634. (org-export-format-code-default src-block info)))
  635. (org-e-man-source-highlight
  636. (let* ((tmpdir (if (featurep 'xemacs)
  637. temp-directory
  638. temporary-file-directory ))
  639. (in-file (make-temp-name
  640. (expand-file-name "srchilite" tmpdir)))
  641. (out-file (make-temp-name
  642. (expand-file-name "reshilite" tmpdir)))
  643. (org-lang (org-element-property :language src-block))
  644. (lst-lang (cadr (assq (intern org-lang)
  645. org-e-man-source-highlight-langs)))
  646. (cmd (concat "source-highlight"
  647. " -s " lst-lang
  648. " -f groff_man "
  649. " -i " in-file
  650. " -o " out-file)))
  651. (if lst-lang
  652. (let ((code-block ""))
  653. (with-temp-file in-file (insert code))
  654. (shell-command cmd)
  655. (setq code-block (org-file-contents out-file))
  656. (delete-file in-file)
  657. (delete-file out-file)
  658. code-block)
  659. (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE" code)))))))
  660. ;;; Statistics Cookie
  661. (defun org-e-man-statistics-cookie (statistics-cookie contents info)
  662. "Transcode a STATISTICS-COOKIE object from Org to Man.
  663. CONTENTS is nil. INFO is a plist holding contextual information."
  664. (org-element-property :value statistics-cookie))
  665. ;;; Strike-Through
  666. (defun org-e-man-strike-through (strike-through contents info)
  667. "Transcode STRIKE-THROUGH from Org to Man.
  668. CONTENTS is the text with strike-through markup. INFO is a plist
  669. holding contextual information."
  670. (format "\\fI%s\\fP" contents))
  671. ;;; Subscript
  672. (defun org-e-man-subscript (subscript contents info)
  673. "Transcode a SUBSCRIPT object from Org to Man.
  674. CONTENTS is the contents of the object. INFO is a plist holding
  675. contextual information."
  676. (format "\\d\\s-2%s\\s+2\\u" contents))
  677. ;;; Superscript "^_%s$
  678. (defun org-e-man-superscript (superscript contents info)
  679. "Transcode a SUPERSCRIPT object from Org to Man.
  680. CONTENTS is the contents of the object. INFO is a plist holding
  681. contextual information."
  682. (format "\\u\\s-2%s\\s+2\\d" contents))
  683. ;;; Table
  684. ;;
  685. ;; `org-e-man-table' is the entry point for table transcoding. It
  686. ;; takes care of tables with a "verbatim" attribute. Otherwise, it
  687. ;; delegates the job to either `org-e-man-table--table.el-table' or
  688. ;; `org-e-man-table--org-table' functions, depending of the type of
  689. ;; the table.
  690. ;;
  691. ;; `org-e-man-table--align-string' is a subroutine used to build
  692. ;; alignment string for Org tables.
  693. (defun org-e-man-table (table contents info)
  694. "Transcode a TABLE element from Org to Man.
  695. CONTENTS is the contents of the table. INFO is a plist holding
  696. contextual information."
  697. (cond
  698. ;; Case 1: verbatim table.
  699. ((or org-e-man-tables-verbatim
  700. (let ((attr (read (format "(%s)"
  701. (mapconcat
  702. #'identity
  703. (org-element-property :attr_man table)
  704. " ")))))
  705. (and attr (plist-get attr :verbatim))))
  706. (format ".nf\n\\fC%s\\fP\n.fi"
  707. ;; Re-create table, without affiliated keywords.
  708. (org-trim
  709. (org-element-interpret-data
  710. `(table nil ,@(org-element-contents table))))))
  711. ;; Case 2: Standard table.
  712. (t (org-e-man-table--org-table table contents info))))
  713. (defun org-e-man-table--align-string (divider table info)
  714. "Return an appropriate Man alignment string.
  715. TABLE is the considered table. INFO is a plist used as
  716. a communication channel."
  717. (let (alignment)
  718. ;; Extract column groups and alignment from first (non-rule)
  719. ;; row.
  720. (org-element-map
  721. (org-element-map
  722. table 'table-row
  723. (lambda (row)
  724. (and (eq (org-element-property :type row) 'standard) row))
  725. info 'first-match)
  726. 'table-cell
  727. (lambda (cell)
  728. (let* ((borders (org-export-table-cell-borders cell info))
  729. (raw-width (org-export-table-cell-width cell info))
  730. (width-cm (when raw-width (/ raw-width 5)))
  731. (width (if raw-width (format "w(%dc)"
  732. (if (< width-cm 1) 1 width-cm)) "")))
  733. ;; Check left border for the first cell only.
  734. (when (and (memq 'left borders) (not alignment))
  735. (push "|" alignment))
  736. (push
  737. (case (org-export-table-cell-alignment cell info)
  738. (left (concat "l" width divider))
  739. (right (concat "r" width divider))
  740. (center (concat "c" width divider)))
  741. alignment)
  742. (when (memq 'right borders) (push "|" alignment))))
  743. info)
  744. (apply 'concat (reverse alignment))))
  745. (defun org-e-man-table--org-table (table contents info)
  746. "Return appropriate Man code for an Org table.
  747. TABLE is the table type element to transcode. CONTENTS is its
  748. contents, as a string. INFO is a plist used as a communication
  749. channel.
  750. This function assumes TABLE has `org' as its `:type' attribute."
  751. (let* ((attr (org-export-read-attribute :attr_man table))
  752. (label (org-element-property :name table))
  753. (caption (and (not (plist-get attr :disable-caption))
  754. (org-e-man--caption/label-string table info)))
  755. (divider (if (plist-get attr :divider) "|" " "))
  756. ;; Determine alignment string.
  757. (alignment (org-e-man-table--align-string divider table info))
  758. ;; Extract others display options.
  759. (lines (org-split-string contents "\n"))
  760. (attr-list
  761. (let ((result-list '()))
  762. (dolist (attr-item
  763. (list
  764. (if (plist-get attr :expand)
  765. "expand" nil)
  766. (case (plist-get attr :placement)
  767. ('center "center")
  768. ('left nil)
  769. (t
  770. (if org-e-man-tables-centered
  771. "center" "")))
  772. (case (plist-get attr :boxtype)
  773. ('box "box")
  774. ('doublebox "doublebox")
  775. ('allbox "allbox")
  776. ('none nil)
  777. (t "box"))))
  778. (if attr-item
  779. (add-to-list 'result-list attr-item)))
  780. result-list ))
  781. (title-line (plist-get attr :title-line))
  782. (long-cells (plist-get attr :long-cells))
  783. (table-format (concat
  784. (format "%s" (or (car attr-list) "" ))
  785. (or
  786. (let ((output-list '()))
  787. (when (cdr attr-list)
  788. (dolist (attr-item (cdr attr-list))
  789. (setq output-list (concat output-list (format ",%s" attr-item)))))
  790. output-list)
  791. "")))
  792. (first-line (when lines (org-split-string (car lines) "\t"))))
  793. ;; Prepare the final format string for the table.
  794. (cond
  795. ;; Others.
  796. (lines (concat ".TS\n " table-format ";\n"
  797. (format "%s.\n"
  798. (let ((final-line ""))
  799. (when title-line
  800. (dotimes (i (length first-line))
  801. (setq final-line (concat final-line "cb" divider))))
  802. (setq final-line (concat final-line "\n"))
  803. (if alignment
  804. (setq final-line (concat final-line alignment))
  805. (dotimes (i (length first-line))
  806. (setq final-line (concat final-line "c" divider))))
  807. final-line ))
  808. (format "%s.TE\n"
  809. (let ((final-line "")
  810. (long-line "")
  811. (lines (org-split-string contents "\n")))
  812. (dolist (line-item lines)
  813. (setq long-line "")
  814. (if long-cells
  815. (progn
  816. (if (string= line-item "_")
  817. (setq long-line (format "%s\n" line-item))
  818. ;; else string =
  819. (let ((cell-item-list (org-split-string line-item "\t")))
  820. (dolist (cell-item cell-item-list)
  821. (cond ((eq cell-item (car (last cell-item-list)))
  822. (setq long-line (concat long-line
  823. (format "T{\n%s\nT}\t\n" cell-item ))))
  824. (t
  825. (setq long-line (concat long-line
  826. (format "T{\n%s\nT}\t" cell-item ))))))
  827. long-line))
  828. ;; else long cells
  829. (setq final-line (concat final-line long-line )))
  830. (setq final-line (concat final-line line-item "\n"))))
  831. final-line))
  832. (and caption (format ".TB \"%s\"" caption)))))))
  833. ;;; Table Cell
  834. (defun org-e-man-table-cell (table-cell contents info)
  835. "Transcode a TABLE-CELL element from Org to Man
  836. CONTENTS is the cell contents. INFO is a plist used as
  837. a communication channel."
  838. (concat (if (and contents
  839. org-e-man-table-scientific-notation
  840. (string-match orgtbl-exp-regexp contents))
  841. ;; Use appropriate format string for scientific
  842. ;; notation.
  843. (format org-e-man-table-scientific-notation
  844. (match-string 1 contents)
  845. (match-string 2 contents))
  846. contents )
  847. (when (org-export-get-next-element table-cell info) "\t")))
  848. ;;; Table Row
  849. (defun org-e-man-table-row (table-row contents info)
  850. "Transcode a TABLE-ROW element from Org to Man
  851. CONTENTS is the contents of the row. INFO is a plist used as
  852. a communication channel."
  853. ;; Rules are ignored since table separators are deduced from
  854. ;; borders of the current row.
  855. (when (eq (org-element-property :type table-row) 'standard)
  856. (let* ((attr (mapconcat 'identity
  857. (org-element-property
  858. :attr_man (org-export-get-parent table-row))
  859. " "))
  860. ;; TABLE-ROW's borders are extracted from its first cell.
  861. (borders
  862. (org-export-table-cell-borders
  863. (car (org-element-contents table-row)) info)))
  864. (concat
  865. ;; Mark horizontal lines
  866. (cond ((and (memq 'top borders) (memq 'above borders)) "_\n"))
  867. contents
  868. (cond
  869. ;; When BOOKTABS are activated enforce bottom rule even when
  870. ;; no hline was specifically marked.
  871. ((and (memq 'bottom borders) (memq 'below borders)) "\n_")
  872. ((memq 'below borders) "\n_"))))))
  873. ;;; Target
  874. (defun org-e-man-target (target contents info)
  875. "Transcode a TARGET object from Org to Man.
  876. CONTENTS is nil. INFO is a plist holding contextual
  877. information."
  878. (format "\\fI%s\\fP"
  879. (org-export-solidify-link-text (org-element-property :value target))))
  880. ;;; Timestamp
  881. (defun org-e-man-timestamp (timestamp contents info)
  882. "Transcode a TIMESTAMP object from Org to Man.
  883. CONTENTS is nil. INFO is a plist holding contextual
  884. information."
  885. "" )
  886. ;;; Underline
  887. (defun org-e-man-underline (underline contents info)
  888. "Transcode UNDERLINE from Org to Man.
  889. CONTENTS is the text with underline markup. INFO is a plist
  890. holding contextual information."
  891. (format "\\fI%s\\fP" contents))
  892. ;;; Verbatim
  893. (defun org-e-man-verbatim (verbatim contents info)
  894. "Transcode a VERBATIM object from Org to Man.
  895. CONTENTS is nil. INFO is a plist used as a communication
  896. channel."
  897. (format ".nf\n%s\n.fi" contents))
  898. ;;; Verse Block
  899. (defun org-e-man-verse-block (verse-block contents info)
  900. "Transcode a VERSE-BLOCK element from Org to Man.
  901. CONTENTS is verse block contents. INFO is a plist holding
  902. contextual information."
  903. (format ".RS\n.ft I\n%s\n.ft\n.RE" contents))
  904. ;;; Interactive functions
  905. (defun org-e-man-export-to-man
  906. (&optional subtreep visible-only body-only ext-plist pub-dir)
  907. "Export current buffer to a Man file.
  908. If narrowing is active in the current buffer, only export its
  909. narrowed part.
  910. If a region is active, export that region.
  911. When optional argument SUBTREEP is non-nil, export the sub-tree
  912. at point, extracting information from the headline properties
  913. first.
  914. When optional argument VISIBLE-ONLY is non-nil, don't export
  915. contents of hidden elements.
  916. When optional argument BODY-ONLY is non-nil, only the body
  917. without any markers.
  918. EXT-PLIST, when provided, is a property list with external
  919. parameters overriding Org default settings, but still inferior to
  920. file-local settings.
  921. When optional argument PUB-DIR is set, use it as the publishing
  922. directory.
  923. Return output file's name."
  924. (interactive)
  925. (let ((outfile (org-export-output-file-name ".man" subtreep pub-dir)))
  926. (org-export-to-file
  927. 'e-man outfile subtreep visible-only body-only ext-plist)))
  928. (defun org-e-man-export-to-pdf
  929. (&optional subtreep visible-only body-only ext-plist pub-dir)
  930. "Export current buffer to Groff then process through to PDF.
  931. If narrowing is active in the current buffer, only export its
  932. narrowed part.
  933. If a region is active, export that region.
  934. When optional argument SUBTREEP is non-nil, export the sub-tree
  935. at point, extracting information from the headline properties
  936. first.
  937. When optional argument VISIBLE-ONLY is non-nil, don't export
  938. contents of hidden elements.
  939. When optional argument BODY-ONLY is non-nil, only write between
  940. markers.
  941. EXT-PLIST, when provided, is a property list with external
  942. parameters overriding Org default settings, but still inferior to
  943. file-local settings.
  944. When optional argument PUB-DIR is set, use it as the publishing
  945. directory.
  946. Return PDF file's name."
  947. (interactive)
  948. (org-e-man-compile
  949. (org-e-man-export-to-man
  950. subtreep visible-only body-only ext-plist pub-dir)))
  951. (defun org-e-man-compile (file)
  952. "Compile a Groff file.
  953. FILE is the name of the file being compiled. Processing is done
  954. through the command specified in `org-e-man-pdf-process'.
  955. Return PDF file name or an error if it couldn't be produced."
  956. (let* ((base-name (file-name-sans-extension (file-name-nondirectory file)))
  957. (full-name (file-truename file))
  958. (out-dir (file-name-directory file))
  959. ;; Make sure `default-directory' is set to FILE directory,
  960. ;; not to whatever value the current buffer may have.
  961. (default-directory (file-name-directory full-name))
  962. errors)
  963. (message (format "Processing Groff file %s ..." file))
  964. (save-window-excursion
  965. (cond
  966. ;; A function is provided: Apply it.
  967. ((functionp org-e-man-pdf-process)
  968. (funcall org-e-man-pdf-process (shell-quote-argument file)))
  969. ;; A list is provided: Replace %b, %f and %o with appropriate
  970. ;; values in each command before applying it. Output is
  971. ;; redirected to "*Org PDF Groff Output*" buffer.
  972. ((consp org-e-man-pdf-process)
  973. (let ((outbuf (get-buffer-create "*Org PDF Groff Output*")))
  974. (mapc
  975. (lambda (command)
  976. (shell-command
  977. (replace-regexp-in-string
  978. "%b" (shell-quote-argument base-name)
  979. (replace-regexp-in-string
  980. "%f" (shell-quote-argument full-name)
  981. (replace-regexp-in-string
  982. "%o" (shell-quote-argument out-dir) command t t) t t) t t)
  983. outbuf))
  984. org-e-man-pdf-process)
  985. ;; Collect standard errors from output buffer.
  986. (setq errors (org-e-man-collect-errors outbuf))))
  987. (t (error "No valid command to process to PDF")))
  988. (let ((pdffile (concat out-dir base-name ".pdf")))
  989. ;; Check for process failure. Provide collected errors if
  990. ;; possible.
  991. (if (not (file-exists-p pdffile))
  992. (error (concat (format "PDF file %s wasn't produced" pdffile)
  993. (when errors (concat ": " errors))))
  994. ;; Else remove log files, when specified, and signal end of
  995. ;; process to user, along with any error encountered.
  996. (when org-e-man-remove-logfiles
  997. (dolist (ext org-e-man-logfiles-extensions)
  998. (let ((file (concat out-dir base-name "." ext)))
  999. (when (file-exists-p file) (delete-file file)))))
  1000. (message (concat "Process completed"
  1001. (if (not errors) "."
  1002. (concat " with errors: " errors)))))
  1003. ;; Return output file name.
  1004. pdffile))))
  1005. (defun org-e-man-collect-errors (buffer)
  1006. "Collect some kind of errors from \"groff\" output
  1007. BUFFER is the buffer containing output.
  1008. Return collected error types as a string, or nil if there was
  1009. none."
  1010. (with-current-buffer buffer
  1011. (save-excursion
  1012. (goto-char (point-max))
  1013. ;; Find final run
  1014. nil )))
  1015. (provide 'org-e-man)
  1016. ;;; org-e-man.el ends here