summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Noll <maan@tuebingen.mpg.de>2026-02-25 22:33:54 +0100
committerAndre Noll <maan@tuebingen.mpg.de>2026-03-17 19:25:05 +0100
commit353c4cd671005dd75bbef6fef4e71a138ba5c170 (patch)
tree26890257f6003806b01ee5be031b3c933b786b28
parente279a5b71c2d8f3e9ec0efd6c291381f36170512 (diff)
com_ls(): Make ls --admissible=- work.
We support "-" as the argument to the select subcommand as a shortcut for the name of the previously loaded mood or playlist. However, ls --admissible=- fails. This is inconsistent, so patch the ls subcommand to support this as well. Since the name of the previous mood or playlist is currently only known to afs.c, we have to declare previous_mop in afs.h and make it non-static in afs.c. Do the same with current_mop for consistency.
-rw-r--r--afs.c2
-rw-r--r--afs.h5
-rw-r--r--aft.c9
3 files changed, 14 insertions, 2 deletions
diff --git a/afs.c b/afs.c
index f73c48fb..8a26794c 100644
--- a/afs.c
+++ b/afs.c
@@ -84,7 +84,7 @@ static int server_socket;
static struct command_task command_task_struct;
static struct signal_task *signal_task;
-static char *current_mop, *previous_mop; /* NULL means dummy mood */
+char *current_mop, *previous_mop; /* NULL means dummy mood */
extern uint32_t afs_socket_cookie;
diff --git a/afs.h b/afs.h
index b5456d8a..003f7345 100644
--- a/afs.h
+++ b/afs.h
@@ -308,6 +308,11 @@ extern enum selector_id current_selector_id, previous_selector_id;
extern const struct selector_operations *selector_ops[NUM_SELECTORS];
/** The mood or playlist currently active. */
extern struct selector_instance *current_selector_instance;
+/** Name of the current mood or playlist, including the {m,p}/ prefix. */
+extern char *current_mop;
+/** Name of the previous mood or playlist. */
+extern char *previous_mop;
+
/**
* Get the selector operations of the current mood or playlist.
*
diff --git a/aft.c b/aft.c
index 84fe40a3..b0766339 100644
--- a/aft.c
+++ b/aft.c
@@ -1308,7 +1308,14 @@ static int mop_loop(const char *arg, struct afs_callback_arg *aca,
return 0;
return current_selector()->loop(si, prepare_ls_row, opts);
}
- if (!strncmp(arg, "m/", 2))
+ if (!strcmp(arg, "-")) { /* load previous mop */
+ ops = selector_ops[previous_selector_id];
+ if (!previous_mop) {
+ afs_error(aca, "no previous mood/playlist\n");
+ return -ERRNO_TO_PARA_ERROR(EINVAL);
+ }
+ arg = previous_mop;
+ } else if (!strncmp(arg, "m/", 2))
ops = selector_ops[SEL_MOOD];
else if (!strncmp(arg, "p/", 2))
ops = selector_ops[SEL_PLAYLIST];