1

I'm using avy to select and insert symbols on screen with the help of thing-at-point. Is there an obvious way to get this to include periods? At the moment if I select self.blah I get just self (or blah).

I can obviously do this using regular expressions, save-excursion, and searching back and forward. But a standard approach seems less verbose and likely a better thing to learn.

Att Righ
  • 725
  • 4
  • 14
  • I had a quick look at the thing-at-point source code and it seems fairly easy to define a custom thing... but this seems rather like overkill in this case. – Att Righ Feb 27 '17 at 09:39
  • Well here is my horrible approach it works provided you are english and don't like diacritics. Pasting this inline because answering one's own question too quickly is bad: `(setq extended-word-re "[^a-zA-Z0-9.]") (defun my-extended-word-at-point () (save-excursion (buffer-substring-no-properties (progn (search-backward-regexp extended-word-re) (forward-char) (point) ) (progn (forward-char) (search-forward-regexp extended-word-re) (point) (backward-char) (point)))))` better approaches appreciated! – Att Righ Feb 27 '17 at 09:52

1 Answers1

5

What about this.

(defun dotted-symbol-at-point ()
  (with-syntax-table (make-syntax-table (syntax-table))
    (modify-syntax-entry ?. "_")
    (thing-at-point 'symbol)))
politza
  • 3,316
  • 14
  • 16