From mboxrd@z Thu Jan 1 00:00:00 1970 From: Uwe Brauer Subject: a kludge (was: org-preview-latex-fragment and preview-copy-region-as-mml) Date: Mon, 30 Jan 2012 19:23:42 +0100 Message-ID: <87pqe1nj69.fsf_-_@gilgamesch.quim.ucm.es> References: <87ehuhfot3.fsf@gilgamesch.quim.ucm.es> <87ipjtv3dy.fsf@gmail.com> Reply-To: Uwe Brauer Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: In-Reply-To: <87ipjtv3dy.fsf@gmail.com> (Antoine Levitt's message of "Mon, 30 Jan 2012 12:25:13 +0100") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: auctex-devel-bounces+gead-auctex-devel=m.gmane.org@gnu.org Sender: auctex-devel-bounces+gead-auctex-devel=m.gmane.org@gnu.org To: auctex-devel@gnu.org Cc: emacs-orgmode@gnu.org, ding@gnus.org List-Id: emacs-orgmode.gnu.org --=-=-= Content-Type: text/plain >> On Mon, 30 Jan 2012 12:25:13 +0100, Antoine Levitt wrote: >> >> Uwe Brauer > (ccing gnus mailing list, in case someone is interested) > I ran into that the other day. > I think it would be very useful to have preview-buffer work > on non-latex buffers. Concerning org-preview-latex-fragment: I have some code which indeed attaches the png generated by this function. However it is very primitive. org-preview-latex-fragment generates pngs in a subdirectory called ltxpng. These pngs are then inserted in the buffer where org-preview-latex-fragment was executed. Since one cannot be sure that the ltxpng directory is non-empty, IMHO it should be deleted before generating the png. This is done by function my-delete-ltxpngdir, which needs the trashcan pkg. Then a very simple modification of an already existing function does the rest: message-attach-all-png-from-ltxpngfolder. I attach it if you want to test it. Uwe Brauer --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=my-preview-mml-send-png.el Content-Transfer-Encoding: quoted-printable ;;; my-preview-mml-send-png.el --- Attach automatically generated preview-g= enerated-png ;; Copyright (C) 2012 Uwe Brauer ;; Author: Uwe Brauer oub@mat.ucm.es ;; Maintainer: Uwe Brauer oub@mat.ucm.es ;; Created: 30 Jan 2012 ;; Version: 1.0 ;; Keywords: =20 ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; A copy of the GNU General Public License can be obtained from this ;; program's author (send electronic mail to oub@mat.ucm.es) or from ;; the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA ;; 02139, USA. ;; LCD Archive Entry: ;; my-preview-mml-send-png|Uwe Brauer|oub@mat.ucm.es ;; | ;; |$Date: 2012/01/30 18:14:29 $|$Revision: 1.3 $|~/packages/my-preview-mml= -send-png.el ;;; Commentary: ;;; Change log: ;; $Log: my-preview-mml-send-png.el,v $ ;; Revision 1.3 2012/01/30 18:14:29 oub ;; Cleanup ;; ;; Revision 1.2 2012/01/30 18:13:18 oub ;; (message-attach-all-png-from-ltxpngfolder): New function ;; ;; Revision 1.1 2012/01/30 18:12:25 oub ;; Initial revision ;; ;; Revision 1.1 2012/01/30 13:29:36 oub ;; Initial revision ;; ;;; Code: ;; require (require 'trashcan) (defconst my-preview-mml-send-png-version (concat "0." (substring "$Revisio= n: 1.3 $" 13 14)) "$Id: my-preview-mml-send-png.el,v 1.3 2012/01/30 18:14:29 oub Exp oub $ You have to put this file under some sort of version control. Otherwise,=20 when byte compiling or just loading it, you will get an error!! Report bugs to: Uwe Brauer oub@mat.ucm.es") (defun my-delete-ltxpngdir () (interactive) (trashcan--delete-dangerous (concat default-directory "ltxpng"))) ;; from emacswiki. (defun message-attach-all-png-from-ltxpngfolder () "Create the mml code to attach all png files found in the ltxpng directo= ry." (interactive) (let ((dir-to-attach (concat default-directory "ltxpng")))=20=20=20=20 (if (not (string-match "/$" dir-to-attach)) (setq dir-to-attach (concat dir-to-attach "/"))) =20=20=20=20 (dolist (file (directory-files dir-to-attach)) (when (and (not (string=3D "." file)) (not (string=3D ".." file))) (let (full-file-path mime-type) (setq full-file-path (concat dir-to-attach file)) (if (file-readable-p full-file-path) (if (file-directory-p full-file-path) (message-attach-all-files-from-folder inline full-file-path) (setq mime-type (substring (shell-command-to-string (concat "file --mim= e-type --brief " (shell-quote-argument (expand-file-name full-file-path))))= 0 -1)) (insert-string (concat "<#part type=3D\"" mime-type "\" filename=3D\"" = full-file-path "\" disposition=3D" "inline" ">\n")) ))))))) (provide 'my-preview-mml-attach-png) ;;; MY-PREVIEW-MML-SEND-PNG.EL ends here --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ auctex-devel mailing list auctex-devel@gnu.org https://lists.gnu.org/mailman/listinfo/auctex-devel --=-=-=--