From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arash Esbati Newsgroups: gmane.emacs.bugs Subject: bug#69266: 30.0.50; bibtex-parse-entry misreads escaped \} Date: Fri, 23 Feb 2024 13:07:51 +0100 Message-ID: References: <87cysshl3j.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16969"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69266@debbugs.gnu.org, Roland Winkler To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 23 13:10:26 2024 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 1rdUNm-00042j-Mn for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Feb 2024 13:10:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rdUNP-0006j5-6R; Fri, 23 Feb 2024 07:10:03 -0500 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 1rdUM2-0006Nv-Is for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 07:08:39 -0500 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 1rdUM2-0004UV-AO for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 07:08:38 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rdUMP-0008W3-OC for bug-gnu-emacs@gnu.org; Fri, 23 Feb 2024 07:09:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Arash Esbati Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 23 Feb 2024 12:09:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69266 X-GNU-PR-Package: emacs Original-Received: via spool by 69266-submit@debbugs.gnu.org id=B69266.170869010932649 (code B ref 69266); Fri, 23 Feb 2024 12:09:01 +0000 Original-Received: (at 69266) by debbugs.gnu.org; 23 Feb 2024 12:08:29 +0000 Original-Received: from localhost ([127.0.0.1]:34576 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdULr-0008US-Sk for submit@debbugs.gnu.org; Fri, 23 Feb 2024 07:08:28 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:50324) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rdULp-0008U7-2y for 69266@debbugs.gnu.org; Fri, 23 Feb 2024 07:08:26 -0500 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 1rdULM-0004LQ-A8; Fri, 23 Feb 2024 07:07:56 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=AdLQgARLRwauh078Pt22Wi/wirrOCIdcS4rG6VL/pzI=; b=JumKFcPZCGLfj9mWk6kZ Vor/knwuldX7LlI5PTVGhI9YXxmIwHGX0kXqI3xgVFrgWcSpr3QENBsUDeZ1VGuYSvdYm7oVauPfW oI7ab22BT7rGYvJ6FDSyVZOngJyekcd7CxSF+DGAvLEHp2McdxpoCJC2c+sLSGuPanVO6vcetKHMc kldGp7o69WIkAGjljtAq9i2XNhgHH1kI6nTSX86n7KqeLxTShwZs76JmDCEpqfO1nmRmzN/je0BIW RYVTzP1gaWYsoz76mEjqi64TUrT/qD5/8ipCm9jUc+aATF5c6xdnO35iLOkrz96ECN3Alr5w5Q3dp 6/yHcAz+atrV2w==; In-Reply-To: <87cysshl3j.fsf@localhost> (Ihor Radchenko's message of "Mon, 19 Feb 2024 09:14:24 +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:280491 Archived-At: Ihor Radchenko writes: > Consider the following bibtex entry: > > @InCollection{Geyer2011, > title = {Introduction to Markov Chain Monte \} Carlo}, > pages = 45, > } > > According to https://www.bibtex.org/SpecialSymbols/, characters that > conflict with Bibtex format description can be \-escaped. > > In the above, with point at the beginning of the entry, M-: > (bibtex-parse-entry t), yields > > ("=type=" . "InCollection") > ("=key=" . "Geyer2011") > ("title" . "Introduction to Markov Chain Monte \\") > > The escaped \} is treated as closing }, which is incorrect. > > Expected: escaping is properly processed. I think the issue is that `bibtex-parse-entry' calls `bibtex-text-in-field-bounds' which calls `bibtex-parse-field-string' which is defined like this: --8<---------------cut here---------------start------------->8--- (defun bibtex-parse-field-string () "Parse a BibTeX field string enclosed by braces or quotes. If a syntactically correct string is found, a pair containing the start and end position of the field string is returned, nil otherwise. Do not move point." (let ((end-point (or (and (eq (following-char) ?\") (save-excursion (with-syntax-table bibtex-quoted-string-syntax-table (forward-sexp 1)) (point))) (and (eq (following-char) ?\{) (save-excursion (with-syntax-table bibtex-braced-string-syntax-table (forward-sexp 1)) (point)))))) (if end-point (cons (point) end-point)))) --8<---------------cut here---------------end--------------->8--- `bibtex-braced-string-syntax-table' is defined as: --8<---------------cut here---------------start------------->8--- (defconst bibtex-braced-string-syntax-table (let ((st (make-syntax-table))) (modify-syntax-entry ?\{ "(}" st) (modify-syntax-entry ?\} "){" st) (modify-syntax-entry ?\[ "." st) (modify-syntax-entry ?\] "." st) (modify-syntax-entry ?\( "." st) (modify-syntax-entry ?\) "." st) (modify-syntax-entry ?\\ "." st) (modify-syntax-entry ?\" "." st) st) "Syntax-table to parse matched braces.") --8<---------------cut here---------------end--------------->8--- where the backslash gets the punctuation class. Hence, the (forward-sexp 1) call above goes wrong. You can eval this in scratch --8<---------------cut here---------------start------------->8--- (defconst bibtex-braced-string-syntax-table (let ((st (make-syntax-table))) (modify-syntax-entry ?\{ "(}" st) (modify-syntax-entry ?\} "){" st) (modify-syntax-entry ?\[ "." st) (modify-syntax-entry ?\] "." st) (modify-syntax-entry ?\( "." st) (modify-syntax-entry ?\) "." st) ;; "." changed to "\\" (modify-syntax-entry ?\\ "\\" st) (modify-syntax-entry ?\" "." st) st) "Syntax-table to parse matched braces.") --8<---------------cut here---------------end--------------->8--- and try your test case again -- it should give the expected result. I can't tell why the backslash doesn't get the escape-char syntax, it would make sense IMO, but that's something Roland W. (CC'ed) has to decide. Best, Arash