all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Seweryn Kokot <s.kokot@po.opole.pl>
To: emacs-orgmode@gnu.org
Subject: Re: Electric insert of headline stars
Date: Thu, 25 Oct 2007 14:41:54 +0200	[thread overview]
Message-ID: <87y7drmkml.fsf@poczta.po.opole.pl> (raw)
In-Reply-To: 3c12eb8d0710250511k51750491r5ecbfdb8df66b5dc@mail.gmail.com

"Piotr Zielinski" <piotr.zielinski@gmail.com> writes:

> On 25/10/2007, Seweryn Kokot <s.kokot@po.opole.pl> 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

  parent reply	other threads:[~2007-10-25 12:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-25 10:15 Electric insert of headline stars Piotr Zielinski
2007-10-25 10:59 ` Carsten Dominik
2007-10-25 11:29 ` Bastien
2007-10-25 11:53 ` Seweryn Kokot
2007-10-25 12:11   ` Piotr Zielinski
2007-10-25 12:25     ` Carsten Dominik
2007-10-25 12:41     ` Seweryn Kokot [this message]
2007-10-25 13:03       ` Seweryn Kokot
2007-10-25 13:17     ` Bastien
2007-10-25 12:14   ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87y7drmkml.fsf@poczta.po.opole.pl \
    --to=s.kokot@po.opole.pl \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.