all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Tino Calancha <tino.calancha@gmail.com>
Cc: 24605@debbugs.gnu.org
Subject: bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS
Date: Tue, 04 Oct 2016 21:15:47 -0400	[thread overview]
Message-ID: <877f9ny4sc.fsf@users.sourceforge.net> (raw)
In-Reply-To: <alpine.DEB.2.20.1610041521480.19326@calancha-pc> (Tino Calancha's message of "Tue, 4 Oct 2016 15:22:39 +0900 (JST)")

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)))





  reply	other threads:[~2016-10-05  1:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-04  6:22 bug#24605: Subject: 25.1.50; form-at-point might fail for some THINGS Tino Calancha
2016-10-05  1:15 ` npostavs [this message]
2016-10-05  3:35   ` Tino Calancha
2016-10-05 11:50     ` Noam Postavsky
2016-10-05 12:30       ` Tino Calancha
2016-10-05 12:38         ` Tino Calancha
2016-10-05 13:09           ` Eli Zaretskii
2016-10-05 13:52             ` Tino Calancha
2016-10-05 15:59               ` Eli Zaretskii
2016-10-06  7:13 ` Andreas Röhler
2016-10-11  2:53 ` Tino Calancha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877f9ny4sc.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=24605@debbugs.gnu.org \
    --cc=tino.calancha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.