]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-ascii.el
Sync Org 7.9.2 from the commit tagged "release_7.9.2" in Org's Git repo.
[gnu-emacs] / lisp / org / org-ascii.el
index 61cbe1560a404859f6e78ad1514924e96363acab..655b8db668d57d9365019bf601191b204776f1dd 100644 (file)
@@ -36,7 +36,7 @@
   :tag "Org Export ASCII"
   :group 'org-export)
 
-(defcustom org-export-ascii-underline '(?\- ?\= ?\~ ?^ ?\# ?\$)
+(defcustom org-export-ascii-underline '(?\= ?\- ?\~ ?\^ ?\. ?\# ?\$)
   "Characters for underlining headings in ASCII export.
 In the given sequence, these characters will be used for level 1, 2, ..."
   :group 'org-export-ascii
@@ -144,9 +144,9 @@ command to convert it."
   (interactive "r")
   (let (reg ascii buf pop-up-frames)
     (save-window-excursion
-      (if (eq major-mode 'org-mode)
+      (if (derived-mode-p 'org-mode)
          (setq ascii (org-export-region-as-ascii
-                     beg end t 'string))
+                      beg end t 'string))
        (setq reg (buffer-substring beg end)
              buf (get-buffer-create "*Org tmp*"))
        (with-current-buffer buf
@@ -154,7 +154,7 @@ command to convert it."
          (insert reg)
          (org-mode)
          (setq ascii (org-export-region-as-ascii
-                     (point-min) (point-max) t 'string)))
+                      (point-min) (point-max) t 'string)))
        (kill-buffer buf)))
     (delete-region beg end)
     (insert ascii)))
@@ -193,7 +193,7 @@ in a window.  A non-interactive call will only return the buffer."
 
 ;;;###autoload
 (defun org-export-as-ascii (arg &optional hidden ext-plist
-                              to-buffer body-only pub-dir)
+                               to-buffer body-only pub-dir)
   "Export the outline as a pretty ASCII file.
 If there is an active region, export only the region.
 The prefix ARG specifies how many levels of the outline should become
@@ -373,54 +373,54 @@ publishing directory."
          (push (concat (make-string (string-width (nth 3 lang-words)) ?=)
                        "\n") thetoc)
          (mapc #'(lambda (line)
-                  (if (string-match org-todo-line-regexp
-                                    line)
-                      ;; This is a headline
-                      (progn
-                        (setq have-headings t)
-                        (setq level (- (match-end 1) (match-beginning 1)
-                                       level-offset)
-                              level (org-tr-level level)
-                              txt (match-string 3 line)
-                              todo
-                              (or (and org-export-mark-todo-in-toc
-                                       (match-beginning 2)
-                                       (not (member (match-string 2 line)
-                                                    org-done-keywords)))
+                   (if (string-match org-todo-line-regexp
+                                     line)
+                       ;; This is a headline
+                       (progn
+                         (setq have-headings t)
+                         (setq level (- (match-end 1) (match-beginning 1)
+                                        level-offset)
+                               level (org-tr-level level)
+                               txt (match-string 3 line)
+                               todo
+                               (or (and org-export-mark-todo-in-toc
+                                        (match-beginning 2)
+                                        (not (member (match-string 2 line)
+                                                     org-done-keywords)))
                                        ; TODO, not DONE
-                                  (and org-export-mark-todo-in-toc
-                                       (= level umax-toc)
-                                       (org-search-todo-below
-                                        line lines level))))
-                        (setq txt (org-html-expand-for-ascii txt))
-
-                        (while (string-match org-bracket-link-regexp txt)
-                          (setq txt
-                                (replace-match
-                                 (match-string (if (match-end 2) 3 1) txt)
-                                 t t txt)))
-
-                        (if (and (memq org-export-with-tags '(not-in-toc nil))
-                                 (string-match
-                                  (org-re "[ \t]+:[[:alnum:]_@#%:]+:[ \t]*$")
-                                  txt))
-                            (setq txt (replace-match "" t t txt)))
-                        (if (string-match quote-re0 txt)
-                            (setq txt (replace-match "" t t txt 1)))
-
-                        (if org-export-with-section-numbers
-                            (setq txt (concat (org-section-number level)
-                                              " " txt)))
-                        (if (<= level umax-toc)
-                            (progn
-                              (push
-                               (concat
-                                (make-string
-                                 (* (max 0 (- level org-min-level)) 4) ?\ )
-                                (format (if todo "%s (*)\n" "%s\n") txt))
-                               thetoc)
-                              (setq org-last-level level))
-                          ))))
+                                   (and org-export-mark-todo-in-toc
+                                        (= level umax-toc)
+                                        (org-search-todo-below
+                                         line lines level))))
+                         (setq txt (org-html-expand-for-ascii txt))
+
+                         (while (string-match org-bracket-link-regexp txt)
+                           (setq txt
+                                 (replace-match
+                                  (match-string (if (match-end 2) 3 1) txt)
+                                  t t txt)))
+
+                         (if (and (memq org-export-with-tags '(not-in-toc nil))
+                                  (string-match
+                                   (org-re "[ \t]+:[[:alnum:]_@#%:]+:[ \t]*$")
+                                   txt))
+                             (setq txt (replace-match "" t t txt)))
+                         (if (string-match quote-re0 txt)
+                             (setq txt (replace-match "" t t txt 1)))
+
+                         (if org-export-with-section-numbers
+                             (setq txt (concat (org-section-number level)
+                                               " " txt)))
+                         (if (<= level umax-toc)
+                             (progn
+                               (push
+                                (concat
+                                 (make-string
+                                  (* (max 0 (- level org-min-level)) 4) ?\ )
+                                 (format (if todo "%s (*)\n" "%s\n") txt))
+                                thetoc)
+                               (setq org-last-level level))
+                           ))))
                lines)
          (setq thetoc (if have-headings (nreverse thetoc) nil))))