From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bastien Subject: Using C-c - to (un)listify and/or C-c * to (un)"headify" ? Date: Sat, 22 Dec 2007 19:20:15 +0100 Message-ID: <873atu617k.fsf@bzg.ath.cx> 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 1J68xR-0005B4-Rs for emacs-orgmode@gnu.org; Sat, 22 Dec 2007 13:20:21 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1J68xQ-00055s-2z for emacs-orgmode@gnu.org; Sat, 22 Dec 2007 13:20:21 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1J68xP-00055d-Vi for emacs-orgmode@gnu.org; Sat, 22 Dec 2007 13:20:20 -0500 Received: from hu-out-0506.google.com ([72.14.214.236]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1J68xP-0004oo-MU for emacs-orgmode@gnu.org; Sat, 22 Dec 2007 13:20:19 -0500 Received: by hu-out-0506.google.com with SMTP id 23so1542099huc.1 for ; Sat, 22 Dec 2007 10:20:18 -0800 (PST) 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: emacs-orgmode@gnu.org Ahem. Sorry for the messy subject line. Here are two needs I often meet: 1. I need to listify the lines between a region 2. I need to convert lines into headlines For now I'm using two simple functions (see below). But I think there is room for improvement. The first function could be merged into (org-ctrl-c-minus): (un)listify the active region, and if there is no active region, just cycle through the list types (as it does now). The second fonction could convert raw lines into headings and headings back into raw lines. Do other people find this useful? ======================================================================== (defun bzg-org-convert-to-plain-list (beg end) "Convert each line in the region into a plain list." (interactive "r") (string-rectangle beg end "- ")) (defun bzg-org-convert-to-headings (beg end) "Convert each line in the region into subheadings." (interactive "r") (let ((stars (save-excursion (re-search-backward org-complex-heading-regexp nil t) (or (match-string 1) "*"))) (add-stars (if org-odd-levels-only "**" "*"))) (string-rectangle beg end (concat add-stars stars " ")))) (define-key org-mode-map (kbd "C-c C--") 'bzg-org-convert-to-list) (define-key org-mode-map (kbd "C-c C-*") 'bzg-org-convert-to-headings) ======================================================================== -- Bastien