changeset 112110:5f273d1516d7

Small rst.el stuff. * lisp/textmodes/rst.el (rst-compile-toolsets): Make it a defcustom. Add `pdf' and `s5' entries. Use `prog.py' if found, otherwise default to `prog' without a .py extension. (rst-compile-pdf-preview, rst-compile-slides-preview): Use program names from rst-compile-toolsets, rather than hard-coding. (rst-portable-mark-active-p): Fix presumed typo.
author Glenn Morris <rgm@gnu.org>
date Mon, 03 Jan 2011 20:47:39 -0800
parents 5284aa9ea62d
children 4e3dc3aca537
files lisp/ChangeLog lisp/textmodes/rst.el
diffstat 2 files changed, 46 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Jan 03 20:42:43 2011 -0800
+++ b/lisp/ChangeLog	Mon Jan 03 20:47:39 2011 -0800
@@ -1,3 +1,12 @@
+2011-01-04  Glenn Morris  <rgm@gnu.org>
+
+	* textmodes/rst.el (rst-compile-toolsets): Make it a defcustom.
+	Add `pdf' and `s5' entries.  Use `prog.py' if found, otherwise
+	default to `prog' without a .py extension.
+	(rst-compile-pdf-preview, rst-compile-slides-preview):
+	Use program names from rst-compile-toolsets, rather than hard-coding.
+	(rst-portable-mark-active-p): Fix presumed typo.
+
 2011-01-02  Eli Zaretskii  <eliz@gnu.org>
 
 	* term/w32-win.el (dynamic-library-alist): Set up correctly for
--- a/lisp/textmodes/rst.el	Mon Jan 03 20:42:43 2011 -0800
+++ b/lisp/textmodes/rst.el	Mon Jan 03 20:47:39 2011 -0800
@@ -1,6 +1,6 @@
 ;;; rst.el --- Mode for viewing and editing reStructuredText-documents.
 
-;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   Free Software Foundation, Inc.
 
 ;; Authors: Martin Blais <blais@furius.ca>,
@@ -3234,16 +3234,37 @@
   :group 'rst
   :version "21.1")
 
-(defvar rst-compile-toolsets
-  '((html . ("rst2html.py" ".html" nil))
-    (latex . ("rst2latex.py" ".tex" nil))
-    (newlatex . ("rst2newlatex.py" ".tex" nil))
-    (pseudoxml . ("rst2pseudoxml.py" ".xml" nil))
-    (xml . ("rst2xml.py" ".xml" nil)))
+(defcustom rst-compile-toolsets
+  `((html ,(if (executable-find "rst2html.py") "rst2html.py" "rst2html")
+          ".html" nil)
+    (latex ,(if (executable-find "rst2latex.py") "rst2latex.py" "rst2latex")
+           ".tex" nil)
+    (newlatex ,(if (executable-find "rst2newlatex.py") "rst2newlatex.py"
+                 "rst2newlatex")
+              ".tex" nil)
+    (pseudoxml ,(if (executable-find "rst2pseudoxml.py") "rst2pseudoxml.py"
+                  "rst2pseudoxml")
+               ".xml" nil)
+    (xml ,(if (executable-find "rst2xml.py") "rst2xml.py" "rst2xml")
+         ".xml" nil)
+    (pdf ,(if (executable-find "rst2pdf.py") "rst2pdf.py" "rst2pdf")
+         ".pdf" nil)
+    (s5 ,(if (executable-find "rst2s5.py") "rst2s5.py" "rst2s5")
+        ".html" nil))
   "Table describing the command to use for each toolset.
 An association list of the toolset to a list of the (command to use,
 extension of produced filename, options to the tool (nil or a
-string)) to be used for converting the document.")
+string)) to be used for converting the document."
+  :type '(alist :options (html latex newlatex pseudoxml xml)
+                :key-type symbol
+                :value-type (list :tag "Specification"
+                             (file :tag "Command")
+                             (string :tag "File extension")
+                             (choice :tag "Command options"
+                                     (const :tag "No options" nil)
+                                     (string :tag "Options"))))
+  :group 'rst
+  :version "24.1")
 
 ;; Note for Python programmers not familiar with association lists: you can set
 ;; values in an alists like this, e.g. :
@@ -3331,7 +3352,7 @@
     (shell-command-on-region
      (if mark-active (region-beginning) (point-min))
      (if mark-active (region-end) (point-max))
-     "rst2pseudoxml.py"
+     (cadr (assq 'pseudoxml rst-compile-toolsets))
      standard-output)))
 
 (defvar rst-pdf-program "xpdf"
@@ -3341,6 +3362,8 @@
   "Convert the document to a PDF file and launch a preview program."
   (interactive)
   (let* ((tmp-filename (make-temp-file "rst-out" nil ".pdf"))
+	 (command (format "%s %s %s && %s %s"
+			  (cadr (assq 'pdf rst-compile-toolsets))
 	 (command (format "rst2pdf.py %s %s && %s %s"
 			  buffer-file-name tmp-filename
 			  rst-pdf-program tmp-filename)))
@@ -3356,7 +3379,10 @@
   "Convert the document to an S5 slide presentation and launch a preview program."
   (interactive)
   (let* ((tmp-filename (make-temp-file "rst-slides" nil ".html"))
+	 (command (format "%s %s %s && %s %s"
+			  (cadr (assq 's5 rst-compile-toolsets))
 	 (command (format "rst2s5.py %s %s && %s %s"
+
 			  buffer-file-name tmp-filename
 			  rst-slides-program tmp-filename)))
     (start-process-shell-command "rst-slides-preview" nil command)
@@ -3454,11 +3480,10 @@
   "A portable function that returns non-nil if the mark is active."
   (cond
    ((fboundp 'region-active-p) (region-active-p))
-   ((boundp 'transient-mark-mode) transient-mark-mode mark-active)))
-
+   ((boundp 'transient-mark-mode) (and transient-mark-mode mark-active))
+   (t mark-active)))
 
 
 (provide 'rst)
 
-;; arch-tag: 255ac0a3-a689-44cb-8643-04ca55ae490d
 ;;; rst.el ends here