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#74415: 29.4; mouse-start-end does not respect syntax-table text properties Date: Thu, 28 Nov 2024 18:02:10 +0200 Message-ID: <86mshjcpod.fsf@gnu.org> References: <86cyilj6ks.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19390"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 74415@debbugs.gnu.org To: guillaume.brunerie@gmail.com, Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 28 17:03:30 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 1tGgzJ-0004r2-SC for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 28 Nov 2024 17:03:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGgyu-000853-Bv; Thu, 28 Nov 2024 11:03:04 -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 1tGgyt-00084k-FX for bug-gnu-emacs@gnu.org; Thu, 28 Nov 2024 11:03:03 -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 1tGgyt-00083Z-6k for bug-gnu-emacs@gnu.org; Thu, 28 Nov 2024 11:03:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:In-Reply-To:From:Date:To:Subject; bh=cDFcp5PNjUTBmgSVVl0c16YMB+niUFKWKBfgrCYLeqc=; b=dfweSpFEWRBRpNgoZw3Gbs2NjMc1IrMT9XlfodnwQf7m8YQFL2JABEfr1OlaNU/2fxgKTQ4+is45eyjsJ3D1WNfbw1klQp67zl1DrPkv/OmXy3+HDOEDoXD4EdLJaRslwy454L4E7BtUxqHCuj1s9aVETo16P+CDYqMKFOynotpX1C4P8Zx56ARaaUjHZ/IvDX1TxTjYfMo51R1s5XdVaevu3mQ7fMQaCojqo6MBKIXUC5blE2/onPW61Gmt2ev760JBL00tnJiB/QW2wJb1IN0u2yq1PSsgBUEZEglQnUHeQM6UhfK1OMjH1gciGfdAgzAJfonAg6SdWwZCtz+KnA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tGgys-0001KV-2U for bug-gnu-emacs@gnu.org; Thu, 28 Nov 2024 11:03:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 28 Nov 2024 16:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74415 X-GNU-PR-Package: emacs Original-Received: via spool by 74415-submit@debbugs.gnu.org id=B74415.17328097435004 (code B ref 74415); Thu, 28 Nov 2024 16:03:02 +0000 Original-Received: (at 74415) by debbugs.gnu.org; 28 Nov 2024 16:02:23 +0000 Original-Received: from localhost ([127.0.0.1]:39439 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGgyE-0001Id-PU for submit@debbugs.gnu.org; Thu, 28 Nov 2024 11:02:23 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39516) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGgyC-0001IF-7p for 74415@debbugs.gnu.org; Thu, 28 Nov 2024 11:02:21 -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 1tGgy6-0007ZJ-J9; Thu, 28 Nov 2024 11:02:14 -0500 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=cDFcp5PNjUTBmgSVVl0c16YMB+niUFKWKBfgrCYLeqc=; b=AfcLvyFCKqt8 UE4JkrM28bXyt7jbi41qdxWbIKseVNtlRxTKzYQDOKoVvOne9juR46dc4ns9dqhf79asMnzYIte86 ngcd6MEpOhQrunha9dSmrHZWW+wl+fBMru3H06DMTgDFjuGQ5xdwO/ft8NifuqXyOlvLwM697+oiN 7ZteYSQvQAq2f/QBu9o8Rogli+kNlMhwxfz9MNaxNBHsJumz1JT0Fa9dB+ZvlpIMkwNIFC4qSLAg+ GiKjwecTtQlls2yQcSNKTa4kudJSX8aan2BUziVMn1QG0aeFbzli4BBl4ep4wkVqtqukKHYP4YtJL D67fq5APZkwwDzSclpQsog==; In-Reply-To: (message from Stefan Monnier on Mon, 25 Nov 2024 18:15:12 -0500) 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:296058 Archived-At: > From: Stefan Monnier > Cc: Guillaume Brunerie , 74415@debbugs.gnu.org > Date: Mon, 25 Nov 2024 18:15:12 -0500 > > > Stefan, is there any reason not to use syntax-after everywhere in > > mouse.el? > > Not that I can think of, no. > AFAIU, this code simply predates `syntax-after`. Thanks. Guillaume, does the patch below give good results? diff --git a/lisp/mouse.el b/lisp/mouse.el index 410e52b..766c4d8 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -632,7 +632,9 @@ context-menu-region (with-current-buffer (window-buffer (posn-window (event-end click))) (when (let* ((pos (posn-point (event-end click))) (char (when pos (char-after pos)))) - (or (and char (eq (char-syntax char) ?\")) + (or (and char (eq (syntax-class-to-char + (syntax-class (syntax-after pos))) + ?\")) (nth 3 (save-excursion (syntax-ppss pos))))) (define-key-after submenu [mark-string] `(menu-item "String" @@ -1890,7 +1892,8 @@ mouse-skip-word If `mouse-1-double-click-prefer-symbols' is non-nil, skip over symbol. If DIR is positive skip forward; if negative, skip backward." (let* ((char (following-char)) - (syntax (char-to-string (char-syntax char))) + (syntax (char-to-string + (syntax-class-to-char (syntax-class (syntax-after (point)))))) sym) (cond ((and mouse-1-double-click-prefer-symbols (setq sym (bounds-of-thing-at-point 'symbol))) @@ -1938,7 +1941,9 @@ mouse-start-end ((and (= mode 1) (= start end) (char-after start) - (= (char-syntax (char-after start)) ?\()) + (= (syntax-class-to-char + (syntax-class (syntax-after start))) + ?\()) (if (/= (syntax-class (syntax-after start)) 4) ; raw syntax code for ?\( ;; This happens in CC Mode when unbalanced parens in CPP ;; constructs are given punctuation syntax with @@ -1953,7 +1958,9 @@ mouse-start-end ((and (= mode 1) (= start end) (char-after start) - (= (char-syntax (char-after start)) ?\))) + (= (syntax-class-to-char + (syntax-class (syntax-after start))) + ?\))) (if (/= (syntax-class (syntax-after start)) 5) ; raw syntax code for ?\) ;; See above comment about CC Mode. (signal 'scan-error (list "Unbalanced parentheses" start start)) @@ -1965,7 +1972,9 @@ mouse-start-end ((and (= mode 1) (= start end) (char-after start) - (= (char-syntax (char-after start)) ?\")) + (= (syntax-class-to-char + (syntax-class (syntax-after start))) + ?\")) (let ((open (or (eq start (point-min)) (save-excursion (goto-char (- start 1))