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.

2
  • 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
    Commented Feb 27, 2017 at 9: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
    Commented Feb 27, 2017 at 9:52

1 Answer 1

5

What about this.

(defun dotted-symbol-at-point ()
  (with-syntax-table (make-syntax-table (syntax-table))
    (modify-syntax-entry ?. "_")
    (thing-at-point 'symbol)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.