Index: src/sclj
===================================================================
--- src/sclj	(revision 2)
+++ src/sclj	(revision 8)
@@ -90,7 +90,7 @@
 ##########################################################
 # Default values {{{2
 
-$VERSION = '3.2';
+$VERSION = '3.3';
 
 $DOTDIR = '';
 $EVENT_EXT = '.html';
@@ -266,13 +266,17 @@
 	my ($success, $msg, @dirlist);
 
 	@dirlist = SCLJ::IO::DirList(1, "accounts");
-	$entries = $#dirlist + 1;
+	$entries = scalar @dirlist;
 
 	if($entries == 0 && $rc->{'rcless'} != 1) {
 		print "No accounts found; falling back to rc-less mode.\n";
 		$rc->{'rcless'} = 1;
 	}
 
+	if($entries > 0 && $rc->{'rcless'} == 0) {
+		$rc->{'accts'} = \@dirlist; # Save account list for later reference
+	}
+
 	if($rc->{'rcless'} == 1) {
 		OpenPost($postr);
 	} elsif($entries == 1) {
@@ -457,7 +461,7 @@
 			'cmd' => 'Account',
 			'args' => "\\\$p->{'post'}->{'acct'}, \\\$p->{'post'}->{'picture'}, " .
 				"\\\$p->{'post'}->{'journal'}, \\\$p->{'post'}->{'allowmask'}, " .
-				"\\\$p->{'post'}->{'security'}",
+				"\\\$p->{'post'}->{'security'}, \$p->{'rc'}->{'accts'}",
 			'desc' => <<ENDDESC
 "account foo" sets the account to foo. An account tells what username,
 password, and server to use. Journal and picture will be set to the default,
@@ -552,18 +556,22 @@
 		},
 		'list' => { # {{{4
 			'cmd' => 'List',
-			'args' => "{ 'moods' => \$p->{'post'}->{'acct'}->{'serv'}->{'moods'}, ".
+			'args' => "{ " .
+					"'accounts' => \$p->{'rc'}->{'accts'}, " .
 					"'groups' => \$p->{'post'}->{'acct'}->{'frgrps'}, " .
 					"'journals' => \$p->{'post'}->{'acct'}->{'journals'}, " .
+					"'moods' => \$p->{'post'}->{'acct'}->{'serv'}->{'moods'}, ".
 					"'pictures' => \$p->{'post'}->{'acct'}->{'pics'} " .
 				"}",
 			'desc' => <<ENDDESC
-Lists various bits of information about the account. "list moods" shows the
-moods that have icons, "list groups" shows the friend groups, "list journals"
-shows the available journals, and "list pictures" shows the pictures. Any of
-these may be followed by prefixes to show only items beginning with those
-prefixes. For example, "list moods m n" will show only moods beginning with m
-and n. Everything completes, so "li mo m n" would be equivalent.
+Lists various bits of information about the account. "list accounts" shows the
+accounts that have been set up, "list groups" shows the available friend
+groups for custom security, "list journals" shows the available journals,
+"list moods" shows the moods that have icons, and "list pictures" shows the
+pictures. Any of these may be followed by prefixes to show only items
+beginning with those prefixes. For example, "list moods m n" will show only
+moods beginning with m and n. Everything completes, so "li mo m n" would be
+equivalent.
 ENDDESC
 		},
 		'login' => { # {{{4
@@ -693,6 +701,15 @@
 remove the subject from the entry.
 ENDDESC
 		},
+		'tags' => { # {{{4
+			'cmd' => 'Tags',
+			'args' => "\\\$p->{'post'}->{'tags'}",
+			'desc' => <<ENDDESC
+"tags foo, bar, baz" attaches the three tags "foo", "bar", and "baz" to this
+entry. Tags cannot contain any commas themselves. sclj doesn't have any fancy
+support, it just sends them verbatim.
+ENDDESC
+		},
 		'time' => { # {{{4
 			'cmd' => 'Time',
 			'args' => "\\\$p->{'post'}->{'time'}",
@@ -829,6 +846,8 @@
 
 	print "Subject: $post->{'subject'}\n"; # {{{4
 
+	print "Tags: $post->{'tags'}\n"; # {{{4
+
 	print "Mood: $post->{'moodtxt'}"; # {{{4
 	if($post->{'moodid'}) { print " (with icon)"; }
 	print "\n";
@@ -995,6 +1014,14 @@
 	return GenericText(@args);
 }
 
