all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Strange behavior in search-forward-regexp?
@ 2006-02-11  1:43 Mathias Dahl
  2006-02-11  2:04 ` Barry Margolin
  2006-02-11 11:48 ` Peter Dyballa
  0 siblings, 2 replies; 10+ messages in thread
From: Mathias Dahl @ 2006-02-11  1:43 UTC (permalink / raw)



Take these "buffers":

Buffer 0:

---------- this line is not part of the buffer ----------
row0;test0
row1;test1
row2;test2
---------------------------------------------------------

Buffer 1:

---------- this line is not part of the buffer ----------

row0;test0
row1;test1
row2;test2
---------------------------------------------------------

Evaluate these functions:

(defun test1 ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (if (search-forward-regexp "^[^;]+;.*test1" nil t)
        (message (match-string-no-properties 0)))))

(defun test2 ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (if (search-forward-regexp "^.*test1" nil t)
        (message (match-string-no-properties 0)))))

In buffer 0, test1 and test2 willreturn the same result, "row1;test1",
but in buffer 1, test1 will return "\nrow1;test1" (\n is a newline)
and test2 "row1;test1".

Can someone explain this to me? Why would, in the case of test1, the
newline be included just because the line before is empty?

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2006-02-12 21:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-11  1:43 Strange behavior in search-forward-regexp? Mathias Dahl
2006-02-11  2:04 ` Barry Margolin
2006-02-11  9:45   ` Mathias Dahl
2006-02-12  9:58     ` Barry Margolin
2006-02-12 14:58       ` Mathias Dahl
2006-02-12 21:19         ` Barry Margolin
2006-02-11 11:48 ` Peter Dyballa
2006-02-11 19:00   ` Mattis
2006-02-11 19:33     ` Peter Dyballa
     [not found]     ` <mailman.17.1139690074.2858.help-gnu-emacs@gnu.org>
2006-02-11 21:43       ` Mathias Dahl

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.