diff --git a/ChangeLog b/ChangeLog
index 876d63afde222268125a4759daeb190cfb4ea56d..10e5bd396b6f4c73d2ef784bf91041a44184f5be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 	* src/global.c (shortcut_init): Add default keybindings for Cut,
 	PrevWord and NextWord in the prompt input lines; the code for those
 	special operations already exists, just the shortcuts were missing.
+	* src/rcfile.c (parse_binding): When binding keys, only allow those
+	menus where the bound function is actually present.  This reduces
+	the meaning of 'all' to "all menus where the function exists".
+	* src/rcfile.c (is_universal): New function, returning TRUE for the
+	functions that are present in most menus but only listed in MMAIN.
 
 2014-06-25  Benno Schulenberg  <bensberg@justemail.net>
 	* src/browser.c (do_browser): Allow 'firstfile' and 'lastfile' to be
diff --git a/src/rcfile.c b/src/rcfile.c
index 4ffd7ed44aca42e8bd87834e2ae05adb9397e73e..041c1cbcf5c67c2de9137b88fa11f8df16114e00 100644
--- a/src/rcfile.c
+++ b/src/rcfile.c
@@ -397,6 +397,22 @@ int check_bad_binding(sc *s)
     return 0;
 }
 
+/* Check whether the given executable function is "universal" (meaning
+ * any horizontal movement or deletion) and thus is present in almost
+ * all menus. */
+bool is_universal(void (*func))
+{
+    if (func == do_left || func == do_right ||
+	func == do_home || func == do_end ||
+	func == do_prev_word_void || func == do_next_word_void ||
+	func == do_verbatim_input || func == do_cut_text_void ||
+	func == do_delete || func == do_backspace ||
+	func == do_tab || func == do_enter)
+	return TRUE;
+    else
+	return FALSE;
+}
+
 /* Bind or unbind a key combo, to or from a function. */
 void parse_binding(char *ptr, bool dobind)
 {
@@ -487,6 +503,26 @@ void parse_binding(char *ptr, bool dobind)
 #endif
 
     if (dobind) {
+	subnfunc *f;
+	int mask = 0;
+
+	/* Tally up the menus where the function exists. */
+	for (f = allfuncs; f != NULL; f = f->next)
+	    if (f->scfunc == newsc->scfunc)
+		mask = mask | f->menus;
+
+	/* Now limit the given menu to those where the function exists. */
+	if (is_universal(newsc->scfunc))
+	    menu = menu & MMOST;
+	else
+	    menu = menu & mask;
+
+	if (!menu) {
+	    rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
+	    free(newsc);
+	    return;
+	}
+
 	newsc->keystr = keycopy;
 	newsc->menu = menu;
 	newsc->type = strtokeytype(newsc->keystr);