After further experimentation, I suspect that "[^]" is simply not a valid regular expression. For instance, grep(1) gives the following behavior: $ echo "^" | grep "[^]" grep: brackets ([ ]) not balanced This suggests that the broken behavior is within `regexp-opt-charset`. I've attached a patch for that function. Here are some test cases which reveal the behavior of the unpatched and patched versions of the function (the only difference is the handling of the "[^]" case): ;; Pre-patch (regexp-opt-charset (list ?^)) ; "[^]" (regexp-opt-charset (list ?^ ?a)) ; "[a^]" (regexp-opt-charset (list ?^ ?-)) ; "[-^]" (regexp-opt-charset (list ?^ ?\])) ; "[]^]" (regexp-opt-charset (list ?^ ?- ?\])) ; "[]^-]" ;; Post-patch (regexp-opt-charset (list ?^)) ; "\\^" (regexp-opt-charset (list ?^ ?a)) ; "[a^]" (regexp-opt-charset (list ?^ ?-)) ; "[-^]" (regexp-opt-charset (list ?^ ?\])) ; "[]^]" (regexp-opt-charset (list ?^ ?- ?\])) ; "[]^-]" -- Cameron Desautels