Re: ed(1) man page doesn't mention use of single / and ?

2019-07-15 Thread Ingo Schwarze
Hi Ian,

ropers wrote on Sun, Jul 07, 2019 at 12:28:37AM +0200:

> And no, don't ask me how much of my weekend I wasted figuring out how
> to suppress mandoc's insistence upon two spaces after the 'i.e.' just
> because there's a period at the end of a line.

Ouch, sorry about that.

Actually, it's not a mandoc(1) thing, the behaviour was inherited
from groff.

But indeed, it doesn't appear to be explained in the mandoc
documentation, even though it's a somewhat common trap for the
unwary.  It was a typical case of someone too familiar with the
subject missing an aspect that needs to be explained.  Ironically,
so far, it was only explained in the groff_man(7) manual page, in
the "Zero-width space" list entry.  Obviously, no one should have
to read that manual page.

So, i committed the following fix.  The place where this is explained
in detail (including an example) is roff(7) because this is really
a roff thing and not specific to manual pages.  Then again, since
the page people are advised to study foremost is mdoc(7), i also
put a hint there.  It fits well enough below "Delimiters" because
this detail is really an example of a delimiter in need of escaping.

Thanks for the report,
  Ingo


Log Message:
---
explain escaping of end-of-sentence characters;
missing info reported by Ian  on misc@

Modified Files:
--
mandoc:
mdoc.7
roff.7

Revision Data
-
Index: roff.7
===
RCS file: /home/cvs/mandoc/mandoc/roff.7,v
retrieving revision 1.113
retrieving revision 1.114
diff -Lroff.7 -Lroff.7 -u -p -r1.113 -r1.114
--- roff.7
+++ roff.7
@@ -315,12 +315,18 @@ delimiters
 The proper spacing is also intelligently preserved if a sentence ends at
 the boundary of a macro line.
 .Pp
+If an input line happens to end with a period, exclamation or question
+mark that isn't the end of a sentence, append a zero-width space
+.Pq Sq \e& .
+.Pp
 Examples:
 .Bd -literal -offset indent -compact
 Do not end sentences mid-line like this.  Instead,
 end a sentence like this.
 A macro would end like this:
 \&.Xr mandoc 1 \&.
+An abbreviation at the end of an input line needs escaping, e.g.\e&
+like this.
 .Ed
 .Sh REQUEST SYNTAX
 A request or macro line consists of:
Index: mdoc.7
===
RCS file: /home/cvs/mandoc/mandoc/mdoc.7,v
retrieving revision 1.278
retrieving revision 1.279
diff -Lmdoc.7 -Lmdoc.7 -u -p -r1.278 -r1.279
--- mdoc.7
+++ mdoc.7
@@ -3005,6 +3005,13 @@ in the same way as a plain
 .Sq \&|
 character.
 Using this predefined string is not recommended in new manuals.
+.Pp
+Appending a zero-width space
+.Pq Sq \e&
+to the end of an input line is also useful to prevent the interpretation
+of a trailing period, exclamation or question mark as the end of a
+sentence, for example when an abbreviation happens to occur
+at the end of a text or macro input line.
 .Ss Font handling
 In
 .Nm



Re: ed(1) man page doesn't mention use of single / and ?

2019-07-15 Thread Ingo Schwarze
Hi,

mazoc...@disroot.org wrote on Wed, Jul 03, 2019 at 07:21:53AM +0300:

> I am not good at explaining something shortly and clearly to fit into
> proper documentation, so I'll just describe my experience here.

Well, sending patches - even such patches as may not be perfect yet
but require some tweaking - is often better than a bare bug report
because a patch *plus* an explanation often explains a problem more
clearly than the report alone, but when you feel unable to write a
patch, a bare report is OK as well.

> Terminating regular expressions with / or ? is necessary only if they
> are followed by commands, otherwise the following are legal in both
> OpenBSD ed, Plan 9 ed and GNU ed:
> /something
> /
> ?
> g/ing

The cases of addresses and the 's' command have already been fixed
earlier.  The v and V commands need no change, and i just committed
the following fix for the g and G commands.

