From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/78413 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: Thu, 07 Apr 2011 14:57:41 -0500 Organization: =?utf-8?B?0KLQtdC+0LTQvtGAINCX0LvQsNGC0LDQvdC+0LI=?= @ Cienfuegos Message-ID: <87aag1rg0a.fsf@lifelogs.com> References: <87hbadqran.fsf@ericabrahamsen.net> <87sjtw40jh.fsf@ericabrahamsen.net> <87ipurqzjr.fsf_-_@lifelogs.com> <87sjtvpiju.fsf@lifelogs.com> <87fwpvpcti.fsf@lifelogs.com> <878vvm7bp3.fsf@keller.adm.naquadah.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1302206418 5803 80.91.229.12 (7 Apr 2011 20:00:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 7 Apr 2011 20:00:18 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M26716=ding+2Daccount=gmane.org@lists.math.uh.edu Thu Apr 07 22:00:14 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 1Q7vNB-0000JZ-LE for ding-account@gmane.org; Thu, 07 Apr 2011 22:00:09 +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 1Q7vNB-0000zX-12 for ding-account@gmane.org; Thu, 07 Apr 2011 15:00:09 -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 1Q7vNA-0000zS-61 for ding@lists.math.uh.edu; Thu, 07 Apr 2011 15:00:08 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.72) (envelope-from ) id 1Q7vN9-0004vZ-G2 for ding@lists.math.uh.edu; Thu, 07 Apr 2011 15:00:08 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]) by quimby.gnus.org with esmtp (Exim 4.72) (envelope-from ) id 1Q7vN8-0005vf-9r for ding@gnus.org; Thu, 07 Apr 2011 22:00:06 +0200 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1Q7vN8-0000Hi-2g for ding@gnus.org; Thu, 07 Apr 2011 22:00:06 +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 ; Thu, 07 Apr 2011 22:00:06 +0200 Original-Received: from tzz by 38.98.147.130 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 07 Apr 2011 22:00:06 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 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:YNJr/tjd0MW2PBmt8nLLIvYW5j0= X-Spam-Score: -0.7 (/) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:78413 Archived-At: On Thu, 07 Apr 2011 09:38:48 +0200 Julien Danjou wrote: JD> On Wed, Apr 06 2011, Ted Zlatanov wrote: >> 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? JD> You do not need a cond. Simply put the current major mode symbol's name JD> without the -mode, e.g. lisp-interaction-mode -> lisp-interaction. Like this? Or should I say "text" as a fallback? #+begin_src emacs-lisp (defun tzz-copy-region-with-mode-property (beg end) (interactive "r") (let ((text (buffer-substring beg end)) (mode (symbol-name major-mode))) (with-temp-buffer (insert text) (goto-char (point-min)) (insert "#+begin_src" (if (string-match "\\(.+\\)-mode" mode) (concat " " (match-string 1 mode)) "") "\n") (goto-char (point-max)) (insert "\n" "#+end_src" "\n") (copy-region-as-kill (point-min) (point-max))))) #+end_src Thanks Ted