ソースを参照

Export: Make all export commands push the result to the kill ring

All export commands now push the result to the kill ring by default.
This is subject to the variable `org-export-push-to-kill-ring'.

Also, this commit adds a new variable
`org-export-show-temporary-export-buffer' which can be used to turn
off the display of the temporary buffer containing the exported text.
Since this stuff is now automatically pushed onto the kill ring, some
people might prefer not to see this buffer.
Carsten Dominik 16 年 前
コミット
91f77d7029
6 ファイル変更74 行追加20 行削除
  1. 34 0
      lisp/ChangeLog
  2. 4 13
      lisp/org-ascii.el
  3. 4 2
      lisp/org-docbook.el
  4. 24 1
      lisp/org-exp.el
  5. 4 2
      lisp/org-html.el
  6. 4 2
      lisp/org-latex.el

+ 34 - 0
lisp/ChangeLog

@@ -1,5 +1,39 @@
 2009-05-21  Carsten Dominik  <carsten.dominik@gmail.com>
 
+	* org-exp.el (org-export-push-to-kill-ring): New function.
+	(org-export-copy-to-kill-ring): New option.
+
+	* org-latex.el (org-export-as-latex): Call
+	`org-export-push-to-kill-ring'.
+
+	* org-html.el (org-export-as-html): Call
+	`org-export-push-to-kill-ring'.
+
+	* org-docbook.el (org-export-as-docbook): Call
+	`org-export-push-to-kill-ring'.
+
+	* org-ascii.el (org-export-as-ascii): Call
+	`org-export-push-to-kill-ring'.
+
+	* org-exp.el (org-export-show-temporary-export-buffer): New
+	option. 
+
+	* org-latex.el (org-export-as-latex): Use
+	`org-export-show-temporary-export-buffer'.
+
+	* org-html.el (org-export-as-html): Use
+	`org-export-show-temporary-export-buffer'.
+
+	* org-docbook.el (org-export-as-docbook): Use
+	`org-export-show-temporary-export-buffer'.
+
+	* org-ascii.el (org-export-as-ascii-to-buffer): Use
+	`org-export-show-temporary-export-buffer'.
+
+	* org-exp.el (org-export-show-temporary-export-buffer): New
+	option.
+	(org-export-push-to-kill-ring): New function.
+
 	* org-colview.el (org-columns-compile-map): New variable.
 	(org-columns-new, org-columns-compute)
 	(org-columns-number-to-string, org-columns-uncompile-format)

+ 4 - 13
lisp/org-ascii.el

@@ -33,12 +33,6 @@
   :tag "Org Export ASCII"
   :group 'org-export)
 
