emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bastien <bzg@altern.org>
To: emacs-orgmode@gnu.org
Subject: Using C-c - to (un)listify and/or C-c * to (un)"headify" ?
Date: Sat, 22 Dec 2007 19:20:15 +0100	[thread overview]
Message-ID: <873atu617k.fsf@bzg.ath.cx> (raw)

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

             reply	other threads:[~2007-12-22 18:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-22 18:20 Bastien [this message]
2008-03-03 10:57 ` Using C-c - to (un)listify and/or C-c * to (un)"headify" ? Carsten Dominik
2008-03-03 11:06   ` Bastien Guerry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873atu617k.fsf@bzg.ath.cx \
    --to=bzg@altern.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).