We are still considering more improvements in the vicinity, but i
believe the particular issue you reported is now fully repaired.
If you think it is not, please simply speak up again!

Thanks,
  Ingo



CVSROOT:/cvs
Module name:src
Changes by: schwa...@cvs.openbsd.org2019/07/15 11:57:48

Modified files:
bin/ed : ed.1 

Log message:
Explain in which circumstances trailing slashes can be omitted after
the g and G commands, and polish the wording a bit explaining empty
command lists.
Closing a gap in the manual reported by .
OK jmc@ martijn@


Index: ed.1
===
RCS file: /cvs/src/bin/ed/ed.1,v
retrieving revision 1.72
diff -u -r1.72 ed.1
--- ed.112 Jul 2019 19:28:48 -  1.72
+++ ed.115 Jul 2019 17:56:37 -
@@ -392,14 +392,20 @@
 .Ic v ,
 and
 .Ic V .
-A newline alone in command-list is equivalent to a
+An empty
+.Ar command-list
+is equivalent to a
 .Ic p
 command.
+In this case, the trailing slash can be omitted.
 .Sm off
 .It (1,$) Ic G No / Ar re No /
 .Sm on
 Interactively edits the addressed lines matching a regular expression
 .Ar re .
+The trailing slash after
+.Ar re
+can be omitted.
 For each matching line, the line is printed, the current address is set,
 and the user is prompted to enter a
 .Ar command-list .
@@ -415,11 +421,10 @@
 .Ar command-list
 is the same as that of the
 .Ic g
-command.
-A newline alone acts as a null command list.
+command, but an empty command list does nothing.
 A single
 .Sq &
-repeats the last non-null command list.
+repeats the last non-empty command list.
 .It Ic H
 Toggles the printing of error explanations.
 By default, explanations are not printed.



Re: ed(1) man page doesn't mention use of single / and ?

2019-07-06 Thread chohag
ropers writes:
> Okay, so since nobody else appears to be making any pertinent noise, I
> guess it falls to me:
>
> Index: ed.1
> ===
> RCS file: /cvs/src/bin/ed/ed.1,v
> retrieving revision 1.70
> diff -u -r1.70 ed.1
> --- ed.1  26 Apr 2018 12:18:54 -  1.70
> +++ ed.1  6 Jul 2019 21:20:15 -
> @@ -269,6 +269,9 @@
>  current line, if necessary.
>  .Qq //
>  repeats the last search.
> +The second slash is optional for a bare search without any suffixed
> command, i.e.\&
> +.Qq / Ns Ar re
> +is sufficient when followed by a newline.
>  .It Pf ? Ar re ?
>  The previous line containing the regular expression
>  .Ar re .
> @@ -276,6 +279,9 @@
>  current line, if necessary.
>  .Qq ??
>  repeats the last search.
> +The second question mark is optional for a bare search without any
> suffixed command, i.e.\&
> +.Ns Qq ? Ns Ar re
> +is sufficient when followed by a newline.
>  .It \&' Ns Ar lc
>  The line previously marked by a
>  .Ic k
>
> Questions? Comments? Complaints? Secondary trade sanctions?

Better to be thorough, if this is to be done. The final slash in a substitution 
is also unnecessary and ed reacts differently depending whether or not it's 
included. I expect it's the same for the other commands with delimited options.

Matthew



Re: ed(1) man page doesn't mention use of single / and ?

2019-07-06 Thread ropers
Second thought, maybe the 'i.e.'s should be changed to 'e.g.'s,
because '/' and '?' also work (instead of '//' and '??',
respectively), so '/re' and '?re' are indeed only examples.

Or maybe this is overdoing it. I don't know. Whatever you all think is
best and most correct. I have no strong personal opinion on this. I'm
just trying to respond to mazocomp's reasonable observation and
suggestion.

Ian

