emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] small function suggestion (org-examplize-region)


From: Carsten Dominik
Subject: Re: [Orgmode] small function suggestion (org-examplize-region)
Date: Wed, 18 Mar 2009 09:38:40 +0100


On Mar 17, 2009, at 8:00 PM, Manish wrote:

On Tue, Mar 17, 2009 at 11:32 PM, Eric Schulte wrote:
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---

I think org-toggle-fixed-width-section does the same for me.

Which is bound to `C-c :'.

- Carsten





reply via email to

[Prev in Thread] Current Thread [Next in Thread]