emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Electric insert of headline stars
@ 2007-10-25 10:15 Piotr Zielinski
  2007-10-25 10:59 ` Carsten Dominik
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Piotr Zielinski @ 2007-10-25 10:15 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

Here's a small piece of elisp code that might be useful to some of you.
Pressing '*' now inserts '*' as before, but if there are only spaces
between the beginning of the current line and the point, then all of
them are converted to stars.  Useful for inserting new headlines.

Longer explanaition: assume you have the following structure:

* first level headline
_* second level headline
__* third level headline

(_ denotes an invisible star) Since stars are invisible, I often find
myself trying to create a new subheadline by just inserting a single
star

* first level headline
_* second level headline
__* third level headline
   *

which of course doesn't normally work, hence this elisp code.

(defun local-org-insert-stars ()
  (interactive)
  (when (looking-back "^ *" (point-at-bol))
    (replace-string " " "*" nil (point-at-bol) (point)))
  (insert "*"))

(define-key org-mode-map "*" 'local-org-insert-stars)

Haven't thoroughly tested it, but it seems to work ok.

Piotr

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

end of thread, other threads:[~2007-10-25 13:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-25 10:15 Electric insert of headline stars Piotr Zielinski
2007-10-25 10:59 ` Carsten Dominik
2007-10-25 11:29 ` Bastien
2007-10-25 11:53 ` Seweryn Kokot
2007-10-25 12:11   ` Piotr Zielinski
2007-10-25 12:25     ` Carsten Dominik
2007-10-25 12:41     ` Seweryn Kokot
2007-10-25 13:03       ` Seweryn Kokot
2007-10-25 13:17     ` Bastien
2007-10-25 12:14   ` Carsten Dominik

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