On 07/07/2019, ropers  wrote:
> mazocomp opined:
>> Hi!
>>
>> I am not good at explaining something shortly and clearly to fit into
>> proper documentation, so I'll just describe my experience here.
>>
>> Terminating regular expressions with / or ? is necessary only if they
>> are followed by commands, otherwise the following are legal in both
>> OpenBSD ed, Plan 9 ed and GNU ed:
>> /something
>> /
>> ?
>> g/ing
>>
>> I hope I made life of many ed users easier :)
>
>
>> On Thu, Jul 04, 2019 at 11:47:50PM +0200, ropers wrote:
>>> Do I understand correctly that this is in reference to these parts of
>>> man
>>> 1 ed:
>>>
>>> > /re/
>>> >The next line containing the regular expression re. The search
>>> > wraps
>>> > to the beginning of the buffer and continues down to the current line,
>>> > if necessary. ???//??? repeats the last search.
>>>
>>> > ?re?
>>> >The previous line containing the regular expression re. The search
>>> > wraps to the end of the buffer and continues up to the current line,
>>> > if
>>> > necessary.  repeats the last search.
>>>
>>> and:
>>>
>>> > (1,$)g/re/command-list
>>> >Applies command-list to each of the addressed lines matching a
>>> > regular expression re. The current address is set to the line
>>> > currently
>>> > matched before command-list is executed. At the end of the g command,
>>> > the current address is set to the last line affected by command-list.
>>> > If
>>> > no lines were matched, the current line number remains unchanged.
>>> >
>>> >Each command in command-list must be on a separate line, and every
>>> > line except for the last must be terminated by a backslash (???\???).
>>> > Any commands are allowed, except for g, G, v, and V. A newline alone
>>> > in
>>> > command-list is equivalent to a p command.
>>>
>>>
>>> If yes, then the corresponding parts of ed.1 are:
>>>
>>> 
>>>
>>> and:
>>>
>>> 
>>>
>>> I'm not actually sure how to rewrite that. Would this call for
>>> separate /re, ?re and (1,$)g/re entries, or would it suffice to say
>>> that the second question mark or slash can be omitted if immediately
>>> followed by a newline?
>>>
>>> Does anyone else have any ideas?
>>>
>>> NB: In case people haven't seen it, here's an excellent ed(1)
>>> tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
>>> I just thought I'd mention that.
>
>
> Mohamed proffered:
>> To add to Ian's reference. "Ed Mastery" is the only book I know
>> specific to ed(1).
>>
>> Mo
>
>
> Jason McIntyre expounded:
>>
>> hi.
>>
>> if we were going to document it, i'd say it definitely wouldn;t warrant
>> adding separate entries. it would be enough to describe when the / or ?
>> were optional.
>>
>> neither freebsd nor netbsd seemingly document this.
>>
>> posix documents it for /re/ and ?re?, but not g/RE/command-list, like
>> this:
>>
>>  In addition, the second  can be omitted at the end of a
>>  command line.
>>
>> without having tested any of this, i guess we'd want to add such a note
>> to /re/ and ?re?, but not g/RE/command-list. something along the lines
>> of:
>>
>>  The second slash is optional when followed by a newline.
>>
>> you could ping a diff to tech, and see if anyone has any input that
>> could help. if no one does, i'll take it.
>
>
> Okay, so since nobody else appears to be making any pertinent noise, I
> guess it falls to me:
>
> Index: ed.1
> ===
> RCS file: /cvs/src/bin/ed/ed.1,v
> retrieving revision 1.70
> diff -u -r1.70 ed.1
> --- ed.1  26 Apr 2018 12:18:54 -  1.70
> +++ ed.1  6 Jul 2019 21:20:15 -
> @@ -269,6 +269,9 @@
>  current line, if necessary.
>  .Qq //
>  repeats the last search.
> +The second slash is optional for a bare search without any suffixed
> command, i.e.\&
> +.Qq / Ns Ar re
> +is sufficient when followed by a newline.
>  .It Pf ? Ar re ?
>  The previous line containing the regular expression
>  .Ar re .
> @@ -276,6 +279,9 @@
>  current line, if necessary.
>  .Qq ??
>  repeats the last search.
> +The second question mark is optional for a bare search without any
> suffixed command, i.e.\&
> +.Ns Qq ? Ns Ar re
> +is sufficient when followed by a newline.
>  .It \&' Ns Ar lc
>  The line previously marked by a
>  .Ic k
>
> Questions? Comments? Complaints? Secondary trade sanctions?
>
> And no, don't ask me how much of my weekend I wasted figuring out how
> to suppress mandoc's insistence upon two spaces after the 'i.e.' just
> because there's a period at the end of a line. Because 

