1

I know I can do this kind of thing with the sentence boundary, using (setq sentence-end "[regexp]"), but how can I do this with the word boundary?

I'd like to add capital letters to the default word boundary symbol sets, so that I could use forward word command from the beginning of the line below to select only the "set".

setWordBoundary blah blah blah
4

Here are two possibilities:

  • Use subword-mode. It is designed to do what you request.

    Emacs’s word commands recognize upper case letters in StudlyCapsIdentifiers as word boundaries. When Subword mode is enabled, the minor mode indicator , appears in the mode line.

  • Change the syntax class of uppercase letters to something other than word-constituent. To do that, use function modify-syntax-entry. For example, this changes uppercase letter A to be in symbols but not words:

    (modify-syntax-entry ?A "_") ; Give `A` symbol syntax, not word syntax
    
  • Thanks! I upvoted your answer, since it solved my problem for now, but I'm planning to set a lot of characters except English alphabet and numbers as word boundaries as well. Is there a way to add all the non-English irrelevant characters to the modify-syntax-entry at once? – stacko Jan 17 '16 at 7:29
  • At once? Define "non-English irrelevant characters". If you can list them then use dolist to iterate over them. If not, but if you can characterize them using a function, then use the function to iterate over them. And if this answer answers the question you posed, you might consider accepting it. ;-) – Drew Jan 17 '16 at 17:42

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.