emacs-orgmode
[Top][All Lists]
Advanced

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

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


From: Eric Schulte
Subject: [Orgmode] small function suggestion (org-examplize-region)
Date: Tue, 17 Mar 2009 11:02:47 -0700
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.90 (gnu/linux)

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---




reply via email to

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