summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2016-02-25 09:31:23 +0000
committerAlan Mackenzie <acm@muc.de>2016-02-25 09:31:23 +0000
commit95f5a4337c9092ab81d57d8ab5f341fc182d10cd (patch)
treead21a55c17e51bdd4226c66efe41a693b3137e34
parent7d206fc6044dc429a8c037856d30529a403395f5 (diff)
downloademacs-95f5a4337c9092ab81d57d8ab5f341fc182d10cd.tar.gz
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.
-rw-r--r--lisp/mouse.el29
1 files changed, 19 insertions, 10 deletions
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 85ffc43d0dc..fa355ffeb71 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -931,20 +931,29 @@ If MODE is 2 then do the same for lines."
(= start end)
(char-after start)
(= (char-syntax (char-after start)) ?\())
- (list start
- (save-excursion
- (goto-char start)
- (forward-sexp 1)
- (point))))
+ (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
+ ;; syntax-table text properties. (2016-02-21).
+ (signal 'scan-error (list "Containing expression ends prematurely"
+ start start))
+ (list start
+ (save-excursion
+ (goto-char start)
+ (forward-sexp 1)
+ (point)))))
((and (= mode 1)
(= start end)
(char-after start)
(= (char-syntax (char-after start)) ?\)))
- (list (save-excursion
- (goto-char (1+ start))
- (backward-sexp 1)
- (point))
- (1+ 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))
+ (list (save-excursion
+ (goto-char (1+ start))
+ (backward-sexp 1)
+ (point))
+ (1+ start))))
((and (= mode 1)
(= start end)
(char-after start)