diff options
| author | Alan Mackenzie | 2016-02-25 09:31:23 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2016-02-25 09:31:23 +0000 |
| commit | 95f5a4337c9092ab81d57d8ab5f341fc182d10cd (patch) | |
| tree | ad21a55c17e51bdd4226c66efe41a693b3137e34 | |
| parent | 7d206fc6044dc429a8c037856d30529a403395f5 (diff) | |
| download | emacs-95f5a4337c9092ab81d57d8ab5f341fc182d10cd.tar.gz emacs-95f5a4337c9092ab81d57d8ab5f341fc182d10cd.zip | |
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.el | 29 |
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." | |||
| 931 | (= start end) | 931 | (= start end) |
| 932 | (char-after start) | 932 | (char-after start) |
| 933 | (= (char-syntax (char-after start)) ?\()) | 933 | (= (char-syntax (char-after start)) ?\()) |
| 934 | (list start | 934 | (if (/= (syntax-class (syntax-after start)) 4) ; raw syntax code for ?\( |
| 935 | (save-excursion | 935 | ;; This happens in CC Mode when unbalanced parens in CPP |
| 936 | (goto-char start) | 936 | ;; constructs are given punctuation syntax with |
| 937 | (forward-sexp 1) | 937 | ;; syntax-table text properties. (2016-02-21). |
| 938 | (point)))) | 938 | (signal 'scan-error (list "Containing expression ends prematurely" |
| 939 | start start)) | ||
| 940 | (list start | ||
| 941 | (save-excursion | ||
| 942 | (goto-char start) | ||
| 943 | (forward-sexp 1) | ||
| 944 | (point))))) | ||
| 939 | ((and (= mode 1) | 945 | ((and (= mode 1) |
| 940 | (= start end) | 946 | (= start end) |
| 941 | (char-after start) | 947 | (char-after start) |
| 942 | (= (char-syntax (char-after start)) ?\))) | 948 | (= (char-syntax (char-after start)) ?\))) |
| 943 | (list (save-excursion | 949 | (if (/= (syntax-class (syntax-after start)) 5) ; raw syntax code for ?\) |
| 944 | (goto-char (1+ start)) | 950 | ;; See above comment about CC Mode. |
| 945 | (backward-sexp 1) | 951 | (signal 'scan-error (list "Unbalanced parentheses" start start)) |
| 946 | (point)) | 952 | (list (save-excursion |
| 947 | (1+ start))) | 953 | (goto-char (1+ start)) |
| 954 | (backward-sexp 1) | ||
| 955 | (point)) | ||
| 956 | (1+ start)))) | ||
| 948 | ((and (= mode 1) | 957 | ((and (= mode 1) |
| 949 | (= start end) | 958 | (= start end) |
| 950 | (char-after start) | 959 | (char-after start) |