Re: ed(1) man page doesn't mention use of single / and ?

2019-07-06 Thread ropers
mazocomp opined:
> Hi!
>
> I am not good at explaining something shortly and clearly to fit into
> proper documentation, so I'll just describe my experience here.
>
> Terminating regular expressions with / or ? is necessary only if they
> are followed by commands, otherwise the following are legal in both
> OpenBSD ed, Plan 9 ed and GNU ed:
> /something
> /
> ?
> g/ing
>
> I hope I made life of many ed users easier :)


> On Thu, Jul 04, 2019 at 11:47:50PM +0200, ropers wrote:
>> Do I understand correctly that this is in reference to these parts of man
>> 1 ed:
>>
>> > /re/
>> >The next line containing the regular expression re. The search wraps
>> > to the beginning of the buffer and continues down to the current line,
>> > if necessary. ???//??? repeats the last search.
>>
>> > ?re?
>> >The previous line containing the regular expression re. The search
>> > wraps to the end of the buffer and continues up to the current line, if
>> > necessary.  repeats the last search.
>>
>> and:
>>
>> > (1,$)g/re/command-list
>> >Applies command-list to each of the addressed lines matching a
>> > regular expression re. The current address is set to the line currently
>> > matched before command-list is executed. At the end of the g command,
>> > the current address is set to the last line affected by command-list. If
>> > no lines were matched, the current line number remains unchanged.
>> >
>> >Each command in command-list must be on a separate line, and every
>> > line except for the last must be terminated by a backslash (???\???).
>> > Any commands are allowed, except for g, G, v, and V. A newline alone in
>> > command-list is equivalent to a p command.
>>
>>
>> If yes, then the corresponding parts of ed.1 are:
>>
>> 
>>
>> and:
>>
>> 
>>
>> I'm not actually sure how to rewrite that. Would this call for
>> separate /re, ?re and (1,$)g/re entries, or would it suffice to say
>> that the second question mark or slash can be omitted if immediately
>> followed by a newline?
>>
>> Does anyone else have any ideas?
>>
>> NB: In case people haven't seen it, here's an excellent ed(1)
>> tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
>> I just thought I'd mention that.


Mohamed proffered:
> To add to Ian's reference. "Ed Mastery" is the only book I know
> specific to ed(1).
>
> Mo


Jason McIntyre expounded:
>
> hi.
>
> if we were going to document it, i'd say it definitely wouldn;t warrant
> adding separate entries. it would be enough to describe when the / or ?
> were optional.
>
> neither freebsd nor netbsd seemingly document this.
>
> posix documents it for /re/ and ?re?, but not g/RE/command-list, like
> this:
>
>   In addition, the second  can be omitted at the end of a
>   command line.
>
> without having tested any of this, i guess we'd want to add such a note
> to /re/ and ?re?, but not g/RE/command-list. something along the lines
> of:
>
>   The second slash is optional when followed by a newline.
>
> you could ping a diff to tech, and see if anyone has any input that
> could help. if no one does, i'll take it.


Okay, so since nobody else appears to be making any pertinent noise, I
guess it falls to me:

Index: ed.1
===
RCS file: /cvs/src/bin/ed/ed.1,v
retrieving revision 1.70
diff -u -r1.70 ed.1
--- ed.126 Apr 2018 12:18:54 -  1.70
+++ ed.16 Jul 2019 21:20:15 -
@@ -269,6 +269,9 @@
 current line, if necessary.
 .Qq //
 repeats the last search.
