[Top][All Lists]

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

Inserting spaces after/before braces...

From: luca . spinacci
Subject: Inserting spaces after/before braces...
Date: Tue, 19 Apr 2005 11:14:22 +0200

I wrote a function to insert a space after an open brace and before a close
in a selection. I would like it to work better skipping those occurences
I already have a space before or after the brace.

(defun brace-and-space(start end)
 (interactive "*r")
      (narrow-to-region start end)
      (goto-char start)
      (while (re-search-forward "(" nil t)
        (replace-match "( " nil t))
      (goto-char start)
      (while (re-search-forward ")" nil t)
        (replace-match " )" nil t)))))

So, for instance

if((a==1)) => if(_(_a==1_)_) as expected

if(_(_a==1_)_ ) => if(__(__a==1__ ) __ ) as expected but I would like it to

the replace operation having a space

after/before the brace

Any suggestions?

Thank you very much.

reply via email to

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