From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#64733: [PATCH] ; Handle string-at-point at end of buffer gracefully Date: Wed, 19 Jul 2023 22:06:48 +0300 Message-ID: <83cz0n4t6f.fsf@gnu.org> References: <87zg3rn3ae.fsf@posteo.net> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="24986"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64733@debbugs.gnu.org To: Philip Kaludercic Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 19 21:07:15 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qMCW3-0006Ig-CG for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jul 2023 21:07:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMCVs-0003KZ-RA; Wed, 19 Jul 2023 15:07:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMCVr-0003Ji-Ep for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 15:07:03 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qMCVq-0000Ds-5B for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 15:07:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qMCVp-0000fN-Q2 for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 15:07:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Jul 2023 19:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64733 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 64733-submit@debbugs.gnu.org id=B64733.16897935872517 (code B ref 64733); Wed, 19 Jul 2023 19:07:01 +0000 Original-Received: (at 64733) by debbugs.gnu.org; 19 Jul 2023 19:06:27 +0000 Original-Received: from localhost ([127.0.0.1]:57129 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMCVG-0000eW-He for submit@debbugs.gnu.org; Wed, 19 Jul 2023 15:06:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:45378) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMCVE-0000eI-UD for 64733@debbugs.gnu.org; Wed, 19 Jul 2023 15:06:25 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMCV8-00008x-0a; Wed, 19 Jul 2023 15:06:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=aobA+/hNlJBU2bFjA74/YKZH2Wk4aooJXgSPTVUoZeQ=; b=abvTi4EPVoAQ LYaGbNRM450OxYfeaMcLRD/dkXUMNPKaIbigaTZcBr/WkErf8d9GGgro0h4pZBRz17qEZ0yYa1LPw Hadu7xbK8lmyZaNnL1ih52svKhjBIp3FddZYtevOmbhzas2933D4Nd0Ff8JFHbUx6NLkUYfTOAeU8 NiXc65xe1qSSxlw3mwFE6NCy54zTG6mM+NZVHEChDfhDkwaeErQAwAgKIKOBXZnmPTcMiePSVxf7F PMA8McmkXkdsL61gfHzo+UV6kNRQSDGUCzbh8YYDrgPWv+Cl2JIwv8WA5Xfeudcw3Idlo6QQIjQG+ r58vi6qMCyXdNg437bXMWw==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMCV7-0006vi-FY; Wed, 19 Jul 2023 15:06:17 -0400 In-Reply-To: <87zg3rn3ae.fsf@posteo.net> (message from Philip Kaludercic on Wed, 19 Jul 2023 18:51:05 +0000) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:265557 Archived-At: > From: Philip Kaludercic > 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?