help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: writing a custom command file


From: Kai Grossjohann
Subject: Re: writing a custom command file
Date: Sat, 07 Aug 2004 18:25:46 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

thomas.strohmann@gmail.com (thomas) writes:

> I would like to write a custom command file (say foo.el) that
> interactively asks
> for one argument (a string "s") and then executes a couple of
> replace-regexp
> commands, e.g.:
>
> (replace-regexp "abc" "abc "+s)    ; + meaning string concatenation
> (replace-regexp "def" "ghi")
> (replace-regexp "123" "456")
>
> Since i don't know anything about customizing emacs with Lisp
> functions can anyone please tell me what the .el file for this would
> look like?

In this case, I feel like it, but in general, you'll get more answers
when you show some willingness to spend time on it.  Then it's more
fun to help others, because the questioner will appreciate the answer.

(defun foo (s)
  (interactive "sExtra string: ")
  (replace-regexp "abc" (concat "abc " s))
  (replace-regexp "def" "ghi")
  (replace-regexp "123" "456"))

It's possible that you have to add a statement (goto-char (point-min))
before each of the replace-regexp statements because replace-regexp
starts replacing at point, not at the beginning of the buffer.

Does this help?

Kai





reply via email to

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