9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: umbraticus@prosimetrum.com
To: 9fans@9fans.net
Subject: Re: [9fans] Deleting lines in sam - d
Date: Thu, 12 May 2022 07:22:45 +1200	[thread overview]
Message-ID: <476022036E2F79108FF992088E604799@prosimetrum.com> (raw)
In-Reply-To: <16522963000.08D5B.40230@composer.9fans.topicbox.com>

= 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

  reply	other threads:[~2022-05-11 19:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-11 19:11 revcomninos
2022-05-11 19:22 ` umbraticus [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=476022036E2F79108FF992088E604799@prosimetrum.com \
    --to=umbraticus@prosimetrum.com \
    --cc=9fans@9fans.net \
    --subject='Re: [9fans] Deleting lines in sam - d' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).