Gnus development mailing list
 help / color / mirror / Atom feed
From: Ted Zlatanov <tzz@lifelogs.com>
To: ding@gnus.org
Subject: Re: quoting code blocks in Gnus without Org functions
Date: Wed, 06 Apr 2011 11:24:57 -0500	[thread overview]
Message-ID: <87fwpvpcti.fsf@lifelogs.com> (raw)
In-Reply-To: <sa38vvn5tg9.fsf@cigue.easter-eggs.fr>

On Wed, 06 Apr 2011 16:45:58 +0200 Julien Danjou <julien@danjou.info> 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




  reply	other threads:[~2011-04-06 16:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-05  4:02 draft group weirdness Eric Abrahamsen
2011-04-05 10:48 ` Richard Riley
2011-04-06  0:24 ` Lars Magne Ingebrigtsen
2011-04-06  1:43   ` Eric Abrahamsen
2011-04-06 13:28     ` quoting code blocks in Gnus without Org functions (was: draft group weirdness) Ted Zlatanov
2011-04-06 14:14       ` quoting code blocks in Gnus without Org functions Julien Danjou
2011-04-06 14:21         ` Ted Zlatanov
2011-04-06 14:45           ` Julien Danjou
2011-04-06 16:24             ` Ted Zlatanov [this message]
2011-04-07  7:38               ` Julien Danjou
2011-04-07 19:57                 ` Ted Zlatanov
2011-04-07 21:20                   ` Ted Zlatanov
2011-04-08  5:52                     ` Ted Zlatanov
2011-04-08  9:34                       ` Balázs Tóth
2011-04-08  9:40                   ` Julien Danjou
2011-04-11 18:47                     ` Ted Zlatanov
2011-04-10 15:50     ` draft group weirdness Eric Abrahamsen
2011-04-11 18:39       ` Ted Zlatanov
2011-04-10 15:54     ` Eric Abrahamsen
2011-04-12 16:21       ` Lars Magne Ingebrigtsen
2011-04-12 23:02         ` Eric Abrahamsen
2011-04-12 16:19     ` Lars Magne Ingebrigtsen
2011-05-18 11:39     ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87fwpvpcti.fsf@lifelogs.com \
    --to=tzz@lifelogs.com \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).