* Looking for some examples
@ 2021-10-06 19:30 Patrick Mahan
2021-10-06 20:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 20:32 ` Stephen Berman
0 siblings, 2 replies; 6+ messages in thread
From: Patrick Mahan @ 2021-10-06 19:30 UTC (permalink / raw)
To: Help Gnu Emacs
I've looked around on the wiki and googled, but I haven't really found any
examples.
I am cleaning a bunch of old code with tons of CPP macros of the form -
#define MACRONAME(_arg1, _arg2) \
do { \
/* code */ \
} while (0)
I am converting these all to inline functions and already have some emacs
lisp code written to handle converting everything but the backslashes. I
would like to remove the backslashes, but I do not want to leave all that
empty whitespace behind. Is there a way to do this using
query-replace-regexp that also removes the whitespace?
Thanks,
Patrick
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Looking for some examples
2021-10-06 19:30 Looking for some examples Patrick Mahan
@ 2021-10-06 20:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 20:10 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 20:32 ` Stephen Berman
1 sibling, 1 reply; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 20:01 UTC (permalink / raw)
To: help-gnu-emacs
Patrick Mahan wrote:
> I am converting these all to inline functions and already
> have some emacs lisp code written to handle converting
> everything but the backslashes. I would like to remove the
> backslashes, but I do not want to leave all that empty
> whitespace behind. Is there a way to do this using
> query-replace-regexp that also removes the whitespace?
;; (setq before-save-hook nil)
(defun before-save-hook-f ()
(untab-all)
(delete-trailing-whitespace) )
(add-hook 'before-save-hook #'before-save-hook-f)
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Looking for some examples
2021-10-06 20:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-06 20:10 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 6+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-10-06 20:10 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Patrick Mahan wrote:
>
>> I am converting these all to inline functions and already
>> have some emacs lisp code written to handle converting
>> everything but the backslashes. I would like to remove the
>> backslashes, but I do not want to leave all that empty
>> whitespace behind. Is there a way to do this using
>> query-replace-regexp that also removes the whitespace?
>
> ;; (setq before-save-hook nil)
> (defun before-save-hook-f ()
> (untab-all)
> (delete-trailing-whitespace) )
> (add-hook 'before-save-hook #'before-save-hook-f)
Also see `whitespace-cleanup'.
As for your question ... can't you just add [[:space:]]* to
the regexp that matches the backslash and have all of
it removed?
Maybe better to just save the buffer still ...
--
underground experts united
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Looking for some examples
2021-10-06 19:30 Looking for some examples Patrick Mahan
2021-10-06 20:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-10-06 20:32 ` Stephen Berman
2021-10-06 20:47 ` 2QdxY4RzWzUUiLuE
2021-10-06 21:33 ` Patrick Mahan
1 sibling, 2 replies; 6+ messages in thread
From: Stephen Berman @ 2021-10-06 20:32 UTC (permalink / raw)
To: Patrick Mahan; +Cc: Help Gnu Emacs
On Wed, 6 Oct 2021 12:30:40 -0700 Patrick Mahan <plmahan@gmail.com> wrote:
> I've looked around on the wiki and googled, but I haven't really found any
> examples.
>
> I am cleaning a bunch of old code with tons of CPP macros of the form -
> #define MACRONAME(_arg1, _arg2) \
> do { \
> /* code */ \
> } while (0)
>
> I am converting these all to inline functions and already have some emacs
> lisp code written to handle converting everything but the backslashes. I
> would like to remove the backslashes, but I do not want to leave all that
> empty whitespace behind. Is there a way to do this using
> query-replace-regexp that also removes the whitespace?
C-M-% [[:space:]]+\\$ RET RET !
Steve Berman
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Looking for some examples
2021-10-06 20:32 ` Stephen Berman
@ 2021-10-06 20:47 ` 2QdxY4RzWzUUiLuE
2021-10-06 21:33 ` Patrick Mahan
1 sibling, 0 replies; 6+ messages in thread
From: 2QdxY4RzWzUUiLuE @ 2021-10-06 20:47 UTC (permalink / raw)
To: help-gnu-emacs
On 2021-10-06 at 22:32:15 +0200,
Stephen Berman <stephen.berman@gmx.net> wrote:
> On Wed, 6 Oct 2021 12:30:40 -0700 Patrick Mahan <plmahan@gmail.com> wrote:
>
> > I've looked around on the wiki and googled, but I haven't really found any
> > examples.
> >
> > I am cleaning a bunch of old code with tons of CPP macros of the form -
> > #define MACRONAME(_arg1, _arg2) \
> > do { \
> > /* code */ \
> > } while (0)
> >
> > I am converting these all to inline functions and already have some emacs
> > lisp code written to handle converting everything but the backslashes. I
> > would like to remove the backslashes, but I do not want to leave all that
> > empty whitespace behind. Is there a way to do this using
> > query-replace-regexp that also removes the whitespace?
>
> C-M-% [[:space:]]+\\$ RET RET !
That won't remove the backslashes that *aren't* preceded by whitespace,
which may or may not be a problem in your case. To address that, change
the + (one or more) to a * (zero or more):
C-M-% [[:space:]]*\\$ RET RET !
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Looking for some examples
2021-10-06 20:32 ` Stephen Berman
2021-10-06 20:47 ` 2QdxY4RzWzUUiLuE
@ 2021-10-06 21:33 ` Patrick Mahan
1 sibling, 0 replies; 6+ messages in thread
From: Patrick Mahan @ 2021-10-06 21:33 UTC (permalink / raw)
To: Stephen Berman; +Cc: Help Gnu Emacs
On Wed, Oct 6, 2021 at 1:32 PM Stephen Berman <stephen.berman@gmx.net>
wrote:
> On Wed, 6 Oct 2021 12:30:40 -0700 Patrick Mahan <plmahan@gmail.com> wrote:
>
> > I've looked around on the wiki and googled, but I haven't really found
> any
> > examples.
> >
> > I am cleaning a bunch of old code with tons of CPP macros of the form -
> > #define MACRONAME(_arg1, _arg2) \
> > do { \
> > /* code */ \
> > } while (0)
> >
> > I am converting these all to inline functions and already have some emacs
> > lisp code written to handle converting everything but the backslashes. I
> > would like to remove the backslashes, but I do not want to leave all that
> > empty whitespace behind. Is there a way to do this using
> > query-replace-regexp that also removes the whitespace?
>
> C-M-% [[:space:]]+\\$ RET RET !
>
>
ARRGGGH! Why can I not remember '[[:space:]]'!!!! *Sigh* that's what I was
looking for...
Patrick
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-10-06 21:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-06 19:30 Looking for some examples Patrick Mahan
2021-10-06 20:01 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 20:10 ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-10-06 20:32 ` Stephen Berman
2021-10-06 20:47 ` 2QdxY4RzWzUUiLuE
2021-10-06 21:33 ` Patrick Mahan
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).