emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Electric insert of headline stars


From: Carsten Dominik
Subject: Re: [Orgmode] Electric insert of headline stars
Date: Thu, 25 Oct 2007 12:59:36 +0200


On Oct 25, 2007, at 12:15 PM, Piotr Zielinski wrote:

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.


hmm, intresting.


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

like this it will break table alignment.  it is better to use

(org-self-insert-command 1)

    instead of

(insert "*")


- Carsten


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

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

Piotr


_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
address@hidden
http://lists.gnu.org/mailman/listinfo/emacs-orgmode





reply via email to

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