I wrote a function to insert a space after an open brace and before a close
brace
in a selection. I would like it to work better skipping those occurences
where
I already have a space before or after the brace.
(defun brace-and-space(start end)
(interactive "*r")
(save-excursion
(save-restriction
(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
skip
the replace operation having a space
after/before the brace
Any suggestions?
Thank you very much.
Luca.
_______________________________________________
Help-gnu-emacs mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gnu-emacs