9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: 6o205zd02@sneakemail.com
To: 9fans@9fans.net
Subject: Re: [9fans] com: comments toggle in acme
Date: Thu, 15 Nov 2012 20:16:44 -0800	[thread overview]
Message-ID: <12284-1353039400-461956@sneakemail.com> (raw)
In-Reply-To: <CA+BaOWxu0dTDpj7AnoqkGUyf7zgx1mFjaT_qe5+VSmQ+=KRfTA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]

Nice.  Thanks.

BTW, I know what fmt is, but what do a- and a+ do?

On 11/13/2012 3:13 PM, Jacek Masiulaniec jacekm-at-dobremiasto.net
|9fans| wrote:
> My latest addition to the acme column tag, alongside |a-, |a+, and |fmt.
>
> #!/usr/bin/env rc
>
> fn f {
> n=$1
> if(! cat $f | cut -c1-$n | 9 grep -v '^[ ]+$' >/dev/null){
> x=`{f `{expr $n + 1}}
> echo '.'$"x
> }
> }
>
> f=/tmp/com.$pid
> cat >$f
>
> switch($%){
> case *.go *.c
> c='//'
> case *
> c='#'
> }
>
> # Remove comment?
> if(cat $f | 9 grep '^[ ]*'$c' ' >/dev/null){
> cat $f | 9 sed 's|'$c' ||'
> rm $f
> exit
> }
>
> # Add comment.
> s=`{f 1}
> if(~ $#s 0)
> cat $f | 9 sed 's|^|'$c' |'
> if not
> cat $f | 9 sed 's|^('$"s')|\1'$c' |'
>
> rm $f
>
> I name this |com. The original motivation was to avoid manual keying
> in of the comment characters, which I found myself doing quite
> frequently for short line ranges.
>
> It also works well with Go's "imported and not used" error. Once
> plumbed to the offending import line, it only takes one click to
> temporarily disable an import.


[-- Attachment #2: Type: text/html, Size: 3389 bytes --]

  reply	other threads:[~2012-11-16  4:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13 23:13 Jacek Masiulaniec
2012-11-16  4:16 ` 6o205zd02 [this message]
2012-11-16  8:15   ` Martin Kühl
2012-11-16  9:55 ` Mark van Atten

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=12284-1353039400-461956@sneakemail.com \
    --to=6o205zd02@sneakemail.com \
    --cc=9fans@9fans.net \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).