+# Set tags {{{3
+sub Tags {
+	my (@args) = @_;
+
+	push(@args, "Tags");
+	return GenericText(@args);
+}
+
 # Set a generic boolean field {{{3
 sub GenericBoolean {
 	my ($fieldref, $arg, $default) = @_;
@@ -1082,16 +1109,16 @@
 
 # Change the current account {{{3
 sub Account {
-	my ($acctref, $picref, $journalref, $maskref, $secref, $arg) = @_;
+	my ($acctref, $picref, $journalref, $maskref, $secref, $acctsref, $arg) =
+		@_;
 	my ($acctname, @accts, $newacct, $msg, $code, $fakepost);
 
-	# opendir/readdir to get a list of accounts, then closedir
-	@accts = SCLJ::IO::DirList(1, "accounts");
-
 	# GenericList to select one of them
 	$acctname = $$acctref->{'alias'};
-	#GenericList($fieldref, $fieldarr, $arg, $desc, $defstr);
-	$code = GenericList(\$acctname, \@accts, $arg);
+	if(!defined $arg) { # Force GenericList to list completions on empty arg
+		$arg = '';
+	}
+	$code = GenericList(\$acctname, $acctsref, $arg);
 
 	# steal the response to actually get+set the account and server info
 	if(exists $code->{'OK'} && $code->{'OK'} == 1) {
@@ -2242,7 +2269,7 @@
 	$post{'comments'} = $post{'emails'} = 1;
 	$post{'backdate'} = $post{'moodid'} = $post{'allowmask'} = 0;
 	$post{'journal'} = $post{'picture'} = $post{'subject'} = $post{'music'} =
-		$post{'moodtxt'} = $post{'screen'} = '';
+		$post{'moodtxt'} = $post{'screen'} = $post{'tags'} = '';
 	$post{'date'} = [ () ];
 	$post{'time'} = [ () ];
 	$post{'event'} = [ () ];
@@ -2500,6 +2527,11 @@
 		$webvars{"subject"} = $post->{"subject"};
 	}
 
+	# Set the tags {{{3
+	if(length($post->{"tags"}) > 0) {
+		$webvars{"prop_taglist"} = $post->{"tags"};
+	}
+
 	# Set the security level {{{3
 	if(length($post->{"security"}) == 0 || $post->{"security"} eq 'public') {
 		$webvars{"security"} = 'public';
Index: Changes
===================================================================
--- Changes	(revision 2)
+++ Changes	(revision 8)
@@ -7,9 +7,13 @@
 Original code (up to 1.0.1) was written by Brad Fitzpatrick and
 placed in the public domain.
 
-Versions 2.0 - 3.2 were written by C. A. Daelhousen and are licensed
+Versions 2.0 - 3.3 were written by C. A. Daelhousen and are licensed
 under the GNU GPL. See the file 'README' for details.
 
+3.3:
+  * 'list accounts' support
+  * 'accounts' with no arguments tries to do something sensible
+  * tags support (New LJ feature)
 3.2:
   * 'auth' command added (New LJ feature)
   * editor setting splits words, handling quotes and spaces
Index: Documentation/changes-3.3
===================================================================
--- Documentation/changes-3.3	(revision 0)
+++ Documentation/changes-3.3	(revision 8)
@@ -0,0 +1,39 @@
+ABSTRACT
+========
+
+	This file documents changes made between 3.2 and 3.3.
+
+
+
+CONTENTS
+========
+
+1. "Account" command handling improved
+2. "Tags" command added
+
+
+
+1. "ACCOUNT" COMMAND HANDLING IMPROVED
+======================================
+
+	A bug was discovered by dennisthetiger, where typing "ac" would return
+that '~/.sclj3/accounts' does not look like a sclj3 data file. (Which it's not:
+it's a directory.) The account command now attempts to do account name
+completion in this situation.
+
+	In addition, "list accounts" was added to enable listing the available
+accounts.
+
+
+
+2. "TAGS" COMMAND ADDED
+=======================
+
+	The "tags" command accepts a comma-separated list of tags to place on
+the entry. There is no way to have a tag with a comma in it in the LJ protocol
+itself, so this restriction is inherited by sclj. As usual, "tags" with no
+arguments clears the tag list.
+
+	The current tags appear in the "values" output immediately below
+Subject.
+
