all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / 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

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.