# NOTE: Best I can tell you need to open Treeview at least once and make sure
# it's authorized. Otherwise it just returns a 404, even though the URL is
# valid.
#
# You'll need to add `exts=/path/to/texapp-treeview.pm` to your .texapprc or
# call Texapp with `texapp -exts=/path/to/texapp-treeview.pm`.
#
# From a running Texapp instance, call with /tree [menucode]
#
$addaction = sub {
	my $command = shift;

	return 0 unless ($command =~ s#^/tree ## && length($command));

	my $post = &get_post($command);
	my $canonical_id = $post->{'id'};
	unless ($canonical_id) {
		&std(" -- sorry, no such post (yet?): $command\n");
		return 1;
	}

	# I use the following command, because I call an external script with
	# urlopen in .texapprc:
	#
	# system "xdg-open", "http://treeview.us/home/Form?postID=$canonical_id";
	#
	# You'll probably want this:
	&openurl("http://treeview.us/home/Form?postID=$canonical_id");
	return 1;
};

# NOTE: Best I can tell you need to open Treeview at least once and make sure
# it's authorized. Otherwise it just returns a 404, even though the URL is
# valid.
#
# You'll need to add `exts=/path/to/texapp-treeview.pm` to your .texapprc or
# call Texapp with `texapp -exts=/path/to/texapp-treeview.pm`.
#
# From a running Texapp instance, call with /tree [menucode]
#
$addaction = sub {
	my $command = shift;

	return 0 unless ($command =~ s#^/tree ## && length($command));

	my $canonical_id = &get_post($command)->{'id'};
	unless ($canonical_id) {
		&std(" -- sorry, no such post (yet?): $command\n");
		return 1;
	}

	# I use the following command, because I call an external script with
	# urlopen in .texapprc:
	#
	# system "xdg-open", "http://treeview.us/home/Form?postID=$canonical_id";
	#
	# You'll probably want this:
	&openurl("http://treeview.us/home/Form?postID=$canonical_id");
	return 1;
};

Replace variable with direct expression
Replace variable with direct expression

get_post is named clearly enough that it doesn't need to be assigned to
an explaining variable.

Omitting the variable means there's one less name in scope during the
rest of the function, which makes it simpler to read. There's no more
waiting for the other shoe to drop - "when will we see $post again?"