+The second slash is optional for a bare search without any suffixed
command, i.e.\&
+.Qq / Ns Ar re
+is sufficient when followed by a newline.
 .It Pf ? Ar re ?
 The previous line containing the regular expression
 .Ar re .
@@ -276,6 +279,9 @@
 current line, if necessary.
 .Qq ??
 repeats the last search.
+The second question mark is optional for a bare search without any
suffixed command, i.e.\&
+.Ns Qq ? Ns Ar re
+is sufficient when followed by a newline.
 .It \&' Ns Ar lc
 The line previously marked by a
 .Ic k

Questions? Comments? Complaints? Secondary trade sanctions?

And no, don't ask me how much of my weekend I wasted figuring out how
to suppress mandoc's insistence upon two spaces after the 'i.e.' just
because there's a period at the end of a line. Because 

Re: ed(1) man page doesn't mention use of single / and ?

2019-07-05 Thread Vincent Waciuk
Wonderful is perhaps too strong, but I chuckled many times while reading it.



Re: ed(1) man page doesn't mention use of single / and ?

2019-07-05 Thread Mohamed Fouad
I wouldn't say it is particularly wonderful but it is whats out there!
However, Michael W. Lucas(the author) do have awesome books.

On Fri, Jul 5, 2019 at 8:26 PM Vincent Waciuk 
wrote:

> Ed Mastery is a wonderful read. Highly recommended.
>


Re: ed(1) man page doesn't mention use of single / and ?

2019-07-05 Thread Vincent Waciuk
Ed Mastery is a wonderful read. Highly recommended.



Re: ed(1) man page doesn't mention use of single / and ?

2019-07-05 Thread Jason McIntyre
On Thu, Jul 04, 2019 at 11:47:50PM +0200, ropers wrote:
> Do I understand correctly that this is in reference to these parts of man 1 
> ed:
> 
> > /re/
> >The next line containing the regular expression re. The search wraps to 
> > the beginning of the buffer and continues down to the current line, if 
> > necessary. ???//??? repeats the last search.
> 
> > ?re?
> >The previous line containing the regular expression re. The search wraps 
> > to the end of the buffer and continues up to the current line, if 
> > necessary.  repeats the last search.
> 
> and:
> 
> > (1,$)g/re/command-list
> >Applies command-list to each of the addressed lines matching a regular 
> > expression re. The current address is set to the line currently matched 
> > before command-list is executed. At the end of the g command, the current 
> > address is set to the last line affected by command-list. If no lines were 
> > matched, the current line number remains unchanged.
> >
> >Each command in command-list must be on a separate line, and every line 
> > except for the last must be terminated by a backslash (???\???). Any 
> > commands are allowed, except for g, G, v, and V. A newline alone in 
> > command-list is equivalent to a p command.
> 
> 
> If yes, then the corresponding parts of ed.1 are:
> 
> .It / Ns Ar re Ns /
> The next line containing the regular expression
> .Ar re .
> The search wraps to the beginning of the buffer and continues down to the
> current line, if necessary.
> .Qq //
> repeats the last search.
> .It Pf ? Ar re ?
> The previous line containing the regular expression
> .Ar re .
> The search wraps to the end of the buffer and continues up to the
> current line, if necessary.
> .Qq ??
> repeats the last search.
> 
> and:
> 
> .It Xo
> .Pf (1,$) Ic g No /
> .Ar re No / Ar command-list
> .Xc
> .Sm on
> Applies
> .Ar command-list
> to each of the addressed lines matching a regular expression
> .Ar re .
> The current address is set to the line currently matched before
> command-list is executed.
> At the end of the
> .Ic g
> command, the current address is set to the last line affected by command-list.
> If no lines were matched,
> the current line number remains unchanged.
> .Pp
> Each command in
> .Ar command-list
> must be on a separate line,
> and every line except for the last must be terminated by a backslash
> .Pq Sq \e .
> Any commands are allowed, except for
> .Ic g ,
> .Ic G ,
> .Ic v ,
> and
> .Ic V .
> A newline alone in command-list is equivalent to a
> .Ic p
> command.
> .Sm off
> 
> I'm not actually sure how to rewrite that. Would this call for
> separate /re, ?re and (1,$)g/re entries, or would it suffice to say
> that the second question mark or slash can be omitted if immediately
> followed by a newline?
> 
> Does anyone else have any ideas?
> 
> NB: In case people haven't seen it, here's an excellent ed(1)
> tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
> I just thought I'd mention that.
> 
> Ian
> 