-(defcustom org-export-ascii-copy-to-kill t
-  "Non-nil means, copy ASCII export aways to kill ring.
-This makes it easy to generate ASCII and then paste it."
-  :group 'org-export-ascii
-  :type 'boolean)
-
 (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, ..."
@@ -72,7 +66,8 @@ in this way, it will be wrapped."
 No file is created.  The prefix ARG is passed through to `org-export-as-ascii'."
   (interactive "P")
   (org-export-as-ascii arg nil nil "*Org ASCII Export*")
-  (switch-to-buffer-other-window "*Org ASCII Export*"))
+  (when org-export-show-temporary-export-buffer
+    (switch-to-buffer-other-window "*Org ASCII Export*")))
 
 ;;;###autoload
 (defun org-replace-region-by-ascii (beg end)
@@ -458,12 +453,8 @@ publishing directory."
 	(goto-char beg)))
     (or to-buffer (save-buffer))
     (goto-char (point-min))
-    (when org-export-ascii-copy-to-kill
-      (kill-new (buffer-string))
-      (when (fboundp 'x-set-selection)
-	(x-set-selection 'PRIMARY (buffer-string))
-	(x-set-selection 'CLIPBOARD (buffer-string)))
-      (message "Exported ASCII pushed to kill ring and clipboard"))
+    (or (org-export-push-to-kill-ring "ASCII")
+	(message "Exporting... done"))
     ;; Return the buffer or a string, according to how this function was called
     (if (eq to-buffer 'string)
 	(prog1 (buffer-substring (point-min) (point-max))

+ 4 - 2
lisp/org-docbook.el

@@ -263,7 +263,8 @@ $ emacs --batch
 No file is created."
   (interactive)
   (org-export-as-docbook nil nil "*Org DocBook Export*")
-  (switch-to-buffer-other-window "*Org DocBook Export*"))
+  (when org-export-show-temporary-export-buffer
+    (switch-to-buffer-other-window "*Org DocBook Export*")))
 
 ;;;###autoload
 (defun org-replace-region-by-docbook (beg end)
@@ -1117,7 +1118,8 @@ publishing directory."
 	(insert "</article>"))
       (or to-buffer (save-buffer))
       (goto-char (point-min))
-      (message "Exporting... done")
+      (or (org-export-push-to-kill-ring "DocBook")
+	  (message "Exporting... done"))
       (if (eq to-buffer 'string)
 	  (prog1 (buffer-substring (point-min) (point-max))
 	    (kill-buffer (current-buffer)))

+ 24 - 1
lisp/org-exp.el

@@ -53,6 +53,20 @@
 ;; FIXME
 (defvar org-export-publishing-directory nil)
 
+(defcustom org-export-show-temporary-export-buffer t
+  "Non-nil means, show buffer after exporting to temp buffer.
+When Org exports to a file, the buffer visiting that file is ever
+shown, but remains buried.  However, when exporting to a temporary
+buffer, that buffer is popped up in a second window.  When this variable
+is nil, the buffer remains buried also in these cases."
+  :group 'org-export-general
+  :type 'boolean)
+
+(defcustom org-export-copy-to-kill-ring t
+  "Non-nil means, exported stuff will also be pushed onto the kill ring."
+  :group 'org-export-general
+  :type 'boolean)
+
 (defcustom org-export-run-in-background nil
   "Non-nil means export and publishing commands will run in background.
 This works by starting up a separate Emacs process visiting the same file
@@ -68,7 +82,6 @@ force an export command into the current process."
   :group 'org-export-general
   :type 'boolean)
 
-
 (defcustom org-export-select-tags '("export")
   "Tags that select a tree for export.
 If any such tag is found in a buffer, all trees that do not carry one
@@ -2706,6 +2719,16 @@ stacked delimiters is N.  Escaping delimiters is not possible."
 	(replace-match "%s" t t desc)
       (or desc "%s"))))
 
+(defun org-export-push-to-kill-ring (format)
+  "Push buffer content to kill ring.
+The depends on the variable `org-export-copy-to-kill'."
+  (when org-export-copy-to-kill-ring
+    (kill-new (buffer-string))
+    (when (fboundp 'x-set-selection)
+      (x-set-selection 'PRIMARY (buffer-string))
+      (x-set-selection 'CLIPBOARD (buffer-string)))
+    (message "%s export done, pushed to kill ring and clipboard" format)))
+
 (provide 'org-exp)
 
 ;; arch-tag: 65985fe9-095c-49c7-a7b6-cb4ee15c0a95

+ 4 - 2
lisp/org-html.el

@@ -399,7 +399,8 @@ emacs   --batch
 No file is created.  The prefix ARG is passed through to `org-export-as-html'."
   (interactive "P")
   (org-export-as-html arg nil nil "*Org HTML Export*")
-  (switch-to-buffer-other-window "*Org HTML Export*"))
+  (when org-export-show-temporary-export-buffer
+    (switch-to-buffer-other-window "*Org HTML Export*")))
 
 ;;;###autoload
 (defun org-replace-region-by-html (beg end)
@@ -1367,7 +1368,8 @@ lang=\"%s\" xml:lang=\"%s\">
 			  (make-string n ?x)))))
       (or to-buffer (save-buffer))
       (goto-char (point-min))
-      (message "Exporting... done")
+      (or (org-export-push-to-kill-ring "HTML")
+	  (message "Exporting... done"))
       (if (eq to-buffer 'string)
 	  (prog1 (buffer-substring (point-min) (point-max))
 	    (kill-buffer (current-buffer)))

+ 4 - 2
lisp/org-latex.el

@@ -363,7 +363,8 @@ emacs   --batch
 No file is created.  The prefix ARG is passed through to `org-export-as-latex'."
   (interactive "P")
   (org-export-as-latex arg nil nil "*Org LaTeX Export*")
-  (switch-to-buffer-other-window "*Org LaTeX Export*"))
+  (when org-export-show-temporary-export-buffer
+    (switch-to-buffer-other-window "*Org LaTeX Export*")))
 
 ;;;###autoload
 (defun org-replace-region-by-latex (beg end)
@@ -585,7 +586,8 @@ when PUB-DIR is set, use this as the publishing directory."
     (unless body-only (insert "\n\\end{document}"))
     (or to-buffer (save-buffer))
     (goto-char (point-min))
-    (message "Exporting to LaTeX...done")
+    (or (org-export-push-to-kill-ring "LaTeX")
+	(message "Exporting to LaTeX...done"))
     (prog1
 	(if (eq to-buffer 'string)
 	    (prog1 (buffer-substring (point-min) (point-max))