From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: small function suggestion (org-examplize-region) Date: Tue, 17 Mar 2009 11:02:47 -0700 Message-ID: <87hc1sc9iw.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ljdc0-0005dW-Md for emacs-orgmode@gnu.org; Tue, 17 Mar 2009 14:02:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ljdbw-0005Xw-23 for emacs-orgmode@gnu.org; Tue, 17 Mar 2009 14:02:00 -0400 Received: from [199.232.76.173] (port=47708 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ljdbv-0005Xl-TQ for emacs-orgmode@gnu.org; Tue, 17 Mar 2009 14:01:55 -0400 Received: from wf-out-1314.google.com ([209.85.200.173]:58788) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ljdbv-0000c5-Dx for emacs-orgmode@gnu.org; Tue, 17 Mar 2009 14:01:55 -0400 Received: by wf-out-1314.google.com with SMTP id 23so102534wfg.24 for ; Tue, 17 Mar 2009 11:01:53 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org Mode List Hi, This function could be used to comment out a region of an org-mode file as an example using the ': ' syntax. Would this function be a useful addition to org-mode or has this need already been filled, and I was just unable to find it in the documentation. Thanks -- Eric --8<---------------cut here---------------start------------->8--- (defun org-examplize-region (beg end) "Comment out region using the ': ' org example quote." (interactive "*r") (let ((size (abs (- (line-number-at-pos end) (line-number-at-pos beg))))) (if (= size 0) (let ((result (buffer-substring beg end))) (delete-region beg end) (insert (concat ": " result))) (save-excursion (goto-char beg) (dotimes (n size) (move-beginning-of-line 1) (insert ": ") (forward-line 1)))))) --8<---------------cut here---------------end--------------->8---