ox.el (org-export-copy-to-kill-ring): Default back to 'if-interactive

* ox.el (org-export--copy-to-kill-ring-p): New function.
(org-export-copy-to-kill-ring): Use 'if-interactive as the
default.
(org-export-to-buffer, org-export-to-file): Use
`org-export--copy-to-kill-ring-p' and fix docstrings.

* ox-odt.el (org-odt-export-as-odf): Use
`org-export--copy-to-kill-ring-p'.
This commit is contained in:
Bastien Guerry 2013-03-15 13:39:45 +01:00
parent 791ebc6e7b
commit ce0473532d
2 changed files with 21 additions and 11 deletions

View File

@ -4146,8 +4146,8 @@ Use `org-create-math-formula' to convert LATEX-FRAG first to
MathML. When invoked as an interactive command, use MathML. When invoked as an interactive command, use
`org-latex-regexps' to infer LATEX-FRAG from currently active `org-latex-regexps' to infer LATEX-FRAG from currently active
region. If no LaTeX fragments are found, prompt for it. Push region. If no LaTeX fragments are found, prompt for it. Push
MathML source to kill ring, if `org-export-copy-to-kill-ring' is MathML source to kill ring depending on the value of
non-nil." `org-export-copy-to-kill-ring'."
(interactive (interactive
`(,(let (frag) `(,(let (frag)
(setq frag (and (setq frag (and (region-active-p) (setq frag (and (setq frag (and (region-active-p)
@ -4187,7 +4187,7 @@ non-nil."
(unless mathml (error "No Math formula created")) (unless mathml (error "No Math formula created"))
(insert mathml) (insert mathml)
;; Add MathML to kill ring, if needed. ;; Add MathML to kill ring, if needed.
(when org-export-copy-to-kill-ring (when (org-export--copy-to-kill-ring-p)
(org-kill-new (buffer-string)))))))) (org-kill-new (buffer-string))))))))
;;;###autoload ;;;###autoload

View File

@ -748,10 +748,14 @@ HTML code while every other back-end will ignore it."
:package-version '(Org . "8.0") :package-version '(Org . "8.0")
:type 'coding-system) :type 'coding-system)
(defcustom org-export-copy-to-kill-ring t (defcustom org-export-copy-to-kill-ring 'if-interactive
"Non-nil means exported stuff will also be pushed onto the kill ring." "Should we push exported content to the kill ring?"
:group 'org-export-general :group 'org-export-general
:type 'boolean) :version "24.3"
:type '(choice
(const :tag "Always" t)
(const :tag "When export is done interactively" if-interactive)
(const :tag "Never" nil)))
(defcustom org-export-initial-scope 'buffer (defcustom org-export-initial-scope 'buffer
"The initial scope when exporting with `org-export-dispatch'. "The initial scope when exporting with `org-export-dispatch'.
@ -1989,7 +1993,6 @@ a tree with a select tag."
(not (memq (org-element-property :type blob) (not (memq (org-element-property :type blob)
'(inactive inactive-range)))))))) '(inactive inactive-range))))))))
;;; The Transcoder ;;; The Transcoder
;; ;;
@ -2956,7 +2959,7 @@ Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
EXT-PLIST are similar to those used in `org-export-as', which EXT-PLIST are similar to those used in `org-export-as', which
see. see.
If `org-export-copy-to-kill-ring' is non-nil, add buffer contents Depending on `org-export-copy-to-kill-ring', add buffer contents
to kill ring. Return buffer." to kill ring. Return buffer."
(let ((out (org-export-as backend subtreep visible-only body-only ext-plist)) (let ((out (org-export-as backend subtreep visible-only body-only ext-plist))
(buffer (get-buffer-create buffer))) (buffer (get-buffer-create buffer)))
@ -2965,7 +2968,7 @@ to kill ring. Return buffer."
(insert out) (insert out)
(goto-char (point-min))) (goto-char (point-min)))
;; Maybe add buffer contents to kill ring. ;; Maybe add buffer contents to kill ring.
(when (and org-export-copy-to-kill-ring (org-string-nw-p out)) (when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p out))
(org-kill-new out)) (org-kill-new out))
;; Return buffer. ;; Return buffer.
buffer)) buffer))
@ -2982,7 +2985,7 @@ Optional arguments SUBTREEP, VISIBLE-ONLY, BODY-ONLY and
EXT-PLIST are similar to those used in `org-export-as', which EXT-PLIST are similar to those used in `org-export-as', which
see. see.
If `org-export-copy-to-kill-ring' is non-nil, add file contents Depending on `org-export-copy-to-kill-ring', add file contents
to kill ring. Return output file's name." to kill ring. Return output file's name."
;; Checks for FILE permissions. `write-file' would do the same, but ;; Checks for FILE permissions. `write-file' would do the same, but
;; we'd rather avoid needless transcoding of parse tree. ;; we'd rather avoid needless transcoding of parse tree.
@ -2994,7 +2997,7 @@ to kill ring. Return output file's name."
(let ((coding-system-for-write org-export-coding-system)) (let ((coding-system-for-write org-export-coding-system))
(write-file file))) (write-file file)))
;; Maybe add file contents to kill ring. ;; Maybe add file contents to kill ring.
(when (and org-export-copy-to-kill-ring (org-string-nw-p out)) (when (and (org-export--copy-to-kill-ring-p) (org-string-nw-p out))
(org-kill-new out))) (org-kill-new out)))
;; Return full path. ;; Return full path.
file) file)
@ -5700,7 +5703,14 @@ options as CDR."
;; Otherwise, enter sub-menu. ;; Otherwise, enter sub-menu.
(t (org-export--dispatch-ui options key expertp))))) (t (org-export--dispatch-ui options key expertp)))))
;;; Miscellaneous
(defun org-export--copy-to-kill-ring-p ()
"Should we copy the export buffer to the kill ring?
See also `org-export-copy-to-kill-ring'."
(if (eq org-export-copy-to-kill-ring 'if-interactive)
(not (or executing-kbd-macro noninteractive))
(eq org-export-copy-to-kill-ring t)))
(provide 'ox) (provide 'ox)