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.
This commit is contained in:
parent
c9e2a5ec26
commit
09bf476836
1 changed files with 66 additions and 73 deletions
|
@ -2153,86 +2153,79 @@ non-nil, a caret is prepended to invert the set."
|
||||||
;; Record whether the `category' text property works.
|
;; Record whether the `category' text property works.
|
||||||
(if c-use-category (setq list (cons 'category-properties list)))
|
(if c-use-category (setq list (cons 'category-properties list)))
|
||||||
|
|
||||||
(let ((buf (generate-new-buffer " test"))
|
(let ((buf (generate-new-buffer " test")))
|
||||||
parse-sexp-lookup-properties
|
|
||||||
parse-sexp-ignore-comments
|
|
||||||
lookup-syntax-properties) ; XEmacs
|
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(set-syntax-table (make-syntax-table))
|
(let ((parse-sexp-lookup-properties t)
|
||||||
|
(parse-sexp-ignore-comments t)
|
||||||
|
(lookup-syntax-properties t))
|
||||||
|
(set-syntax-table (make-syntax-table))
|
||||||
|
|
||||||
;; For some reason we have to set some of these after the
|
;; Find out if the `syntax-table' text property works.
|
||||||
;; buffer has been made current. (Specifically,
|
(modify-syntax-entry ?< ".")
|
||||||
;; `parse-sexp-ignore-comments' in Emacs 21.)
|
(modify-syntax-entry ?> ".")
|
||||||
(setq parse-sexp-lookup-properties t
|
(insert "<()>")
|
||||||
parse-sexp-ignore-comments t
|
(c-mark-<-as-paren (point-min))
|
||||||
lookup-syntax-properties t)
|
(c-mark->-as-paren (+ 3 (point-min)))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(c-forward-sexp)
|
||||||
|
(if (= (point) (+ 4 (point-min)))
|
||||||
|
(setq list (cons 'syntax-properties list))
|
||||||
|
(error (concat
|
||||||
|
"CC Mode is incompatible with this version of Emacs - "
|
||||||
|
"support for the `syntax-table' text property "
|
||||||
|
"is required.")))
|
||||||
|
|
||||||
;; Find out if the `syntax-table' text property works.
|
;; Find out if "\\s!" (generic comment delimiters) work.
|
||||||
(modify-syntax-entry ?< ".")
|
(c-safe
|
||||||
(modify-syntax-entry ?> ".")
|
(modify-syntax-entry ?x "!")
|
||||||
(insert "<()>")
|
(if (string-match "\\s!" "x")
|
||||||
(c-mark-<-as-paren (point-min))
|
(setq list (cons 'gen-comment-delim list))))
|
||||||
(c-mark->-as-paren (+ 3 (point-min)))
|
|
||||||
(goto-char (point-min))
|
|
||||||
(c-forward-sexp)
|
|
||||||
(if (= (point) (+ 4 (point-min)))
|
|
||||||
(setq list (cons 'syntax-properties list))
|
|
||||||
(error (concat
|
|
||||||
"CC Mode is incompatible with this version of Emacs - "
|
|
||||||
"support for the `syntax-table' text property "
|
|
||||||
"is required.")))
|
|
||||||
|
|
||||||
;; Find out if "\\s!" (generic comment delimiters) work.
|
;; Find out if "\\s|" (generic string delimiters) work.
|
||||||
(c-safe
|
(c-safe
|
||||||
(modify-syntax-entry ?x "!")
|
(modify-syntax-entry ?x "|")
|
||||||
(if (string-match "\\s!" "x")
|
(if (string-match "\\s|" "x")
|
||||||
(setq list (cons 'gen-comment-delim list))))
|
(setq list (cons 'gen-string-delim list))))
|
||||||
|
|
||||||
;; Find out if "\\s|" (generic string delimiters) work.
|
;; See if POSIX char classes work.
|
||||||
(c-safe
|
(when (and (string-match "[[:alpha:]]" "a")
|
||||||
(modify-syntax-entry ?x "|")
|
;; All versions of Emacs 21 so far haven't fixed
|
||||||
(if (string-match "\\s|" "x")
|
;; char classes in `skip-chars-forward' and
|
||||||
(setq list (cons 'gen-string-delim list))))
|
;; `skip-chars-backward'.
|
||||||
|
(progn
|
||||||
|
(delete-region (point-min) (point-max))
|
||||||
|
(insert "foo123")
|
||||||
|
(skip-chars-backward "[:alnum:]")
|
||||||
|
(bobp))
|
||||||
|
(= (skip-chars-forward "[:alpha:]") 3))
|
||||||
|
(setq list (cons 'posix-char-classes list)))
|
||||||
|
|
||||||
;; See if POSIX char classes work.
|
;; See if `open-paren-in-column-0-is-defun-start' exists and
|
||||||
(when (and (string-match "[[:alpha:]]" "a")
|
;; isn't buggy (Emacs >= 21.4).
|
||||||
;; All versions of Emacs 21 so far haven't fixed
|
(when (boundp 'open-paren-in-column-0-is-defun-start)
|
||||||
;; char classes in `skip-chars-forward' and
|
(let ((open-paren-in-column-0-is-defun-start nil)
|
||||||
;; `skip-chars-backward'.
|
(parse-sexp-ignore-comments t))
|
||||||
(progn
|
(delete-region (point-min) (point-max))
|
||||||
(delete-region (point-min) (point-max))
|
(set-syntax-table (make-syntax-table))
|
||||||
(insert "foo123")
|
(modify-syntax-entry ?\' "\"")
|
||||||
(skip-chars-backward "[:alnum:]")
|
(cond
|
||||||
(bobp))
|
;; XEmacs. Afaik this is currently an Emacs-only
|
||||||
(= (skip-chars-forward "[:alpha:]") 3))
|
;; feature, but it's good to be prepared.
|
||||||
(setq list (cons 'posix-char-classes list)))
|
((memq '8-bit list)
|
||||||
|
(modify-syntax-entry ?/ ". 1456")
|
||||||
|
(modify-syntax-entry ?* ". 23"))
|
||||||
|
;; Emacs
|
||||||
|
((memq '1-bit list)
|
||||||
|
(modify-syntax-entry ?/ ". 124b")
|
||||||
|
(modify-syntax-entry ?* ". 23")))
|
||||||
|
(modify-syntax-entry ?\n "> b")
|
||||||
|
(insert "/* '\n () */")
|
||||||
|
(backward-sexp)
|
||||||
|
(if (bobp)
|
||||||
|
(setq list (cons 'col-0-paren list)))))
|
||||||
|
|
||||||
;; See if `open-paren-in-column-0-is-defun-start' exists and
|
(set-buffer-modified-p nil))
|
||||||
;; isn't buggy (Emacs >= 21.4).
|
(kill-buffer buf)))
|
||||||
(when (boundp 'open-paren-in-column-0-is-defun-start)
|
|
||||||
(let ((open-paren-in-column-0-is-defun-start nil)
|
|
||||||
(parse-sexp-ignore-comments t))
|
|
||||||
(delete-region (point-min) (point-max))
|
|
||||||
(set-syntax-table (make-syntax-table))
|
|
||||||
(modify-syntax-entry ?\' "\"")
|
|
||||||
(cond
|
|
||||||
;; XEmacs. Afaik this is currently an Emacs-only
|
|
||||||
;; feature, but it's good to be prepared.
|
|
||||||
((memq '8-bit list)
|
|
||||||
(modify-syntax-entry ?/ ". 1456")
|
|
||||||
(modify-syntax-entry ?* ". 23"))
|
|
||||||
;; Emacs
|
|
||||||
((memq '1-bit list)
|
|
||||||
(modify-syntax-entry ?/ ". 124b")
|
|
||||||
(modify-syntax-entry ?* ". 23")))
|
|
||||||
(modify-syntax-entry ?\n "> b")
|
|
||||||
(insert "/* '\n () */")
|
|
||||||
(backward-sexp)
|
|
||||||
(if (bobp)
|
|
||||||
(setq list (cons 'col-0-paren list)))))
|
|
||||||
|
|
||||||
(set-buffer-modified-p nil))
|
|
||||||
(kill-buffer buf))
|
|
||||||
|
|
||||||
;; Check how many elements `parse-partial-sexp' returns.
|
;; Check how many elements `parse-partial-sexp' returns.
|
||||||
(let ((ppss-size (or (c-safe (length
|
(let ((ppss-size (or (c-safe (length
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue