bo0ts/expand-region.el — comment on commit 83644ffdee46786bdc3db0d54be286493b3c1e95
File:  line 0
By gvol:

That's why I was wondering if it should be fixed in all the `er/mark-*` commands. If we decide this is better it would be nice to have this documented and maybe even an `er--trim-space` function to clean off the space (both at mark and point) that could be called in the `er/mark-functions` if desired. I'm open to either. The only thing I can think of is that it might be nice to not have the white space trimmed off--except for when there is another `er/mark-*` command which differs only by white space. I suppose it could be called in a mode-specific way. I think a relatively easy fix for this is to add

;; Either the start or end differs by more than whitespace
(or (string-match (concat "[^" er--space-str "]")
(buffer-substring-no-properties
(point) start))
(string-match (concat "[^" er--space-str "]")
(buffer-substring-no-properties
(mark) end)))

to the appropriate spot in `er/expand-region`. It seems a little bit hacky the way I created the regex from `er--space-str`, especially if `er--space-str` ever has `[]^-` etc. in it. Fortunately, I don't see that happening anytime soon. :-) I wish we could use syntax tables without having to worry whether `\n` is whitespace or comment terminator. That has to be a problem someone has solved before.