0

It is easy to present list of allowed characters as string, like " \n\t".

(char-before) return integer.

How can I check that a character is in a string?

There is What is the easiest way to check if a character belongs to a particular set of characters? where (memq ch (list ?a ?b)) is suggested.

I think that string is constant and don't need to be evaluated in comparison to (list ?a ?b).

I wrote (seq-some (lambda (el) (eq el 32)) "a b") but it also is too high level.

It is possible to convert a character to string: (string-match "[a b]" (char-to-string 32)).

If string is a sequence there is probably a function that detects element in a sequence... (member 32 "a b") doesn't work...

1

There are a few ways you can test whether a character is in a string. Here are two:

(seq-contains "abcd" char)

(memq char (string-to-list "abcd")) ; Which is just (memq char (append "abcd" nil))

(seq-contains is similar to what you did with seq-some.)

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.