瀏覽代碼

Merge branch 'master' of orgmode.org:org-mode

Bastien Guerry 13 年之前
父節點
當前提交
ee483e98f7
共有 4 個文件被更改,包括 473 次插入585 次删除
  1. 281 358
      contrib/lisp/org-e-groff.el
  2. 174 218
      contrib/lisp/org-e-man.el
  3. 5 5
      lisp/org.el
  4. 13 4
      testing/lisp/test-org.el

文件差異過大導致無法顯示
+ 281 - 358
contrib/lisp/org-e-groff.el


+ 174 - 218
contrib/lisp/org-e-man.el

@@ -5,7 +5,7 @@
 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 ;; Author: Nicolas Goaziou <n.goaziou at gmail dot com>
 ;; Author: Luis R Anaya <papoanaya aroba hot mail punto com>
 ;; Author: Luis R Anaya <papoanaya aroba hot mail punto com>
 ;; Keywords: outlines, hypermedia, calendar, wp
 ;; Keywords: outlines, hypermedia, calendar, wp
-;; 
+;;
 
 
 ;; This program is free software; you can redistribute it and/or modify
 ;; This program is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
 ;; it under the terms of the GNU General Public License as published by
@@ -32,10 +32,10 @@
 ;; export.  See contrib/lisp/org-export.el for more details on how
 ;; export.  See contrib/lisp/org-export.el for more details on how
 ;; this exporter works.
 ;; this exporter works.
 ;;
 ;;
