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 19:17:07 +0000 Message-ID: <87r0p3n230.fsf@posteo.net> References: <87zg3rn3ae.fsf@posteo.net> <83cz0n4t6f.fsf@gnu.org> 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="374"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64733@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jul 19 21:18:29 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 1qMCgu-000APb-DC for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 19 Jul 2023 21:18:28 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qMCgV-0004ks-Tg; Wed, 19 Jul 2023 15:18:03 -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 1qMCgU-0004kW-Dw for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 15:18:02 -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 1qMCgU-0005Xn-6C for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 15:18:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qMCgT-0000vJ-Q3 for bug-gnu-emacs@gnu.org; Wed, 19 Jul 2023 15:18:01 -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 19:18: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.16897942413495 (code B ref 64733); Wed, 19 Jul 2023 19:18:01 +0000 Original-Received: (at 64733) by debbugs.gnu.org; 19 Jul 2023 19:17:21 +0000 Original-Received: from localhost ([127.0.0.1]:57134 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMCfn-0000uH-Rd for submit@debbugs.gnu.org; Wed, 19 Jul 2023 15:17:21 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:57339) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qMCfi-0000tz-De for 64733@debbugs.gnu.org; Wed, 19 Jul 2023 15:17:18 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 9F947240029 for <64733@debbugs.gnu.org>; Wed, 19 Jul 2023 21:17:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1689794228; bh=9saomB3Uw/a8Rka3i//oqVFRMj1BTM7svohLzI4w2p4=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=NrPnMkPJEX3QIqY47eBnVTWd8OW8wIAKAxdbf/G45d7ykmkyQOc0fM+1GAkOqGc/t ovUM9CnKDbOpkvMa46B26wSRRsiIAhuX2+zCURxpAvIfzty0ALQ3AUMYX9n/Yaai52 XHPw39Gow9pPpyuSnRhtoJnkru/Hbe7ht7gRb+YXoO6UbUnbm65UJUiCT4zedIX4ZO 81n7VanMVYy8N/CFDYZEGtVq35+TYnqQP7UOwsYJNoFI5oEsJ1bXcu2KuuOAT/sK/l KMK9B2iFQ1MldFncmz+IErlDxRn64zB/xH0Pwmoh5PAutkI3hiq/RmdcQltbYVwQR9 iTOXFwlh/bInA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4R5ltr0tzBz9rxB; Wed, 19 Jul 2023 21:17:07 +0200 (CEST) In-Reply-To: <83cz0n4t6f.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 19 Jul 2023 22:06:48 +0300") 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 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:265558 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: > Thanks, but could you rewrite so as not to call char-after more than > once? Sure, --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Handle-string-at-point-at-end-of-buffer-gracefully.patch >From 6fe6b91970a50c5609e81567c4b486b02e4f1a66 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Wed, 19 Jul 2023 21:14:40 +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'. (Bug#64733) --- lisp/thingatpt.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/thingatpt.el b/lisp/thingatpt.el index 46e700c2091..22a356efa83 100644 --- a/lisp/thingatpt.el +++ b/lisp/thingatpt.el @@ -250,7 +250,8 @@ 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 (and (char-after) (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)) -- 2.39.2 --=-=-=--