From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Piotr Zielinski" Subject: Electric insert of headline stars Date: Thu, 25 Oct 2007 11:15:46 +0100 Message-ID: <3c12eb8d0710250315r633d0c9au1fdcc8c8000437b@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ikzkk-0000Wv-Pb for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 06:15:50 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ikzkj-0000Tn-EV for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 06:15:50 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ikzkj-0000TZ-78 for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 06:15:49 -0400 Received: from an-out-0708.google.com ([209.85.132.246]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Ikzkj-0004Ul-9f for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 06:15:49 -0400 Received: by an-out-0708.google.com with SMTP id c38so72988ana for ; Thu, 25 Oct 2007 03:15:48 -0700 (PDT) Content-Disposition: inline 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 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