diff options
| author | Alan Mackenzie | 2023-04-14 10:33:03 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2023-04-14 10:33:03 +0000 |
| commit | f9d8cdbdbdd4f49650f2f682db89f302220b43d6 (patch) | |
| tree | 0dbb94fa8d9348ed81b11af9d98dd7f59f1b0f56 | |
| parent | d664969544b13fe93a548c9908ce566f9b5cde9c (diff) | |
| download | emacs-f9d8cdbdbdd4f49650f2f682db89f302220b43d6.tar.gz emacs-f9d8cdbdbdd4f49650f2f682db89f302220b43d6.zip | |
Make c-emacs-features use the proper binding of parse-sexp-lookup-properties
This is relevant for bug #58558, although it does not fix it. Due to a wrong
ordering of with-current-buffer and a let form, the function overwrote the
global value of parse-sexp-lookup-properties and two other variables.
* lisp/progmodes/cc-defs.el (c-emacs-features): Change the nesting of
with-current-buffer and let so that the let bindings get used.
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 151 |
1 files changed, 72 insertions, 79 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index aa6f33e9cab..1d98b215525 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -2153,86 +2153,79 @@ non-nil, a caret is prepended to invert the set." | |||
| 2153 | ;; Record whether the `category' text property works. | 2153 | ;; Record whether the `category' text property works. |
| 2154 | (if c-use-category (setq list (cons 'category-properties list))) | 2154 | (if c-use-category (setq list (cons 'category-properties list))) |
| 2155 | 2155 | ||
| 2156 | (let ((buf (generate-new-buffer " test")) | 2156 | (let ((buf (generate-new-buffer " test"))) |
| 2157 | parse-sexp-lookup-properties | ||
| 2158 | parse-sexp-ignore-comments | ||
| 2159 | lookup-syntax-properties) ; XEmacs | ||
| 2160 | (with-current-buffer buf | 2157 | (with-current-buffer buf |
| 2161 | (set-syntax-table (make-syntax-table)) | 2158 | (let ((parse-sexp-lookup-properties t) |
| 2162 | 2159 | (parse-sexp-ignore-comments t) | |
| 2163 | ;; For some reason we have to set some of these after the | 2160 | (lookup-syntax-properties t)) |
| 2164 | ;; buffer has been made current. (Specifically, | 2161 | (set-syntax-table (make-syntax-table)) |
| 2165 | ;; `parse-sexp-ignore-comments' in Emacs 21.) | 2162 | |
| 2166 | (setq parse-sexp-lookup-properties t | 2163 | ;; Find out if the `syntax-table' text property works. |
| 2167 | parse-sexp-ignore-comments t | 2164 | (modify-syntax-entry ?< ".") |
| 2168 | lookup-syntax-properties t) | 2165 | (modify-syntax-entry ?> ".") |
| 2169 | 2166 | (insert "<()>") | |
| 2170 | ;; Find out if the `syntax-table' text property works. | 2167 | (c-mark-<-as-paren (point-min)) |
| 2171 | (modify-syntax-entry ?< ".") | 2168 | (c-mark->-as-paren (+ 3 (point-min))) |
| 2172 | (modify-syntax-entry ?> ".") | 2169 | (goto-char (point-min)) |
| 2173 | (insert "<()>") | 2170 | (c-forward-sexp) |
| 2174 | (c-mark-<-as-paren (point-min)) | 2171 | (if (= (point) (+ 4 (point-min))) |
| 2175 | (c-mark->-as-paren (+ 3 (point-min))) | 2172 | (setq list (cons 'syntax-properties list)) |
| 2176 | (goto-char (point-min)) | 2173 | (error (concat |
| 2177 | (c-forward-sexp) | 2174 | "CC Mode is incompatible with this version of Emacs - " |
| 2178 | (if (= (point) (+ 4 (point-min))) | 2175 | "support for the `syntax-table' text property " |
| 2179 | (setq list (cons 'syntax-properties list)) | 2176 | "is required."))) |
| 2180 | (error (concat | 2177 | |
| 2181 | "CC Mode is incompatible with this version of Emacs - " | 2178 | ;; Find out if "\\s!" (generic comment delimiters) work. |
| 2182 | "support for the `syntax-table' text property " | 2179 | (c-safe |
| 2183 | "is required."))) | 2180 | (modify-syntax-entry ?x "!") |
| 2184 | 2181 | (if (string-match "\\s!" "x") | |
| 2185 | ;; Find out if "\\s!" (generic comment delimiters) work. | 2182 | (setq list (cons 'gen-comment-delim list)))) |
| 2186 | (c-safe | 2183 | |
| 2187 | (modify-syntax-entry ?x "!") | 2184 | ;; Find out if "\\s|" (generic string delimiters) work. |
| 2188 | (if (string-match "\\s!" "x") | 2185 | (c-safe |
| 2189 | (setq list (cons 'gen-comment-delim list)))) | 2186 | (modify-syntax-entry ?x "|") |
| 2190 | 2187 | (if (string-match "\\s|" "x") | |
| 2191 | ;; Find out if "\\s|" (generic string delimiters) work. | 2188 | (setq list (cons 'gen-string-delim list)))) |
| 2192 | (c-safe | 2189 | |
| 2193 | (modify-syntax-entry ?x "|") | 2190 | ;; See if POSIX char classes work. |
| 2194 | (if (string-match "\\s|" "x") | 2191 | (when (and (string-match "[[:alpha:]]" "a") |
| 2195 | (setq list (cons 'gen-string-delim list)))) | 2192 | ;; All versions of Emacs 21 so far haven't fixed |
| 2196 | 2193 | ;; char classes in `skip-chars-forward' and | |
| 2197 | ;; See if POSIX char classes work. | 2194 | ;; `skip-chars-backward'. |
| 2198 | (when (and (string-match "[[:alpha:]]" "a") | 2195 | (progn |
| 2199 | ;; All versions of Emacs 21 so far haven't fixed | 2196 | (delete-region (point-min) (point-max)) |
| 2200 | ;; char classes in `skip-chars-forward' and | 2197 | (insert "foo123") |
| 2201 | ;; `skip-chars-backward'. | 2198 | (skip-chars-backward "[:alnum:]") |
| 2202 | (progn | 2199 | (bobp)) |
| 2203 | (delete-region (point-min) (point-max)) | 2200 | (= (skip-chars-forward "[:alpha:]") 3)) |
| 2204 | (insert "foo123") | 2201 | (setq list (cons 'posix-char-classes list))) |
| 2205 | (skip-chars-backward "[:alnum:]") | 2202 | |
| 2206 | (bobp)) | 2203 | ;; See if `open-paren-in-column-0-is-defun-start' exists and |
| 2207 | (= (skip-chars-forward "[:alpha:]") 3)) | 2204 | ;; isn't buggy (Emacs >= 21.4). |
| 2208 | (setq list (cons 'posix-char-classes list))) | 2205 | (when (boundp 'open-paren-in-column-0-is-defun-start) |
| 2209 | 2206 | (let ((open-paren-in-column-0-is-defun-start nil) | |
| 2210 | ;; See if `open-paren-in-column-0-is-defun-start' exists and | 2207 | (parse-sexp-ignore-comments t)) |
| 2211 | ;; isn't buggy (Emacs >= 21.4). | 2208 | (delete-region (point-min) (point-max)) |
| 2212 | (when (boundp 'open-paren-in-column-0-is-defun-start) | 2209 | (set-syntax-table (make-syntax-table)) |
| 2213 | (let ((open-paren-in-column-0-is-defun-start nil) | 2210 | (modify-syntax-entry ?\' "\"") |
| 2214 | (parse-sexp-ignore-comments t)) | 2211 | (cond |
| 2215 | (delete-region (point-min) (point-max)) | 2212 | ;; XEmacs. Afaik this is currently an Emacs-only |
| 2216 | (set-syntax-table (make-syntax-table)) | 2213 | ;; feature, but it's good to be prepared. |
| 2217 | (modify-syntax-entry ?\' "\"") | 2214 | ((memq '8-bit list) |
| 2218 | (cond | 2215 | (modify-syntax-entry ?/ ". 1456") |
| 2219 | ;; XEmacs. Afaik this is currently an Emacs-only | 2216 | (modify-syntax-entry ?* ". 23")) |
| 2220 | ;; feature, but it's good to be prepared. | 2217 | ;; Emacs |
| 2221 | ((memq '8-bit list) | 2218 | ((memq '1-bit list) |
| 2222 | (modify-syntax-entry ?/ ". 1456") | 2219 | (modify-syntax-entry ?/ ". 124b") |
| 2223 | (modify-syntax-entry ?* ". 23")) | 2220 | (modify-syntax-entry ?* ". 23"))) |
| 2224 | ;; Emacs | 2221 | (modify-syntax-entry ?\n "> b") |
| 2225 | ((memq '1-bit list) | 2222 | (insert "/* '\n () */") |
| 2226 | (modify-syntax-entry ?/ ". 124b") | 2223 | (backward-sexp) |
| 2227 | (modify-syntax-entry ?* ". 23"))) | 2224 | (if (bobp) |
| 2228 | (modify-syntax-entry ?\n "> b") | 2225 | (setq list (cons 'col-0-paren list))))) |
| 2229 | (insert "/* '\n () */") | 2226 | |
| 2230 | (backward-sexp) | 2227 | (set-buffer-modified-p nil)) |
| 2231 | (if (bobp) | 2228 | (kill-buffer buf))) |
| 2232 | (setq list (cons 'col-0-paren list))))) | ||
| 2233 | |||
| 2234 | (set-buffer-modified-p nil)) | ||
| 2235 | (kill-buffer buf)) | ||
| 2236 | 2229 | ||
| 2237 | ;; Check how many elements `parse-partial-sexp' returns. | 2230 | ;; Check how many elements `parse-partial-sexp' returns. |
| 2238 | (let ((ppss-size (or (c-safe (length | 2231 | (let ((ppss-size (or (c-safe (length |