From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/81031 Path: news.gmane.org!not-for-mail From: Uwe Brauer Newsgroups: gmane.emacs.auctex.devel,gmane.emacs.orgmode,gmane.emacs.gnus.general 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 NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1327947847 20497 80.91.229.3 (30 Jan 2012 18:24:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 30 Jan 2012 18:24:07 +0000 (UTC) Cc: emacs-orgmode@gnu.org, ding@gnus.org To: auctex-devel@gnu.org Original-X-From: auctex-devel-bounces+gead-auctex-devel=m.gmane.org@gnu.org Mon Jan 30 19:24:06 2012 Return-path: Envelope-to: gead-auctex-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rrvta-0002No-0x for gead-auctex-devel@m.gmane.org; Mon, 30 Jan 2012 19:24:02 +0100 Original-Received: from localhost ([::1]:51293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrvtZ-0003mC-FH for gead-auctex-devel@m.gmane.org; Mon, 30 Jan 2012 13:24:01 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:40933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrvtS-0003m2-N4 for auctex-devel@gnu.org; Mon, 30 Jan 2012 13:24:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RrvtM-0004ZJ-SK for auctex-devel@gnu.org; Mon, 30 Jan 2012 13:23:54 -0500 Original-Received: from mail-wi0-f169.google.com ([209.85.212.169]:57250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RrvtM-0004Yb-Ir; Mon, 30 Jan 2012 13:23:48 -0500 Original-Received: by wibhj13 with SMTP id hj13so4539289wib.0 for ; Mon, 30 Jan 2012 10:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:x-mailer:from:to:cc:subject:references:reply-to:x-hashcash :date:in-reply-to:message-id:user-agent:mime-version:content-type; bh=IwVytsIOVYFugUHC1PmtobrkVxguLjdmXObXMpTkCvY=; b=qH/TCwA2Up+E9B10EF+9sujB2UYceu2Bv8BFtjBPonfo+nD5VeL0OrcwB/qA2KpUXx q5+BbqpVVPqo66GJPkLkaY+1lMO6d0N7UYq92ft/VBBm6OyNA0eie2cJwVoSHtTigxQ8 Q/AkkrqmKhcbjcT9BO4q3vLlX9Jjerg8eu3Hk= Original-Received: by 10.180.8.103 with SMTP id q7mr29417378wia.1.1327947827677; Mon, 30 Jan 2012 10:23:47 -0800 (PST) Original-Received: from gilgamesch.quim.ucm.es (gilgamesch.quim.ucm.es. [147.96.12.99]) by mx.google.com with ESMTPS id di5sm54947481wib.3.2012.01.30.10.23.45 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Jan 2012 10:23:46 -0800 (PST) X-Mailer: 21.5 (beta31) "ginger" XEmacs Lucid (via feedmail 11-beta-1 I) X-Hashcash: 1:20:120130:auctex-devel@gnu.org::wg6hEhkBjIUwRjEM:000000000000000000000000000000000000000003l5F In-Reply-To: <87ipjtv3dy.fsf@gmail.com> (Antoine Levitt's message of "Mon, 30 Jan 2012 12:25:13 +0100") User-Agent: Gnus/5.110018 (No Gnus v0.18) XEmacs/21.5-b31 (linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.169 X-BeenThere: auctex-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion list for AUCTeX developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: auctex-devel-bounces+gead-auctex-devel=m.gmane.org@gnu.org Original-Sender: auctex-devel-bounces+gead-auctex-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.auctex.devel:2687 gmane.emacs.orgmode:51737 gmane.emacs.gnus.general:81031 Archived-At: --=-=-= 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 --=-=-=--