[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21391: 24.5; `thing-at-point' returns error when called with argumen
From: |
Drew Adams |
Subject: |
bug#21391: 24.5; `thing-at-point' returns error when called with arguments 'number t) |
Date: |
Fri, 4 Nov 2016 09:31:38 -0700 (PDT) |
Tino is right. The mistake behind the handling of optional arg
NO-PROPERTIES (which was added in Emacs 24.4) is to assume that
`thing-at-point' returns a string. This is a common misconception.
It can return anything that Emacs Lisp can return.
emacs -Q
M-x load-library thingatpt
M-: (put 'list 'thing-at-point (lambda () '(1 2 3 4)))
In *scratch*:
C-x h
C-w
M-: (insert "(foo)")
M-x goto-char 2
M-: (thing-at-point 'list) ; => (1 2 3 4)
M-: (thing-at-point 'list t) ; => error raised
The proper test is not `sequencep', but either `stringp' or
(or (stringp text) (buffer-live-p text)). This is obvious
from just the signature of `set-text-properties'.
And "text" should be renamed accordingly - it is a THING,
not necessarily text.
[And I disagree that the doc string should say that THING
specifies a type of "syntactic" entity. It should say that
THING specifies a type of thing that can be manipulated by
Emacs Lisp. You could say a type of Lisp object, but it
could be, say, a file (not just a file name).]
- bug#21391: 24.5; `thing-at-point' returns error when called with arguments 'number t),
Drew Adams <=
bug#21391: 24.5; `thing-at-point' returns error when called with arguments 'number t), Drew Adams, 2016/11/04