emacs-orgmode
[Top][All Lists]
Advanced

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

[Orgmode] Re: Electric insert of headline stars


From: Seweryn Kokot
Subject: [Orgmode] Re: Electric insert of headline stars
Date: Thu, 25 Oct 2007 14:41:54 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

"Piotr Zielinski" <address@hidden> writes:

> On 25/10/2007, Seweryn Kokot <address@hidden> 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





reply via email to

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