Make double-click-1 work with unbalanced parens in CC Mode. Fixes bug#5560.

* lisp/mouse.el (mouse-start-end): check the syntax of alleged parens with
`syntax-after' to ensure syntax-table text properties are respected.
This commit is contained in:
Alan Mackenzie 2016-02-25 09:31:23 +00:00
parent 7d206fc604
commit 95f5a4337c

View file

@ -931,20 +931,29 @@ If MODE is 2 then do the same for lines."
(= start end) (= start end)
(char-after start) (char-after start)
(= (char-syntax (char-after start)) ?\()) (= (char-syntax (char-after start)) ?\())
(list start (if (/= (syntax-class (syntax-after start)) 4) ; raw syntax code for ?\(
(save-excursion ;; This happens in CC Mode when unbalanced parens in CPP
(goto-char start) ;; constructs are given punctuation syntax with
(forward-sexp 1) ;; syntax-table text properties. (2016-02-21).
(point)))) (signal 'scan-error (list "Containing expression ends prematurely"
start start))
(list start
(save-excursion
(goto-char start)
(forward-sexp 1)
(point)))))
((and (= mode 1) ((and (= mode 1)
(= start end) (= start end)
(char-after start) (char-after start)
(= (char-syntax (char-after start)) ?\))) (= (char-syntax (char-after start)) ?\)))
(list (save-excursion (if (/= (syntax-class (syntax-after start)) 5) ; raw syntax code for ?\)
(goto-char (1+ start)) ;; See above comment about CC Mode.
(backward-sexp 1) (signal 'scan-error (list "Unbalanced parentheses" start start))
(point)) (list (save-excursion
(1+ start))) (goto-char (1+ start))
(backward-sexp 1)
(point))
(1+ start))))
((and (= mode 1) ((and (= mode 1)
(= start end) (= start end)
(char-after start) (char-after start)