diff options
| author | Alan Mackenzie | 2023-03-13 16:42:02 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2023-03-13 16:42:02 +0000 |
| commit | 3fb30c8f1338ee8429411d6d36cd8ffbeb42f3cc (patch) | |
| tree | e3af20cbe1db2277e81a53944c80fb34ba945b90 | |
| parent | 75f04848a653e70f12f0e5a62b756c5bba0dd204 (diff) | |
| download | emacs-3fb30c8f1338ee8429411d6d36cd8ffbeb42f3cc.tar.gz emacs-3fb30c8f1338ee8429411d6d36cd8ffbeb42f3cc.zip | |
CC Mode: Allow lists of strings as safe values for *-font-lock-extra-types
* lisp/progmodes/cc-vars.el (c-list-of-strings): New function.
(c-font-lock-extra-types, c++-font-lock-extra-types)
(objc-font-lock-extra-types, java-font-lock-extra-types)
(idl-font-lock-extra-types, pike-font-lock-extra-types): Add a :safe entry
into each of thes defcustoms for c-list-of-string.
(Top level): Add an autoload entry for each of the above.
| -rw-r--r-- | lisp/progmodes/cc-vars.el | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index 60ed3521b8a..dbf24fbbb8b 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el | |||
| @@ -1561,6 +1561,16 @@ also elsewhere in CC Mode to tell types from other identifiers.")) | |||
| 1561 | ;; (as opposed to the *-font-lock-keywords-* variables) since the old | 1561 | ;; (as opposed to the *-font-lock-keywords-* variables) since the old |
| 1562 | ;; values work fairly well anyway. | 1562 | ;; values work fairly well anyway. |
| 1563 | 1563 | ||
| 1564 | (defun c-list-of-strings (obj) | ||
| 1565 | "Return non-nil when OBJ is a list of strings (including the empty list)." | ||
| 1566 | (and | ||
| 1567 | (listp obj) | ||
| 1568 | (catch 'check | ||
| 1569 | (dolist (elt obj) | ||
| 1570 | (when (not (stringp elt)) | ||
| 1571 | (throw 'check nil))) | ||
| 1572 | t))) | ||
| 1573 | |||
| 1564 | (defcustom c-font-lock-extra-types | 1574 | (defcustom c-font-lock-extra-types |
| 1565 | '("\\sw+_t" | 1575 | '("\\sw+_t" |
| 1566 | ;; Defined in C99: | 1576 | ;; Defined in C99: |
| @@ -1576,8 +1586,11 @@ also elsewhere in CC Mode to tell types from other identifiers.")) | |||
| 1576 | "For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word \"FILE\" | 1586 | "For example, a value of (\"FILE\" \"\\\\sw+_t\") means the word \"FILE\" |
| 1577 | and words ending in \"_t\" are treated as type names.") | 1587 | and words ending in \"_t\" are treated as type names.") |
| 1578 | :type 'c-extra-types-widget | 1588 | :type 'c-extra-types-widget |
| 1589 | :safe #'c-list-of-strings | ||
| 1579 | :group 'c) | 1590 | :group 'c) |
| 1580 | 1591 | ||
| 1592 | ;;;###autoload (put 'c-font-lock-extra-types 'safe-local-variable #'c-list-of-strings) | ||
| 1593 | |||
| 1581 | (defcustom c++-font-lock-extra-types | 1594 | (defcustom c++-font-lock-extra-types |
| 1582 | '("\\sw+_t" | 1595 | '("\\sw+_t" |
| 1583 | ;; C library types (except those matched by the _t pattern): | 1596 | ;; C library types (except those matched by the _t pattern): |
| @@ -1607,8 +1620,11 @@ and words ending in \"_t\" are treated as type names.") | |||
| 1607 | "For example, a value of (\"string\") means the word \"string\" is treated | 1620 | "For example, a value of (\"string\") means the word \"string\" is treated |
| 1608 | as a type name.") | 1621 | as a type name.") |
| 1609 | :type 'c-extra-types-widget | 1622 | :type 'c-extra-types-widget |
| 1623 | :safe #'c-list-of-strings | ||
| 1610 | :group 'c) | 1624 | :group 'c) |
| 1611 | 1625 | ||
| 1626 | ;;;###autoload (put 'c++-font-lock-extra-types 'safe-local-variable #'c-list-of-strings) | ||
| 1627 | |||
| 1612 | (defcustom objc-font-lock-extra-types nil | 1628 | (defcustom objc-font-lock-extra-types nil |
| 1613 | (c-make-font-lock-extra-types-blurb "ObjC" "objc-mode" (concat | 1629 | (c-make-font-lock-extra-types-blurb "ObjC" "objc-mode" (concat |
| 1614 | "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means | 1630 | "For example, a value of (\"[" c-upper "]\\\\sw*[" c-lower "]\\\\sw*\") means |
| @@ -1616,8 +1632,11 @@ capitalized words are treated as type names (the requirement for a | |||
| 1616 | lower case char is to avoid recognizing all-caps macro and constant | 1632 | lower case char is to avoid recognizing all-caps macro and constant |
| 1617 | names).")) | 1633 | names).")) |
| 1618 | :type 'c-extra-types-widget | 1634 | :type 'c-extra-types-widget |
| 1635 | :safe #'c-list-of-strings | ||
| 1619 | :group 'c) | 1636 | :group 'c) |
| 1620 | 1637 | ||
| 1638 | ;;;###autoload (put 'objc-font-lock-extra-types 'safe-local-variable #'c-list-of-strings) | ||
| 1639 | |||
| 1621 | (defcustom java-font-lock-extra-types | 1640 | (defcustom java-font-lock-extra-types |
| 1622 | (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw")) | 1641 | (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw")) |
| 1623 | (c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat | 1642 | (c-make-font-lock-extra-types-blurb "Java" "java-mode" (concat |
| @@ -1625,13 +1644,19 @@ names).")) | |||
| 1625 | capitalized words are treated as type names (the requirement for a | 1644 | capitalized words are treated as type names (the requirement for a |
| 1626 | lower case char is to avoid recognizing all-caps constant names).")) | 1645 | lower case char is to avoid recognizing all-caps constant names).")) |
| 1627 | :type 'c-extra-types-widget | 1646 | :type 'c-extra-types-widget |
| 1647 | :safe #'c-list-of-strings | ||
| 1628 | :group 'c) | 1648 | :group 'c) |
| 1629 | 1649 | ||
| 1650 | ;;;###autoload (put 'java-font-lock-extra-types 'safe-local-variable #'c-list-of-strings) | ||
| 1651 | |||
| 1630 | (defcustom idl-font-lock-extra-types nil | 1652 | (defcustom idl-font-lock-extra-types nil |
| 1631 | (c-make-font-lock-extra-types-blurb "IDL" "idl-mode" "") | 1653 | (c-make-font-lock-extra-types-blurb "IDL" "idl-mode" "") |
| 1632 | :type 'c-extra-types-widget | 1654 | :type 'c-extra-types-widget |
| 1655 | :safe #'c-list-of-strings | ||
| 1633 | :group 'c) | 1656 | :group 'c) |
| 1634 | 1657 | ||
| 1658 | ;;;###autoload (put 'idl-font-lock-extra-types 'safe-local-variable #'c-list-of-strings) | ||
| 1659 | |||
| 1635 | (defcustom pike-font-lock-extra-types | 1660 | (defcustom pike-font-lock-extra-types |
| 1636 | (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) | 1661 | (list (concat "[" c-upper "]\\sw*[" c-lower "]\\sw*")) |
| 1637 | (c-make-font-lock-extra-types-blurb "Pike" "pike-mode" (concat | 1662 | (c-make-font-lock-extra-types-blurb "Pike" "pike-mode" (concat |
| @@ -1640,8 +1665,11 @@ capitalized words are treated as type names (the requirement for a | |||
| 1640 | lower case char is to avoid recognizing all-caps macro and constant | 1665 | lower case char is to avoid recognizing all-caps macro and constant |
| 1641 | names).")) | 1666 | names).")) |
| 1642 | :type 'c-extra-types-widget | 1667 | :type 'c-extra-types-widget |
| 1668 | :safe #'c-list-of-strings | ||
| 1643 | :group 'c) | 1669 | :group 'c) |
| 1644 | 1670 | ||
| 1671 | ;;;###autoload (put 'pike-font-lock-extra-types 'safe-local-variable #'c-list-of-strings) | ||
| 1672 | |||
| 1645 | (defcustom c-asymmetry-fontification-flag t | 1673 | (defcustom c-asymmetry-fontification-flag t |
| 1646 | "Whether to fontify certain ambiguous constructs by white space asymmetry. | 1674 | "Whether to fontify certain ambiguous constructs by white space asymmetry. |
| 1647 | 1675 | ||