From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Re: Electric insert of headline stars Date: Thu, 25 Oct 2007 14:25:54 +0200 Message-ID: References: <3c12eb8d0710250315r633d0c9au1fdcc8c8000437b@mail.gmail.com> <878x5rpg0l.fsf@poczta.po.opole.pl> <3c12eb8d0710250511k51750491r5ecbfdb8df66b5dc@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Il1mm-0004Zo-S7 for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:26:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Il1mk-0004Z9-AK for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:26:04 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Il1mk-0004Z1-0G for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:26:02 -0400 Received: from ug-out-1314.google.com ([66.249.92.169]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Il1mj-00014G-Ou for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:26:01 -0400 Received: by ug-out-1314.google.com with SMTP id a2so552563ugf for ; Thu, 25 Oct 2007 05:26:00 -0700 (PDT) In-Reply-To: <3c12eb8d0710250511k51750491r5ecbfdb8df66b5dc@mail.gmail.com> 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: Piotr Zielinski Cc: Seweryn Kokot , emacs-orgmode@gnu.org On Oct 25, 2007, at 2:11 PM, Piotr Zielinski wrote: > On 25/10/2007, Seweryn Kokot wrote: > >> A minor inconvenience is a warning when compiling the code > > First, here's the version after Bastien's and Carsten's comments: > > (defun local-org-insert-stars () > (interactive) > (when (looking-back "^ +" (point-at-bol)) > (replace-string " " "*" nil (point-at-bol) (point))) > (org-self-insert-command 1)) > >> .emacs:2604:30:Warning: `replace-string' used from Lisp code >> That command is designed for interactive use only. > >> How to get rid of this? > > This is what I came up with after following the suggestion from the > manual, but it looks complicated to me, so I don't really like it: > > > (defun local-org-insert-stars () > (interactive) > (when (looking-back "^ +" (point-at-bol)) > (save-excursion > (while (search-backward " " (point-at-bol) t) > (replace-match "*" nil t)))) > (org-self-insert-command 1)) > Another option would be: (defun local-org-insert-stars () (interactive) (if (looking-back "^ +" (point-at-bol)) (insert (make-string (prog1 (current-column) (replace-match "")) ?*) "* ") (org-self-insert-command 1))) - Carsten