9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Akshat Kumar <akumar@mail.nanosouffle.net>
To: 9fans@9fans.net
Subject: [9fans] Les Misérables
Date: Fri, 16 Jan 2009 17:07:14 -0800	[thread overview]
Message-ID: <4e6ca2050901161707v6cf45421x76a01638059f8e50@mail.gmail.com> (raw)

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

Certain applications have been blessed with 9fans' ignorance for too long.
dict(7) and friends seemed to be becoming over-joyous.

For those interested in Japanese on Plan 9, I provide here (edict2.tar) scripts
to convert Jim Breen's extended Japanese dictionary, EDICT2, to a format
usable with dict(7). However, the simple.c format was not appealing to me,
so I decided to use the format Andrey proposed for converting DICTD
dictionaries, thus, a patch[1] to dict(7), and the appropriate indexing
application[2], are necessary in order to perform the conversion and
use the resulting dictionary (the path to the indexing app
must be specified in leginx.rc).

Parts of adict, the Acme interface to dict(7), still presume some incapabilities
of Acme that are no longer present. One I've found is the assumption that
Acme tags cannot contain non-alphanumeric characters, so adict goes through
the trouble of converting all such characters to underscores.
The simple fix:
comment lines
  /acme/bin/source/adict/adict.c:288 through /acme/bin/source/adict/adict.c:294
-- by the way, the source distributed with Plan 9 by default is not what the
binary adict was built from; updated sources (though still lacking the
above change)
are in /n/sources/patch/applied/adict-fix2

However, I find Russ Cox's idea of making Acme interfaces entirely
scriptable, even
more appealing. For that, his acmeevent[3] from P9P is entirely
portable to native
Plan 9 -- no changes required. I believe the prime example he's used is a
scripted version of adict, also available in P9P -- for this, I've made a few
changes to the script for use on native Plan 9; see nadict.rc.


by the way, has anyone looked into the venti problem Oleg F. posted about,
on my behalf, earlier this month?
ak


[1] http://mirtchovski.com/p9/dict/dict.patch.tgz
[2] http://mirtchovski.com/p9/dict/mkdictd.c

[3] http://swtch.com/usr/local/plan9/src/cmd/acmeevent.c

[-- Attachment #2: edict2.tar --]
[-- Type: application/x-tar, Size: 10240 bytes --]

[-- Attachment #3: nadict.rc --]
[-- Type: application/octet-stream, Size: 2120 bytes --]

#!/bin/rc

fn newwindow {
	winctl=`{read /mnt/acme/new/ctl}
	winid=$winctl(1)
	winctl noscroll
}

fn winctl {	
	echo $* > /mnt/acme/$winid/ctl
}

fn winread {
	cat /mnt/acme/$winid/$1
}

fn winwrite {
	cat > /mnt/acme/$winid/$1
}

fn windump {
	if(! ~ $1 - '')
		winctl dumpdir $1
	if(! ~ $2 - '')
		winctl dump $2
}

fn winname {
	winctl name $1
}

fn wintag {
	winctl tag $1
}

fn winwriteevent {
	echo $1$2$3 $4 | winwrite event
}

fn windel {
	if(~ $1 sure)
		winctl delete
	if not
		winctl del
}

fn wineventloop {
	. <{winread event >[2]/dev/null | acmeevent}
}

fn event {
	# $1 - c1 origin of event
	# $2 - c2 type of action
	# $3 - q0 beginning of selection
	# $4 - q1 end of selection
	# $5 - eq0 beginning of expanded selection
	# $6 - eq1 end of expanded selection
	# $7 - flag
	# $8 - nr number of runes in $9
	# $9 - text
	# $10 - chorded argument
	# $11 - origin of chorded argument

	switch($1$2){
	case E*	# write to body or tag
	case F*	# generated by ourselves; ignore
	case K*	# type away we do not care
	case Mi	# mouse: text inserted in tag
	case MI	# mouse: text inserted in body
	case Md	# mouse: text deleted from tag
	case MD	# mouse: text deleted from body

	case Mx MX	# button 2 in tag or body
		winwriteevent $*

	case Ml ML	# button 3 in tag or body
		{
			if(~ $dict NONE)
				dictwin /nadict/$9/ $9
			if not				
				dictwin /nadict/$dict/$9 $dict $9
		} &
	}
}

fn dictwin {
	newwindow
	winname $1
	switch($#*){
	case 1
		dict -d '?' >[2=1] | sed 1d | winwrite body
	case 2
		dict=$2
	case 3
		dict=$2
		dict -d $dict $3 >[2=1] | winwrite body
	}
	winctl clean
	wineventloop
}

dict=NONE
if(~ $1 -d){
	shift
	dict=$1
	shift
}
if(~ $1 -d*){
	dict=`{echo $1 | sed 's/-d//'}
	shift
}
if(~ $1 -*){
	echo 'usage: adict [-d dict] [word...]' >[1=2]
	exit usage
}

switch($#*){
case 0
	if(~ $dict NONE)
		dictwin /nadict/
	if not
		dictwin /nadict/$dict/ $dict
case *
	if(~ $dict NONE){
		dict=`{dict -d'?' | sed -n 's/^   ([^\[ 	]+).*/\1/p' | sed 1q}
		if(~ $#dict 0){
			echo 'no dictionaries present on this system' >[1=2]
			exit nodict
		}
	}
	for(i)
		dictwin /nadict/$dict/$i $dict $i
}

             reply	other threads:[~2009-01-17  1:07 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-17  1:07 Akshat Kumar [this message]
2009-01-18  2:04 ` Akshat Kumar
2009-01-18 11:14   ` Uriel
2009-01-18 14:28     ` erik quanstrom
2009-01-18 18:12       ` Steve Simon
2009-01-18 19:41       ` hiro
2009-01-19  9:26         ` Akshat Kumar
2009-01-18 20:16       ` LiteStar numnums
2009-01-18 21:53         ` Charles Forsyth
2009-01-18 21:50           ` LiteStar numnums
2009-01-18 22:26             ` erik quanstrom
2009-01-18 23:37               ` LiteStar numnums
2009-01-18 23:52                 ` erik quanstrom
2009-01-19  0:19                   ` LiteStar numnums
2009-01-18 11:39   ` hiro
2009-01-17  1:14 Akshat Kumar
2009-01-17  1:17 ` erik quanstrom
2009-01-17 14:36   ` Eris Discordia
2009-01-19  6:53 [9fans] Les Mis?rables jimmy brisson
2009-01-19  8:31 ` Eris Discordia
2009-01-19  9:45 ` Akshat Kumar
2009-01-19 13:39   ` erik quanstrom
2009-01-19 16:25 ` ron minnich
2009-01-19 16:43   ` erik quanstrom
2009-01-19 17:39 jimmy brisson
2009-01-19 20:05 ` Steve Simon
2009-01-19 20:27 ` Akshat Kumar
2009-02-25  4:00 ` Enrico Weigelt
2009-02-25 19:45   ` jimmy brisson
2009-02-25 20:40     ` Enrico Weigelt
2009-02-25 22:45       ` jimmy brisson

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=4e6ca2050901161707v6cf45421x76a01638059f8e50@mail.gmail.com \
    --to=akumar@mail.nanosouffle.net \
    --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).