Windows 10, Emacs 26.1


  1. Start Emacs
  2. Open *scratch* buffer.
  3. C-s text
  4. C-g
  5. C-s visit
  6. C-g

Nice. Now I want to go backward and forward through search history with M-p and M-n respectively. But I get error:

M-p/M-n is underfined". 

If I input command "previous-history-element" I get another error: Wrong type argument: number-or-marker-p, nil

I try this in pure Emacs by: emacs -Q

But I get same errors.

  • Why are you typing M-x C-s? I've just checked Emacs 26.1 under windows 7 without any init file, and isearch history seems to just work for me. – user12563 Oct 24 '18 at 17:53
  • Maybe this will help out a little bit: asciinema.org/a/nzAMu0WCJrV9vPVV4was69qZk – user12563 Oct 24 '18 at 18:01
  • Because C-s is incremental search forward (isearch-forward) – a_subscriber Oct 24 '18 at 20:06
  • 1
    You don't need to prefix it with M-x. – user12563 Oct 24 '18 at 20:28
  • I update my post. It's not help. I get same error – a_subscriber Oct 25 '18 at 7:17

When you cancel the search with C-g the search item isn't added to your search history. Try this instead:

  1. Start Emacs
  2. Open scratch buffer.
  3. C-s text
  4. ENTER
  5. C-s visit
  6. ENTER

Now you can access your search history:

  1. C-s
  2. M-n or M-p

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.