From: Ralf Angeli <[EMAIL PROTECTED]>
* Adam Johnson (2006-11-01) writes:
> When I first select a region like "abc" forward from 'a' to 'c', and
then
> use C-c C-{, a pair of {} was added around "abc" so it becomes "{abc}".
If
> I select the same region backwards from 'c' to 'a', the same operation
> produces something like "}abc{", which, in general, is meaningless.
This has been fixed in CVS for quite some time.
> Just a thought, can you please produce any operation to delete a pair of
> braces, that is to change "{blabla}" to "blabla"? In general, an extra
pair
> of "{}" will not affect anything, but I'd like to keep my document as
neat
> as possible. (that is, without extra things like this in the document.)
How about the following function?
(defun TeX-remove-braces ()
"Remove a pair of braces.
Braces are only removed if point is between a matching pair of
them. The function does nothing if this is not the case."
(interactive)
(let ((opening-brace (TeX-find-opening-brace))
(closing-brace (TeX-find-closing-brace)))
(when (and opening-brace closing-brace)
(delete-region (1- closing-brace) closing-brace)
(delete-region opening-brace (1+ opening-brace)))))
I should probably write a function which returns both the opening and
the closing brace in one go.
And here is something if you want to remove a whole macro:
(defun TeX-remove-macro ()
"Remove a single-argument TeX macro leaving its argument untouched."
(interactive)
(let ((macro-start (TeX-find-macro-start))
(macro-end (TeX-find-macro-end))
opening-brace)
(when (and macro-start macro-end)
(save-excursion
(goto-char (1- macro-end))
(setq opening-brace (TeX-find-opening-brace)))
(delete-region (1- macro-end) macro-end)
(delete-region macro-start (1+ opening-brace)))))
Thanks Ralf, let me try it.
For the first command, I may expect something as follows:
{\emph{blah}}, cursor is put at blah, will also remove the outer {}.
\textbf{\emph{blah}}, cursor anywhere, will remove nothing.
For the second one, I may expect:
For \textbf{\emph{blah}}, cursor is put at {blah, will remove the \emph{},
otherwise, it will remove \textbf{}.
Anyway, I appreciate it and let me try it first.
--
Adam
_________________________________________________________________
Stay in touch with old friends and meet new ones with Windows Live Spaces
http://clk.atdmt.com/MSN/go/msnnkwsp0070000001msn/direct/01/?href=http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us
_______________________________________________
auctex mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/auctex