From mboxrd@z Thu Jan 1 00:00:00 1970 From: Seweryn Kokot Subject: Re: Electric insert of headline stars Date: Thu, 25 Oct 2007 14:41:54 +0200 Message-ID: <87y7drmkml.fsf@poczta.po.opole.pl> References: <3c12eb8d0710250315r633d0c9au1fdcc8c8000437b@mail.gmail.com> <878x5rpg0l.fsf@poczta.po.opole.pl> <3c12eb8d0710250511k51750491r5ecbfdb8df66b5dc@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Il20Q-0006SM-OJ for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:40:10 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Il20O-0006RD-TP for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:40:10 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Il20O-0006R3-J3 for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:40:08 -0400 Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Il20N-0006PA-Vw for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 08:40:08 -0400 Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Il20L-0000wh-Nj for emacs-orgmode@gnu.org; Thu, 25 Oct 2007 12:40:05 +0000 Received: from nat-warynskiego.po.opole.pl ([217.173.199.132]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Oct 2007 12:40:05 +0000 Received: from s.kokot by nat-warynskiego.po.opole.pl with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 25 Oct 2007 12:40:05 +0000 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 "Piotr Zielinski" writes: > 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)) It seems that the line "(when (looking-back "^ +" (point-at-bol))" is not required in the second version. And for me it's better to add and extra whitespace to directly type a heading name. I don't know if the line (insert " ") is correct in this case or it should be replaced with something (org-self-insert-command x)? (defun ks-org-insert-stars () (interactive) (save-excursion (while (search-backward " " (point-at-bol) t) (replace-match "*" nil t))) (org-self-insert-command 1) (insert " ")) Anyway I prefer the version without a warning and it is politically correct according to the manual :) -- Seweryn Kokot