[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS
From: |
npostavs |
Subject: |
bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS |
Date: |
Tue, 04 Oct 2016 21:15:47 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) |
tags 24605 patch
severity 24605 minor
quit
Tino Calancha <tino.calancha@gmail.com> writes:
> Because `thing-at-point' doesn't return always a string, as
> `form-at-point' currently assumes.
[...]
>
> (with-temp-buffer
> (require 'thingatpt)
> (insert "1")
> (let ((res
> (cond ((and (number-at-point)
> (form-at-point 'number)) 0)
> ((and (number-at-point)
> (not (form-at-point 'number))) -1)
> ((and (not (number-at-point))
> (form-at-point 'number)) -2)
> ((and (not (number-at-point))
> (not (form-at-point 'number))) -3))))
> (pcase res
> ('0 (message "OK, both 'number-at-point and 'form-at-point
> successfull"))
> (-1 (message "'number-at-point' works but (form-at-point 'number)
> fails"))
> (-2 (message "(form-at-point 'number) works but 'number-at-point'
> fails"))
> (-3 (message "Both 'number-at-point' and (form-at-point 'number)
> fails")))))
> => "’number-at-point’ works but (form-at-point ’number) fails"
Well, it looks like `form-at-point' was assumed to be used only for
implementing the foo-at-point functions, (form-at-point 'sexp 'numberp)
does work fine for this. But we may as well let (form-at-point 'number)
work too, since it's the more obvious way to call it.
> (defun form-at-point (&optional thing pred)
> - (let ((sexp (ignore-errors
> - (thing-at-point--read-from-whole-string
> - (thing-at-point (or thing 'sexp))))))
> + (let* ((obj (thing-at-point (or thing 'sexp)))
> + (sexp (ignore-errors
> + (if (stringp obj)
> + (thing-at-point--read-from-whole-string obj)
> + obj))))
I suggest keeping the `ignore-errors' strictly around the
`thing-at-point--read-from-whole-string' call.
> (if (or (not pred) (funcall pred sexp)) sexp)))
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Tino Calancha, 2016/10/04
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS,
npostavs <=
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Tino Calancha, 2016/10/04
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Noam Postavsky, 2016/10/05
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Tino Calancha, 2016/10/05
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Tino Calancha, 2016/10/05
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Eli Zaretskii, 2016/10/05
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Tino Calancha, 2016/10/05
- bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Eli Zaretskii, 2016/10/05
bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Andreas Röhler, 2016/10/06
bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS, Tino Calancha, 2016/10/10