help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any way to remove ^L or ^M from some buffer outputs?


From: Patrick Mahan
Subject: Re: Any way to remove ^L or ^M from some buffer outputs?
Date: Sun, 4 Oct 2020 13:32:50 -0700

Yes, I have never byte-compiled it as I have only used it interactively to
clean-up text files coming from a DOS world to linux/unix/macos.  It is
defined in my .emacs init file.

On Sun, Oct 4, 2020 at 12:50 PM Emanuel Berg via Users list for the GNU
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Patrick Mahan wrote:
>
> > (defun cut-ctrlM ()
> >   "Cut all visible ^M."
> >   (interactive)
> >   (beginning-of-buffer)
> >   (while (search-forward "\r" nil t)
> >     (replace-match "" nil t))
> >   (not-modified)
> >   (beginning-of-buffer))
>
> Well, yeah, if we want to replace (not hide), only,
> as always, the byte compiler is your friend!
>
>   In cut-ctrlM:
>   [...]Warning: ‘beginning-of-buffer’ is for interactive use only; use
>       ‘(goto-char (point-min))’ instead.
>   [...]Warning: ‘not-modified’ is for interactive use only; use
>       ‘set-buffer-modified-p’ instead.
>   [...]Warning: ‘beginning-of-buffer’ is for interactive use only; use
>       ‘(goto-char (point-min))’ instead.
>
> And... maybe wrap it in `save-excursion' as well?
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]