all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Philip Kaludercic <philipk@posteo.net>
Cc: 64733@debbugs.gnu.org
Subject: bug#64733: [PATCH] ; Handle string-at-point at end of buffer gracefully
Date: Wed, 19 Jul 2023 22:06:48 +0300	[thread overview]
Message-ID: <83cz0n4t6f.fsf@gnu.org> (raw)
In-Reply-To: <87zg3rn3ae.fsf@posteo.net> (message from Philip Kaludercic on Wed, 19 Jul 2023 18:51:05 +0000)

> From: Philip Kaludercic <philipk@posteo.net>
> Date: Wed, 19 Jul 2023 18:51:05 +0000
> 
> Evaluating (thing-at-point 'string) at the end of a buffer raises an
> error:
> 
> --8<---------------cut here---------------start------------->8---
> Debugger entered--Lisp error: (wrong-type-argument characterp nil)
>   char-syntax(nil)
>   (eq (char-syntax (char-after)) 34)
>   (if (eq (char-syntax (char-after)) 34) (let ((bound (bounds-of-thing-at-point 'sexp))) (and bound (<= (car bound) (point)) (< (point) (cdr bound)) bound)))
>   (if (nth 3 ppss) (condition-case nil (progn (goto-char (nth 8 ppss)) (cons (point) (progn (forward-sexp) (point)))) (error nil)) (if (eq (char-syntax (char-after)) 34) (let ((bound (bounds-of-thing-at-point 'sexp))) (and bound (<= (car bound) (point)) (< (point) (cdr bound)) bound))))
>   (let ((ppss (syntax-ppss))) (if (nth 3 ppss) (condition-case nil (progn (goto-char (nth 8 ppss)) (cons (point) (progn (forward-sexp) (point)))) (error nil)) (if (eq (char-syntax (char-after)) 34) (let ((bound (bounds-of-thing-at-point 'sexp))) (and bound (<= (car bound) (point)) (< (point) (cdr bound)) bound)))))
>   (save-excursion (let ((ppss (syntax-ppss))) (if (nth 3 ppss) (condition-case nil (progn (goto-char (nth 8 ppss)) (cons (point) (progn (forward-sexp) (point)))) (error nil)) (if (eq (char-syntax (char-after)) 34) (let ((bound (bounds-of-thing-at-point ...))) (and bound (<= (car bound) (point)) (< (point) (cdr bound)) bound))))))
>   thing-at-point-bounds-of-string-at-point()
>   funcall(thing-at-point-bounds-of-string-at-point)
>   (cond ((get thing 'bounds-of-thing-at-point) (funcall (get thing 'bounds-of-thing-at-point))) ((and (not (eq thing 'whitespace)) (save-excursion (goto-char (point-min)) (not (re-search-forward "[^\11\n ]" nil t)))) nil) (t (let ((orig (point))) (condition-case nil (progn (save-excursion (funcall (or ... ...)) (funcall (or ... ...)) (let (...) (if ... ... ... ... ... ...)))) (error nil)))))
>   bounds-of-thing-at-point(string)
>   (let ((bounds (bounds-of-thing-at-point thing))) (if bounds (progn (buffer-substring (car bounds) (cdr bounds)))))
>   (cond ((let* ((--cl-var-- thing-at-point-provider-alist) #'nil (pthing nil) (result nil) (--cl-var-- t) (--cl-var-- t) --cl-var--) (while (and (consp --cl-var--) (progn (progn (setq function ...) (setq pthing ...)) (if (eq pthing thing) (progn ...)) (if result (progn ... ...) t))) (setq --cl-var-- (cdr --cl-var--)) (setq --cl-var-- nil)) --cl-var--)) ((get thing 'thing-at-point) (funcall (get thing 'thing-at-point))) (t (let ((bounds (bounds-of-thing-at-point thing))) (if bounds (progn (buffer-substring (car bounds) (cdr bounds)))))))
>   (let ((text (cond ((let* ((--cl-var-- thing-at-point-provider-alist) #'nil (pthing nil) (result nil) (--cl-var-- t) (--cl-var-- t) --cl-var--) (while (and ... ...) (setq --cl-var-- ...) (setq --cl-var-- nil)) --cl-var--)) ((get thing 'thing-at-point) (funcall (get thing 'thing-at-point))) (t (let ((bounds ...)) (if bounds (progn ...))))))) (if (and text no-properties (sequencep text)) (progn (set-text-properties 0 (length text) nil text))) text)
>   thing-at-point(string)
>   eval-expression((thing-at-point 'string) nil nil 127)
>   funcall-interactively(eval-expression (thing-at-point 'string) nil nil 127)
>   command-execute(eval-expression)
> --8<---------------cut here---------------end--------------->8---
> 
> In this case it is easy to avoid it, with the below patch, by ensuring
> that `char-syntax' is not passed a nil.

Thanks, but could you rewrite so as not to call char-after more than
once?





  reply	other threads:[~2023-07-19 19:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 18:51 bug#64733: [PATCH] ; Handle string-at-point at end of buffer gracefully Philip Kaludercic
2023-07-19 19:06 ` Eli Zaretskii [this message]
2023-07-19 19:17   ` Philip Kaludercic
2023-07-20  4:40     ` Eli Zaretskii
2023-07-20  6:57       ` Philip Kaludercic
2023-07-20  7:38         ` Eli Zaretskii
2023-07-20  8:42           ` Philip Kaludercic
2023-07-20 10:21             ` Eli Zaretskii
2023-07-21 14:53               ` Philip Kaludercic
2023-07-21 15:13                 ` Eli Zaretskii
2023-07-22  7:21                   ` Philip Kaludercic

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=83cz0n4t6f.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=64733@debbugs.gnu.org \
    --cc=philipk@posteo.net \
    /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.