help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

elisp oddity: search-forward-regexp and search-backward-regexp not symm


From: Xah Lee
Subject: elisp oddity: search-forward-regexp and search-backward-regexp not symmetric
Date: Wed, 08 Dec 2010 15:15:08 -0000
User-agent: G2/1.0

Summary: if you do search-forward-regexp with " +", then it'll skip
all spaces. However, if you use the backward version, it'll stop at
the first space.

reading the inline doc carefully, it seems the behavior is as
specified in the doc...  seems odd.

(defun xub-forward-to-space ()
  "Move cursor forward to next end of space or newline."
  (interactive)
  (search-forward-regexp " +\\|\n+" nil t)
  )

(defun xub-backward-to-space ()
  "Move cursor backward to previous beginning of space or newline."
  (interactive)
  (search-backward-regexp " +\\|\n+" nil t)
  )

Thanks.

  Xah
∑ http://xahlee.org/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]