hi.

if we were going to document it, i'd say it definitely wouldn;t warrant
adding separate entries. it would be enough to describe when the / or ?
were optional.

neither freebsd nor netbsd seemingly document this.

posix documents it for /re/ and ?re?, but not g/RE/command-list, like
this:

In addition, the second  can be omitted at the end of a
command line.

without having tested any of this, i guess we'd want to add such a note
to /re/ and ?re?, but not g/RE/command-list. something along the lines
of:

The second slash is optional when followed by a newline.

you could ping a diff to tech, and see if anyone has any input that
could help. if no one does, i'll take it.

jmc



Re: ed(1) man page doesn't mention use of single / and ?

2019-07-04 Thread Mohamed Fouad
To add to Ian's reference. "Ed Mastery" is the only book I know specific to
ed(1).

Mo

On Thu, 4 Jul 2019, 6:54 pm ropers  Do I understand correctly that this is in reference to these parts of man
> 1 ed:
>
> > /re/
> >The next line containing the regular expression re. The search wraps
> to the beginning of the buffer and continues down to the current line, if
> necessary. “//” repeats the last search.
>
> > ?re?
> >The previous line containing the regular expression re. The search
> wraps to the end of the buffer and continues up to the current line, if
> necessary. “??” repeats the last search.
>
> and:
>
> > (1,$)g/re/command-list
> >Applies command-list to each of the addressed lines matching a
> regular expression re. The current address is set to the line currently
> matched before command-list is executed. At the end of the g command, the
> current address is set to the last line affected by command-list. If no
> lines were matched, the current line number remains unchanged.
> >
> >Each command in command-list must be on a separate line, and every
> line except for the last must be terminated by a backslash (‘\’). Any
> commands are allowed, except for g, G, v, and V. A newline alone in
> command-list is equivalent to a p command.
>
>
> If yes, then the corresponding parts of ed.1 are:
>
> .It / Ns Ar re Ns /
> The next line containing the regular expression
> .Ar re .
> The search wraps to the beginning of the buffer and continues down to the
> current line, if necessary.
> .Qq //
> repeats the last search.
> .It Pf ? Ar re ?
> The previous line containing the regular expression
> .Ar re .
> The search wraps to the end of the buffer and continues up to the
> current line, if necessary.
> .Qq ??
> repeats the last search.
>
> and:
>
> .It Xo
> .Pf (1,$) Ic g No /
> .Ar re No / Ar command-list
> .Xc
> .Sm on
> Applies
> .Ar command-list
> to each of the addressed lines matching a regular expression
> .Ar re .
> The current address is set to the line currently matched before
> command-list is executed.
> At the end of the
> .Ic g
> command, the current address is set to the last line affected by
> command-list.
> If no lines were matched,
> the current line number remains unchanged.
> .Pp
> Each command in
> .Ar command-list
> must be on a separate line,
> and every line except for the last must be terminated by a backslash
> .Pq Sq \e .
> Any commands are allowed, except for
> .Ic g ,
> .Ic G ,
> .Ic v ,
> and
> .Ic V .
> A newline alone in command-list is equivalent to a
> .Ic p
> command.
> .Sm off
>
> I'm not actually sure how to rewrite that. Would this call for
> separate /re, ?re and (1,$)g/re entries, or would it suffice to say
> that the second question mark or slash can be omitted if immediately
> followed by a newline?
>
> Does anyone else have any ideas?
>
> NB: In case people haven't seen it, here's an excellent ed(1)
> tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
> I just thought I'd mention that.
>
> Ian
>
> On 03/07/2019, mazoc...@disroot.org  wrote:
> > Hi!
> >
> > I am not good at explaining something shortly and clearly to fit into
> > proper documentation, so I'll just describe my experience here.
> >
> > Terminating regular expressions with / or ? is necessary only if they
> > are followed by commands, otherwise the following are legal in both
> > OpenBSD ed, Plan 9 ed and GNU ed:
> > /something
> > /
> > ?
> > g/ing
> >
> > I hope I made life of many ed users easier :)
> >
> >
>
>


