* [9fans] Deleting lines in sam - d
@ 2022-05-11 19:11 revcomninos
2022-05-11 19:22 ` umbraticus
0 siblings, 1 reply; 6+ messages in thread
From: revcomninos @ 2022-05-11 19:11 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 448 bytes --]
In ed one can show line numbers using n. To delete line nubers is thus easy. In sam - d it appears this is not possible. I understand sam is not a line editor. What the would be the best way to delete a range of lines?
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-M54374be671082c4e329d2aeb
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 940 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] Deleting lines in sam - d
2022-05-11 19:11 [9fans] Deleting lines in sam - d revcomninos
@ 2022-05-11 19:22 ` umbraticus
2022-05-11 20:26 ` revcomninos
0 siblings, 1 reply; 6+ messages in thread
From: umbraticus @ 2022-05-11 19:22 UTC (permalink / raw)
To: 9fans
= prints line number
3,7d deletes some lines
Setting and working with the mark may also suit your problem
find a place, press k, find another place, then ',.d or .,' deletes
everything in between. Multiple marks à la ed would be a nice
addition to sam.
umbraticus
P.S. Here's a patch to make = more sensible (ie. plumbable):
--- a/sys/man/1/sam Wed Apr 27 19:24:07 2022
+++ b/sys/man/1/sam Sat Apr 16 02:53:35 2022
@@ -403,10 +403,10 @@
Set dot.
.TP
.B =
-Print the line address and character address of the range.
+Print the file name and line address of the range.
.TP
.B =#
-Print just the character address of the range.
+Print the file name and character address of the range.
.PD
.SS File commands
.PD 0
--- a/sys/src/cmd/sam/sam.c Wed Apr 27 19:24:07 2022
+++ b/sys/src/cmd/sam/sam.c Sat Apr 16 02:53:35 2022
@@ -688,11 +688,27 @@
}
void
-printposn(File *f, int charsonly)
+printposn(File *f, int chars)
{
Posn l1, l2;
+ char *s;
- if(!charsonly){
+ if(f->name.s[0]){
+ if(f->name.s[0]!='/'){
+ getcurwd();
+ s = Strtoc(&curwd);
+ dprint("%s", s);
+ free(s);
+ }
+ s = Strtoc(&f->name);
+ dprint("%s:", s);
+ free(s);
+ }
+ if(chars){
+ dprint("#%lud", addr.r.p1);
+ if(addr.r.p2 != addr.r.p1)
+ dprint(",#%lud", addr.r.p2);
+ }else{
l1 = 1+nlcount(f, (Posn)0, addr.r.p1);
l2 = l1+nlcount(f, addr.r.p1, addr.r.p2);
/* check if addr ends with '\n' */
@@ -701,11 +717,7 @@
dprint("%lud", l1);
if(l2 != l1)
dprint(",%lud", l2);
- dprint("; ");
}
- dprint("#%lud", addr.r.p1);
- if(addr.r.p2 != addr.r.p1)
- dprint(",#%lud", addr.r.p2);
dprint("\n");
}
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-M738ed39a9ebb9a95372a4aad
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] Deleting lines in sam - d
2022-05-11 19:22 ` umbraticus
@ 2022-05-11 20:26 ` revcomninos
2022-05-12 5:54 ` Chris Fröschl
2022-05-12 10:00 ` revcomninos
0 siblings, 2 replies; 6+ messages in thread
From: revcomninos @ 2022-05-11 20:26 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 430 bytes --]
Many thanks. I will apply your solutions and revert back. It just seems a little counter intuitive not to be able to show the line numbers as ed does,especially if one is viewing a large body of text.
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-M2a8d78f0b893ede1f6ec5cb3
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 922 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] Deleting lines in sam - d
2022-05-11 20:26 ` revcomninos
@ 2022-05-12 5:54 ` Chris Fröschl
2022-05-12 6:41 ` umbraticus
2022-05-12 10:00 ` revcomninos
1 sibling, 1 reply; 6+ messages in thread
From: Chris Fröschl @ 2022-05-12 5:54 UTC (permalink / raw)
To: 9fans
revcomninos@gmail.com wrote:
> Many thanks. I will apply your solutions and revert back. It just seems a little counter intuitive not to be able to show the line numbers as ed does,especially if one is viewing a large body of text.
You can also try:
unix: ,>nl
plan9: ,x {
p
} (or write your own nl)
That might do it for larger bodies. Although you have to prepare a
more dedicated script for a clean nl approach.
I like that sam doesn't offer that feature (especially because it
doesn't really need it). It makes you think more about your environment
scripts and how to use/prepare the utilities inside the sam env.
I'm always trying to prepare some sam specific shell/rc scripts and
get my 'missing' features that way. I would appreciate a more clean
nl solution if anyone got something to offer.
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-Madd47ff7eed5de28fbce700a
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] Deleting lines in sam - d
2022-05-12 5:54 ` Chris Fröschl
@ 2022-05-12 6:41 ` umbraticus
0 siblings, 0 replies; 6+ messages in thread
From: umbraticus @ 2022-05-12 6:41 UTC (permalink / raw)
To: 9fans
I mean, if you really want it, you can
,|awk '{print NR "\t" $0}'
then
,x/^[0-9]+ /d
or something.
umbraticus
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-Mf73fea5ddae7354548491a99
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] Deleting lines in sam - d
2022-05-11 20:26 ` revcomninos
2022-05-12 5:54 ` Chris Fröschl
@ 2022-05-12 10:00 ` revcomninos
1 sibling, 0 replies; 6+ messages in thread
From: revcomninos @ 2022-05-12 10:00 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 431 bytes --]
I have applied the script and the suggestions are fantastic. For the kind of work I am doing now, having the numbers helps me a lot, although I do also understand the point Christ is making. Many thanks!
------------------------------------------
9fans: 9fans
Permalink: https://9fans.topicbox.com/groups/9fans/Tc5c492077a61275c-M66ddefc2515608e8640fc173
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription
[-- Attachment #2: Type: text/html, Size: 919 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-05-12 10:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 19:11 [9fans] Deleting lines in sam - d revcomninos
2022-05-11 19:22 ` umbraticus
2022-05-11 20:26 ` revcomninos
2022-05-12 5:54 ` Chris Fröschl
2022-05-12 6:41 ` umbraticus
2022-05-12 10:00 ` revcomninos
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 NNTP newsgroup(s).