emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* small function suggestion (org-examplize-region)
@ 2009-03-17 18:02 Eric Schulte
  2009-03-17 19:00 ` Manish
  2009-03-18  0:50 ` Charles Cave
  0 siblings, 2 replies; 8+ messages in thread
From: Eric Schulte @ 2009-03-17 18:02 UTC (permalink / raw)
  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---

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-03-18 16:07 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-17 18:02 small function suggestion (org-examplize-region) Eric Schulte
2009-03-17 19:00 ` Manish
2009-03-18  8:38   ` Carsten Dominik
2009-03-18  0:50 ` Charles Cave
2009-03-18  1:34   ` Nick Dokos
2009-03-18  5:35     ` Charles Cave
2009-03-18  8:32       ` Mikael Fornius
2009-03-18 16:07       ` Daniel Clemente

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).