* Any way to remove ^L or ^M from some buffer outputs?
@ 2020-10-04 14:52 Jean Louis
2020-10-04 16:51 ` Drew Adams
` (2 more replies)
0 siblings, 3 replies; 25+ messages in thread
From: Jean Louis @ 2020-10-04 14:52 UTC (permalink / raw)
To: help-gnu-emacs
\f
Compiling file /home/data1/protected/Programming/emacs-lisp/rcd-cf.el at Sun Oct 4 17:48:33 2020
In cf-sms-exists:
rcd-cf.el:437:18: Warning: reference to free variable ‘n’ Disable showing
Disable logging
I am not sure if you can see ^L above, let us say I am compiling or
having some shell output, then I see often ^L, this may be line feed,
I do not know, but it looks green here on my side and is often not
interpreted correctly, line after line, but just as special character
after which other output lines are shown.
In this case I see Emacs compiling buffer. It seems not necessary to
be in the buffer like that.
Then in shell buffers, I see something like this below:
Output file: /home/data1/protected/Media/Videos/Recordings/2020/10/2020-10-04/2020-10-04-17:51:02.ogv
^M[0%] ^M[1%] ^M[2%] ^M[3%] ^M[4%] ^M[5%] ^M[6%] ^M[7%] ^M[8%] ^M[9%]
^M[10%] ^M[10%] ^M[11%] ^M[12%] ^M[13%] ^M[14%] ^M[15%] ^M[16%]
^M[17%] ^M[18%] ^M[19%] ^M[20%] ^M[20%] ^M[21%] ^M[22%] ^M[23%]
^M[24%] ^M[25%] ^M[26%] ^M[27%] ^M[28%] ^M[29%] ^M[30%]
Is that alright to be so? Maybe there is way to remove those by
setting something?
^ permalink raw reply [flat|nested] 25+ messages in thread
* RE: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 14:52 Any way to remove ^L or ^M from some buffer outputs? Jean Louis
@ 2020-10-04 16:51 ` Drew Adams
2020-10-04 18:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-04 19:41 ` Patrick Mahan
2020-10-05 19:16 ` Nick Dokos
2 siblings, 1 reply; 25+ messages in thread
From: Drew Adams @ 2020-10-04 16:51 UTC (permalink / raw)
To: Jean Louis, help-gnu-emacs
Use `query-replace' (`M-%') or `M-x replace-string'.
When prompted for what to replace, use `C-q' followed by the Control key (char) you want to replace. When prompted for what to replace it with, just hit `RET' (replace it with the empty string).
E.g., to remove Control-M chars:
M-x replace-string RET C-q C-m RET RET
(Using `C-m' is the same as using `RET' - same char. But I write it that way to make it clear that `C-q C-m', which inserts a `C-m' char, is the string of chars to replace.)
If you want to be sure/careful of what you're doing, use `M-%' instead. Once you see that it's doing what you want (by using `y' to replace some occurrences), just hit `!' to replace the rest of the chars.
In both cases, start with the cursor at bob (beginning of buffer), or `point-min' if you want to do it on the narrowed portion the buffer.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 16:51 ` Drew Adams
@ 2020-10-04 18:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 9:06 ` Jean Louis
0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-04 18:41 UTC (permalink / raw)
To: help-gnu-emacs
Drew Adams wrote:
> Use `query-replace' (`M-%') or `M-x replace-string'
But this assumes the buffer is editable ... besides
there should be a command (onee) that toggles the
visibility of that specific kind of representation,
whatever it is called, for _all_ such chars...
And, even if one wishes to do it manually one would
use a regexp, not not query about it, right?
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 18:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-10-05 9:06 ` Jean Louis
2020-10-05 9:43 ` Eli Zaretskii
` (2 more replies)
0 siblings, 3 replies; 25+ messages in thread
From: Jean Louis @ 2020-10-05 9:06 UTC (permalink / raw)
To: help-gnu-emacs
* Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> [2020-10-04 21:42]:
> Drew Adams wrote:
>
> > Use `query-replace' (`M-%') or `M-x replace-string'
>
> But this assumes the buffer is editable ... besides
> there should be a command (onee) that toggles the
> visibility of that specific kind of representation,
> whatever it is called, for _all_ such chars...
It is in read-only buffers, I was just thinking there is option to
remove that as it looks as garbiage.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 9:06 ` Jean Louis
@ 2020-10-05 9:43 ` Eli Zaretskii
2020-10-05 9:47 ` Joost Kremers
2020-10-05 17:06 ` Drew Adams
2 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-10-05 9:43 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Mon, 5 Oct 2020 12:06:44 +0300
> From: Jean Louis <bugs@gnu.support>
>
> > But this assumes the buffer is editable ... besides
> > there should be a command (onee) that toggles the
> > visibility of that specific kind of representation,
> > whatever it is called, for _all_ such chars...
>
> It is in read-only buffers
You can make it writable with "C-x C-q".
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 9:06 ` Jean Louis
2020-10-05 9:43 ` Eli Zaretskii
@ 2020-10-05 9:47 ` Joost Kremers
2020-10-05 12:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 17:06 ` Drew Adams
2 siblings, 1 reply; 25+ messages in thread
From: Joost Kremers @ 2020-10-05 9:47 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
On Mon, Oct 05 2020, Jean Louis wrote:
> It is in read-only buffers, I was just thinking there is option
> to
> remove that as it looks as garbiage.
There is a package that should take care of ^L at least:
https://github.com/purcell/page-break-lines
--
Joost Kremers
Life has its moments
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 9:47 ` Joost Kremers
@ 2020-10-05 12:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-05 12:54 UTC (permalink / raw)
To: help-gnu-emacs
Joost Kremers wrote:
> There is a package that should take care of ^L at least:
What is the deal with them chars, what are they
called, and why do they appear to begin with,
and where?
I know them only from IRC where you can do, with ERC
first
(setq erc-interpret-mirc-color t)
then
$ 08,04 * red army * ( <-- here I use real chars, i.e
M-x insert-char RET 3 RET )
which looks like this
$ ^C08,04 * red army * ^C
only the ^C are in cyan (wierd, `what-face' [1] don't
report any face for them?)
BTW, actually, you don't need the closing char if
there is just one thing to color and that's to the
EOL. but consider:
$ 08,03it\x0302,00al\x0308,04ia
which looks like
$ ^C08,03it^C^C02,00al^C^C08,04ia^C
See this dump for how that looks, the red army one :) [2]
How to use the colors: [3]
Bonus photo: another red machine [4]
[1] https://dataswamp.org/~incal/emacs-init/my-faces.el
[2] https://dataswamp.org/~incal/figures/emacs/red-army.png
[3] https://help.codeux.com/textual/Text-Formatting.kb
[4] https://dataswamp.org/~incal/pimgs/red-machine.png
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 25+ messages in thread
* RE: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 9:06 ` Jean Louis
2020-10-05 9:43 ` Eli Zaretskii
2020-10-05 9:47 ` Joost Kremers
@ 2020-10-05 17:06 ` Drew Adams
2020-10-05 18:14 ` Jean Louis
2 siblings, 1 reply; 25+ messages in thread
From: Drew Adams @ 2020-10-05 17:06 UTC (permalink / raw)
To: Jean Louis, help-gnu-emacs
> > > Use `query-replace' (`M-%') or `M-x replace-string'
> >
> > But this assumes the buffer is editable ... besides
> > there should be a command (onee) that toggles the
> > visibility of that specific kind of representation,
> > whatever it is called, for _all_ such chars...
>
> It is in read-only buffers,
If you want to edit a read-only buffer, toggle it
to writable with `C-x C-q'.
If it's a file buffer and you don't have write
permission for the file, then you likely won't be
able to write the updated buffer back to the file.
But that's a different problem from being able to
edit the buffer.
> I was just thinking there is option to
> remove that as it looks as garbiage.
Garbage/noise is in the eye of the beholder.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 17:06 ` Drew Adams
@ 2020-10-05 18:14 ` Jean Louis
2020-10-05 18:21 ` Eli Zaretskii
0 siblings, 1 reply; 25+ messages in thread
From: Jean Louis @ 2020-10-05 18:14 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs
* Drew Adams <drew.adams@oracle.com> [2020-10-05 20:06]:
> > > > Use `query-replace' (`M-%') or `M-x replace-string'
> > >
> > > But this assumes the buffer is editable ... besides
> > > there should be a command (onee) that toggles the
> > > visibility of that specific kind of representation,
> > > whatever it is called, for _all_ such chars...
> >
> > It is in read-only buffers,
>
> If you want to edit a read-only buffer, toggle it
> to writable with `C-x C-q'.
Those are shell output buffers and similar, and it looks ugly, I was
thinking there is some option to set, to avoid that. Of course I will
not edit it with hand, it is about watching output nicely formatted.
For example instead of ^L to get new line, I do not see new line, so
it just continues.
> If it's a file buffer and you don't have write
> permission for the file, then you likely won't be
> able to write the updated buffer back to the file.
> But that's a different problem from being able to
> edit the buffer.
>
> > I was just thinking there is option to
> > remove that as it looks as garbiage.
>
> Garbage/noise is in the eye of the beholder.
Exactly. So it is not expected output. If I do shell command, there is
expected output that should be similar or same as in the shell, in
Emacs the new lines are not always interpreted correctly.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 18:14 ` Jean Louis
@ 2020-10-05 18:21 ` Eli Zaretskii
2020-10-05 18:23 ` Eli Zaretskii
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-10-05 18:21 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Mon, 5 Oct 2020 21:14:25 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
>
> Those are shell output buffers and similar, and it looks ugly, I was
> thinking there is some option to set, to avoid that. Of course I will
> not edit it with hand, it is about watching output nicely formatted.
If this text comes from the shell, you can make Emacs eliminate the ^M
characters by setting the read part of process-coding-system to *-dos.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 18:21 ` Eli Zaretskii
@ 2020-10-05 18:23 ` Eli Zaretskii
2020-10-05 18:59 ` Yuri Khan
` (2 subsequent siblings)
3 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-10-05 18:23 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Mon, 05 Oct 2020 21:21:57 +0300
> From: Eli Zaretskii <eliz@gnu.org>
>
> If this text comes from the shell, you can make Emacs eliminate the ^M
> characters by setting the read part of process-coding-system to *-dos.
Or maybe *-mac, if the ^M characters appear alone, not before a
newline.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 18:21 ` Eli Zaretskii
2020-10-05 18:23 ` Eli Zaretskii
@ 2020-10-05 18:59 ` Yuri Khan
2020-10-05 19:13 ` Stefan Monnier
2020-10-10 0:23 ` Jean Louis
3 siblings, 0 replies; 25+ messages in thread
From: Yuri Khan @ 2020-10-05 18:59 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
On Tue, 6 Oct 2020 at 01:22, Eli Zaretskii <eliz@gnu.org> wrote:
> > Those are shell output buffers and similar, and it looks ugly, I was
> > thinking there is some option to set, to avoid that. Of course I will
> > not edit it with hand, it is about watching output nicely formatted.
>
> If this text comes from the shell, you can make Emacs eliminate the ^M
> characters by setting the read part of process-coding-system to *-dos.
I believe the issue is not about eliminating the ^M characters as
such. The program is clearly using the CR character to overwrite its
earlier output. Jean probably wants to obtain that effect in an Emacs
shell buffer — seeing only the last string output to a line.
To achieve that, I’d probably try adding a font-lock pattern of .*\r
and fontify it with an invisible face.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 18:21 ` Eli Zaretskii
2020-10-05 18:23 ` Eli Zaretskii
2020-10-05 18:59 ` Yuri Khan
@ 2020-10-05 19:13 ` Stefan Monnier
2020-10-10 0:23 ` Jean Louis
3 siblings, 0 replies; 25+ messages in thread
From: Stefan Monnier @ 2020-10-05 19:13 UTC (permalink / raw)
To: help-gnu-emacs
>> Those are shell output buffers and similar, and it looks ugly, I was
>> thinking there is some option to set, to avoid that. Of course I will
>> not edit it with hand, it is about watching output nicely formatted.
>
> If this text comes from the shell, you can make Emacs eliminate the ^M
> characters by setting the read part of process-coding-system to *-dos.
I think in the OP's case what the users really want is not that but to
treat it like a terminal would (i.e. erasing to BOL).
Stefan
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-05 18:21 ` Eli Zaretskii
` (2 preceding siblings ...)
2020-10-05 19:13 ` Stefan Monnier
@ 2020-10-10 0:23 ` Jean Louis
2020-10-10 7:02 ` Eli Zaretskii
3 siblings, 1 reply; 25+ messages in thread
From: Jean Louis @ 2020-10-10 0:23 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
* Eli Zaretskii <eliz@gnu.org> [2020-10-05 21:23]:
> > Date: Mon, 5 Oct 2020 21:14:25 +0300
> > From: Jean Louis <bugs@gnu.support>
> > Cc: help-gnu-emacs@gnu.org
> >
> > Those are shell output buffers and similar, and it looks ugly, I was
> > thinking there is some option to set, to avoid that. Of course I will
> > not edit it with hand, it is about watching output nicely formatted.
>
> If this text comes from the shell, you can make Emacs eliminate the ^M
> characters by setting the read part of process-coding-system to *-dos.
Do you mean the variable default-process-coding-system ?
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-10 0:23 ` Jean Louis
@ 2020-10-10 7:02 ` Eli Zaretskii
0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2020-10-10 7:02 UTC (permalink / raw)
To: help-gnu-emacs
> Date: Sat, 10 Oct 2020 03:23:02 +0300
> From: Jean Louis <bugs@gnu.support>
> Cc: help-gnu-emacs@gnu.org
>
> * Eli Zaretskii <eliz@gnu.org> [2020-10-05 21:23]:
> > > Date: Mon, 5 Oct 2020 21:14:25 +0300
> > > From: Jean Louis <bugs@gnu.support>
> > > Cc: help-gnu-emacs@gnu.org
> > >
> > > Those are shell output buffers and similar, and it looks ugly, I was
> > > thinking there is some option to set, to avoid that. Of course I will
> > > not edit it with hand, it is about watching output nicely formatted.
> >
> > If this text comes from the shell, you can make Emacs eliminate the ^M
> > characters by setting the read part of process-coding-system to *-dos.
>
> Do you mean the variable default-process-coding-system ?
I'm not sure, because you didn't tell enough details regarding how
this text was received from the shell. In the simplest case, using
"C-x RET c" prefix before invoking the shell command could be a better
solution; no need to change the defaults.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 14:52 Any way to remove ^L or ^M from some buffer outputs? Jean Louis
2020-10-04 16:51 ` Drew Adams
@ 2020-10-04 19:41 ` Patrick Mahan
2020-10-04 19:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 19:16 ` Nick Dokos
2 siblings, 1 reply; 25+ messages in thread
From: Patrick Mahan @ 2020-10-04 19:41 UTC (permalink / raw)
To: Jean Louis; +Cc: help-gnu-emacs
I have a user defined lisp function -
;; If you encounter a file with ^M or ... at the end of every line
;; this gets rid of them by pressing F5.
(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))
Patrick
Emacs addict since 1994
On Sun, Oct 4, 2020 at 7:53 AM Jean Louis <bugs@gnu.support> wrote:
>
> Compiling file /home/data1/protected/Programming/emacs-lisp/rcd-cf.el at
> Sun Oct 4 17:48:33 2020
>
> In cf-sms-exists:
> rcd-cf.el:437:18: Warning: reference to free variable ‘n’ Disable showing
> Disable logging
>
> I am not sure if you can see ^L above, let us say I am compiling or
> having some shell output, then I see often ^L, this may be line feed,
> I do not know, but it looks green here on my side and is often not
> interpreted correctly, line after line, but just as special character
> after which other output lines are shown.
>
> In this case I see Emacs compiling buffer. It seems not necessary to
> be in the buffer like that.
>
> Then in shell buffers, I see something like this below:
>
> Output file:
> /home/data1/protected/Media/Videos/Recordings/2020/10/2020-10-04/2020-10-04-17:51:02.ogv
> ^M[0%] ^M[1%] ^M[2%] ^M[3%] ^M[4%] ^M[5%] ^M[6%] ^M[7%] ^M[8%] ^M[9%]
> ^M[10%] ^M[10%] ^M[11%] ^M[12%] ^M[13%] ^M[14%] ^M[15%] ^M[16%]
> ^M[17%] ^M[18%] ^M[19%] ^M[20%] ^M[20%] ^M[21%] ^M[22%] ^M[23%]
> ^M[24%] ^M[25%] ^M[26%] ^M[27%] ^M[28%] ^M[29%] ^M[30%]
>
> Is that alright to be so? Maybe there is way to remove those by
> setting something?
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 19:41 ` Patrick Mahan
@ 2020-10-04 19:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-04 20:32 ` Patrick Mahan
0 siblings, 1 reply; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-04 19:49 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 19:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-10-04 20:32 ` Patrick Mahan
2020-10-04 22:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
0 siblings, 1 reply; 25+ messages in thread
From: Patrick Mahan @ 2020-10-04 20:32 UTC (permalink / raw)
To: Emanuel Berg, help-gnu-emacs
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
>
>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 20:32 ` Patrick Mahan
@ 2020-10-04 22:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-04 23:26 ` 2QdxY4RzWzUUiLuE
` (3 more replies)
0 siblings, 4 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-04 22:56 UTC (permalink / raw)
To: help-gnu-emacs
Patrick Mahan wrote:
> 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.
Well, you can byte-compile your .emacs as well. It is
just another Elisp file...
Anyway, here (last) is a refined version, if you
don't mind...
I wonder tho... why does (insert-char 13) insert ^M
but M-x insert-char 13 RET inserts ^S?
(defun delete-c-m (&optional beg end)
(interactive (if (use-region-p)
(list (region-beginning) (region-end))
(list (point-min) (point-max)) ))
(save-excursion
(goto-char beg)
(while (search-forward "\r" end t)
(replace-match "" nil t) )
(set-buffer-modified-p nil) ; can be user or omitted...
))
;; (insert-char 13)
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 22:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-10-04 23:26 ` 2QdxY4RzWzUUiLuE
2020-10-04 23:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 3:57 ` Emanuel Berg via Users list for the GNU Emacs text editor
` (2 subsequent siblings)
3 siblings, 1 reply; 25+ messages in thread
From: 2QdxY4RzWzUUiLuE @ 2020-10-04 23:26 UTC (permalink / raw)
To: help-gnu-emacs
On 2020-10-05 at 00:56:05 +0200,
Emanuel Berg via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:
> I wonder tho... why does (insert-char 13) insert ^M
> but M-x insert-char 13 RET inserts ^S?
Interactively, insert-char takes a *hex* value.
13 (hex) is 19 (decimal), which is Control-S.
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 22:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-04 23:26 ` 2QdxY4RzWzUUiLuE
@ 2020-10-05 3:57 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 7:29 ` tomas
2020-10-05 18:44 ` Nick Dokos
3 siblings, 0 replies; 25+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2020-10-05 3:57 UTC (permalink / raw)
To: help-gnu-emacs
> (defun delete-c-m (&optional beg end)
> (interactive (if (use-region-p)
> (list (region-beginning) (region-end))
> (list (point-min) (point-max)) ))
> (save-excursion
> (goto-char beg)
> (while (search-forward "\r" end t)
> (replace-match "" nil t) )
> (set-buffer-modified-p nil) ; can be used or omitted...
> ))
BTW `search-forward' has a formally incorrect
docstring in
GNU Emacs 26.1 (build 2, x86_64-pc-linux-gnu) of
2019-09-23, modified by Debian
that way "bounds" won't get font locked with
`help-argument-name' (it should be BOUNDs, or
reformulated: "An optional second argument bounds the
search" - ... and optimally the word appears as the
argument is and nothing else, right? but regardless
of whatever, please just upcase it so one can see it
instantly, and I'm happy :))
--
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 22:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-04 23:26 ` 2QdxY4RzWzUUiLuE
2020-10-05 3:57 ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2020-10-05 7:29 ` tomas
2020-10-05 18:44 ` Nick Dokos
3 siblings, 0 replies; 25+ messages in thread
From: tomas @ 2020-10-05 7:29 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]
On Mon, Oct 05, 2020 at 12:56:05AM +0200, Emanuel Berg via Users list for the GNU Emacs text editor wrote:
> Patrick Mahan wrote:
>
> > 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.
>
> Well, you can byte-compile your .emacs as well. It is
> just another Elisp file...
>
> Anyway, here (last) is a refined version, if you
> don't mind...
>
> I wonder tho... why does (insert-char 13) insert ^M
> but M-x insert-char 13 RET inserts ^S?
Because the interactive version (your second above) tries to be
helpful and interprets the 13 as hex, whereas the non-interactive
is plain lisp, and there 13 is decimal 13, as it always has been.
To be fair, the interactive version has told you, in the prompt.
But who reads prompts these days? ;-D
(Not intended by any means as a slur at anyone: I've been caught
doing that more than once!)
Cheers
- t
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 22:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
` (2 preceding siblings ...)
2020-10-05 7:29 ` tomas
@ 2020-10-05 18:44 ` Nick Dokos
3 siblings, 0 replies; 25+ messages in thread
From: Nick Dokos @ 2020-10-05 18:44 UTC (permalink / raw)
To: help-gnu-emacs
When you do M-x insert-char RET, you get a prompt that says:
Insert character (Unicode name or hex):
So you need to enter D to get decimal 13.
--
Nick
"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: Any way to remove ^L or ^M from some buffer outputs?
2020-10-04 14:52 Any way to remove ^L or ^M from some buffer outputs? Jean Louis
2020-10-04 16:51 ` Drew Adams
2020-10-04 19:41 ` Patrick Mahan
@ 2020-10-05 19:16 ` Nick Dokos
2 siblings, 0 replies; 25+ messages in thread
From: Nick Dokos @ 2020-10-05 19:16 UTC (permalink / raw)
To: help-gnu-emacs
Jean Louis <bugs@gnu.support> writes:
> \f
> Compiling file /home/data1/protected/Programming/emacs-lisp/rcd-cf.el at Sun Oct 4 17:48:33 2020
>
> In cf-sms-exists:
> rcd-cf.el:437:18: Warning: reference to free variable ‘n’ Disable showing
> Disable logging
>
> I am not sure if you can see ^L above, let us say I am compiling or
> having some shell output, then I see often ^L, this may be line feed,
> I do not know, but it looks green here on my side and is often not
> interpreted correctly, line after line, but just as special character
> after which other output lines are shown.
#+BEGIN_ANCIENT_HISTORY
It is a "form-feed" - in the olden days, the line printer program would output
one of these at the end of a job (although programs could do that as well) in
order to line up the output of the next program with the perforations in the
continuous-feed paper.
Terminals sometimes used it to clear the screen. And it is still used e.g. when
you define file-local variables in emacs:
#+begin_quote
If some unrelated text might look to Emacs as a local variables list,
you can countermand that by inserting a form-feed character (a page
delimiter, *note Pages::) after that text. Emacs only looks for
file-local variables in the last page of a file, after the last page
delimiter.
#+end_quote
>
> In this case I see Emacs compiling buffer. It seems not necessary to
> be in the buffer like that.
>
> Then in shell buffers, I see something like this below:
>
> Output file: /home/data1/protected/Media/Videos/Recordings/2020/10/2020-10-04/2020-10-04-17:51:02.ogv
> ^M[0%] ^M[1%] ^M[2%] ^M[3%] ^M[4%] ^M[5%] ^M[6%] ^M[7%] ^M[8%] ^M[9%]
> ^M[10%] ^M[10%] ^M[11%] ^M[12%] ^M[13%] ^M[14%] ^M[15%] ^M[16%]
> ^M[17%] ^M[18%] ^M[19%] ^M[20%] ^M[20%] ^M[21%] ^M[22%] ^M[23%]
> ^M[24%] ^M[25%] ^M[26%] ^M[27%] ^M[28%] ^M[29%] ^M[30%]
>
> Is that alright to be so? Maybe there is way to remove those by
> setting something?
>
>
This is the output of a program that implements a poor man's version
of a progress meter: ^M is a carriage return (CR) which moves the
typewriter head to the beginning of the current line (it is then
usually - but not in this case - followed by a line feed in order to
allow you to type on the next line - I believe Windows text files
still have a CR/LF combination marking the end of each line in the
file).
By prepending a CR on each output, the next output overwrites the
previous value, showing you the progress of the task.
But it only works on typewrites, teletypes, terminals and terminal
emulators that implement these operations exactly. A shell in emacs
does not do that and prefers to output everything more-or-less verbatim.
#END_ANCIENT_HISTORY
We now return you to the 21st century...
--
Nick
"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2020-10-10 7:02 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-04 14:52 Any way to remove ^L or ^M from some buffer outputs? Jean Louis
2020-10-04 16:51 ` Drew Adams
2020-10-04 18:41 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 9:06 ` Jean Louis
2020-10-05 9:43 ` Eli Zaretskii
2020-10-05 9:47 ` Joost Kremers
2020-10-05 12:54 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 17:06 ` Drew Adams
2020-10-05 18:14 ` Jean Louis
2020-10-05 18:21 ` Eli Zaretskii
2020-10-05 18:23 ` Eli Zaretskii
2020-10-05 18:59 ` Yuri Khan
2020-10-05 19:13 ` Stefan Monnier
2020-10-10 0:23 ` Jean Louis
2020-10-10 7:02 ` Eli Zaretskii
2020-10-04 19:41 ` Patrick Mahan
2020-10-04 19:49 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-04 20:32 ` Patrick Mahan
2020-10-04 22:56 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-04 23:26 ` 2QdxY4RzWzUUiLuE
2020-10-04 23:43 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 3:57 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-10-05 7:29 ` tomas
2020-10-05 18:44 ` Nick Dokos
2020-10-05 19:16 ` Nick Dokos
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).