From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#64733: [PATCH] ; Handle string-at-point at end of buffer gracefully Date: Wed, 19 Jul 2023 18:51:05 +0000 Message-ID: <87zg3rn3ae.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25130"; mail-complaints-to="usenet@ciao.gmane.io" To: 64733@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 19 20:52: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 1qMCHX-0006I8-34 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jul 2023 20:52:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMCHN-0000CN-1t; Wed, 19 Jul 2023 14:52:05 -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 1qMCHL-0000CC-Aa for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 14:52: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 1qMCHK-0003P4-LU for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 14:52:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qMCHK-0000IL-Bm for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 14:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 19 Jul 2023 18:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 64733 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16897926931093 (code B ref -1); Wed, 19 Jul 2023 18:52:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 19 Jul 2023 18:51:33 +0000 Original-Received: from localhost ([127.0.0.1]:57123 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMCGq-0000HZ-Q9 for submit@debbugs.gnu.org; Wed, 19 Jul 2023 14:51:33 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:37674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMCGl-0000H9-Jt for submit@debbugs.gnu.org; Wed, 19 Jul 2023 14:51:30 -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 1qMCGe-00007u-Be for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 14:51:21 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMCGa-0003G5-K5 for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 14:51:18 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B14DA240028 for ; Wed, 19 Jul 2023 20:51:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1689792674; bh=0vUEQMAJmf5w6CXt6AVqIVPkapx6gY+IDj/Dpb81vIk=; h=From:To:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=Z/9STzjaK81iWC8OpmY+d4xIGKWdckuOLXSBjqZJeWbS57VHUtmFBdjR18s8I+/6t yaHAQ6CHiyPrpCIDkw5aJluIaVyjGlLh6zxLislQPvxAW7r5RF9I9fP1MXnQEZBbmS xktCnE2I8PZAY1hk8jVbwsBOmZaR71kUveFOnLxoskbsi2hJVZphjwN5QOdU7W+fjL YJ438F2f2h/r86zvB3jwYZRpdXD8WhHMij9f8sywoDzrHQyusPjsH+rTtkmJ7WGL9a euK7/kjF7EWoiYZmC9YUKHdVkQ4h9Bl/cgbBwfzZFs6otRKkLUSovyVysYbce7LNFn ilAzVoPQXYjfw== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4R5lJy2Qrtz9rxK for ; Wed, 19 Jul 2023 20:51:14 +0200 (CEST) Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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:265556 Archived-At: --=-=-= Content-Type: text/plain Tags: patch 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. In GNU Emacs 29.0.92 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0) of 2023-07-16 built on quetzal Repository revision: fcde115d5748880ad7ebbf43a10753fb7014a6e1 Repository branch: emacs-29 System Description: Debian GNU/Linux 12 (bookworm) Configured using: 'configure --with-pgtk --with-native-compilation --with-imagemagick --with-tree-sitter' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-Handle-string-at-point-at-end-of-buffer-gracefully.patch >From fb5da3b4a4785938d82c8ce4ea59215a8905ddd7 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Wed, 19 Jul 2023 20:49:30 +0200 Subject: [PATCH] ; Handle string-at-point at end of buffer gracefully * lisp/thingatpt.el (thing-at-point-bounds-of-string-at-point): Check if 'char-after' returns non-nil before passing it to 'char-syntax'. --- lisp/thingatpt.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 9363a474cb5..46e700c2091 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -250,7 +250,7 @@ thing-at-point-bounds-of-string-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 (and (char-after) (eq (char-syntax (char-after)) ?\")) (let ((bound (bounds-of-thing-at-point 'sexp))) (and bound (<= (car bound) (point)) (< (point) (cdr bound)) -- 2.39.2 --=-=-=--