-;; It introduces one new buffer keywords: 
-;; "MAN_CLASS_OPTIONS". 
+;; It introduces one new buffer keywords:
+;; "MAN_CLASS_OPTIONS".
 
 
-;;; Code:
+;;;; Code:
 
 
 (require 'org-export)
 (require 'org-export)
 
 
@@ -47,7 +47,9 @@
 
 
 
 
 
 
-;;; Define Back-End
+
+
+;;;; Define Back-End
 
 
 (defvar org-e-man-translate-alist
 (defvar org-e-man-translate-alist
   '((babel-call . org-e-man-babel-call)
   '((babel-call . org-e-man-babel-call)
@@ -116,13 +118,16 @@ structure of the values.")
 
 
 
 
 
 
+
 ;;; User Configurable Variables
 ;;; User Configurable Variables
 
 
+
 (defgroup org-export-e-man nil
 (defgroup org-export-e-man nil
   "Options for exporting Org mode files to Man."
   "Options for exporting Org mode files to Man."
   :tag "Org Export Man"
   :tag "Org Export Man"
   :group 'org-export)
   :group 'org-export)
 
 
+
 ;;;; Tables
 ;;;; Tables
 
 
 
 
@@ -136,7 +141,6 @@ structure of the values.")
   :group 'org-export-e-man
   :group 'org-export-e-man
   :type 'boolean)
   :type 'boolean)
 
 
-
 (defcustom org-e-man-table-scientific-notation "%sE%s"
 (defcustom org-e-man-table-scientific-notation "%sE%s"
   "Format string to display numbers in scientific notation.
   "Format string to display numbers in scientific notation.
 The format should have \"%s\" twice, for mantissa and exponent
 The format should have \"%s\" twice, for mantissa and exponent
@@ -150,35 +154,34 @@ When nil, no transformation is made."
 
 
 
 
 ;;;; Inlinetasks
 ;;;; Inlinetasks
+
+
 ;; Src blocks
 ;; Src blocks
 
 
 (defcustom org-e-man-source-highlight nil
 (defcustom org-e-man-source-highlight nil
-  "Use GNU source highlight to embellish source blocks " 
+  "Use GNU source highlight to embellish source blocks "
   :group 'org-export-e-man
   :group 'org-export-e-man
   :type 'boolean)
   :type 'boolean)
 
 
-
 (defcustom org-e-man-source-highlight-langs
 (defcustom org-e-man-source-highlight-langs
-  '(
-    (emacs-lisp "lisp") (lisp "lisp") (clojure "lisp") 
+  '((emacs-lisp "lisp") (lisp "lisp") (clojure "lisp")
     (scheme "scheme")
     (scheme "scheme")
-    (c "c") (cc "cpp") (csharp "csharp") (d "d") 
+    (c "c") (cc "cpp") (csharp "csharp") (d "d")
     (fortran "fortran") (cobol "cobol") (pascal "pascal")
     (fortran "fortran") (cobol "cobol") (pascal "pascal")
     (ada "ada") (asm "asm")
     (ada "ada") (asm "asm")
-    (perl "perl") (cperl "perl") 
+    (perl "perl") (cperl "perl")
     (python "python") (ruby "ruby") (tcl "tcl") (lua "lua")
     (python "python") (ruby "ruby") (tcl "tcl") (lua "lua")
     (java "java") (javascript "javascript")
     (java "java") (javascript "javascript")
-    (tex "latex") 
+    (tex "latex")
     (shell-script "sh") (awk "awk") (diff "diff") (m4 "m4")
     (shell-script "sh") (awk "awk") (diff "diff") (m4 "m4")
     (ocaml "caml") (caml "caml")
     (ocaml "caml") (caml "caml")
     (sql "sql") (sqlite "sql")
     (sql "sql") (sqlite "sql")
     (html "html") (css "css") (xml "xml")
     (html "html") (css "css") (xml "xml")
     (bat "bat") (bison "bison") (clipper "clipper")
     (bat "bat") (bison "bison") (clipper "clipper")
     (ldap "ldap") (opa "opa")
     (ldap "ldap") (opa "opa")
-    (php "php") (postscript "postscript") (prolog "prolog") 
+    (php "php") (postscript "postscript") (prolog "prolog")
     (properties "properties") (makefile "makefile")
     (properties "properties") (makefile "makefile")
-    (tml "tml") (vala "vala") (vbscript "vbscript") (xorg "xorg")
-    )
+    (tml "tml") (vala "vala") (vbscript "vbscript") (xorg "xorg"))
   "Alist mapping languages to their listing language counterpart.
   "Alist mapping languages to their listing language counterpart.
 The key is a symbol, the major mode symbol without the \"-mode\".
 The key is a symbol, the major mode symbol without the \"-mode\".
 The value is the string that should be inserted as the language
 The value is the string that should be inserted as the language
@@ -192,11 +195,10 @@ in this list - but it does not hurt if it is present."
            (string :tag "Listings language"))))
            (string :tag "Listings language"))))
 
 
 
 
-
 (defvar org-e-man-custom-lang-environments nil
 (defvar org-e-man-custom-lang-environments nil
   "Alist mapping languages to language-specific Man environments.
   "Alist mapping languages to language-specific Man environments.
 
 
-It is used during export of src blocks by the listings and 
+It is used during export of src blocks by the listings and
 man packages.  For example,
 man packages.  For example,
 
 
   \(setq org-e-man-custom-lang-environments
   \(setq org-e-man-custom-lang-environments
@@ -204,9 +206,7 @@ man packages.  For example,
 
 
 would have the effect that if org encounters begin_src python
 would have the effect that if org encounters begin_src python
 during man export."
 during man export."
-  )
-
-
+)
 
 
 
 
 ;;;; Plain text
 ;;;; Plain text
@@ -250,8 +250,7 @@ string defines the replacement string for this quote."
 (defcustom org-e-man-pdf-process
 (defcustom org-e-man-pdf-process
   '("tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
   '("tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
     "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
     "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
-    "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf"
-    )
+    "tbl %f | eqn | groff -man | ps2pdf - > %b.pdf")
 
 
   "Commands to process a Man file to a PDF file.
   "Commands to process a Man file to a PDF file.
 This is a list of strings, each of them will be given to the
 This is a list of strings, each of them will be given to the
@@ -263,7 +262,7 @@ extension) and %o by the base directory of the file.
 By default, Org uses 3 runs of to do the processing.
 By default, Org uses 3 runs of to do the processing.
 
 
 Alternatively, this may be a Lisp function that does the
 Alternatively, this may be a Lisp function that does the
-processing.  This function should accept the file name as 
+processing.  This function should accept the file name as
 its single argument."
 its single argument."
   :group 'org-export-pdf
   :group 'org-export-pdf
   :type '(choice
   :type '(choice
@@ -271,7 +270,7 @@ its single argument."
                   (string :tag "Shell command"))
                   (string :tag "Shell command"))
           (const :tag "2 runs of pdfgroff"
           (const :tag "2 runs of pdfgroff"
                  ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
                  ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
-                  "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf" ))
+                  "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"))
           (const :tag "3 runs of pdfgroff"
           (const :tag "3 runs of pdfgroff"
                  ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
                  ("tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
                   "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
                   "tbl %f | eqn | groff -mm | ps2pdf - > %b.pdf"
@@ -294,6 +293,7 @@ These are the .aux, .log, .out, and .toc files."
 
 
 ;; Preamble
 ;; Preamble
 
 
+
 ;; Adding MAN as a block parser to make sure that its contents
 ;; Adding MAN as a block parser to make sure that its contents
 ;; does not execute
 ;; does not execute
 
 
@@ -302,9 +302,10 @@ These are the .aux, .log, .out, and .toc files."
 
 
 
 
 
 
-;;; Internal Functions
 
 
 
 
+;;; Internal Functions
+
 (defun org-e-man--caption/label-string (caption label info)
 (defun org-e-man--caption/label-string (caption label info)
   "Return caption and label Man string for floats.
   "Return caption and label Man string for floats.
 
 
@@ -316,7 +317,7 @@ information.
 If there's no caption nor label, return the empty string.
 If there's no caption nor label, return the empty string.
 
 
 For non-floats, see `org-e-man--wrap-label'."
 For non-floats, see `org-e-man--wrap-label'."
-  (let ((label-str "" ))
+  (let ((label-str ""))
     (cond
     (cond
      ((and (not caption) (not label)) "")
      ((and (not caption) (not label)) "")
      ((not caption) (format "\\fI%s\\fP" label))
      ((not caption) (format "\\fI%s\\fP" label))
@@ -328,11 +329,7 @@ For non-floats, see `org-e-man--wrap-label'."
               (org-export-data (car caption) info)))
               (org-export-data (car caption) info)))
      ;; Standard caption format.
      ;; Standard caption format.
      (t (format "\\fR%s\\fP"
      (t (format "\\fR%s\\fP"
-                (org-export-data (car caption) info)))))
-
-  )
-
-
+                (org-export-data (car caption) info))))))
 
 
 (defun org-e-man--quotation-marks (text info)
 (defun org-e-man--quotation-marks (text info)
   "Export quotation marks depending on language conventions.
   "Export quotation marks depending on language conventions.
@@ -358,46 +355,42 @@ This function shouldn't be used for floats.  See
       (concat (format "%s\n.br\n" label) output))))
       (concat (format "%s\n.br\n" label) output))))
 
 
 
 
+
+
 ;;; Template
 ;;; Template
 
 
 (defun org-e-man-template (contents info)
 (defun org-e-man-template (contents info)
   "Return complete document string after Man conversion.
   "Return complete document string after Man conversion.
 CONTENTS is the transcoded contents string.  INFO is a plist
 CONTENTS is the transcoded contents string.  INFO is a plist
 holding export options."
 holding export options."
-  (let ((title (org-export-data (plist-get info :title) info))
+  (let* ((title (org-export-data (plist-get info :title) info))
         (attr
         (attr
-         (read
-          (format
-           "(%s)"
+         (read (format "(%s)"
            (mapconcat
            (mapconcat
             #'identity
             #'identity
             (list (plist-get info :man-class-options))
             (list (plist-get info :man-class-options))
-            " ")))) )
-
-    (setq section-item (plist-get attr :section-id))
+            " "))))
+    (section-item (plist-get attr :section-id)))
 
 
     (concat
     (concat
-
-     (cond 
+     (cond
       ((and title (stringp section-item))
       ((and title (stringp section-item))
-       (format ".TH \"%s\" \"%s\" \n" title section-item )
-       )
+       (format ".TH \"%s\" \"%s\" \n" title section-item))
       ((and (string= "" title) (stringp section-item))
       ((and (string= "" title) (stringp section-item))
-       (format ".TH \"%s\" \"%s\" \n" " " section-item )
-       )
+       (format ".TH \"%s\" \"%s\" \n" " " section-item))
       (title
       (title
-       (format ".TH \"%s\" \"1\" \n" title )
-       )
+       (format ".TH \"%s\" \"1\" \n" title))
       (t
       (t
        ".TH \" \" \"1\" "))
        ".TH \" \" \"1\" "))
-
-     contents )))
+     contents)))
 
 
 
 
+
+
 ;;; Transcode Functions
 ;;; Transcode Functions
 
 
 ;;;; Babel Call
 ;;;; Babel Call
-;;
+
 ;; Babel Calls are ignored.
 ;; Babel Calls are ignored.
 
 
 
 
@@ -407,7 +400,7 @@ holding export options."
   "Transcode BOLD from Org to Man.
   "Transcode BOLD from Org to Man.
 CONTENTS is the text with bold markup.  INFO is a plist holding
 CONTENTS is the text with bold markup.  INFO is a plist holding
 contextual information."
 contextual information."
-  (format "\\fB%s\\fP" contents) )
+  (format "\\fB%s\\fP" contents))
 
 
 
 
 ;;;; Center Block
 ;;;; Center Block
@@ -418,8 +411,8 @@ CONTENTS holds the contents of the center block.  INFO is a plist
 holding contextual information."
 holding contextual information."
   (org-e-man--wrap-label
   (org-e-man--wrap-label
    center-block
    center-block
-   (format ".ce %d\n.nf\n%s\n.fi" 
-           (- (length (split-string contents "\n")) 1 ) 
+   (format ".ce %d\n.nf\n%s\n.fi"
+           (- (length (split-string contents "\n")) 1)
            contents)))
            contents)))
 
 
 
 
@@ -429,7 +422,7 @@ holding contextual information."
   "Transcode a CLOCK element from Org to Man.
   "Transcode a CLOCK element from Org to Man.
 CONTENTS is nil.  INFO is a plist holding contextual
 CONTENTS is nil.  INFO is a plist holding contextual
 information."
 information."
-  "" )
+  "")
 
 
 
 
 ;;;; Code
 ;;;; Code
@@ -438,16 +431,14 @@ information."
   "Transcode a CODE object from Org to Man.
   "Transcode a CODE object from Org to Man.
 CONTENTS is nil.  INFO is a plist used as a communication
 CONTENTS is nil.  INFO is a plist used as a communication
 channel."
 channel."
-  (format "\\fC%s\\fP" code) )
+  (format "\\fC%s\\fP" code))
 
 
 
 
 ;;;; Comment
 ;;;; Comment
-;;
 ;; Comments are ignored.
 ;; Comments are ignored.
 
 
 
 
 ;;;; Comment Block
 ;;;; Comment Block
-;;
 ;; Comment Blocks are ignored.
 ;; Comment Blocks are ignored.
 
 
 
 
@@ -456,7 +447,7 @@ channel."
 (defun org-e-man-drawer (drawer contents info)
 (defun org-e-man-drawer (drawer contents info)
   "Transcode a DRAWER element from Org to Man.
   "Transcode a DRAWER element from Org to Man.
    DRAWER holds the drawer information
    DRAWER holds the drawer information
-   CONTENTS holds the contents of the block.  
+   CONTENTS holds the contents of the block.
    INFO is a plist holding contextual information. "
    INFO is a plist holding contextual information. "
   contents)
   contents)
 
 
@@ -488,8 +479,8 @@ information."
   (org-e-man--wrap-label
   (org-e-man--wrap-label
    example-block
    example-block
    (format ".RS\n.nf\n%s\n.fi\n.RE"
    (format ".RS\n.nf\n%s\n.fi\n.RE"
-           (org-export-format-code-default example-block info))
-))
+           (org-export-format-code-default example-block info))))
+
 ;;;; Export Block
 ;;;; Export Block
 
 
 (defun org-e-man-export-block (export-block contents info)
 (defun org-e-man-export-block (export-block contents info)
@@ -521,11 +512,9 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 
 
 
 
 ;;;; Footnote Definition
 ;;;; Footnote Definition
-;;
 ;; Footnote Definitions are ignored.
 ;; Footnote Definitions are ignored.
 
 
 ;;;; Footnote References
 ;;;; Footnote References
-;;
 ;; Footnote References are Ignored
 ;; Footnote References are Ignored
 
 
 
 
@@ -543,13 +532,14 @@ holding contextual information."
 		  (case level
 		  (case level
 			(1 ".SH \"%s\"\n%s")
 			(1 ".SH \"%s\"\n%s")
 			(2 ".SS \"%s\"\n%s")
 			(2 ".SS \"%s\"\n%s")
-			(3 ".SS \"%s\"\n%s") 
-			(t nil)) )
-		 (text (org-export-data (org-element-property :title headline) info)) )
+			(3 ".SS \"%s\"\n%s")
+			(t nil)))
+		 (text (org-export-data (org-element-property :title headline) info)))
 
 
     (cond
     (cond
      ;; Case 1: This is a footnote section: ignore it.
      ;; Case 1: This is a footnote section: ignore it.
      ((org-element-property :footnote-section-p headline) nil)
      ((org-element-property :footnote-section-p headline) nil)
+
      ;; Case 2. This is a deep sub-tree: export it as a list item.
      ;; Case 2. This is a deep sub-tree: export it as a list item.
      ;;         Also export as items headlines for which no section
      ;;         Also export as items headlines for which no section
      ;;         format has been found.
      ;;         format has been found.
@@ -561,7 +551,7 @@ holding contextual information."
 			  (when (org-export-first-sibling-p headline info)
 			  (when (org-export-first-sibling-p headline info)
 				(format "%s\n" ".RS"))
 				(format "%s\n" ".RS"))
 			  ;; Itemize headline
 			  ;; Itemize headline
-			  ".TP\n.ft I\n" text "\n.ft\n" 
+			  ".TP\n.ft I\n" text "\n.ft\n"
 			  contents ".RE")))
 			  contents ".RE")))
 		;; If headline is not the last sibling simply return
 		;; If headline is not the last sibling simply return
 		;; LOW-LEVEL-BODY.  Otherwise, also close the list, before any
 		;; LOW-LEVEL-BODY.  Otherwise, also close the list, before any
@@ -570,16 +560,19 @@ holding contextual information."
 		  (replace-regexp-in-string
 		  (replace-regexp-in-string
 		   "[ \t\n]*\\'" ""
 		   "[ \t\n]*\\'" ""
 		   low-level-body))))
 		   low-level-body))))
+
      ;; Case 3. Standard headline.  Export it as a section.
      ;; Case 3. Standard headline.  Export it as a section.
-     (t (format section-fmt text contents )))))
+     (t (format section-fmt text contents)))))
+
 
 
 ;;;; Horizontal Rule
 ;;;; Horizontal Rule
 ;; Not supported
 ;; Not supported
 
 
+
 ;;;; Inline Babel Call
 ;;;; Inline Babel Call
-;;
 ;; Inline Babel Calls are ignored.
 ;; Inline Babel Calls are ignored.
 
 
+
 ;;;; Inline Src Block
 ;;;; Inline Src Block
 
 
 (defun org-e-man-inline-src-block (inline-src-block contents info)
 (defun org-e-man-inline-src-block (inline-src-block contents info)
@@ -590,42 +583,37 @@ contextual information."
     (cond
     (cond
      (org-e-man-source-highlight
      (org-e-man-source-highlight
       (let* ((tmpdir (if (featurep 'xemacs)
       (let* ((tmpdir (if (featurep 'xemacs)
-                         temp-directory 
-                       temporary-file-directory ))
-             (in-file  (make-temp-name 
-                        (expand-file-name "srchilite" tmpdir))  )
-             (out-file (make-temp-name 
-                        (expand-file-name "reshilite" tmpdir)) )
+                         temp-directory
+                       temporary-file-directory))
+             (in-file  (make-temp-name
+                        (expand-file-name "srchilite" tmpdir)))
+             (out-file (make-temp-name
+                        (expand-file-name "reshilite" tmpdir)))
              (org-lang (org-element-property :language inline-src-block))
              (org-lang (org-element-property :language inline-src-block))
              (lst-lang (cadr (assq (intern org-lang)
              (lst-lang (cadr (assq (intern org-lang)
                                    org-e-man-source-highlight-langs)))
                                    org-e-man-source-highlight-langs)))
-             
+
              (cmd (concat (expand-file-name "source-highlight")
              (cmd (concat (expand-file-name "source-highlight")
                           " -s " lst-lang
                           " -s " lst-lang
                           " -f groff_man"
                           " -f groff_man"
                           " -i " in-file
                           " -i " in-file
-                          " -o " out-file
-                          )
-                  ))
+                          " -o " out-file)))
 
 
         (if lst-lang
         (if lst-lang
-            (let ((code-block "" ))
+            (let ((code-block ""))
               (with-temp-file in-file (insert code))
               (with-temp-file in-file (insert code))
               (shell-command cmd)
               (shell-command cmd)
-              (setq code-block  (org-file-contents out-file) )
+              (setq code-block  (org-file-contents out-file))
               (delete-file in-file)
               (delete-file in-file)
               (delete-file out-file)
               (delete-file out-file)
               code-block)
               code-block)
           (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE\n"
           (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE\n"
-                  code))
-
-        ))
+                  code))))
 
 
      ;; Do not use a special package: transcode it verbatim.
      ;; Do not use a special package: transcode it verbatim.
      (t
      (t
       (concat ".RS\n.nf\n" "\\fC" "\n" code "\n"
       (concat ".RS\n.nf\n" "\\fC" "\n" code "\n"
-              "\\fP\n.fi\n.RE\n"))
-     )))
+              "\\fP\n.fi\n.RE\n")))))
 
 
 
 
 ;;;; Inlinetask
 ;;;; Inlinetask
@@ -640,10 +628,8 @@ contextual information."
 
 
 ;;;; Item
 ;;;; Item
 
 
-
 (defun org-e-man-item (item contents info)
 (defun org-e-man-item (item contents info)
 
 
-
   "Transcode an ITEM element from Org to Man.
   "Transcode an ITEM element from Org to Man.
 CONTENTS holds the contents of the item.  INFO is a plist holding
 CONTENTS holds the contents of the item.  INFO is a plist holding
 contextual information."
 contextual information."
@@ -660,9 +646,9 @@ contextual information."
          (bullet (org-element-property :bullet item))
          (bullet (org-element-property :bullet item))
          (type (org-element-property :type (org-element-property :parent item)))
          (type (org-element-property :type (org-element-property :parent item)))
          (checkbox (case (org-element-property :checkbox item)
          (checkbox (case (org-element-property :checkbox item)
-                     (on "\\o'\\(sq\\(mu'")			;; 
+                     (on "\\o'\\(sq\\(mu'")			;;
                      (off "\\(sq ")					;;
                      (off "\\(sq ")					;;
-                     (trans "\\o'\\(sq\\(mi'"   ))) ;;
+                     (trans "\\o'\\(sq\\(mi'"))) ;;
 
 
          (tag (let ((tag (org-element-property :tag item)))
          (tag (let ((tag (org-element-property :tag item)))
                 ;; Check-boxes must belong to the tag.
                 ;; Check-boxes must belong to the tag.
@@ -670,28 +656,23 @@ contextual information."
                                  (concat checkbox
                                  (concat checkbox
                                          (org-export-data tag info)))))))
                                          (org-export-data tag info)))))))
 
 
-    (if (and (null tag )
-			 (null checkbox)) 
+    (if (and (null tag)
+			 (null checkbox))
 		(let* ((bullet (org-trim bullet))
 		(let* ((bullet (org-trim bullet))
 			   (marker (cond  ((string= "-" bullet) "\\(em")
 			   (marker (cond  ((string= "-" bullet) "\\(em")
 							  ((string= "*" bullet) "\\(bu")
 							  ((string= "*" bullet) "\\(bu")
-							  ((eq type 'ordered)  
+							  ((eq type 'ordered)
 							   (format "%s " (org-trim bullet)))
 							   (format "%s " (org-trim bullet)))
-							  (t "\\(dg") ) ))
+							  (t "\\(dg"))))
 		  (concat ".IP " marker " 4\n"
 		  (concat ".IP " marker " 4\n"
-				  (org-trim (or contents " " ) )))
+				  (org-trim (or contents " "))))
                                         ; else
                                         ; else
       (concat ".TP\n" (or tag (concat " " checkbox)) "\n"
       (concat ".TP\n" (or tag (concat " " checkbox)) "\n"
-              (org-trim (or contents " " ) )
-              ;; If there are footnotes references in tag, be sure to
-              ;; add their definition at the end of the item.  This
-              )) ))
-
+              (org-trim (or contents " "))))))
 
 
 
 
 ;;;; Keyword
 ;;;; Keyword
 
 
-
 (defun org-e-man-keyword (keyword contents info)
 (defun org-e-man-keyword (keyword contents info)
   "Transcode a KEYWORD element from Org to Man.
   "Transcode a KEYWORD element from Org to Man.
 CONTENTS is nil.  INFO is a plist holding contextual information."
 CONTENTS is nil.  INFO is a plist holding contextual information."
@@ -702,7 +683,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
      ((string= key "INDEX") nil)
      ((string= key "INDEX") nil)
      ;; Invisible targets.
      ;; Invisible targets.
      ((string= key "TARGET") nil)
      ((string= key "TARGET") nil)
-     ((string= key "TOC"   ) nil))))
+     ((string= key "TOC") nil))))
 
 
 
 
 ;;;; Man Environment
 ;;;; Man Environment
@@ -743,14 +724,13 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
 
 
 ;;;; Link
 ;;;; Link
 
 
-
 (defun org-e-man-link (link desc info)
 (defun org-e-man-link (link desc info)
   "Transcode a LINK object from Org to Man.
   "Transcode a LINK object from Org to Man.
 
 
 DESC is the description part of the link, or the empty string.
 DESC is the description part of the link, or the empty string.
 INFO is a plist holding contextual information.  See
 INFO is a plist holding contextual information.  See
 `org-export-data'."
 `org-export-data'."
-  
+
   (let* ((type (org-element-property :type link))
   (let* ((type (org-element-property :type link))
          (raw-path (org-element-property :path link))
          (raw-path (org-element-property :path link))
          ;; Ensure DESC really exists, or set it to nil.
          ;; Ensure DESC really exists, or set it to nil.
@@ -773,9 +753,7 @@ INFO is a plist holding contextual information.  See
      ;; External link without a description part.
      ;; External link without a description part.
      (path (format "\\fI%s\\fP" path))
      (path (format "\\fI%s\\fP" path))
      ;; No path, only description.  Try to do something useful.
      ;; No path, only description.  Try to do something useful.
-     (t (format "\\fI%s\\fP" desc))
-     )
-    ))
+     (t (format "\\fI%s\\fP" desc)))))
 
 
 
 
 ;;;; Macro
 ;;;; Macro
@@ -793,22 +771,19 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   "Transcode a PARAGRAPH element from Org to Man.
   "Transcode a PARAGRAPH element from Org to Man.
 CONTENTS is the contents of the paragraph, as a string.  INFO is
 CONTENTS is the contents of the paragraph, as a string.  INFO is
 the plist used as a communication channel."
 the plist used as a communication channel."
-  (setq parent (plist-get (nth 1 paragraph) :parent))
-  (when parent
-    (let ((parent-type (car parent)) 
-          (fixed-paragraph ""))
-      (cond ((and (eq parent-type 'item)
-                  (plist-get (nth 1 parent) :bullet ) )
-             (setq fixed-paragraph (concat "" contents)) )
-            ((eq parent-type 'section)
-             (setq fixed-paragraph (concat ".PP\n" contents) ) )
-            ((eq parent-type 'footnote-definition)
-             (setq fixed-paragraph contents))
-            (t (setq fixed-paragraph (concat "" contents) ) ) 
-            )
-      fixed-paragraph)
-    )
-  )
+  (let ((parent (plist-get (nth 1 paragraph) :parent)))
+    (when parent
+      (let ((parent-type (car parent))
+            (fixed-paragraph ""))
+        (cond ((and (eq parent-type 'item)
+                    (plist-get (nth 1 parent) :bullet))
+               (setq fixed-paragraph (concat "" contents)))
+              ((eq parent-type 'section)
+               (setq fixed-paragraph (concat ".PP\n" contents)))
+              ((eq parent-type 'footnote-definition)
+               (setq fixed-paragraph contents))
+              (t (setq fixed-paragraph (concat "" contents))))
+        fixed-paragraph))))
 
 
 
 
 ;;;; Plain List
 ;;;; Plain List
@@ -820,14 +795,13 @@ contextual information."
   contents)
   contents)
 
 
 
 
-
 ;;;; Plain Text
 ;;;; Plain Text
 
 
 (defun org-e-man-plain-text (text info)
 (defun org-e-man-plain-text (text info)
   "Transcode a TEXT string from Org to Man.
   "Transcode a TEXT string from Org to Man.
 TEXT is the string to transcode.  INFO is a plist holding
 TEXT is the string to transcode.  INFO is a plist holding
 contextual information."
 contextual information."
-  ;; Protect 
+  ;; Protect
   (setq text (replace-regexp-in-string
   (setq text (replace-regexp-in-string
               "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
               "\\(?:[^\\]\\|^\\)\\(\\\\\\)\\(?:[^%$#&{}~^_\\]\\|$\\)"
               "$\\" text nil t 1))
               "$\\" text nil t 1))
@@ -844,10 +818,8 @@ contextual information."
   text)
   text)
 
 
 
 
-
 ;;;; Planning
 ;;;; Planning
 
 
-
 ;;;; Property Drawer
 ;;;; Property Drawer
 
 
 
 
@@ -861,6 +833,7 @@ holding contextual information."
    quote-block
    quote-block
    (format ".RS\n%s\n.RE" contents)))
    (format ".RS\n%s\n.RE" contents)))
 
 
+
 ;;;; Quote Section
 ;;;; Quote Section
 
 
 (defun org-e-man-quote-section (quote-section contents info)
 (defun org-e-man-quote-section (quote-section contents info)
@@ -877,7 +850,7 @@ CONTENTS is nil.  INFO is a plist holding contextual information."
   "Transcode a RADIO-TARGET object from Org to Man.
   "Transcode a RADIO-TARGET object from Org to Man.
 TEXT is the text of the target.  INFO is a plist holding
 TEXT is the text of the target.  INFO is a plist holding
 contextual information."
 contextual information."
-  text )
+  text)
 
 
 
 
 ;;;; Section
 ;;;; Section
@@ -926,46 +899,39 @@ contextual information."
             (float-env (when caption ".RS\n.nf\\fC%s\\fP\n.fi.RE\n")))
             (float-env (when caption ".RS\n.nf\\fC%s\\fP\n.fi.RE\n")))
         (format
         (format
          (or float-env "%s")
          (or float-env "%s")
-         (concat 
+         (concat
           (format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n"
           (format ".RS\n.nf\n\\fC%s\\fP\n.fi\n.RE\n\n"
-                  (org-export-format-code-default src-block info) 
-                  )))))
-     ( (and org-e-man-source-highlight) 
+                  (org-export-format-code-default src-block info))))))
+     ((and org-e-man-source-highlight)
        (let* ((tmpdir (if (featurep 'xemacs)
        (let* ((tmpdir (if (featurep 'xemacs)
-                          temp-directory 
-                        temporary-file-directory ))
-              
-              (in-file  (make-temp-name 
-                         (expand-file-name "srchilite" tmpdir))  )
-              (out-file (make-temp-name 
-                         (expand-file-name "reshilite" tmpdir)) )
+                          temp-directory
+                        temporary-file-directory))
+
+              (in-file  (make-temp-name
+                         (expand-file-name "srchilite" tmpdir)))
+              (out-file (make-temp-name
+                         (expand-file-name "reshilite" tmpdir)))
 
 
               (org-lang (org-element-property :language src-block))
               (org-lang (org-element-property :language src-block))
               (lst-lang (cadr (assq (intern org-lang)
               (lst-lang (cadr (assq (intern org-lang)
-                                    org-e-man-source-highlight-langs)) )
-              
+                                    org-e-man-source-highlight-langs)))
+
               (cmd (concat "source-highlight"
               (cmd (concat "source-highlight"
                            " -s " lst-lang
                            " -s " lst-lang
                            " -f groff_man "
                            " -f groff_man "
                            " -i " in-file
                            " -i " in-file
-                           " -o " out-file
-                           )
-                   ))
-         
+                           " -o " out-file)))
+
          (if lst-lang
          (if lst-lang
-             (let ((code-block "" ))
+             (let ((code-block ""))
                (with-temp-file in-file (insert code))
                (with-temp-file in-file (insert code))
                (shell-command cmd)
                (shell-command cmd)
-               (setq code-block  (org-file-contents out-file) )
+               (setq code-block  (org-file-contents out-file))
                (delete-file in-file)
                (delete-file in-file)
                (delete-file out-file)
                (delete-file out-file)
                code-block)
                code-block)
            (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE"
            (format ".RS\n.nf\n\\fC\\m[black]%s\\m[]\\fP\n.fi\n.RE"
-                   code))
-
-         )
-       )
-     )))
+                   code)))))))
 
 
 
 
 ;;;; Statistics Cookie
 ;;;; Statistics Cookie
@@ -984,6 +950,7 @@ CONTENTS is the text with strike-through markup.  INFO is a plist
 holding contextual information."
 holding contextual information."
   (format "\\fI%s\\fP" contents))
   (format "\\fI%s\\fP" contents))
 
 
+
 ;;;; Subscript
 ;;;; Subscript
 
 
 (defun org-e-man-subscript (subscript contents info)
 (defun org-e-man-subscript (subscript contents info)
@@ -992,6 +959,7 @@ CONTENTS is the contents of the object.  INFO is a plist holding
 contextual information."
 contextual information."
   (format  "\\d\\s-2%s\\s+2\\u" contents))
   (format  "\\d\\s-2%s\\s+2\\u" contents))
 
 
+
 ;;;; Superscript "^_%s$
 ;;;; Superscript "^_%s$
 
 
 (defun org-e-man-superscript (superscript contents info)
 (defun org-e-man-superscript (superscript contents info)
@@ -1026,7 +994,7 @@ contextual information."
                  (mapconcat
                  (mapconcat
                   #'identity
                   #'identity
                   (org-element-property :attr_man table)
                   (org-element-property :attr_man table)
-                  " ")))) )
+                  " ")))))
 
 
           (and attr (plist-get attr :verbatim))))
           (and attr (plist-get attr :verbatim))))
 
 
@@ -1042,20 +1010,20 @@ contextual information."
   "Return an appropriate Man alignment string.
   "Return an appropriate Man alignment string.
 TABLE is the considered table.  INFO is a plist used as
 TABLE is the considered table.  INFO is a plist used as
 a communication channel."
 a communication channel."
-  (let ((attr
+  (let* ((attr
          (read
          (read
           (format
           (format
            "(%s)"
            "(%s)"
            (mapconcat
            (mapconcat
             #'identity
             #'identity
             (org-element-property :attr_man table)
             (org-element-property :attr_man table)
-            " ")))))
+            " "))))
 
 
-    (setq align 	
+    (align
           (case (plist-get  attr :align)
           (case (plist-get  attr :align)
             ('center "c")
             ('center "c")
             ('left "l")
             ('left "l")
-            ('right "r")))
+            ('right "r"))))
 
 
     (let (alignment)
     (let (alignment)
       ;; Extract column groups and alignment from first (non-rule)
       ;; Extract column groups and alignment from first (non-rule)
@@ -1071,23 +1039,22 @@ a communication channel."
          (let* ((borders (org-export-table-cell-borders cell info))
          (let* ((borders (org-export-table-cell-borders cell info))
                 (raw-width (org-export-table-cell-width cell info))
                 (raw-width (org-export-table-cell-width cell info))
                 (width-cm (when raw-width (/ raw-width 5)))
                 (width-cm (when raw-width (/ raw-width 5)))
-                (width (if raw-width (format "w(%dc)" (if (< width-cm 1) 1 width-cm)) "") ))
+                (width (if raw-width (format "w(%dc)"
+                                             (if (< width-cm 1) 1 width-cm)) "")))
            ;; Check left border for the first cell only.
            ;; Check left border for the first cell only.
            (when (and (memq 'left borders) (not alignment))
            (when (and (memq 'left borders) (not alignment))
              (push "|" alignment))
              (push "|" alignment))
-           (push 
+           (push
             (if (not align)
             (if (not align)
                 (case (org-export-table-cell-alignment cell info)
                 (case (org-export-table-cell-alignment cell info)
-                  (left (concat "l" width divider) )
+                  (left (concat "l" width divider))
                   (right (concat "r" width divider))
                   (right (concat "r" width divider))
                   (center (concat "c" width divider)))
                   (center (concat "c" width divider)))
               (concat align divider))
               (concat align divider))
             alignment)
             alignment)
            (when (memq 'right borders) (push "|" alignment))))
            (when (memq 'right borders) (push "|" alignment))))
        info)
        info)
-      (apply 'concat (reverse alignment)))
-
-    ))
+      (apply 'concat (reverse alignment)))))
 
 
 (defun org-e-man-table--org-table (table contents info)
 (defun org-e-man-table--org-table (table contents info)
   "Return appropriate Man code for an Org table.
   "Return appropriate Man code for an Org table.
@@ -1116,93 +1083,82 @@ This function assumes TABLE has `org' as its `:type' attribute."
          ;; Determine alignment string.
          ;; Determine alignment string.
          (alignment (org-e-man-table--align-string divider table info))
          (alignment (org-e-man-table--align-string divider table info))
          ;; Extract others display options.
          ;; Extract others display options.
+         (lines (org-split-string contents "\n"))
 
 
-         )
-    ;; Prepare the final format string for the table.
-
-    (setq lines (org-split-string contents "\n"))
-
-    (setq attr-list
+         (attr-list
           (let ((result-list '()))
           (let ((result-list '()))
-            (dolist (attr-item 
-                     (list 
-                      (if (plist-get attr :expand) 
+            (dolist (attr-item
+                     (list
+                      (if (plist-get attr :expand)
                           "expand"
                           "expand"
-                        nil
-                        )
+                        nil)
 
 
                       (case (plist-get attr :placement)
                       (case (plist-get attr :placement)
                         ('center "center")
                         ('center "center")
                         ('left nil)
                         ('left nil)
-                        (t 
-                         (if org-e-man-tables-centered  
-                             "center" 
-                           "" )))
+                        (t
+                         (if org-e-man-tables-centered
+                             "center" "")))
 
 
                       (case (plist-get attr :boxtype)
                       (case (plist-get attr :boxtype)
                         ('box "box")
                         ('box "box")
                         ('doublebox "doublebox")
                         ('doublebox "doublebox")
                         ('allbox "allbox")
                         ('allbox "allbox")
                         ('none nil)
                         ('none nil)
-                        (t "box"))
-                      ))
+                        (t "box"))))
 
 
               (if attr-item
               (if attr-item
-                  (add-to-list 'result-list attr-item)
-                ))
-            result-list ))
-
-
-    (setq title-line  (plist-get attr :title-line))
-
-    (setq table-format (concat 
-                        (format "%s"
-                                (or (car attr-list) "" ))
-                        (or 
-                         (let ((output-list '()))
-                           (when (cdr attr-list)
-                             (dolist (attr-item (cdr attr-list))
-                               (setq output-list (concat output-list  (format ",%s" attr-item )) ) ))
-                           output-list)
-                         "") ))
-
-    
-    (when lines
-      (setq first-line (org-split-string (car lines) "\t")))
+                  (add-to-list 'result-list attr-item)))
+            result-list))
+
+
+    (title-line  (plist-get attr :title-line))
+
+    (table-format
+     (concat
+      (format "%s"
+              (or (car attr-list) ""))
+      (or
+       (let ((output-list '()))
+         (when (cdr attr-list)
+           (dolist (attr-item (cdr attr-list))
+             (setq output-list (concat output-list  (format ",%s" attr-item)))))
+         output-list)
+       "")))
+
+    (first-line
+      (when lines (org-split-string (car lines) "\t"))))
+    ;; Prepare the final format string for the table.
 
 
     (cond
     (cond
      ;; Others.
      ;; Others.
-     (lines (concat ".TS\n " table-format ";\n" 
-                    
+     (lines (concat ".TS\n " table-format ";\n"
+
                     (format "%s.\n"
                     (format "%s.\n"
                             (let ((final-line ""))
                             (let ((final-line ""))
 
 
                               (when title-line
                               (when title-line
                                 (dotimes (i (length first-line))
                                 (dotimes (i (length first-line))
-                                  (setq final-line (concat final-line "cb" divider))
-                                  ))
+                                  (setq final-line (concat final-line "cb" divider))))
 
 
                               (setq final-line (concat final-line "\n"))
                               (setq final-line (concat final-line "\n"))
                               (if alignment
                               (if alignment
                                   (setq final-line (concat final-line alignment))
                                   (setq final-line (concat final-line alignment))
                                 (dotimes (i (length first-line))
                                 (dotimes (i (length first-line))
                                   (setq final-line (concat final-line "c" divider))))
                                   (setq final-line (concat final-line "c" divider))))
-                              final-line ))
+                              final-line))
+
                     (format "%s.TE"
                     (format "%s.TE"
                             (let ((final-line ""))
                             (let ((final-line ""))
                               (dolist (line-item lines)
                               (dolist (line-item lines)
-                                (cond 
-                                 (t	
+                                (cond
+                                 (t
                                   (setq lines (org-split-string contents "\n"))
                                   (setq lines (org-split-string contents "\n"))
 
 
-                                  (setq final-line (concat final-line 
-                                                           (car (org-split-string line-item "\\\\")) "\n"))
-                                  )
-                                 )
-                                
-                                )  final-line) )
+                                  (setq final-line (concat final-line
+                                                           (car (org-split-string line-item "\\\\")) "\n")))))
+                              final-line)))))))
 
 
-                    )))))
 
 
 ;;;; Table Cell
 ;;;; Table Cell
 
 
@@ -1266,7 +1222,7 @@ information."
   "Transcode a TIMESTAMP object from Org to Man.
   "Transcode a TIMESTAMP object from Org to Man.
   CONTENTS is nil.  INFO is a plist holding contextual
   CONTENTS is nil.  INFO is a plist holding contextual
   information."
   information."
-  "" )
+  "")
 
 
 
 
 ;;;; Underline
 ;;;; Underline
@@ -1315,7 +1271,7 @@ first.
 When optional argument VISIBLE-ONLY is non-nil, don't export
 When optional argument VISIBLE-ONLY is non-nil, don't export
 contents of hidden elements.
 contents of hidden elements.
 
 
-When optional argument BODY-ONLY is non-nil, only the body 
+When optional argument BODY-ONLY is non-nil, only the body
 without any markers.
 without any markers.
 
 
 EXT-PLIST, when provided, is a property list with external
 EXT-PLIST, when provided, is a property list with external
@@ -1348,7 +1304,7 @@ When optional argument VISIBLE-ONLY is non-nil, don't export
 contents of hidden elements.
 contents of hidden elements.
 
 
 When optional argument BODY-ONLY is non-nil, only write between
 When optional argument BODY-ONLY is non-nil, only write between
-markers. 
+markers.
 
 
 EXT-PLIST, when provided, is a property list with external
 EXT-PLIST, when provided, is a property list with external
 parameters overriding Org default settings, but still inferior to
 parameters overriding Org default settings, but still inferior to
@@ -1429,7 +1385,7 @@ none."
     (save-excursion
     (save-excursion
       (goto-char (point-max))
       (goto-char (point-max))
       ;; Find final run
       ;; Find final run
-      nil )))
+      nil)))
 
 
 
 
 (provide 'org-e-man)
 (provide 'org-e-man)

+ 5 - 5
lisp/org.el

@@ -20677,11 +20677,11 @@ This puts point at the start of the current subtree, and mark at
 the end.  If a numeric prefix UP is given, move up into the
 the end.  If a numeric prefix UP is given, move up into the
 hierarchy of headlines by UP levels before marking the subtree."
 hierarchy of headlines by UP levels before marking the subtree."
   (interactive "P")
   (interactive "P")
-  (when (org-with-limited-levels (org-before-first-heading-p))
-    (error "Not currently in a subtree"))
-  (if (org-at-heading-p) (beginning-of-line)
-    (org-with-limited-levels (outline-previous-visible-heading 1)))
-  (when up (dotimes (c (abs up)) (ignore-errors (org-element-up))))
+  (org-with-limited-levels
+   (cond ((org-at-heading-p) (beginning-of-line))
+	 ((org-before-first-heading-p) (error "Not in a subtree"))
+	 (t (outline-previous-visible-heading 1))))
+  (when up (while (and (> up 0) (org-up-heading-safe)) (decf up)))
   (org-element-mark-element))
   (org-element-mark-element))
 
 
 ;;; Indentation
 ;;; Indentation

+ 13 - 4
testing/lisp/test-org.el

@@ -363,9 +363,18 @@ http://article.gmane.org/gmane.emacs.orgmode/21459/"
       (progn (transient-mark-mode 1)
       (progn (transient-mark-mode 1)
 	     (forward-line 2)
 	     (forward-line 2)
 	     (org-mark-subtree 1)
 	     (org-mark-subtree 1)
-	     (list (region-beginning) (region-end)))))))
-
-
-(provide 'test-org)
+	     (list (region-beginning) (region-end))))))
+  ;; Do not get fooled with inlinetasks.
+  (when (featurep 'org-inlinetask)
+    (should
+     (= 1
+	(org-test-with-temp-text "* Headline\n*************** Task\nContents"
+	  (progn (transient-mark-mode 1)
+		 (forward-line 1)
+		 (let ((org-inlinetask-min-level 15)) (org-mark-subtree))
+		 (region-beginning))))))
+
+
+  (provide 'test-org))
 
 
 ;;; test-org.el ends here
 ;;; test-org.el ends here

部分文件因文件數量過多而無法顯示