Re: ed(1) man page doesn't mention use of single / and ?

2019-07-04 Thread ropers
Do I understand correctly that this is in reference to these parts of man 1 ed:

> /re/
>The next line containing the regular expression re. The search wraps to 
> the beginning of the buffer and continues down to the current line, if 
> necessary. “//” repeats the last search.

> ?re?
>The previous line containing the regular expression re. The search wraps 
> to the end of the buffer and continues up to the current line, if necessary. 
> “??” repeats the last search.

and:

> (1,$)g/re/command-list
>Applies command-list to each of the addressed lines matching a regular 
> expression re. The current address is set to the line currently matched 
> before command-list is executed. At the end of the g command, the current 
> address is set to the last line affected by command-list. If no lines were 
> matched, the current line number remains unchanged.
>
>Each command in command-list must be on a separate line, and every line 
> except for the last must be terminated by a backslash (‘\’). Any commands are 
> allowed, except for g, G, v, and V. A newline alone in command-list is 
> equivalent to a p command.


If yes, then the corresponding parts of ed.1 are:

.It / Ns Ar re Ns /
The next line containing the regular expression
.Ar re .
The search wraps to the beginning of the buffer and continues down to the
current line, if necessary.
.Qq //
repeats the last search.
.It Pf ? Ar re ?
The previous line containing the regular expression
.Ar re .
The search wraps to the end of the buffer and continues up to the
current line, if necessary.
.Qq ??
repeats the last search.

and:

.It Xo
.Pf (1,$) Ic g No /
.Ar re No / Ar command-list
.Xc
.Sm on
Applies
.Ar command-list
to each of the addressed lines matching a regular expression
.Ar re .
The current address is set to the line currently matched before
command-list is executed.
At the end of the
.Ic g
command, the current address is set to the last line affected by command-list.
If no lines were matched,
the current line number remains unchanged.
.Pp
Each command in
.Ar command-list
must be on a separate line,
and every line except for the last must be terminated by a backslash
.Pq Sq \e .
Any commands are allowed, except for
.Ic g ,
.Ic G ,
.Ic v ,
and
.Ic V .
A newline alone in command-list is equivalent to a
.Ic p
command.
.Sm off

I'm not actually sure how to rewrite that. Would this call for
separate /re, ?re and (1,$)g/re entries, or would it suffice to say
that the second question mark or slash can be omitted if immediately
followed by a newline?

Does anyone else have any ideas?

NB: In case people haven't seen it, here's an excellent ed(1)
tutorial: https://sanctum.geek.nz/arabesque/actually-using-ed/
I just thought I'd mention that.

Ian

On 03/07/2019, mazoc...@disroot.org  wrote:
> Hi!
>
> I am not good at explaining something shortly and clearly to fit into
> proper documentation, so I'll just describe my experience here.
>
> Terminating regular expressions with / or ? is necessary only if they
> are followed by commands, otherwise the following are legal in both
> OpenBSD ed, Plan 9 ed and GNU ed:
> /something
> /
> ?
> g/ing
>
> I hope I made life of many ed users easier :)
>
>



ed(1) man page doesn't mention use of single / and ?

2019-07-02 Thread mazocomp
Hi!

I am not good at explaining something shortly and clearly to fit into
proper documentation, so I'll just describe my experience here.

Terminating regular expressions with / or ? is necessary only if they
are followed by commands, otherwise the following are legal in both
OpenBSD ed, Plan 9 ed and GNU ed:
/something
/
?
g/ing

I hope I made life of many ed users easier :)