diff --git a/ChangeLog b/ChangeLog
index 8ef02d077cd2802cf2092d51288dffa4a5a61f61..9120f79e4f787ab7361be60693d859174dfe106d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
 2008-05-31 Chris Allegretta <chrisa@asty.org>
-	* prompt.c: Tentative fix for bug #23144: using arrow keys in 
-	  search buffer affects main window (by Mike Frysinger)
+	* prompt.c,search.c,global.c: Tentative fix for bug #23144: using arrow 
+	  keys in search buffer affects main window (by Mike Frysinger)
 
 2008-05-31 Chris Allegretta <chrisa@asty.org>
 	* global.c: Fix for Savannah bug #23442: left/right arrow keys 
diff --git a/src/global.c b/src/global.c
index 9896a3251abc63a87e689b020f9f751e656d2f8b..3e10886d278983aeff6603f85e5d197bcf6b8904 100644
--- a/src/global.c
+++ b/src/global.c
@@ -1064,15 +1064,21 @@ void shortcut_init(bool unjustify)
     add_to_sclist(MALL, "kleft", do_left, 0, TRUE);
     add_to_sclist(MMAIN, "^Q", xon_complaint, 0, TRUE);
     add_to_sclist(MMAIN, "^S", xoff_complaint, 0, TRUE);
-    add_to_sclist(MALL, "^P", do_up_void, 0, TRUE);
-    add_to_sclist(MALL, "kup", do_up_void, 0, TRUE);
-    add_to_sclist(MALL, "^N", do_down_void, 0, TRUE);
-    add_to_sclist(MALL, "kdown", do_down_void, 0, TRUE);
+    add_to_sclist(MMAIN, "^P", do_up_void, 0, TRUE);
+    add_to_sclist(MMAIN, "kup", do_up_void, 0, TRUE);
+    add_to_sclist(MMAIN, "^N", do_down_void, 0, TRUE);
+    add_to_sclist(MMAIN, "kdown", do_down_void, 0, TRUE);
     add_to_sclist(MALL, "^A", do_home, 0, TRUE);
     add_to_sclist(MALL, "khome", do_home, 0, TRUE);
     add_to_sclist(MALL, "^E", do_end, 0, TRUE);
     add_to_sclist(MALL, "kend", do_end, 0, TRUE);
 #ifndef DISABLE_JUSTIFY
+#ifndef NANO_TINY
+    add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^P", (void *) prev_history_msg, 0, FALSE);
+    add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kup", (void *) prev_history_msg, 0, FALSE);
+    add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "^N", (void *) next_history_msg, 0, FALSE);
+    add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2|MWHEREISFILE, "kdown", (void *) next_history_msg, 0, FALSE);
+#endif
     add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
 	"^W", do_para_begin_void, 0, TRUE);
     add_to_sclist(MWHEREIS|MREPLACE|MREPLACE2,
diff --git a/src/prompt.c b/src/prompt.c
index 67f978ddc6461701c656cdcfd61564fd3ea247d2..30ee75ef20b12c907e9f9a416c01e84d0ec6c429 100644
--- a/src/prompt.c
+++ b/src/prompt.c
@@ -1010,7 +1010,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
 	} else 
 #endif /* !DISABLE_TABCOMP */
 #ifndef NANO_TINY
-	if (s && s->scfunc == do_up_void) {
+	if (s && s->scfunc == (void *) prev_history_msg) {
 		if (history_list != NULL) {
 		    /* If we're scrolling up at the bottom of the
 		     * history list and answer isn't blank, save answer
@@ -1038,7 +1038,7 @@ fprintf(stderr, "get_prompt_string: answer = \"%s\", statusbar_x = %d\n", answer
 		     * statusbar prompt. */
 		    finished = FALSE;
 		}
-	} else if (s && s->scfunc == do_down_void) {
+	} else if (s && s->scfunc == (void *) next_history_msg) {
 		if (history_list != NULL) {
 		    /* Get the newer search from the history list and
 		     * save it in answer.  If there is no newer search,
diff --git a/src/proto.h b/src/proto.h
index 3ed75aab139baf01dcc3e56f4001a0b55cbdce0f..c349c36dda8843ac53db76b4b9ab90df765d39c8 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -788,6 +788,8 @@ const char *cancel_msg;
 #ifndef NANO_TINY
 const char *case_sens_msg;
 const char *backwards_msg;
+const char *prev_history_msg;
+const char *next_history_msg;
 #endif
 const char *replace_msg;
 const char *no_replace_msg;
diff --git a/src/search.c b/src/search.c
index f050e2b8aec14563bd271cd3db241fa52ab77ebf..cee7ac1f44c0f7b0aec27f4d017afd155781d7a0 100644
--- a/src/search.c
+++ b/src/search.c
@@ -1383,7 +1383,7 @@ char *get_history_older(filestruct **h)
     assert(h != NULL);
 
     if ((*h)->prev == NULL)
-	return (*h)->data;
+	return NULL;
 
     *h = (*h)->prev;
 
@@ -1397,7 +1397,7 @@ char *get_history_newer(filestruct **h)
     assert(h != NULL);
 
     if ((*h)->next == NULL)
-	return (*h)->data;
+	return NULL;
 
     *h = (*h)->next;