diff --git a/src/gmnlm.c b/src/gmnlm.c
index f1a856cd58092ba29c9e766370f790b1240970f2..1cf43002f036e4987d82837c7b6ca6cb61c08061 100644
--- a/src/gmnlm.c
+++ b/src/gmnlm.c
@@ -94,7 +94,7 @@ "b[N]\t\tJump back N entries in history (N is optional, default 1)\n"
"f[N]\t\tJump forward N entries in history (N is optional, default 1)\n"
"u\t\tNavigate one path element up\n"
"H\t\tView all page history\n"
- "m\t\tSave bookmark\n"
+ "m [title]\t\tSave bookmark\n"
"M\t\tBrowse bookmarks\n"
"k\t\tRemove bookmark for current page\n"
"r\t\tReload the page\n"
@@ -174,7 +174,7 @@ return in;
}
static void
-save_bookmark(struct browser *browser)
+save_bookmark(struct browser *browser, const char *title)
{
char *path_fmt = get_data_pathfmt();
static char path[PATH_MAX+1];
@@ -196,11 +196,6 @@ if (!f) {
fprintf(stderr, "Error opening %s for writing: %s\n",
path, strerror(errno));
return;
- }
-
- char *title = browser->page_title;
- if (title) {
- title = trim_ws(browser->page_title);
}
fprintf(f, "=> %s%s%s\n", browser->plain_url,
@@ -712,8 +707,9 @@ }
result = PROMPT_AGAIN;
goto exit;
case 'm':
- if (in[1]) break;
- save_bookmark(browser);
+ if (in[1] != '\0' && !isspace(in[1])) break;
+ char *title = in[1] ? &in[1] : browser->page_title;
+ save_bookmark(browser, trim_ws(title));
result = PROMPT_AGAIN;
goto exit;
case 'k':