; Handle string-at-point at end of buffer gracefully
authorPhilip Kaludercic <philipk@posteo.net>
Wed, 19 Jul 2023 19:14:40 +0000 (21:14 +0200)
committerPhilip Kaludercic <philipk@posteo.net>
Sat, 22 Jul 2023 07:08:14 +0000 (09:08 +0200)
* lisp/thingatpt.el (thing-at-point-bounds-of-string-at-point): Check
if 'char-after' returns non-nil before passing it to
'char-syntax'.  (Bug#64733)

lisp/thingatpt.el

index f3367290dee5727665904275e3d687f949e589db..408713dda1a01ed9bdd717b967a99abfa635d8cd 100644 (file)
@@ -250,7 +250,8 @@ Prefer the enclosing string with fallback on sexp at point.
             (goto-char (nth 8 ppss))
             (cons (point) (progn (forward-sexp) (point))))
         ;; At the beginning of the string
-        (if (eq (char-syntax (char-after)) ?\")
+        (if (let ((ca (char-after)))
+              (and ca (eq (char-syntax ca) ?\")))
             (let ((bound (bounds-of-thing-at-point 'sexp)))
              (and bound
                   (<= (car bound) (point)) (< (point) (cdr bound))