GNU bug report logs - #74415
29.4; mouse-start-end does not respect syntax-table text properties

Previous Next

Package: emacs;

Reported by: Guillaume Brunerie <guillaume.brunerie <at> gmail.com>

Date: Mon, 18 Nov 2024 10:25:02 UTC

Severity: normal

Found in version 29.4

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: guillaume.brunerie <at> gmail.com, Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 74415 <at> debbugs.gnu.org
Subject: bug#74415: 29.4; mouse-start-end does not respect syntax-table text properties
Date: Thu, 28 Nov 2024 18:02:10 +0200
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: Guillaume Brunerie <guillaume.brunerie <at> gmail.com>,  74415 <at> 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))




This bug report was last modified 199 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.