Commits

Ivan Andrus  committed 75547be

Changed Copy Text to Copy LaTeX and cleaned up the copied text

  • Participants
  • Parent commits e82ce85

Comments (0)

Files changed (1)

File emacs/sage-view.el

   "Check whether there is a valid image associated with OV."
   (eq (car (overlay-get ov 'display)) 'image))
 
+(defun sage-view-cleanup-copied-text (str)
+  "Remove some boilerplate text added by Sage to all LaTeX output."
+  (replace-regexp-in-string
+   (regexp-quote "\\newcommand{\\Bold}[1]{\\mathbf{#1}}")
+   "" str))
+
 (defun sage-view-copy-text (ov)
   "Copy LATEX source of OV into the kill buffer."
   (let ((text (overlay-get ov 'math)))
     (if text
-	(kill-new text)
+	(kill-new (sage-view-cleanup-copied-text text))
       (message "No LaTeX code available"))))
 
 (defun sage-view-save-image (ov)
   (popup-menu
    `("Sage View Mode"
      ["Regenerate" (lambda () (interactive) (sage-view-regenerate ,ov))]
-     ["Copy Text" (lambda () (interactive) (sage-view-copy-text ,ov))]
+     ["Copy LaTeX" (lambda () (interactive) (sage-view-copy-text ,ov))]
      ["Save As..." (lambda () (interactive) (sage-view-save-image ,ov))
       `(sage-view-overlay-activep ,ov)]
      ["Zoom in" (lambda (multiplier) (interactive "p")