unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Inserting spaces after/before braces...
@ 2005-04-19  9:14 luca.spinacci
  2005-04-19 10:05 ` Peter Dyballa
  0 siblings, 1 reply; 5+ messages in thread
From: luca.spinacci @ 2005-04-19  9:14 UTC (permalink / raw)



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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-04-19 20:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.1968.1113902138.2895.help-gnu-emacs@gnu.org>
2005-04-19 20:49 ` Inserting spaces after/before braces rgb
2005-04-19 20:49 ` rgb
2005-04-19  9:14 luca.spinacci
2005-04-19 10:05 ` Peter Dyballa
2005-04-19 10:46   ` Peter Dyballa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).