define shm-in-string-or-comment, use it in shm-insert-char-appending-to-prev-operator and fix it for beginning-of-buffer case