emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Re: Electric insert of headline stars


From: Carsten Dominik
Subject: Re: [Orgmode] Re: Electric insert of headline stars
Date: Thu, 25 Oct 2007 14:14:32 +0200


On Oct 25, 2007, at 1:53 PM, Seweryn Kokot wrote:

"Piotr Zielinski" <address@hidden> writes:

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)


Very nice idea!
A minor inconvenience is a warning when compiling the code

.emacs:2604:30:Warning: `replace-string' used from Lisp code
That command is designed for interactive use only.

How to get rid of this?

The docstring of replace-string shows what replacement code should be used,
a combination of re-search-forward and replace-match.
Or you can wrap the call into a `with-no-warnings' form.

However, is the code is just in your own .emacs and works well, who cares.

- Carsten







reply via email to

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