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

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

Re: Is it obvious that string-match syntax matching is affected by the c


From: Andreas Röhler
Subject: Re: Is it obvious that string-match syntax matching is affected by the current buffer?
Date: Sun, 13 Mar 2016 17:52:32 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:38.0) Gecko/20100101 Icedove/38.5.0



On 13.03.2016 17:31, Tom wrote:
I did a word constituent match with string-match and a question
occured to me: what controls what is considered word constituent
in this case?

I checked info, but I saw no mention of this, so I did a test and
yes, the current syntax table affects string-match:

(let ((tab (make-syntax-table)))
   (modify-syntax-entry ?a " " tab)
   (with-syntax-table tab
     (string-match "\\s-" "a")))


Isn't a strange? E.g. I'm doing a string match in elisp, so I'm
not working with the current buffer, yet its active syntax table
affects the result of string-match. Seems to me these are
different domains and string-match should have its own
string-match-syntax-table or something, so there can be no
match side effects depending on the currently active buffer.

Do you think it's obvious for the elisp users that string-match
is affected by the current buffer? Maybe the documentation should
mention this. (Maybe it does, but I didn't see it.)




string-match here is called from inside a let, so the settings there prevail. Also from inside let: "with-syntax-table tab" - whilst"tab" is also let-bound.

Let protects against outer settings, so current-buffer or not seems not at stake.



reply via email to

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