From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/78394 Path: news.gmane.org!not-for-mail From: Ted Zlatanov Newsgroups: gmane.emacs.gnus.general Subject: Re: quoting code blocks in Gnus without Org functions Date: Wed, 06 Apr 2011 11:24:57 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87fwpvpcti.fsf@lifelogs.com> References: <87hbadqran.fsf@ericabrahamsen.net> <87sjtw40jh.fsf@ericabrahamsen.net> <87ipurqzjr.fsf_-_@lifelogs.com> <87sjtvpiju.fsf@lifelogs.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1302107142 2002 80.91.229.12 (6 Apr 2011 16:25:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 6 Apr 2011 16:25:42 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M26697@lists.math.uh.edu Wed Apr 06 18:25:38 2011 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q7VY2-0004Nk-4U for ding-account@gmane.org; Wed, 06 Apr 2011 18:25:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1Q7VXl-0002jp-2K; Wed, 06 Apr 2011 11:25:21 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1Q7VXk-0002jg-2E for ding@lists.math.uh.edu; Wed, 06 Apr 2011 11:25:20 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1Q7VXf-0007y3-Vj for ding@lists.math.uh.edu; Wed, 06 Apr 2011 11:25:20 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1Q7VXf-0002EV-13 for ding@gnus.org; Wed, 06 Apr 2011 18:25:15 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q7VXd-00046E-I6 for ding@gnus.org; Wed, 06 Apr 2011 18:25:13 +0200 Original-Received: from 38.98.147.130 ([38.98.147.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 06 Apr 2011 18:25:13 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 06 Apr 2011 18:25:13 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 36 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 38.98.147.130 X-Face: bd.DQ~'29fIs`T_%O%C\g%6jW)yi[zuz6;d4V0`@y-~$#3P_Ng{@m+e4o<4P'#(_GJQ%TT= D}[Ep*b!\e,fBZ'j_+#"Ps?s2!4H2-Y"sx" User-Agent: Gnus/5.110016 (No Gnus v0.16) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:Fj6RWUv8XMQWk0xHMcCt+sglEgE= X-Spam-Score: -0.7 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:78394 Archived-At: On Wed, 06 Apr 2011 16:45:58 +0200 Julien Danjou wrote: JD> What you want to do seems totally doable if we can have some information JD> about which buffer comes the yank from. But I doubt this is the case. Here's my attempt. This works for ELisp code but not for others (the `cond' needs to be extended obviously). Am I on the right track? Is there a map of mode to "short name" that the highlight code uses? Or can it just take the `major-mode' as string in addition to the "short name", since it uses that for fontification anyhow? (It felt very meta to copy the function with the function itself :) #+begin_src lisp (defun tzz-copy-region-with-mode-property (beg end) (interactive "r") (let ((text (buffer-substring beg end)) (mode major-mode)) (with-temp-buffer (insert text) (goto-char (point-min)) (insert "#+begin_src " (cond ((memq mode '(lisp-interaction-mode emacs-lisp-mode)) "lisp") (t "text")) "\n") (goto-char (point-max)) (insert "\n" "#+end_src" "\n") (copy-region-as-kill (point-min) (point-max))))) #+end_src Thanks Ted