aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/progmodes/cc-engine.el58
-rw-r--r--lisp/progmodes/cc-mode.el2
-rw-r--r--lisp/progmodes/cc-vars.el4
3 files changed, 52 insertions, 12 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 071efbc55b5..27ce3029c4a 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -1732,6 +1732,7 @@ comment at the start of cc-engine.el for more info."
1732 (put-text-property beg end 'c-is-sws t) 1732 (put-text-property beg end 'c-is-sws t)
1733 ,@(when (facep 'c-debug-is-sws-face) 1733 ,@(when (facep 'c-debug-is-sws-face)
1734 '((c-debug-add-face beg end 'c-debug-is-sws-face))))) 1734 '((c-debug-add-face beg end 'c-debug-is-sws-face)))))
1735(def-edebug-spec c-put-is-sws t)
1735 1736
1736(defmacro c-put-in-sws (beg end) 1737(defmacro c-put-in-sws (beg end)
1737 ;; This macro does a hidden buffer change. 1738 ;; This macro does a hidden buffer change.
@@ -1739,6 +1740,7 @@ comment at the start of cc-engine.el for more info."
1739 (put-text-property beg end 'c-in-sws t) 1740 (put-text-property beg end 'c-in-sws t)
1740 ,@(when (facep 'c-debug-is-sws-face) 1741 ,@(when (facep 'c-debug-is-sws-face)
1741 '((c-debug-add-face beg end 'c-debug-in-sws-face))))) 1742 '((c-debug-add-face beg end 'c-debug-in-sws-face)))))
1743(def-edebug-spec c-put-in-sws t)
1742 1744
1743(defmacro c-remove-is-sws (beg end) 1745(defmacro c-remove-is-sws (beg end)
1744 ;; This macro does a hidden buffer change. 1746 ;; This macro does a hidden buffer change.
@@ -1746,6 +1748,7 @@ comment at the start of cc-engine.el for more info."
1746 (remove-text-properties beg end '(c-is-sws nil)) 1748 (remove-text-properties beg end '(c-is-sws nil))
1747 ,@(when (facep 'c-debug-is-sws-face) 1749 ,@(when (facep 'c-debug-is-sws-face)
1748 '((c-debug-remove-face beg end 'c-debug-is-sws-face))))) 1750 '((c-debug-remove-face beg end 'c-debug-is-sws-face)))))
1751(def-edebug-spec c-remove-is-sws t)
1749 1752
1750(defmacro c-remove-in-sws (beg end) 1753(defmacro c-remove-in-sws (beg end)
1751 ;; This macro does a hidden buffer change. 1754 ;; This macro does a hidden buffer change.
@@ -1753,6 +1756,7 @@ comment at the start of cc-engine.el for more info."
1753 (remove-text-properties beg end '(c-in-sws nil)) 1756 (remove-text-properties beg end '(c-in-sws nil))
1754 ,@(when (facep 'c-debug-is-sws-face) 1757 ,@(when (facep 'c-debug-is-sws-face)
1755 '((c-debug-remove-face beg end 'c-debug-in-sws-face))))) 1758 '((c-debug-remove-face beg end 'c-debug-in-sws-face)))))
1759(def-edebug-spec c-remove-in-sws t)
1756 1760
1757(defmacro c-remove-is-and-in-sws (beg end) 1761(defmacro c-remove-is-and-in-sws (beg end)
1758 ;; This macro does a hidden buffer change. 1762 ;; This macro does a hidden buffer change.
@@ -1761,6 +1765,7 @@ comment at the start of cc-engine.el for more info."
1761 ,@(when (facep 'c-debug-is-sws-face) 1765 ,@(when (facep 'c-debug-is-sws-face)
1762 '((c-debug-remove-face beg end 'c-debug-is-sws-face) 1766 '((c-debug-remove-face beg end 'c-debug-is-sws-face)
1763 (c-debug-remove-face beg end 'c-debug-in-sws-face))))) 1767 (c-debug-remove-face beg end 'c-debug-in-sws-face)))))
1768(def-edebug-spec c-remove-is-and-in-sws t)
1764 1769
1765;; The type of literal position `end' is in a `before-change-functions' 1770;; The type of literal position `end' is in a `before-change-functions'
1766;; function - one of `c', `c++', `pound', or nil (but NOT `string'). 1771;; function - one of `c', `c++', `pound', or nil (but NOT `string').
@@ -1769,12 +1774,14 @@ comment at the start of cc-engine.el for more info."
1769;; enclosing END, if any, else nil. 1774;; enclosing END, if any, else nil.
1770(defvar c-sws-lit-limits nil) 1775(defvar c-sws-lit-limits nil)
1771 1776
1772(defun c-invalidate-sws-region-before (end) 1777(defun c-invalidate-sws-region-before (beg end)
1773 ;; Called from c-before-change. END is the end of the change region, the 1778 ;; Called from c-before-change. BEG and END are the bounds of the change
1774 ;; standard parameter given to all before-change-functions. 1779 ;; region, the standard parameters given to all before-change-functions.
1775 ;; 1780 ;;
1776 ;; Note whether END is inside a comment or CPP construct, and if so note its 1781 ;; Note whether END is inside a comment, CPP construct, or noise macro, and
1777 ;; bounds in `c-sws-lit-limits' and type in `c-sws-lit-type'. 1782 ;; if so note its bounds in `c-sws-lit-limits' and type in `c-sws-lit-type'.
1783 (setq c-sws-lit-type nil
1784 c-sws-lit-limits nil)
1778 (save-excursion 1785 (save-excursion
1779 (goto-char end) 1786 (goto-char end)
1780 (let* ((limits (c-literal-limits)) 1787 (let* ((limits (c-literal-limits))
@@ -1787,8 +1794,19 @@ comment at the start of cc-engine.el for more info."
1787 (setq c-sws-lit-type 'pound 1794 (setq c-sws-lit-type 'pound
1788 c-sws-lit-limits (cons (point) 1795 c-sws-lit-limits (cons (point)
1789 (progn (c-end-of-macro) (point))))) 1796 (progn (c-end-of-macro) (point)))))
1790 (t (setq c-sws-lit-type nil 1797 ((progn (skip-syntax-backward "w_")
1791 c-sws-lit-limits nil)))))) 1798 (looking-at c-noise-macro-name-re))
1799 (setq c-sws-lit-type 'noise
1800 c-sws-lit-limits (cons (match-beginning 1) (match-end 1))))
1801 (t))))
1802 (save-excursion
1803 (goto-char beg)
1804 (skip-syntax-backward "w_")
1805 (when (looking-at c-noise-macro-name-re)
1806 (setq c-sws-lit-type 'noise)
1807 (if (consp c-sws-lit-limits)
1808 (setcar c-sws-lit-limits (match-beginning 1))
1809 (setq c-sws-lit-limits (cons (match-beginning 1) (match-end 1)))))))
1792 1810
1793(defun c-invalidate-sws-region-after-del (beg end old-len) 1811(defun c-invalidate-sws-region-after-del (beg end old-len)
1794 ;; Text has been deleted, OLD-LEN characters of it starting from position 1812 ;; Text has been deleted, OLD-LEN characters of it starting from position
@@ -1797,7 +1815,6 @@ comment at the start of cc-engine.el for more info."
1797 ;; deletion deleted or "damaged" its opening delimiter. If so, return the 1815 ;; deletion deleted or "damaged" its opening delimiter. If so, return the
1798 ;; current position of where the construct ended, otherwise return nil. 1816 ;; current position of where the construct ended, otherwise return nil.
1799 (when c-sws-lit-limits 1817 (when c-sws-lit-limits
1800 (setcdr c-sws-lit-limits (- (cdr c-sws-lit-limits) old-len))
1801 (if (and (< beg (+ (car c-sws-lit-limits) 2)) ; A lazy assumption that 1818 (if (and (< beg (+ (car c-sws-lit-limits) 2)) ; A lazy assumption that
1802 ; comment delimiters are 2 1819 ; comment delimiters are 2
1803 ; chars long. 1820 ; chars long.
@@ -1815,9 +1832,9 @@ comment at the start of cc-engine.el for more info."
1815 ;; or `c-is-sws' text properties inside this literal. If there are, return 1832 ;; or `c-is-sws' text properties inside this literal. If there are, return
1816 ;; the buffer position of the end of the literal, else return nil. 1833 ;; the buffer position of the end of the literal, else return nil.
1817 (save-excursion 1834 (save-excursion
1835 (goto-char end)
1818 (let* ((limits (c-literal-limits)) 1836 (let* ((limits (c-literal-limits))
1819 (lit-type (c-literal-type limits))) 1837 (lit-type (c-literal-type limits)))
1820 (goto-char end)
1821 (when (and (not (memq lit-type '(c c++))) 1838 (when (and (not (memq lit-type '(c c++)))
1822 (c-beginning-of-macro)) 1839 (c-beginning-of-macro))
1823 (setq lit-type 'pound 1840 (setq lit-type 'pound
@@ -1841,6 +1858,10 @@ comment at the start of cc-engine.el for more info."
1841 ;; properties right after they're added. 1858 ;; properties right after they're added.
1842 ;; 1859 ;;
1843 ;; This function does hidden buffer changes. 1860 ;; This function does hidden buffer changes.
1861 (when c-sws-lit-limits
1862 (setcar c-sws-lit-limits (min beg (car c-sws-lit-limits)))
1863 (setcdr c-sws-lit-limits
1864 (max end (- (+ (cdr c-sws-lit-limits) (- end beg)) old-len))))
1844 (let ((del-end 1865 (let ((del-end
1845 (and (> old-len 0) 1866 (and (> old-len 0)
1846 (c-invalidate-sws-region-after-del beg end old-len))) 1867 (c-invalidate-sws-region-after-del beg end old-len)))
@@ -1860,6 +1881,10 @@ comment at the start of cc-engine.el for more info."
1860 (when (and (eolp) (not (eobp))) 1881 (when (and (eolp) (not (eobp)))
1861 (setq end (1+ (point))))) 1882 (setq end (1+ (point)))))
1862 1883
1884 (when (eq c-sws-lit-type 'noise)
1885 (setq beg (car c-sws-lit-limits)
1886 end (cdr c-sws-lit-limits))) ; This last setting may be redundant.
1887
1863 (when (and (= beg end) 1888 (when (and (= beg end)
1864 (get-text-property beg 'c-in-sws) 1889 (get-text-property beg 'c-in-sws)
1865 (> beg (point-min)) 1890 (> beg (point-min))
@@ -1879,6 +1904,7 @@ comment at the start of cc-engine.el for more info."
1879 1904
1880 (setq end (max (or del-end end) 1905 (setq end (max (or del-end end)
1881 (or ins-end end) 1906 (or ins-end end)
1907 (or (cdr c-sws-lit-limits) end)
1882 end)) 1908 end))
1883 1909
1884 (c-debug-sws-msg "c-invalidate-sws-region-after [%s..%s]" beg end) 1910 (c-debug-sws-msg "c-invalidate-sws-region-after [%s..%s]" beg end)
@@ -2147,7 +2173,8 @@ comment at the start of cc-engine.el for more info."
2147 ;; Try to find a rung position in the simple ws preceding point, so that 2173 ;; Try to find a rung position in the simple ws preceding point, so that
2148 ;; we can get a cache hit even if the last bit of the simple ws has 2174 ;; we can get a cache hit even if the last bit of the simple ws has
2149 ;; changed recently. 2175 ;; changed recently.
2150 (setq simple-ws-beg (point)) 2176 (setq simple-ws-beg (or (match-end 1) ; Noise macro
2177 (match-end 0))) ; c-syntactic-ws-end
2151 (skip-chars-backward " \t\n\r\f\v") 2178 (skip-chars-backward " \t\n\r\f\v")
2152 (if (setq rung-is-marked (text-property-any 2179 (if (setq rung-is-marked (text-property-any
2153 (point) (min (1+ rung-pos) (point-max)) 2180 (point) (min (1+ rung-pos) (point-max))
@@ -8672,7 +8699,16 @@ comment at the start of cc-engine.el for more info."
8672 (not (and (c-major-mode-is 'c-mode) 8699 (not (and (c-major-mode-is 'c-mode)
8673 (not got-prefix) 8700 (not got-prefix)
8674 (or (eq context 'top) make-top) 8701 (or (eq context 'top) make-top)
8675 (eq (char-after) ?\))))) 8702 (eq (char-after) ?\))
8703 (or (memq at-type '(nil maybe))
8704 (not got-identifier)
8705 (save-excursion
8706 (goto-char after-paren-pos)
8707 (c-forward-syntactic-ws)
8708 ;; Prevent the symbol being recorded as a type.
8709 (let (c-record-type-identifiers)
8710 (not (memq (c-forward-type)
8711 '(nil maybe)))))))))
8676 (if (eq (char-after) ?\)) 8712 (if (eq (char-after) ?\))
8677 (when (> paren-depth 0) 8713 (when (> paren-depth 0)
8678 (setq paren-depth (1- paren-depth)) 8714 (setq paren-depth (1- paren-depth))
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index a2ad07fddb0..6718813b79c 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -1623,7 +1623,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
1623 ;; Are we coalescing two tokens together, e.g. "fo o" -> "foo"? 1623 ;; Are we coalescing two tokens together, e.g. "fo o" -> "foo"?
1624 (when (< beg end) 1624 (when (< beg end)
1625 (c-unfind-coalesced-tokens beg end)) 1625 (c-unfind-coalesced-tokens beg end))
1626 (c-invalidate-sws-region-before end) 1626 (c-invalidate-sws-region-before beg end)
1627 ;; Are we (potentially) disrupting the syntactic context which 1627 ;; Are we (potentially) disrupting the syntactic context which
1628 ;; makes a type a type? E.g. by inserting stuff after "foo" in 1628 ;; makes a type a type? E.g. by inserting stuff after "foo" in
1629 ;; "foo bar;", or before "foo" in "typedef foo *bar;"? 1629 ;; "foo bar;", or before "foo" in "typedef foo *bar;"?
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 66960b630e1..89534882672 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -1649,7 +1649,9 @@ white space either before or after the operator, but not both."
1649 1649
1650;; Initialize the next two to a regexp which never matches. 1650;; Initialize the next two to a regexp which never matches.
1651(defvar c-noise-macro-with-parens-name-re "a\\`") 1651(defvar c-noise-macro-with-parens-name-re "a\\`")
1652(make-variable-buffer-local 'c-noise-macro-with-parens-name-re)
1652(defvar c-noise-macro-name-re "a\\`") 1653(defvar c-noise-macro-name-re "a\\`")
1654(make-variable-buffer-local 'c-noise-macro-name-re)
1653 1655
1654(defcustom c-noise-macro-names nil 1656(defcustom c-noise-macro-names nil
1655 "A list of names of macros which expand to nothing, or compiler extensions 1657 "A list of names of macros which expand to nothing, or compiler extensions
@@ -1664,6 +1666,7 @@ this implicitly by reinitializing C/C++/Objc Mode on any buffer)."
1664 :type '(repeat :tag "List of names" string) 1666 :type '(repeat :tag "List of names" string)
1665 :group 'c) 1667 :group 'c)
1666(put 'c-noise-macro-names 'safe-local-variable #'c-string-list-p) 1668(put 'c-noise-macro-names 'safe-local-variable #'c-string-list-p)
1669(make-variable-buffer-local 'c-noise-macro-names)
1667 1670
1668(defcustom c-noise-macro-with-parens-names nil 1671(defcustom c-noise-macro-with-parens-names nil
1669 "A list of names of macros \(or compiler extensions like \"__attribute__\") 1672 "A list of names of macros \(or compiler extensions like \"__attribute__\")
@@ -1673,6 +1676,7 @@ These are recognized by CC Mode only in declarations."
1673 :type '(repeat :tag "List of names (possibly empty)" string) 1676 :type '(repeat :tag "List of names (possibly empty)" string)
1674 :group 'c) 1677 :group 'c)
1675(put 'c-noise-macro-with-parens-names 'safe-local-variable #'c-string-list-p) 1678(put 'c-noise-macro-with-parens-names 'safe-local-variable #'c-string-list-p)
1679(make-variable-buffer-local 'c-noise-macro-with-parens-names)
1676 1680
1677(defun c-make-noise-macro-regexps () 1681(defun c-make-noise-macro-regexps ()
1678 ;; Convert `c-noise-macro-names' and `c-noise-macro-with-parens-names' into 1682 ;; Convert `c-noise-macro-names' and `c-noise-macro-with-parens-names' into