From: luca.spinacci@seleniacomms.com
Subject: Inserting spaces after/before braces...
Date: Tue, 19 Apr 2005 11:14:22 +0200 [thread overview]
Message-ID: <OFAFB5A904.85CBA41E-ONC1256FE8.00371D41@SeleniaComms.com> (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.
next reply other threads:[~2005-04-19 9:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-04-19 9:14 luca.spinacci [this message]
2005-04-19 10:05 ` Inserting spaces after/before braces Peter Dyballa
2005-04-19 10:46 ` Peter Dyballa
[not found] <mailman.1968.1113902138.2895.help-gnu-emacs@gnu.org>
2005-04-19 20:49 ` rgb
2005-04-19 20:49 ` rgb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=OFAFB5A904.85CBA41E-ONC1256FE8.00371D41@SeleniaComms.com \
--to=luca.spinacci@seleniacomms.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).