2

Is there a way to tweak thing-at-point symbol regexp, so that it ignore dots as separators? Right now foo.bar in my Emacs is recognized as two different symbols, where I wish it was one.

2

To supplement what @phils said -

Make . have symbol-constituent syntax in the current syntax table, or in a copy of it.

Either define your own replacement function for thing-at-point:

(defun my-thg-at-pt (thing &optional no-properties)
  "..."
  (let ((stab  (copy-syntax-table)))
    (with-syntax-table stab
      (modify-syntax-entry ?. "_")
      (thing-at-point thing no-properties))))

or wrap whatever code calls thing-at-point similarly. For instance, if you call some function foo that you cannot modify, which calls thing-at-point, then wrap your call to foo similarly:

(let ((stab  (copy-syntax-table)))
  (with-syntax-table stab
    (modify-syntax-entry ?. "_")
    ...
    (foo)))

Of course, if foo does other stuff, and some of that depends on . NOT having symbol syntax, then wrapping all of foo this way is too unfocused.

1

That's dependent on the syntax table for the buffer in question. In elisp, for instance, foo.bar is treated as a single symbol.

You can specify that . is symbol-constituent in the current buffer's syntax table with:

(modify-syntax-entry ?. "_")

Unless this is for a custom mode of your own devising, I would suggest that you try to establish if there is a sensible reason why . was not already symbol-constituent.

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.