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.

Drew
  • 75,699
  • 9
  • 109
  • 225
sandric
  • 1,221
  • 9
  • 19

2 Answers2

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.

Drew
  • 75,699
  • 9
  • 109
  • 225
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.

phils
  • 48,657
  • 3
  • 76
  • 115