Ctrl-s, isearch-forward is not appealing to me and so, i wrote a wrapper around it to search from the beginning of the buffer always.

(defun sk-isearch-forward (original)
  (interactive "sEnter search string:  ")
    (isearch-forward original)))

Now, i am seeing two issues:::

1) M-x sk-isearch-forward goes to the beginning of the buffer but never returns to the original cursor position. save-excursion is added to take care of this but it is failing me

2) it is not highlighting any of the matching words in the current buffer.

Is isearch-forward not the right function for this job?

I always search for a word, no regexes and the search, i prefer to start from the beginning. How can i do this?

  • @Name, please make it as the answer... thanks, Name
    – Saravana
    Commented Aug 5, 2015 at 5:07

1 Answer 1


Just remove the argument, i.e.

(defun sk-isearch-forward () 
    (goto-char (point-min))
  • 2
    Thanks @lawlist I modified it. The OP wants to return to the original cursor position as stated in the question, so save-excursion seems to be the right choice in this situation.
    – Name
    Commented Aug 5, 2015 at 5:30
  • how is (beginning-of-buffer) different from (goto-char (point-min))?
    – Saravana
    Commented Aug 5, 2015 at 8:33
  • @MadhavanKumar Check out the docstring of beginning-of-buffer by using C-h f to learn that. Commented Aug 5, 2015 at 10:59
  • 1
    Reproducing the relevant section of beginning-of-buffer's docstring for the benefit of others - Don't use this (beginning-of-buffer) command in Lisp programs! (goto-char (point-min)) is faster)
    – Saravana
    Commented Aug 5, 2015 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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