aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes
diff options
context:
space:
mode:
authorYuuki Harano2020-12-21 01:53:07 +0900
committerYuuki Harano2020-12-21 01:53:07 +0900
commit565d8f57d349c19d9bbb5d5d5fdacf3c70b85d42 (patch)
tree5a25406b9f4ff091cb6856e857d2857bb3e631e4 /lisp/progmodes
parenta44cd7c88121bb0e04bdf13d73e15f085cf3b085 (diff)
parent87b82a1969edf80d3bd4781454ec9fc968773a6d (diff)
downloademacs-565d8f57d349c19d9bbb5d5d5fdacf3c70b85d42.tar.gz
emacs-565d8f57d349c19d9bbb5d5d5fdacf3c70b85d42.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs into feature/pgtk
Diffstat (limited to 'lisp/progmodes')
-rw-r--r--lisp/progmodes/cc-engine.el319
-rw-r--r--lisp/progmodes/cc-fonts.el139
-rw-r--r--lisp/progmodes/cc-langs.el1
-rw-r--r--lisp/progmodes/cc-mode.el33
-rw-r--r--lisp/progmodes/cc-vars.el3
-rw-r--r--lisp/progmodes/cperl-mode.el17
-rw-r--r--lisp/progmodes/elisp-mode.el2
-rw-r--r--lisp/progmodes/flymake-proc.el6
-rw-r--r--lisp/progmodes/flymake.el68
-rw-r--r--lisp/progmodes/gdb-mi.el35
-rw-r--r--lisp/progmodes/hideif.el6
-rw-r--r--lisp/progmodes/octave.el5
-rw-r--r--lisp/progmodes/project.el93
-rw-r--r--lisp/progmodes/python.el15
-rw-r--r--lisp/progmodes/ruby-mode.el2
-rw-r--r--lisp/progmodes/verilog-mode.el3
-rw-r--r--lisp/progmodes/which-func.el7
17 files changed, 472 insertions, 282 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index f14ffb38cde..218bbb47cd5 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -972,7 +972,7 @@ comment at the start of cc-engine.el for more info."
972 ;; that we've moved. 972 ;; that we've moved.
973 (while (progn 973 (while (progn
974 (setq pos (point)) 974 (setq pos (point))
975 (c-backward-syntactic-ws) 975 (c-backward-syntactic-ws lim)
976 ;; Protect post-++/-- operators just before a virtual semicolon. 976 ;; Protect post-++/-- operators just before a virtual semicolon.
977 (and (not (c-at-vsemi-p)) 977 (and (not (c-at-vsemi-p))
978 (/= (skip-chars-backward "-+!*&~@`#") 0)))) 978 (/= (skip-chars-backward "-+!*&~@`#") 0))))
@@ -984,7 +984,7 @@ comment at the start of cc-engine.el for more info."
984 (if (and (memq (char-before) delims) 984 (if (and (memq (char-before) delims)
985 (progn (forward-char -1) 985 (progn (forward-char -1)
986 (setq saved (point)) 986 (setq saved (point))
987 (c-backward-syntactic-ws) 987 (c-backward-syntactic-ws lim)
988 (or (memq (char-before) delims) 988 (or (memq (char-before) delims)
989 (memq (char-before) '(?: nil)) 989 (memq (char-before) '(?: nil))
990 (eq (char-syntax (char-before)) ?\() 990 (eq (char-syntax (char-before)) ?\()
@@ -1164,7 +1164,7 @@ comment at the start of cc-engine.el for more info."
1164 ;; HERE IS THE SINGLE PLACE INSIDE THE PDA LOOP WHERE WE MOVE 1164 ;; HERE IS THE SINGLE PLACE INSIDE THE PDA LOOP WHERE WE MOVE
1165 ;; BACKWARDS THROUGH THE SOURCE. 1165 ;; BACKWARDS THROUGH THE SOURCE.
1166 1166
1167 (c-backward-syntactic-ws) 1167 (c-backward-syntactic-ws lim)
1168 (let ((before-sws-pos (point)) 1168 (let ((before-sws-pos (point))
1169 ;; The end position of the area to search for statement 1169 ;; The end position of the area to search for statement
1170 ;; barriers in this round. 1170 ;; barriers in this round.
@@ -1174,33 +1174,35 @@ comment at the start of cc-engine.el for more info."
1174 ;; Go back over exactly one logical sexp, taking proper 1174 ;; Go back over exactly one logical sexp, taking proper
1175 ;; account of macros and escaped EOLs. 1175 ;; account of macros and escaped EOLs.
1176 (while 1176 (while
1177 (progn 1177 (and
1178 (setq comma-delimited (and (not comma-delim) 1178 (progn
1179 (eq (char-before) ?\,))) 1179 (setq comma-delimited (and (not comma-delim)
1180 (unless (c-safe (c-backward-sexp) t) 1180 (eq (char-before) ?\,)))
1181 ;; Give up if we hit an unbalanced block. Since the 1181 (unless (c-safe (c-backward-sexp) t)
1182 ;; stack won't be empty the code below will report a 1182 ;; Give up if we hit an unbalanced block. Since the
1183 ;; suitable error. 1183 ;; stack won't be empty the code below will report a
1184 (setq pre-stmt-found t) 1184 ;; suitable error.
1185 (throw 'loop nil)) 1185 (setq pre-stmt-found t)
1186 (cond 1186 (throw 'loop nil))
1187 ;; Have we moved into a macro? 1187 (cond
1188 ((and (not macro-start) 1188 ;; Have we moved into a macro?
1189 (c-beginning-of-macro)) 1189 ((and (not macro-start)
1190 (save-excursion 1190 (c-beginning-of-macro))
1191 (c-backward-syntactic-ws)
1192 (setq before-sws-pos (point)))
1193 ;; Have we crossed a statement boundary? If not,
1194 ;; keep going back until we find one or a "real" sexp.
1195 (and
1196 (save-excursion 1191 (save-excursion
1197 (c-end-of-macro) 1192 (c-backward-syntactic-ws lim)
1198 (not (c-crosses-statement-barrier-p 1193 (setq before-sws-pos (point)))
1199 (point) maybe-after-boundary-pos))) 1194 ;; Have we crossed a statement boundary? If not,
1200 (setq maybe-after-boundary-pos (point)))) 1195 ;; keep going back until we find one or a "real" sexp.
1201 ;; Have we just gone back over an escaped NL? This 1196 (and
1202 ;; doesn't count as a sexp. 1197 (save-excursion
1203 ((looking-at "\\\\$"))))) 1198 (c-end-of-macro)
1199 (not (c-crosses-statement-barrier-p
1200 (point) maybe-after-boundary-pos)))
1201 (setq maybe-after-boundary-pos (point))))
1202 ;; Have we just gone back over an escaped NL? This
1203 ;; doesn't count as a sexp.
1204 ((looking-at "\\\\$"))))
1205 (>= (point) lim)))
1204 1206
1205 ;; Have we crossed a statement boundary? 1207 ;; Have we crossed a statement boundary?
1206 (setq boundary-pos 1208 (setq boundary-pos
@@ -1413,7 +1415,7 @@ comment at the start of cc-engine.el for more info."
1413 1415
1414 ;; Skip over the unary operators that can start the statement. 1416 ;; Skip over the unary operators that can start the statement.
1415 (while (progn 1417 (while (progn
1416 (c-backward-syntactic-ws) 1418 (c-backward-syntactic-ws lim)
1417 ;; protect AWK post-inc/decrement operators, etc. 1419 ;; protect AWK post-inc/decrement operators, etc.
1418 (and (not (c-at-vsemi-p (point))) 1420 (and (not (c-at-vsemi-p (point)))
1419 (/= (skip-chars-backward "-.+!*&~@`#") 0))) 1421 (/= (skip-chars-backward "-.+!*&~@`#") 0)))
@@ -3568,15 +3570,19 @@ mhtml-mode."
3568 ;; Return a start position for building `c-state-cache' from 3570 ;; Return a start position for building `c-state-cache' from
3569 ;; scratch. This will be at the top level, 2 defuns back. 3571 ;; scratch. This will be at the top level, 2 defuns back.
3570 (save-excursion 3572 (save-excursion
3571 ;; Go back 2 bods, but ignore any bogus positions returned by 3573 (save-restriction
3572 ;; beginning-of-defun (i.e. open paren in column zero). 3574 (when (> here (* 10 c-state-cache-too-far))
3573 (goto-char here) 3575 (narrow-to-region (- here (* 10 c-state-cache-too-far)) here))
3574 (let ((cnt 2)) 3576 ;; Go back 2 bods, but ignore any bogus positions returned by
3575 (while (not (or (bobp) (zerop cnt))) 3577 ;; beginning-of-defun (i.e. open paren in column zero).
3576 (c-beginning-of-defun-1) ; Pure elisp BOD. 3578 (goto-char here)
3577 (if (eq (char-after) ?\{) 3579 (let ((cnt 2))
3578 (setq cnt (1- cnt))))) 3580 (while (not (or (bobp) (zerop cnt)))
3579 (point))) 3581 (c-beginning-of-defun-1) ; Pure elisp BOD.
3582 (if (eq (char-after) ?\{)
3583 (setq cnt (1- cnt)))))
3584 (and (not (bobp))
3585 (point)))))
3580 3586
3581(defun c-state-balance-parens-backwards (here- here+ top) 3587(defun c-state-balance-parens-backwards (here- here+ top)
3582 ;; Return the position of the opening paren/brace/bracket before HERE- which 3588 ;; Return the position of the opening paren/brace/bracket before HERE- which
@@ -3667,9 +3673,7 @@ mhtml-mode."
3667 how-far 0)) 3673 how-far 0))
3668 ((<= good-pos here) 3674 ((<= good-pos here)
3669 (setq strategy 'forward 3675 (setq strategy 'forward
3670 start-point (if changed-macro-start 3676 start-point (max good-pos cache-pos)
3671 cache-pos
3672 (max good-pos cache-pos))
3673 how-far (- here start-point))) 3677 how-far (- here start-point)))
3674 ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting. 3678 ((< (- good-pos here) (- here cache-pos)) ; FIXME!!! ; apply some sort of weighting.
3675 (setq strategy 'backward 3679 (setq strategy 'backward
@@ -3688,7 +3692,8 @@ mhtml-mode."
3688 ;; (not (c-major-mode-is 'c++-mode)) 3692 ;; (not (c-major-mode-is 'c++-mode))
3689 (> how-far c-state-cache-too-far)) 3693 (> how-far c-state-cache-too-far))
3690 (setq BOD-pos (c-get-fallback-scan-pos here)) ; somewhat EXPENSIVE!!! 3694 (setq BOD-pos (c-get-fallback-scan-pos here)) ; somewhat EXPENSIVE!!!
3691 (if (< (- here BOD-pos) how-far) 3695 (if (and BOD-pos
3696 (< (- here BOD-pos) how-far))
3692 (setq strategy 'BOD 3697 (setq strategy 'BOD
3693 start-point BOD-pos))) 3698 start-point BOD-pos)))
3694 3699
@@ -4337,8 +4342,12 @@ mhtml-mode."
4337 (if (and dropped-cons 4342 (if (and dropped-cons
4338 (<= too-high-pa here)) 4343 (<= too-high-pa here))
4339 (c-append-lower-brace-pair-to-state-cache too-high-pa here here-bol)) 4344 (c-append-lower-brace-pair-to-state-cache too-high-pa here here-bol))
4340 (setq c-state-cache-good-pos (or (c-state-cache-after-top-paren) 4345 (if (and c-state-cache-good-pos (< here c-state-cache-good-pos))
4341 (c-state-get-min-scan-pos))))) 4346 (setq c-state-cache-good-pos
4347 (or (save-excursion
4348 (goto-char here)
4349 (c-literal-start))
4350 here)))))
4342 4351
4343 ;; The brace-pair desert marker: 4352 ;; The brace-pair desert marker:
4344 (when (car c-state-brace-pair-desert) 4353 (when (car c-state-brace-pair-desert)
@@ -4796,7 +4805,7 @@ comment at the start of cc-engine.el for more info."
4796 4805
4797 ;; Handle the "operator +" syntax in C++. 4806 ;; Handle the "operator +" syntax in C++.
4798 (when (and c-overloadable-operators-regexp 4807 (when (and c-overloadable-operators-regexp
4799 (= (c-backward-token-2 0) 0)) 4808 (= (c-backward-token-2 0 nil (c-determine-limit 500)) 0))
4800 4809
4801 (cond ((and (looking-at c-overloadable-operators-regexp) 4810 (cond ((and (looking-at c-overloadable-operators-regexp)
4802 (or (not c-opt-op-identifier-prefix) 4811 (or (not c-opt-op-identifier-prefix)
@@ -5065,7 +5074,8 @@ See `c-forward-token-2' for details."
5065 (while (and 5074 (while (and
5066 (> count 0) 5075 (> count 0)
5067 (progn 5076 (progn
5068 (c-backward-syntactic-ws) 5077 (c-backward-syntactic-ws
5078 limit)
5069 (backward-char) 5079 (backward-char)
5070 (if (looking-at jump-syntax) 5080 (if (looking-at jump-syntax)
5071 (goto-char (scan-sexps (1+ (point)) -1)) 5081 (goto-char (scan-sexps (1+ (point)) -1))
@@ -5402,8 +5412,12 @@ comment at the start of cc-engine.el for more info."
5402 ;; Optimize for, in particular, large blocks of comments from 5412 ;; Optimize for, in particular, large blocks of comments from
5403 ;; `comment-region'. 5413 ;; `comment-region'.
5404 (progn (when opt-ws 5414 (progn (when opt-ws
5405 (c-backward-syntactic-ws) 5415 (let ((opt-pos (point)))
5406 (setq paren-level-pos (point))) 5416 (c-backward-syntactic-ws limit)
5417 (if (or (null limit)
5418 (> (point) limit))
5419 (setq paren-level-pos (point))
5420 (goto-char opt-pos))))
5407 t) 5421 t)
5408 ;; Move back to a candidate end point which isn't in a literal 5422 ;; Move back to a candidate end point which isn't in a literal
5409 ;; or in a macro we didn't start in. 5423 ;; or in a macro we didn't start in.
@@ -5423,7 +5437,11 @@ comment at the start of cc-engine.el for more info."
5423 (setq macro-start (point)))) 5437 (setq macro-start (point))))
5424 (goto-char macro-start)))) 5438 (goto-char macro-start))))
5425 (when opt-ws 5439 (when opt-ws
5426 (c-backward-syntactic-ws))) 5440 (let ((opt-pos (point)))
5441 (c-backward-syntactic-ws limit)
5442 (if (and limit
5443 (<= (point) limit))
5444 (goto-char opt-pos)))))
5427 (< (point) pos)) 5445 (< (point) pos))
5428 5446
5429 ;; Check whether we're at the wrong level of nesting (when 5447 ;; Check whether we're at the wrong level of nesting (when
@@ -5474,7 +5492,7 @@ comment at the start of cc-engine.el for more info."
5474 (progn 5492 (progn
5475 ;; Skip syntactic ws afterwards so that we don't stop at the 5493 ;; Skip syntactic ws afterwards so that we don't stop at the
5476 ;; end of a comment if `skip-chars' is something like "^/". 5494 ;; end of a comment if `skip-chars' is something like "^/".
5477 (c-backward-syntactic-ws) 5495 (c-backward-syntactic-ws limit)
5478 (point))))) 5496 (point)))))
5479 5497
5480 ;; We might want to extend this with more useful return values in 5498 ;; We might want to extend this with more useful return values in
@@ -5762,12 +5780,23 @@ comment at the start of cc-engine.el for more info."
5762 (t 'c))) ; Assuming the range is valid. 5780 (t 'c))) ; Assuming the range is valid.
5763 range)) 5781 range))
5764 5782
5783(defun c-determine-limit-no-macro (here org-start)
5784 ;; If HERE is inside a macro, and ORG-START is not also in the same macro,
5785 ;; return the beginning of the macro. Otherwise return HERE. Point is not
5786 ;; preserved by this function.
5787 (goto-char here)
5788 (let ((here-BOM (and (c-beginning-of-macro) (point))))
5789 (if (and here-BOM
5790 (not (eq (progn (goto-char org-start)
5791 (and (c-beginning-of-macro) (point)))
5792 here-BOM)))
5793 here-BOM
5794 here)))
5795
5765(defsubst c-determine-limit-get-base (start try-size) 5796(defsubst c-determine-limit-get-base (start try-size)
5766 ;; Get a "safe place" approximately TRY-SIZE characters before START. 5797 ;; Get a "safe place" approximately TRY-SIZE characters before START.
5767 ;; This defsubst doesn't preserve point. 5798 ;; This defsubst doesn't preserve point.
5768 (goto-char start) 5799 (goto-char start)
5769 (c-backward-syntactic-ws)
5770 (setq start (point))
5771 (let* ((pos (max (- start try-size) (point-min))) 5800 (let* ((pos (max (- start try-size) (point-min)))
5772 (s (c-semi-pp-to-literal pos)) 5801 (s (c-semi-pp-to-literal pos))
5773 (cand (or (car (cddr s)) pos))) 5802 (cand (or (car (cddr s)) pos)))
@@ -5776,20 +5805,23 @@ comment at the start of cc-engine.el for more info."
5776 (parse-partial-sexp pos start nil nil (car s) 'syntax-table) 5805 (parse-partial-sexp pos start nil nil (car s) 'syntax-table)
5777 (point)))) 5806 (point))))
5778 5807
5779(defun c-determine-limit (how-far-back &optional start try-size) 5808(defun c-determine-limit (how-far-back &optional start try-size org-start)
5780 ;; Return a buffer position approximately HOW-FAR-BACK non-literal 5809 ;; Return a buffer position approximately HOW-FAR-BACK non-literal
5781 ;; characters from START (default point). The starting position, either 5810 ;; characters from START (default point). The starting position, either
5782 ;; point or START may not be in a comment or string. 5811 ;; point or START may not be in a comment or string.
5783 ;; 5812 ;;
5784 ;; The position found will not be before POINT-MIN and won't be in a 5813 ;; The position found will not be before POINT-MIN and won't be in a
5785 ;; literal. 5814 ;; literal. It will also not be inside a macro, unless START/point is also
5815 ;; in the same macro.
5786 ;; 5816 ;;
5787 ;; We start searching for the sought position TRY-SIZE (default 5817 ;; We start searching for the sought position TRY-SIZE (default
5788 ;; twice HOW-FAR-BACK) bytes back from START. 5818 ;; twice HOW-FAR-BACK) bytes back from START.
5789 ;; 5819 ;;
5790 ;; This function must be fast. :-) 5820 ;; This function must be fast. :-)
5821
5791 (save-excursion 5822 (save-excursion
5792 (let* ((start (or start (point))) 5823 (let* ((start (or start (point)))
5824 (org-start (or org-start start))
5793 (try-size (or try-size (* 2 how-far-back))) 5825 (try-size (or try-size (* 2 how-far-back)))
5794 (base (c-determine-limit-get-base start try-size)) 5826 (base (c-determine-limit-get-base start try-size))
5795 (pos base) 5827 (pos base)
@@ -5842,21 +5874,27 @@ comment at the start of cc-engine.el for more info."
5842 (setq elt (car stack) 5874 (setq elt (car stack)
5843 stack (cdr stack)) 5875 stack (cdr stack))
5844 (setq count (+ count (cdr elt)))) 5876 (setq count (+ count (cdr elt))))
5845
5846 ;; Have we found enough yet?
5847 (cond 5877 (cond
5848 ((null elt) ; No non-literal characters found. 5878 ((null elt) ; No non-literal characters found.
5849 (if (> base (point-min)) 5879 (cond
5850 (c-determine-limit how-far-back base (* 2 try-size)) 5880 ((> pos start) ; Nothing but literals
5851 (point-min))) 5881 base)
5882 ((> base (point-min))
5883 (c-determine-limit how-far-back base (* 2 try-size) org-start))
5884 (t base)))
5852 ((>= count how-far-back) 5885 ((>= count how-far-back)
5853 (+ (car elt) (- count how-far-back))) 5886 (c-determine-limit-no-macro
5887 (+ (car elt) (- count how-far-back))
5888 org-start))
5854 ((eq base (point-min)) 5889 ((eq base (point-min))
5855 (point-min)) 5890 (point-min))
5856 ((> base (- start try-size)) ; Can only happen if we hit point-min. 5891 ((> base (- start try-size)) ; Can only happen if we hit point-min.
5857 (car elt)) 5892 (c-determine-limit-no-macro
5893 (car elt)
5894 org-start))
5858 (t 5895 (t
5859 (c-determine-limit (- how-far-back count) base (* 2 try-size))))))) 5896 (c-determine-limit (- how-far-back count) base (* 2 try-size)
5897 org-start))))))
5860 5898
5861(defun c-determine-+ve-limit (how-far &optional start-pos) 5899(defun c-determine-+ve-limit (how-far &optional start-pos)
5862 ;; Return a buffer position about HOW-FAR non-literal characters forward 5900 ;; Return a buffer position about HOW-FAR non-literal characters forward
@@ -6248,8 +6286,14 @@ comment at the start of cc-engine.el for more info."
6248 ;; preceding syntactic ws to set `cfd-match-pos' and to catch 6286 ;; preceding syntactic ws to set `cfd-match-pos' and to catch
6249 ;; any decl spots in the syntactic ws. 6287 ;; any decl spots in the syntactic ws.
6250 (unless cfd-re-match 6288 (unless cfd-re-match
6251 (c-backward-syntactic-ws) 6289 (let ((cfd-cbsw-lim
6252 (setq cfd-re-match (point)))) 6290 (max (- (point) 1000) (point-min))))
6291 (c-backward-syntactic-ws cfd-cbsw-lim)
6292 (setq cfd-re-match
6293 (if (or (bobp) (> (point) cfd-cbsw-lim))
6294 (point)
6295 (point-min)))) ; Set BOB case if the token's too far back.
6296 ))
6253 6297
6254 ;; Choose whichever match is closer to the start. 6298 ;; Choose whichever match is closer to the start.
6255 (if (< cfd-re-match cfd-prop-match) 6299 (if (< cfd-re-match cfd-prop-match)
@@ -6410,7 +6454,7 @@ comment at the start of cc-engine.el for more info."
6410 (while (and (not (bobp)) 6454 (while (and (not (bobp))
6411 (c-got-face-at (1- (point)) c-literal-faces)) 6455 (c-got-face-at (1- (point)) c-literal-faces))
6412 (goto-char (previous-single-property-change 6456 (goto-char (previous-single-property-change
6413 (point) 'face nil (point-min)))) 6457 (point) 'face nil (point-min)))) ; No limit. FIXME, perhaps? 2020-12-07.
6414 6458
6415 ;; XEmacs doesn't fontify the quotes surrounding string 6459 ;; XEmacs doesn't fontify the quotes surrounding string
6416 ;; literals. 6460 ;; literals.
@@ -6482,12 +6526,15 @@ comment at the start of cc-engine.el for more info."
6482 (c-invalidate-find-decl-cache cfd-start-pos) 6526 (c-invalidate-find-decl-cache cfd-start-pos)
6483 6527
6484 (setq syntactic-pos (point)) 6528 (setq syntactic-pos (point))
6485 (unless (eq syntactic-pos c-find-decl-syntactic-pos) 6529 (unless
6530 (eq syntactic-pos c-find-decl-syntactic-pos)
6486 ;; Don't have to do this if the cache is relevant here, 6531 ;; Don't have to do this if the cache is relevant here,
6487 ;; typically if the same line is refontified again. If 6532 ;; typically if the same line is refontified again. If
6488 ;; we're just some syntactic whitespace further down we can 6533 ;; we're just some syntactic whitespace further down we can
6489 ;; still use the cache to limit the skipping. 6534 ;; still use the cache to limit the skipping.
6490 (c-backward-syntactic-ws c-find-decl-syntactic-pos)) 6535 (c-backward-syntactic-ws
6536 (max (or c-find-decl-syntactic-pos (point-min))
6537 (- (point) 10000) (point-min))))
6491 6538
6492 ;; If we hit `c-find-decl-syntactic-pos' and 6539 ;; If we hit `c-find-decl-syntactic-pos' and
6493 ;; `c-find-decl-match-pos' is set then we install the cached 6540 ;; `c-find-decl-match-pos' is set then we install the cached
@@ -6613,7 +6660,8 @@ comment at the start of cc-engine.el for more info."
6613 ;; syntactic ws. 6660 ;; syntactic ws.
6614 (when (and cfd-match-pos (< cfd-match-pos syntactic-pos)) 6661 (when (and cfd-match-pos (< cfd-match-pos syntactic-pos))
6615 (goto-char syntactic-pos) 6662 (goto-char syntactic-pos)
6616 (c-forward-syntactic-ws) 6663 (c-forward-syntactic-ws
6664 (min (+ (point) 2000) (point-max)))
6617 (and cfd-continue-pos 6665 (and cfd-continue-pos
6618 (< cfd-continue-pos (point)) 6666 (< cfd-continue-pos (point))
6619 (setq cfd-token-pos (point)))) 6667 (setq cfd-token-pos (point))))
@@ -6654,7 +6702,8 @@ comment at the start of cc-engine.el for more info."
6654 ;; can't be nested, and that's already been done in 6702 ;; can't be nested, and that's already been done in
6655 ;; `c-find-decl-prefix-search'. 6703 ;; `c-find-decl-prefix-search'.
6656 (when (> cfd-continue-pos cfd-token-pos) 6704 (when (> cfd-continue-pos cfd-token-pos)
6657 (c-forward-syntactic-ws) 6705 (c-forward-syntactic-ws
6706 (min (+ (point) 2000) (point-max)))
6658 (setq cfd-token-pos (point))) 6707 (setq cfd-token-pos (point)))
6659 6708
6660 ;; Continue if the following token fails the 6709 ;; Continue if the following token fails the
@@ -8262,7 +8311,8 @@ comment at the start of cc-engine.el for more info."
8262 ;; typically called from `c-forward-type' in this case, and 8311 ;; typically called from `c-forward-type' in this case, and
8263 ;; the caller only wants the top level type that it finds to 8312 ;; the caller only wants the top level type that it finds to
8264 ;; be promoted. 8313 ;; be promoted.
8265 c-promote-possible-types) 8314 c-promote-possible-types
8315 (lim+ (c-determine-+ve-limit 500)))
8266 (while 8316 (while
8267 (and 8317 (and
8268 (looking-at c-identifier-key) 8318 (looking-at c-identifier-key)
@@ -8292,7 +8342,7 @@ comment at the start of cc-engine.el for more info."
8292 8342
8293 ;; Handle a C++ operator or template identifier. 8343 ;; Handle a C++ operator or template identifier.
8294 (goto-char id-end) 8344 (goto-char id-end)
8295 (c-forward-syntactic-ws) 8345 (c-forward-syntactic-ws lim+)
8296 (cond ((eq (char-before id-end) ?e) 8346 (cond ((eq (char-before id-end) ?e)
8297 ;; Got "... ::template". 8347 ;; Got "... ::template".
8298 (let ((subres (c-forward-name))) 8348 (let ((subres (c-forward-name)))
@@ -8322,13 +8372,13 @@ comment at the start of cc-engine.el for more info."
8322 (looking-at "::") 8372 (looking-at "::")
8323 (progn 8373 (progn
8324 (goto-char (match-end 0)) 8374 (goto-char (match-end 0))
8325 (c-forward-syntactic-ws) 8375 (c-forward-syntactic-ws lim+)
8326 (eq (char-after) ?*)) 8376 (eq (char-after) ?*))
8327 (progn 8377 (progn
8328 (forward-char) 8378 (forward-char)
8329 t)))) 8379 t))))
8330 (while (progn 8380 (while (progn
8331 (c-forward-syntactic-ws) 8381 (c-forward-syntactic-ws lim+)
8332 (setq pos (point)) 8382 (setq pos (point))
8333 (looking-at c-opt-type-modifier-key)) 8383 (looking-at c-opt-type-modifier-key))
8334 (goto-char (match-end 1)))))) 8384 (goto-char (match-end 1))))))
@@ -8338,7 +8388,7 @@ comment at the start of cc-engine.el for more info."
8338 (setq c-last-identifier-range 8388 (setq c-last-identifier-range
8339 (cons (point) (match-end 0))) 8389 (cons (point) (match-end 0)))
8340 (goto-char (match-end 0)) 8390 (goto-char (match-end 0))
8341 (c-forward-syntactic-ws) 8391 (c-forward-syntactic-ws lim+)
8342 (setq pos (point) 8392 (setq pos (point)
8343 res 'operator))) 8393 res 'operator)))
8344 8394
@@ -8352,7 +8402,7 @@ comment at the start of cc-engine.el for more info."
8352 (setq c-last-identifier-range 8402 (setq c-last-identifier-range
8353 (cons id-start id-end))) 8403 (cons id-start id-end)))
8354 (goto-char id-end) 8404 (goto-char id-end)
8355 (c-forward-syntactic-ws) 8405 (c-forward-syntactic-ws lim+)
8356 (setq pos (point) 8406 (setq pos (point)
8357 res t))) 8407 res t)))
8358 8408
@@ -8368,7 +8418,7 @@ comment at the start of cc-engine.el for more info."
8368 ;; cases with tricky syntactic whitespace that aren't 8418 ;; cases with tricky syntactic whitespace that aren't
8369 ;; covered in `c-identifier-key'. 8419 ;; covered in `c-identifier-key'.
8370 (goto-char (match-end 0)) 8420 (goto-char (match-end 0))
8371 (c-forward-syntactic-ws) 8421 (c-forward-syntactic-ws lim+)
8372 t) 8422 t)
8373 8423
8374 ((and c-recognize-<>-arglists 8424 ((and c-recognize-<>-arglists
@@ -8377,7 +8427,7 @@ comment at the start of cc-engine.el for more info."
8377 (when (let (c-last-identifier-range) 8427 (when (let (c-last-identifier-range)
8378 (c-forward-<>-arglist nil)) 8428 (c-forward-<>-arglist nil))
8379 8429
8380 (c-forward-syntactic-ws) 8430 (c-forward-syntactic-ws lim+)
8381 (unless (eq (char-after) ?\() 8431 (unless (eq (char-after) ?\()
8382 (setq c-last-identifier-range nil) 8432 (setq c-last-identifier-range nil)
8383 (c-add-type start (1+ pos))) 8433 (c-add-type start (1+ pos)))
@@ -8392,7 +8442,7 @@ comment at the start of cc-engine.el for more info."
8392 (when (and c-record-type-identifiers id-start) 8442 (when (and c-record-type-identifiers id-start)
8393 (c-record-ref-id (cons id-start id-end))) 8443 (c-record-ref-id (cons id-start id-end)))
8394 (forward-char 2) 8444 (forward-char 2)
8395 (c-forward-syntactic-ws) 8445 (c-forward-syntactic-ws lim+)
8396 t) 8446 t)
8397 8447
8398 (when (and c-record-type-identifiers id-start 8448 (when (and c-record-type-identifiers id-start
@@ -8817,7 +8867,7 @@ comment at the start of cc-engine.el for more info."
8817 (or res (goto-char here)) 8867 (or res (goto-char here))
8818 res)) 8868 res))
8819 8869
8820(defmacro c-back-over-list-of-member-inits () 8870(defmacro c-back-over-list-of-member-inits (limit)
8821 ;; Go back over a list of elements, each looking like: 8871 ;; Go back over a list of elements, each looking like:
8822 ;; <symbol> (<expression>) , 8872 ;; <symbol> (<expression>) ,
8823 ;; or <symbol> {<expression>} , (with possibly a <....> expressions 8873 ;; or <symbol> {<expression>} , (with possibly a <....> expressions
@@ -8826,21 +8876,21 @@ comment at the start of cc-engine.el for more info."
8826 ;; a comma. If either of <symbol> or bracketed <expression> is missing, 8876 ;; a comma. If either of <symbol> or bracketed <expression> is missing,
8827 ;; throw nil to 'level. If the terminating } or ) is unmatched, throw nil 8877 ;; throw nil to 'level. If the terminating } or ) is unmatched, throw nil
8828 ;; to 'done. This is not a general purpose macro! 8878 ;; to 'done. This is not a general purpose macro!
8829 '(while (eq (char-before) ?,) 8879 `(while (eq (char-before) ?,)
8830 (backward-char) 8880 (backward-char)
8831 (c-backward-syntactic-ws) 8881 (c-backward-syntactic-ws ,limit)
8832 (when (not (memq (char-before) '(?\) ?}))) 8882 (when (not (memq (char-before) '(?\) ?})))
8833 (throw 'level nil)) 8883 (throw 'level nil))
8834 (when (not (c-go-list-backward)) 8884 (when (not (c-go-list-backward))
8835 (throw 'done nil)) 8885 (throw 'done nil))
8836 (c-backward-syntactic-ws) 8886 (c-backward-syntactic-ws ,limit)
8837 (while (eq (char-before) ?>) 8887 (while (eq (char-before) ?>)
8838 (when (not (c-backward-<>-arglist nil)) 8888 (when (not (c-backward-<>-arglist nil))
8839 (throw 'done nil)) 8889 (throw 'done nil))
8840 (c-backward-syntactic-ws)) 8890 (c-backward-syntactic-ws ,limit))
8841 (when (not (c-back-over-compound-identifier)) 8891 (when (not (c-back-over-compound-identifier))
8842 (throw 'level nil)) 8892 (throw 'level nil))
8843 (c-backward-syntactic-ws))) 8893 (c-backward-syntactic-ws ,limit)))
8844 8894
8845(defun c-back-over-member-initializers (&optional limit) 8895(defun c-back-over-member-initializers (&optional limit)
8846 ;; Test whether we are in a C++ member initializer list, and if so, go back 8896 ;; Test whether we are in a C++ member initializer list, and if so, go back
@@ -8859,14 +8909,14 @@ comment at the start of cc-engine.el for more info."
8859 (catch 'done 8909 (catch 'done
8860 (setq level-plausible 8910 (setq level-plausible
8861 (catch 'level 8911 (catch 'level
8862 (c-backward-syntactic-ws) 8912 (c-backward-syntactic-ws limit)
8863 (when (memq (char-before) '(?\) ?})) 8913 (when (memq (char-before) '(?\) ?}))
8864 (when (not (c-go-list-backward)) 8914 (when (not (c-go-list-backward))
8865 (throw 'done nil)) 8915 (throw 'done nil))
8866 (c-backward-syntactic-ws)) 8916 (c-backward-syntactic-ws limit))
8867 (when (c-back-over-compound-identifier) 8917 (when (c-back-over-compound-identifier)
8868 (c-backward-syntactic-ws)) 8918 (c-backward-syntactic-ws limit))
8869 (c-back-over-list-of-member-inits) 8919 (c-back-over-list-of-member-inits limit)
8870 (and (eq (char-before) ?:) 8920 (and (eq (char-before) ?:)
8871 (save-excursion 8921 (save-excursion
8872 (c-backward-token-2) 8922 (c-backward-token-2)
@@ -8880,14 +8930,14 @@ comment at the start of cc-engine.el for more info."
8880 (setq level-plausible 8930 (setq level-plausible
8881 (catch 'level 8931 (catch 'level
8882 (goto-char pos) 8932 (goto-char pos)
8883 (c-backward-syntactic-ws) 8933 (c-backward-syntactic-ws limit)
8884 (when (not (c-back-over-compound-identifier)) 8934 (when (not (c-back-over-compound-identifier))
8885 (throw 'level nil)) 8935 (throw 'level nil))
8886 (c-backward-syntactic-ws) 8936 (c-backward-syntactic-ws limit)
8887 (c-back-over-list-of-member-inits) 8937 (c-back-over-list-of-member-inits limit)
8888 (and (eq (char-before) ?:) 8938 (and (eq (char-before) ?:)
8889 (save-excursion 8939 (save-excursion
8890 (c-backward-token-2) 8940 (c-backward-token-2 nil nil limit)
8891 (not (looking-at c-:$-multichar-token-regexp))) 8941 (not (looking-at c-:$-multichar-token-regexp)))
8892 (c-just-after-func-arglist-p))))) 8942 (c-just-after-func-arglist-p)))))
8893 8943
@@ -12016,7 +12066,7 @@ comment at the start of cc-engine.el for more info."
12016 (goto-char haskell-op-pos)) 12066 (goto-char haskell-op-pos))
12017 12067
12018 (while (and (eq res 'maybe) 12068 (while (and (eq res 'maybe)
12019 (progn (c-backward-syntactic-ws) 12069 (progn (c-backward-syntactic-ws lim)
12020 (> (point) closest-lim)) 12070 (> (point) closest-lim))
12021 (not (bobp)) 12071 (not (bobp))
12022 (progn (backward-char) 12072 (progn (backward-char)
@@ -12721,7 +12771,7 @@ comment at the start of cc-engine.el for more info."
12721 literal char-before-ip before-ws-ip char-after-ip macro-start 12771 literal char-before-ip before-ws-ip char-after-ip macro-start
12722 in-macro-expr c-syntactic-context placeholder 12772 in-macro-expr c-syntactic-context placeholder
12723 step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos 12773 step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos
12724 containing-< 12774 tmp-pos2 containing-<
12725 ;; The following record some positions for the containing 12775 ;; The following record some positions for the containing
12726 ;; declaration block if we're directly within one: 12776 ;; declaration block if we're directly within one:
12727 ;; `containing-decl-open' is the position of the open 12777 ;; `containing-decl-open' is the position of the open
@@ -12787,7 +12837,7 @@ comment at the start of cc-engine.el for more info."
12787 (setq paren-state (cons containing-sexp paren-state) 12837 (setq paren-state (cons containing-sexp paren-state)
12788 containing-sexp nil))) 12838 containing-sexp nil)))
12789 (setq lim (1+ containing-sexp)))) 12839 (setq lim (1+ containing-sexp))))
12790 (setq lim (point-min))) 12840 (setq lim (c-determine-limit 1000)))
12791 12841
12792 ;; If we're in a parenthesis list then ',' delimits the 12842 ;; If we're in a parenthesis list then ',' delimits the
12793 ;; "statements" rather than being an operator (with the 12843 ;; "statements" rather than being an operator (with the
@@ -13029,7 +13079,9 @@ comment at the start of cc-engine.el for more info."
13029 ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and 13079 ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and
13030 ;; 17E. 13080 ;; 17E.
13031 ((setq placeholder (c-looking-at-inexpr-block 13081 ((setq placeholder (c-looking-at-inexpr-block
13032 (c-safe-position containing-sexp paren-state) 13082 (or
13083 (c-safe-position containing-sexp paren-state)
13084 (c-determine-limit 1000 containing-sexp))
13033 containing-sexp 13085 containing-sexp
13034 ;; Have to turn on the heuristics after 13086 ;; Have to turn on the heuristics after
13035 ;; the point even though it doesn't work 13087 ;; the point even though it doesn't work
@@ -13154,7 +13206,8 @@ comment at the start of cc-engine.el for more info."
13154 ;; init lists can, in practice, be very large. 13206 ;; init lists can, in practice, be very large.
13155 ((save-excursion 13207 ((save-excursion
13156 (when (and (c-major-mode-is 'c++-mode) 13208 (when (and (c-major-mode-is 'c++-mode)
13157 (setq placeholder (c-back-over-member-initializers))) 13209 (setq placeholder (c-back-over-member-initializers
13210 lim)))
13158 (setq tmp-pos (point)))) 13211 (setq tmp-pos (point))))
13159 (if (= (c-point 'bosws) (1+ tmp-pos)) 13212 (if (= (c-point 'bosws) (1+ tmp-pos))
13160 (progn 13213 (progn
@@ -13473,7 +13526,7 @@ comment at the start of cc-engine.el for more info."
13473 ;; CASE 5I: ObjC method definition. 13526 ;; CASE 5I: ObjC method definition.
13474 ((and c-opt-method-key 13527 ((and c-opt-method-key
13475 (looking-at c-opt-method-key)) 13528 (looking-at c-opt-method-key))
13476 (c-beginning-of-statement-1 nil t) 13529 (c-beginning-of-statement-1 (c-determine-limit 1000) t)
13477 (if (= (point) indent-point) 13530 (if (= (point) indent-point)
13478 ;; Handle the case when it's the first (non-comment) 13531 ;; Handle the case when it's the first (non-comment)
13479 ;; thing in the buffer. Can't look for a 'same return 13532 ;; thing in the buffer. Can't look for a 'same return
@@ -13546,7 +13599,16 @@ comment at the start of cc-engine.el for more info."
13546 (if (>= (point) indent-point) 13599 (if (>= (point) indent-point)
13547 (throw 'not-in-directive t)) 13600 (throw 'not-in-directive t))
13548 (setq placeholder (point))) 13601 (setq placeholder (point)))
13549 nil))))) 13602 nil))
13603 (and macro-start
13604 (not (c-beginning-of-statement-1 lim nil nil nil t))
13605 (setq placeholder
13606 (let ((ps-top (car paren-state)))
13607 (if (consp ps-top)
13608 (progn
13609 (goto-char (cdr ps-top))
13610 (c-forward-syntactic-ws indent-point))
13611 (point-min))))))))
13550 ;; For historic reasons we anchor at bol of the last 13612 ;; For historic reasons we anchor at bol of the last
13551 ;; line of the previous declaration. That's clearly 13613 ;; line of the previous declaration. That's clearly
13552 ;; highly bogus and useless, and it makes our lives hard 13614 ;; highly bogus and useless, and it makes our lives hard
@@ -13595,31 +13657,47 @@ comment at the start of cc-engine.el for more info."
13595 (eq (char-before) ?<) 13657 (eq (char-before) ?<)
13596 (not (and c-overloadable-operators-regexp 13658 (not (and c-overloadable-operators-regexp
13597 (c-after-special-operator-id lim)))) 13659 (c-after-special-operator-id lim))))
13598 (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) 13660 (c-beginning-of-statement-1
13661 (or
13662 (c-safe-position (point) paren-state)
13663 (c-determine-limit 1000)))
13599 (c-add-syntax 'template-args-cont (c-point 'boi))) 13664 (c-add-syntax 'template-args-cont (c-point 'boi)))
13600 13665
13601 ;; CASE 5Q: we are at a statement within a macro. 13666 ;; CASE 5Q: we are at a statement within a macro.
13602 (macro-start 13667 ((and
13603 (c-beginning-of-statement-1 containing-sexp) 13668 macro-start
13669 (save-excursion
13670 (prog1
13671 (not (eq (c-beginning-of-statement-1
13672 (or containing-sexp (c-determine-limit 1000))
13673 nil nil nil t)
13674 nil)))
13675 (setq placeholder (point))))
13676 (goto-char placeholder)
13604 (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) 13677 (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
13605 13678
13606 ;;CASE 5N: We are at a topmost continuation line and the only 13679 ;;CASE 5S: We are at a topmost continuation line and the only
13607 ;;preceding items are annotations. 13680 ;;preceding items are annotations.
13608 ((and (c-major-mode-is 'java-mode) 13681 ((and (c-major-mode-is 'java-mode)
13609 (setq placeholder (point)) 13682 (setq placeholder (point))
13610 (c-beginning-of-statement-1) 13683 (c-beginning-of-statement-1 lim)
13611 (progn 13684 (progn
13612 (while (and (c-forward-annotation)) 13685 (while (and (setq tmp-pos (point))
13613 (c-forward-syntactic-ws)) 13686 (< (point) placeholder)
13687 (c-forward-annotation))
13688 (c-forward-syntactic-ws)
13689 (setq tmp-pos2 tmp-pos))
13614 t) 13690 t)
13615 (prog1 13691 (prog1
13616 (>= (point) placeholder) 13692 (>= (point) placeholder)
13617 (goto-char placeholder))) 13693 (goto-char placeholder)))
13618 (c-add-syntax 'annotation-top-cont (c-point 'boi))) 13694 (c-add-syntax 'annotation-top-cont (c-point 'boi tmp-pos2)))
13619 13695
13620 ;; CASE 5M: we are at a topmost continuation line 13696 ;; CASE 5M: we are at a topmost continuation line
13621 (t 13697 (t
13622 (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) 13698 (c-beginning-of-statement-1
13699 (or (c-safe-position (point) paren-state)
13700 (c-determine-limit 1000)))
13623 (when (c-major-mode-is 'objc-mode) 13701 (when (c-major-mode-is 'objc-mode)
13624 (setq placeholder (point)) 13702 (setq placeholder (point))
13625 (while (and (c-forward-objc-directive) 13703 (while (and (c-forward-objc-directive)
@@ -13675,8 +13753,9 @@ comment at the start of cc-engine.el for more info."
13675 (setq tmpsymbol '(block-open . inexpr-statement) 13753 (setq tmpsymbol '(block-open . inexpr-statement)
13676 placeholder 13754 placeholder
13677 (cdr-safe (c-looking-at-inexpr-block 13755 (cdr-safe (c-looking-at-inexpr-block
13678 (c-safe-position containing-sexp 13756 (or
13679 paren-state) 13757 (c-safe-position containing-sexp paren-state)
13758 (c-determine-limit 1000 containing-sexp))
13680 containing-sexp))) 13759 containing-sexp)))
13681 ;; placeholder is nil if it's a block directly in 13760 ;; placeholder is nil if it's a block directly in
13682 ;; a function arglist. That makes us skip out of 13761 ;; a function arglist. That makes us skip out of
@@ -13808,7 +13887,9 @@ comment at the start of cc-engine.el for more info."
13808 (setq placeholder (c-guess-basic-syntax)))) 13887 (setq placeholder (c-guess-basic-syntax))))
13809 (setq c-syntactic-context placeholder) 13888 (setq c-syntactic-context placeholder)
13810 (c-beginning-of-statement-1 13889 (c-beginning-of-statement-1
13811 (c-safe-position (1- containing-sexp) paren-state)) 13890 (or
13891 (c-safe-position (1- containing-sexp) paren-state)
13892 (c-determine-limit 1000 (1- containing-sexp))))
13812 (c-forward-token-2 0) 13893 (c-forward-token-2 0)
13813 (while (cond 13894 (while (cond
13814 ((looking-at c-specifier-key) 13895 ((looking-at c-specifier-key)
@@ -13842,7 +13923,8 @@ comment at the start of cc-engine.el for more info."
13842 (c-add-syntax 'brace-list-close (point)) 13923 (c-add-syntax 'brace-list-close (point))
13843 (setq lim (or (save-excursion 13924 (setq lim (or (save-excursion
13844 (and 13925 (and
13845 (c-back-over-member-initializers) 13926 (c-back-over-member-initializers
13927 (c-determine-limit 1000))
13846 (point))) 13928 (point)))
13847 (c-most-enclosing-brace state-cache (point)))) 13929 (c-most-enclosing-brace state-cache (point))))
13848 (c-beginning-of-statement-1 lim nil nil t) 13930 (c-beginning-of-statement-1 lim nil nil t)
@@ -13875,7 +13957,8 @@ comment at the start of cc-engine.el for more info."
13875 (c-add-syntax 'brace-list-intro (point)) 13957 (c-add-syntax 'brace-list-intro (point))
13876 (setq lim (or (save-excursion 13958 (setq lim (or (save-excursion
13877 (and 13959 (and
13878 (c-back-over-member-initializers) 13960 (c-back-over-member-initializers
13961 (c-determine-limit 1000))
13879 (point))) 13962 (point)))
13880 (c-most-enclosing-brace state-cache (point)))) 13963 (c-most-enclosing-brace state-cache (point))))
13881 (c-beginning-of-statement-1 lim nil nil t) 13964 (c-beginning-of-statement-1 lim nil nil t)
@@ -13931,7 +14014,9 @@ comment at the start of cc-engine.el for more info."
13931 ;; CASE 16A: closing a lambda defun or an in-expression 14014 ;; CASE 16A: closing a lambda defun or an in-expression
13932 ;; block? C.f. cases 4, 7B and 17E. 14015 ;; block? C.f. cases 4, 7B and 17E.
13933 ((setq placeholder (c-looking-at-inexpr-block 14016 ((setq placeholder (c-looking-at-inexpr-block
13934 (c-safe-position containing-sexp paren-state) 14017 (or
14018 (c-safe-position containing-sexp paren-state)
14019 (c-determine-limit 1000 containing-sexp))
13935 nil)) 14020 nil))
13936 (setq tmpsymbol (if (eq (car placeholder) 'inlambda) 14021 (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
13937 'inline-close 14022 'inline-close
@@ -14094,7 +14179,9 @@ comment at the start of cc-engine.el for more info."
14094 ;; CASE 17E: first statement in an in-expression block. 14179 ;; CASE 17E: first statement in an in-expression block.
14095 ;; C.f. cases 4, 7B and 16A. 14180 ;; C.f. cases 4, 7B and 16A.
14096 ((setq placeholder (c-looking-at-inexpr-block 14181 ((setq placeholder (c-looking-at-inexpr-block
14097 (c-safe-position containing-sexp paren-state) 14182 (or
14183 (c-safe-position containing-sexp paren-state)
14184 (c-determine-limit 1000 containing-sexp))
14098 nil)) 14185 nil))
14099 (setq tmpsymbol (if (eq (car placeholder) 'inlambda) 14186 (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
14100 'defun-block-intro 14187 'defun-block-intro
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el
index bb7e5bea6e6..e403c49e398 100644
--- a/lisp/progmodes/cc-fonts.el
+++ b/lisp/progmodes/cc-fonts.el
@@ -947,7 +947,7 @@ casts and declarations are fontified. Used on level 2 and higher."
947 ;; closest token before the region. 947 ;; closest token before the region.
948 (save-excursion 948 (save-excursion
949 (let ((pos (point))) 949 (let ((pos (point)))
950 (c-backward-syntactic-ws) 950 (c-backward-syntactic-ws (max (- (point) 500) (point-min)))
951 (c-clear-char-properties 951 (c-clear-char-properties
952 (if (and (not (bobp)) 952 (if (and (not (bobp))
953 (memq (c-get-char-property (1- (point)) 'c-type) 953 (memq (c-get-char-property (1- (point)) 'c-type)
@@ -969,7 +969,7 @@ casts and declarations are fontified. Used on level 2 and higher."
969 ;; The declared identifiers are font-locked correctly as types, if 969 ;; The declared identifiers are font-locked correctly as types, if
970 ;; that is what they are. 970 ;; that is what they are.
971 (let ((prop (save-excursion 971 (let ((prop (save-excursion
972 (c-backward-syntactic-ws) 972 (c-backward-syntactic-ws (max (- (point) 500) (point-min)))
973 (unless (bobp) 973 (unless (bobp)
974 (c-get-char-property (1- (point)) 'c-type))))) 974 (c-get-char-property (1- (point)) 'c-type)))))
975 (when (memq prop '(c-decl-id-start c-decl-type-start)) 975 (when (memq prop '(c-decl-id-start c-decl-type-start))
@@ -1008,66 +1008,75 @@ casts and declarations are fontified. Used on level 2 and higher."
1008 (boundp 'parse-sexp-lookup-properties))) 1008 (boundp 'parse-sexp-lookup-properties)))
1009 (c-parse-and-markup-<>-arglists t) 1009 (c-parse-and-markup-<>-arglists t)
1010 c-restricted-<>-arglists 1010 c-restricted-<>-arglists
1011 id-start id-end id-face pos kwd-sym) 1011 id-start id-end id-face pos kwd-sym
1012 old-pos)
1012 1013
1013 (while (and (< (point) limit) 1014 (while (and (< (point) limit)
1014 (re-search-forward c-opt-<>-arglist-start limit t)) 1015 (setq old-pos (point))
1015 1016 (c-syntactic-re-search-forward "<" limit t nil t))
1016 (setq id-start (match-beginning 1) 1017 (setq pos (point))
1017 id-end (match-end 1) 1018 (save-excursion
1018 pos (point)) 1019 (backward-char)
1019 1020 (c-backward-syntactic-ws old-pos)
1020 (goto-char id-start) 1021 (if (re-search-backward
1021 (unless (c-skip-comments-and-strings limit) 1022 (concat "\\(\\`\\|" c-nonsymbol-key "\\)\\(" c-symbol-key"\\)\\=")
1022 (setq kwd-sym nil 1023 old-pos t)
1023 c-restricted-<>-arglists nil 1024 (setq id-start (match-beginning 2)
1024 id-face (get-text-property id-start 'face)) 1025 id-end (match-end 2))
1025 1026 (setq id-start nil id-end nil)))
1026 (if (cond 1027
1027 ((eq id-face 'font-lock-type-face) 1028 (when id-start
1028 ;; The identifier got the type face so it has already been 1029 (goto-char id-start)
1029 ;; handled in `c-font-lock-declarations'. 1030 (unless (c-skip-comments-and-strings limit)
1030 nil) 1031 (setq kwd-sym nil
1031 1032 c-restricted-<>-arglists nil
1032 ((eq id-face 'font-lock-keyword-face) 1033 id-face (get-text-property id-start 'face))
1033 (when (looking-at c-opt-<>-sexp-key) 1034
1034 ;; There's a special keyword before the "<" that tells 1035 (if (cond
1035 ;; that it's an angle bracket arglist. 1036 ((eq id-face 'font-lock-type-face)
1036 (setq kwd-sym (c-keyword-sym (match-string 1))))) 1037 ;; The identifier got the type face so it has already been
1037 1038 ;; handled in `c-font-lock-declarations'.
1038 (t 1039 nil)
1039 ;; There's a normal identifier before the "<". If we're not in
1040 ;; a declaration context then we set `c-restricted-<>-arglists'
1041 ;; to avoid recognizing templates in function calls like "foo (a
1042 ;; < b, c > d)".
1043 (c-backward-syntactic-ws)
1044 (when (and (memq (char-before) '(?\( ?,))
1045 (not (eq (get-text-property (1- (point)) 'c-type)
1046 'c-decl-arg-start)))
1047 (setq c-restricted-<>-arglists t))
1048 t))
1049 1040
1050 (progn 1041 ((eq id-face 'font-lock-keyword-face)
1051 (goto-char (1- pos)) 1042 (when (looking-at c-opt-<>-sexp-key)
1052 ;; Check for comment/string both at the identifier and 1043 ;; There's a special keyword before the "<" that tells
1053 ;; at the "<". 1044 ;; that it's an angle bracket arglist.
1054 (unless (c-skip-comments-and-strings limit) 1045 (setq kwd-sym (c-keyword-sym (match-string 2)))))
1055 1046
1056 (c-fontify-types-and-refs () 1047 (t
1057 (when (c-forward-<>-arglist (c-keyword-member 1048 ;; There's a normal identifier before the "<". If we're not in
1058 kwd-sym 'c-<>-type-kwds)) 1049 ;; a declaration context then we set `c-restricted-<>-arglists'
1059 (when (and c-opt-identifier-concat-key 1050 ;; to avoid recognizing templates in function calls like "foo (a
1060 (not (get-text-property id-start 'face))) 1051 ;; < b, c > d)".
1061 (c-forward-syntactic-ws) 1052 (c-backward-syntactic-ws)
1062 (cond ((looking-at c-opt-identifier-concat-key) 1053 (when (and (memq (char-before) '(?\( ?,))
1063 (c-put-font-lock-face id-start id-end 1054 (not (eq (get-text-property (1- (point)) 'c-type)
1064 c-reference-face-name)) 1055 'c-decl-arg-start)))
1065 ((eq (char-after) ?\()) 1056 (setq c-restricted-<>-arglists t))
1066 (t (c-put-font-lock-face id-start id-end 1057 t))
1067 'font-lock-type-face)))))) 1058
1068 1059 (progn
1069 (goto-char pos))) 1060 (goto-char (1- pos))
1070 (goto-char pos)))))) 1061 ;; Check for comment/string both at the identifier and
1062 ;; at the "<".
1063 (unless (c-skip-comments-and-strings limit)
1064
1065 (c-fontify-types-and-refs ()
1066 (when (c-forward-<>-arglist (c-keyword-member
1067 kwd-sym 'c-<>-type-kwds))
1068 (when (and c-opt-identifier-concat-key
1069 (not (get-text-property id-start 'face)))
1070 (c-forward-syntactic-ws)
1071 (cond ((looking-at c-opt-identifier-concat-key)
1072 (c-put-font-lock-face id-start id-end
1073 c-reference-face-name))
1074 ((eq (char-after) ?\())
1075 (t (c-put-font-lock-face id-start id-end
1076 'font-lock-type-face))))))
1077
1078 (goto-char pos)))
1079 (goto-char pos)))))))
1071 nil) 1080 nil)
1072 1081
1073(defun c-font-lock-declarators (limit list types not-top 1082(defun c-font-lock-declarators (limit list types not-top
@@ -1496,7 +1505,8 @@ casts and declarations are fontified. Used on level 2 and higher."
1496 1505
1497 ;; Check we haven't missed a preceding "typedef". 1506 ;; Check we haven't missed a preceding "typedef".
1498 (when (not (looking-at c-typedef-key)) 1507 (when (not (looking-at c-typedef-key))
1499 (c-backward-syntactic-ws) 1508 (c-backward-syntactic-ws
1509 (max (- (point) 1000) (point-min)))
1500 (c-backward-token-2) 1510 (c-backward-token-2)
1501 (or (looking-at c-typedef-key) 1511 (or (looking-at c-typedef-key)
1502 (goto-char start-pos))) 1512 (goto-char start-pos)))
@@ -1536,8 +1546,10 @@ casts and declarations are fontified. Used on level 2 and higher."
1536 (c-backward-token-2) 1546 (c-backward-token-2)
1537 (and 1547 (and
1538 (not (looking-at c-opt-<>-sexp-key)) 1548 (not (looking-at c-opt-<>-sexp-key))
1539 (progn (c-backward-syntactic-ws) 1549 (progn
1540 (memq (char-before) '(?\( ?,))) 1550 (c-backward-syntactic-ws
1551 (max (- (point) 1000) (point-min)))
1552 (memq (char-before) '(?\( ?,)))
1541 (not (eq (c-get-char-property (1- (point)) 1553 (not (eq (c-get-char-property (1- (point))
1542 'c-type) 1554 'c-type)
1543 'c-decl-arg-start)))))) 1555 'c-decl-arg-start))))))
@@ -2295,7 +2307,8 @@ need for `c-font-lock-extra-types'.")
2295 (and c-colon-type-list-re 2307 (and c-colon-type-list-re
2296 (c-go-up-list-backward) 2308 (c-go-up-list-backward)
2297 (eq (char-after) ?{) 2309 (eq (char-after) ?{)
2298 (eq (car (c-beginning-of-decl-1)) 'same) 2310 (eq (car (c-beginning-of-decl-1
2311 (c-determine-limit 1000))) 'same)
2299 (looking-at c-colon-type-list-re))) 2312 (looking-at c-colon-type-list-re)))
2300 ;; Inherited protected member: leave unfontified 2313 ;; Inherited protected member: leave unfontified
2301 ) 2314 )
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index d6089ea2950..4d1aeaa5cb9 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -699,6 +699,7 @@ It's assumed to not contain any submatchers."
699 ;; The same thing regarding Unicode identifiers applies here as to 699 ;; The same thing regarding Unicode identifiers applies here as to
700 ;; `c-symbol-key'. 700 ;; `c-symbol-key'.
701 t (concat "[" (c-lang-const c-nonsymbol-chars) "]")) 701 t (concat "[" (c-lang-const c-nonsymbol-chars) "]"))
702(c-lang-defvar c-nonsymbol-key (c-lang-const c-nonsymbol-key))
702 703
703(c-lang-defconst c-identifier-ops 704(c-lang-defconst c-identifier-ops
704 "The operators that make up fully qualified identifiers. nil in 705 "The operators that make up fully qualified identifiers. nil in
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 5e8cf6161ef..7a111017074 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -499,11 +499,14 @@ preferably use the `c-mode-menu' language constant directly."
499 (save-excursion 499 (save-excursion
500 (when (< beg end) 500 (when (< beg end)
501 (goto-char beg) 501 (goto-char beg)
502 (let ((lim (c-determine-limit 1000))
503 (lim+ (c-determine-+ve-limit 1000 end)))
502 (when 504 (when
503 (and (not (bobp)) 505 (and (not (bobp))
504 (progn (c-backward-syntactic-ws) (eq (point) beg)) 506 (progn (c-backward-syntactic-ws lim) (eq (point) beg))
505 (/= (skip-chars-backward c-symbol-chars (1- (point))) 0) 507 (/= (skip-chars-backward c-symbol-chars (1- (point))) 0)
506 (progn (goto-char beg) (c-forward-syntactic-ws) (<= (point) end)) 508 (progn (goto-char beg) (c-forward-syntactic-ws lim+)
509 (<= (point) end))
507 (> (point) beg) 510 (> (point) beg)
508 (goto-char end) 511 (goto-char end)
509 (looking-at c-symbol-char-key)) 512 (looking-at c-symbol-char-key))
@@ -514,14 +517,14 @@ preferably use the `c-mode-menu' language constant directly."
514 (goto-char end) 517 (goto-char end)
515 (when 518 (when
516 (and (not (eobp)) 519 (and (not (eobp))
517 (progn (c-forward-syntactic-ws) (eq (point) end)) 520 (progn (c-forward-syntactic-ws lim+) (eq (point) end))
518 (looking-at c-symbol-char-key) 521 (looking-at c-symbol-char-key)
519 (progn (c-backward-syntactic-ws) (>= (point) beg)) 522 (progn (c-backward-syntactic-ws lim) (>= (point) beg))
520 (< (point) end) 523 (< (point) end)
521 (/= (skip-chars-backward c-symbol-chars (1- (point))) 0)) 524 (/= (skip-chars-backward c-symbol-chars (1- (point))) 0))
522 (goto-char (1+ end)) 525 (goto-char (1+ end))
523 (c-end-of-current-token) 526 (c-end-of-current-token)
524 (c-unfind-type (buffer-substring-no-properties end (point))))))) 527 (c-unfind-type (buffer-substring-no-properties end (point))))))))
525 528
526;; c-maybe-stale-found-type records a place near the region being 529;; c-maybe-stale-found-type records a place near the region being
527;; changed where an element of `found-types' might become stale. It 530;; changed where an element of `found-types' might become stale. It
@@ -1996,7 +1999,7 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
1996 ;; We search for appropriate c-type properties "near" 1999 ;; We search for appropriate c-type properties "near"
1997 ;; the change. First, find an appropriate boundary 2000 ;; the change. First, find an appropriate boundary
1998 ;; for this property search. 2001 ;; for this property search.
1999 (let (lim 2002 (let (lim lim-2
2000 type type-pos 2003 type type-pos
2001 marked-id term-pos 2004 marked-id term-pos
2002 (end1 2005 (end1
@@ -2007,8 +2010,11 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
2007 (when (>= end1 beg) ; Don't hassle about changes entirely in 2010 (when (>= end1 beg) ; Don't hassle about changes entirely in
2008 ; comments. 2011 ; comments.
2009 ;; Find a limit for the search for a `c-type' property 2012 ;; Find a limit for the search for a `c-type' property
2013 ;; Point is currently undefined. A `goto-char' somewhere is needed. (2020-12-06).
2014 (setq lim-2 (c-determine-limit 1000 (point) ; that is wrong. FIXME!!! (2020-12-06)
2015 ))
2010 (while 2016 (while
2011 (and (/= (skip-chars-backward "^;{}") 0) 2017 (and (/= (skip-chars-backward "^;{}" lim-2) 0)
2012 (> (point) (point-min)) 2018 (> (point) (point-min))
2013 (memq (c-get-char-property (1- (point)) 'face) 2019 (memq (c-get-char-property (1- (point)) 'face)
2014 '(font-lock-comment-face font-lock-string-face)))) 2020 '(font-lock-comment-face font-lock-string-face))))
@@ -2032,7 +2038,8 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
2032 (buffer-substring-no-properties (point) type-pos))) 2038 (buffer-substring-no-properties (point) type-pos)))
2033 2039
2034 (goto-char end1) 2040 (goto-char end1)
2035 (skip-chars-forward "^;{}") ; FIXME!!! loop for 2041 (setq lim-2 (c-determine-+ve-limit 1000))
2042 (skip-chars-forward "^;{}" lim-2) ; FIXME!!! loop for
2036 ; comment, maybe 2043 ; comment, maybe
2037 (setq lim (point)) 2044 (setq lim (point))
2038 (setq term-pos 2045 (setq term-pos
@@ -2270,9 +2277,11 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
2270 ;; preserved. 2277 ;; preserved.
2271 (goto-char pos) 2278 (goto-char pos)
2272 (let ((lit-start (c-literal-start)) 2279 (let ((lit-start (c-literal-start))
2280 (lim (c-determine-limit 1000))
2273 enclosing-attribute pos1) 2281 enclosing-attribute pos1)
2274 (unless lit-start 2282 (unless lit-start
2275 (c-backward-syntactic-ws) 2283 (c-backward-syntactic-ws
2284 lim)
2276 (when (setq enclosing-attribute (c-enclosing-c++-attribute)) 2285 (when (setq enclosing-attribute (c-enclosing-c++-attribute))
2277 (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode. 2286 (goto-char (car enclosing-attribute))) ; Only happens in C++ Mode.
2278 (when (setq pos1 (c-on-identifier)) 2287 (when (setq pos1 (c-on-identifier))
@@ -2296,14 +2305,14 @@ Note that this is a strict tail, so won't match, e.g. \"0x....\".")
2296 (setq pos1 (c-on-identifier)) 2305 (setq pos1 (c-on-identifier))
2297 (goto-char pos1) 2306 (goto-char pos1)
2298 (progn 2307 (progn
2299 (c-backward-syntactic-ws) 2308 (c-backward-syntactic-ws lim)
2300 (eq (char-before) ?\()) 2309 (eq (char-before) ?\())
2301 (c-fl-decl-end (1- (point)))) 2310 (c-fl-decl-end (1- (point))))
2302 (c-backward-syntactic-ws) 2311 (c-backward-syntactic-ws lim)
2303 (point)))) 2312 (point))))
2304 (and (progn (c-forward-syntactic-ws lim) 2313 (and (progn (c-forward-syntactic-ws lim)
2305 (not (eobp))) 2314 (not (eobp)))
2306 (c-backward-syntactic-ws) 2315 (c-backward-syntactic-ws lim)
2307 (point))))))))) 2316 (point)))))))))
2308 2317
2309(defun c-change-expand-fl-region (_beg _end _old-len) 2318(defun c-change-expand-fl-region (_beg _end _old-len)
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el
index 9e6f9527ca1..8772ed06324 100644
--- a/lisp/progmodes/cc-vars.el
+++ b/lisp/progmodes/cc-vars.el
@@ -575,7 +575,8 @@ comment styles:
575 575
576 javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode). 576 javadoc -- Javadoc style for \"/** ... */\" comments (default in Java mode).
577 autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode). 577 autodoc -- Pike autodoc style for \"//! ...\" comments (default in Pike mode).
578 gtkdoc -- GtkDoc style for \"/** ... **/\" comments (default in C and C++ modes). 578 gtkdoc -- GtkDoc style for \"/** ... **/\" comments
579 (default in C and C++ modes).
579 doxygen -- Doxygen style. 580 doxygen -- Doxygen style.
580 581
581The value may also be a list of doc comment styles, in which case all 582The value may also be a list of doc comment styles, in which case all
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index ae839a66220..87542ea133c 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -232,7 +232,9 @@ Versions 5.2 ... 5.20 behaved as if this were nil."
232 :group 'cperl-indentation-details) 232 :group 'cperl-indentation-details)
233 233
234(defcustom cperl-indent-subs-specially t 234(defcustom cperl-indent-subs-specially t
235 "Non-nil means indent subs that are inside other blocks (hash values, for example) relative to the beginning of the \"sub\" keyword, rather than relative to the statement that contains the declaration." 235 "If non-nil, indent subs inside other blocks relative to \"sub\" keyword.
236Otherwise, indent them relative to statement that contains the declaration.
237This applies to, for example, hash values."
236 :type 'boolean 238 :type 'boolean
237 :group 'cperl-indentation-details) 239 :group 'cperl-indentation-details)
238 240
@@ -3694,13 +3696,14 @@ the sections using `cperl-pod-head-face', `cperl-pod-face',
3694 ;; ;; "\\([^= \t0-9$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)" ; 6 + 1 3696 ;; ;; "\\([^= \t0-9$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)" ; 6 + 1
3695 ;; "\\(\\)" ; To preserve count of pars :-( 6 + 1 3697 ;; "\\(\\)" ; To preserve count of pars :-( 6 + 1
3696 ;; "\\)" 3698 ;; "\\)"
3697 ((match-beginning 3) ; 2 + 1 3699 ((match-beginning 3) ; 2 + 1: found "<<", detect its type
3698 (setq b (point) 3700 (setq b (point)
3699 tb (match-beginning 0) 3701 tb (match-beginning 0)
3700 c (and ; not HERE-DOC 3702 c (and ; not HERE-DOC
3701 (match-beginning 6) 3703 (match-beginning 6)
3702 (save-match-data 3704 (save-match-data
3703 (or (looking-at "[ \t]*(") ; << function_call() 3705 (or (looking-at "[ \t]*(") ; << function_call()
3706 (looking-at ">>") ; <<>> operator
3704 (save-excursion ; 1 << func_name, or $foo << 10 3707 (save-excursion ; 1 << func_name, or $foo << 10
3705 (condition-case nil 3708 (condition-case nil
3706 (progn 3709 (progn
@@ -7260,6 +7263,7 @@ __DATA__ Ends program source.
7260__FILE__ Current (source) filename. 7263__FILE__ Current (source) filename.
7261__LINE__ Current line in current source. 7264__LINE__ Current line in current source.
7262__PACKAGE__ Current package. 7265__PACKAGE__ Current package.
7266__SUB__ Current sub.
7263ARGV Default multi-file input filehandle. <ARGV> is a synonym for <>. 7267ARGV Default multi-file input filehandle. <ARGV> is a synonym for <>.
7264ARGVOUT Output filehandle with -i flag. 7268ARGVOUT Output filehandle with -i flag.
7265BEGIN { ... } Immediately executed (during compilation) piece of code. 7269BEGIN { ... } Immediately executed (during compilation) piece of code.
@@ -7525,14 +7529,17 @@ use PACKAGE [SYMBOL1, ...] Compile-time `require' with consequent `import'.
7525prototype \\&SUB Returns prototype of the function given a reference. 7529prototype \\&SUB Returns prototype of the function given a reference.
7526=head1 Top-level heading. 7530=head1 Top-level heading.
7527=head2 Second-level heading. 7531=head2 Second-level heading.
7528=head3 Third-level heading (is there such?). 7532=head3 Third-level heading.
7533=head4 Fourth-level heading.
7529=over [ NUMBER ] Start list. 7534=over [ NUMBER ] Start list.
7530=item [ TITLE ] Start new item in the list. 7535=item [ TITLE ] Start new item in the list.
7531=back End list. 7536=back End list.
7532=cut Switch from POD to Perl. 7537=cut Switch from POD to Perl.
7533=pod Switch from Perl to POD. 7538=pod Switch from Perl to POD.
7534=begin Switch from Perl6 to POD. 7539=begin formatname Start directly formatted region.
7535=end Switch from POD to Perl6. 7540=end formatname End directly formatted region.
7541=for formatname text Paragraph in special format.
7542=encoding encodingname Encoding of the document.
7536") 7543")
7537 7544
7538(defun cperl-switch-to-doc-buffer (&optional interactive) 7545(defun cperl-switch-to-doc-buffer (&optional interactive)
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index b7e0c452288..0e515530852 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -682,7 +682,7 @@ otherwise build the summary from TYPE and SYMBOL."
682 (xref-make-elisp-location symbol type file))) 682 (xref-make-elisp-location symbol type file)))
683 683
684(defvar elisp-xref-find-def-functions nil 684(defvar elisp-xref-find-def-functions nil
685 "List of functions to be run from `elisp--xref-find-definitions' to add additional xrefs. 685 "List of functions run from `elisp--xref-find-definitions' to add more xrefs.
686Called with one arg; the symbol whose definition is desired. 686Called with one arg; the symbol whose definition is desired.
687Each function should return a list of xrefs, or nil; the first 687Each function should return a list of xrefs, or nil; the first
688non-nil result supersedes the xrefs produced by 688non-nil result supersedes the xrefs produced by
diff --git a/lisp/progmodes/flymake-proc.el b/lisp/progmodes/flymake-proc.el
index 152dc725c74..744c110f6b0 100644
--- a/lisp/progmodes/flymake-proc.el
+++ b/lisp/progmodes/flymake-proc.el
@@ -120,8 +120,10 @@ This is an alist with elements of the form:
120 REGEXP INIT [CLEANUP [NAME]] 120 REGEXP INIT [CLEANUP [NAME]]
121REGEXP is a regular expression that matches a file name. 121REGEXP is a regular expression that matches a file name.
122INIT is the init function to use. 122INIT is the init function to use.
123CLEANUP is the cleanup function to use, default `flymake-proc-simple-cleanup'. 123CLEANUP is the cleanup function to use, default
124NAME is the file name function to use, default `flymake-proc-get-real-file-name'." 124 `flymake-proc-simple-cleanup'.
125NAME is the file name function to use, default
126 `flymake-proc-get-real-file-name'."
125 :group 'flymake 127 :group 'flymake
126 :type '(alist :key-type (regexp :tag "File regexp") 128 :type '(alist :key-type (regexp :tag "File regexp")
127 :value-type 129 :value-type
diff --git a/lisp/progmodes/flymake.el b/lisp/progmodes/flymake.el
index efa7b2ffbf1..40bb90d0f15 100644
--- a/lisp/progmodes/flymake.el
+++ b/lisp/progmodes/flymake.el
@@ -412,44 +412,46 @@ verify FILTER, a function, and sort them by COMPARE (using KEY)."
412(defun flymake-diag-region (buffer line &optional col) 412(defun flymake-diag-region (buffer line &optional col)
413 "Compute BUFFER's region (BEG . END) corresponding to LINE and COL. 413 "Compute BUFFER's region (BEG . END) corresponding to LINE and COL.
414If COL is nil, return a region just for LINE. Return nil if the 414If COL is nil, return a region just for LINE. Return nil if the
415region is invalid." 415region is invalid. This function saves match data."
416 (condition-case-unless-debug _err 416 (condition-case-unless-debug _err
417 (with-current-buffer buffer 417 (with-current-buffer buffer
418 (let ((line (min (max line 1) 418 (let ((line (min (max line 1)
419 (line-number-at-pos (point-max) 'absolute)))) 419 (line-number-at-pos (point-max) 'absolute))))
420 (save-excursion 420 (save-excursion
421 (goto-char (point-min)) 421 (save-match-data
422 (forward-line (1- line)) 422 (goto-char (point-min))
423 (cl-flet ((fallback-bol 423 (forward-line (1- line))
424 () 424 (cl-flet ((fallback-bol
425 (back-to-indentation) 425 ()
426 (if (eobp) 426 (back-to-indentation)
427 (line-beginning-position 0) 427 (if (eobp)
428 (point))) 428 (line-beginning-position 0)
429 (fallback-eol 429 (point)))
430 (beg) 430 (fallback-eol
431 (progn 431 (beg)
432 (end-of-line) 432 (progn
433 (skip-chars-backward " \t\f\n" beg) 433 (end-of-line)
434 (if (eq (point) beg) 434 (skip-chars-backward " \t\f\n" beg)
435 (line-beginning-position 2) 435 (if (eq (point) beg)
436 (point))))) 436 (line-beginning-position 2)
437 (if (and col (cl-plusp col)) 437 (point)))))
438 (let* ((beg (progn (forward-char (1- col)) 438 (if (and col (cl-plusp col))
439 (point))) 439 (let* ((beg (progn (forward-char (1- col))
440 (sexp-end (ignore-errors (end-of-thing 'sexp))) 440 (point)))
441 (end (or (and sexp-end 441 (sexp-end (or (ignore-errors (end-of-thing 'sexp))
442 (not (= sexp-end beg)) 442 (ignore-errors (end-of-thing 'symbol))))
443 sexp-end) 443 (end (or (and sexp-end
444 (and (< (goto-char (1+ beg)) (point-max)) 444 (not (= sexp-end beg))
445 (point))))) 445 sexp-end)
446 (if end 446 (and (< (goto-char (1+ beg)) (point-max))
447 (cons beg end) 447 (point)))))
448 (cons (setq beg (fallback-bol)) 448 (if end
449 (fallback-eol beg)))) 449 (cons beg end)
450 (let* ((beg (fallback-bol)) 450 (cons (setq beg (fallback-bol))
451 (end (fallback-eol beg))) 451 (fallback-eol beg))))
452 (cons beg end))))))) 452 (let* ((beg (fallback-bol))
453 (end (fallback-eol beg)))
454 (cons beg end))))))))
453 (error (flymake-log :warning "Invalid region line=%s col=%s" line col) 455 (error (flymake-log :warning "Invalid region line=%s col=%s" line col)
454 nil))) 456 nil)))
455 457
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 4c248f771cd..99ca0a639a8 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -3009,7 +3009,7 @@ If NOPRESERVE is non-nil, window point is not restored after CUSTOM-DEFUN."
3009 (,custom-defun) 3009 (,custom-defun)
3010 (gdb-update-buffer-name) 3010 (gdb-update-buffer-name)
3011 ,@(when (not nopreserve) 3011 ,@(when (not nopreserve)
3012 '((set-window-start window start) 3012 '((set-window-start window start t)
3013 (set-window-point window p)))))) 3013 (set-window-point window p))))))
3014 3014
3015(defmacro def-gdb-trigger-and-handler (trigger-name gdb-command 3015(defmacro def-gdb-trigger-and-handler (trigger-name gdb-command
@@ -3127,24 +3127,27 @@ See `def-gdb-auto-update-handler'."
3127 (concat "fullname=\\(" gdb--string-regexp "\\)")) 3127 (concat "fullname=\\(" gdb--string-regexp "\\)"))
3128 3128
3129(defun gdb-get-location (bptno line flag) 3129(defun gdb-get-location (bptno line flag)
3130 "Find the directory containing the relevant source file. 3130 "Glean name of source file using `gdb-source-file-regexp', and visit it.
3131Put in buffer and place breakpoint icon." 3131Place breakpoint icon in its buffer."
3132 (goto-char (point-min)) 3132 (goto-char (point-min))
3133 (catch 'file-not-found 3133 (catch 'file-not-found
3134 (if (re-search-forward gdb-source-file-regexp nil t) 3134 (let (source-file)
3135 (delete (cons bptno "File not found") gdb-location-alist) 3135 (if (re-search-forward gdb-source-file-regexp nil t)
3136 ;; FIXME: Why/how do we use (match-string 1) when the search failed? 3136 (progn
3137 (push (cons bptno (match-string 1)) gdb-location-alist) 3137 (setq source-file (gdb-mi--c-string-from-string (match-string 1)))
3138 (gdb-resync) 3138 (delete (cons bptno "File not found") gdb-location-alist)
3139 (unless (assoc bptno gdb-location-alist) 3139 (push (cons bptno source-file) gdb-location-alist))
3140 (push (cons bptno "File not found") gdb-location-alist) 3140 (gdb-resync)
3141 (message-box "Cannot find source file for breakpoint location. 3141 (unless (assoc bptno gdb-location-alist)
3142 (push (cons bptno "File not found") gdb-location-alist)
3143 (message-box "Cannot find source file for breakpoint location.
3142Add directory to search path for source files using the GDB command, dir.")) 3144Add directory to search path for source files using the GDB command, dir."))
3143 (throw 'file-not-found nil)) 3145 (throw 'file-not-found nil))
3144 (with-current-buffer (find-file-noselect (match-string 1)) 3146 (with-current-buffer (find-file-noselect source-file)
3145 (gdb-init-buffer) 3147 (gdb-init-buffer)
3146 ;; only want one breakpoint icon at each location 3148 ;; Only want one breakpoint icon at each location.
3147 (gdb-put-breakpoint-icon (eq flag ?y) bptno (string-to-number line))))) 3149 (gdb-put-breakpoint-icon (string-equal flag "y") bptno
3150 (string-to-number line))))))
3148 3151
3149(add-hook 'find-file-hook 'gdb-find-file-hook) 3152(add-hook 'find-file-hook 'gdb-find-file-hook)
3150 3153
diff --git a/lisp/progmodes/hideif.el b/lisp/progmodes/hideif.el
index 7cbc9708fce..fb487f7e1f2 100644
--- a/lisp/progmodes/hideif.el
+++ b/lisp/progmodes/hideif.el
@@ -153,8 +153,8 @@ The first time we visit such a file, _XXX_HEADER_FILE_INCLUDED_ is
153undefined, and so nothing is hidden. The next time we visit it, everything will 153undefined, and so nothing is hidden. The next time we visit it, everything will
154be hidden. 154be hidden.
155 155
156This behavior is generally undesirable. If this option is non-nil, the outermost 156This behavior is generally undesirable. If this option is non-nil, the
157#if is always visible." 157outermost #if is always visible."
158 :type 'boolean 158 :type 'boolean
159 :version "25.1") 159 :version "25.1")
160 160
@@ -304,7 +304,7 @@ Several variables affect how the hiding is done:
304 ;; (C-c @ C) every time before hiding current buffer. 304 ;; (C-c @ C) every time before hiding current buffer.
305;; (setq-local hide-ifdef-env 305;; (setq-local hide-ifdef-env
306;; (default-value 'hide-ifdef-env)) 306;; (default-value 'hide-ifdef-env))
307 (set 'hide-ifdef-env (default-value 'hide-ifdef-env)) 307 (setq hide-ifdef-env (default-value 'hide-ifdef-env))
308 ;; Some C/C++ headers might have other ways to prevent reinclusion and 308 ;; Some C/C++ headers might have other ways to prevent reinclusion and
309 ;; thus would like `hide-ifdef-expand-reinclusion-protection' to be nil. 309 ;; thus would like `hide-ifdef-expand-reinclusion-protection' to be nil.
310 (setq-local hide-ifdef-expand-reinclusion-protection 310 (setq-local hide-ifdef-expand-reinclusion-protection
diff --git a/lisp/progmodes/octave.el b/lisp/progmodes/octave.el
index c313ad11792..bda4e60c55c 100644
--- a/lisp/progmodes/octave.el
+++ b/lisp/progmodes/octave.el
@@ -1605,8 +1605,9 @@ code line."
1605 1605
1606(defun octave-eldoc-function-signatures (fn) 1606(defun octave-eldoc-function-signatures (fn)
1607 (unless (equal fn (car octave-eldoc-cache)) 1607 (unless (equal fn (car octave-eldoc-cache))
1608 (inferior-octave-send-list-and-digest 1608 (while-no-input
1609 (list (format "print_usage ('%s');\n" fn))) 1609 (inferior-octave-send-list-and-digest
1610 (list (format "print_usage ('%s');\n" fn))))
1610 (let (result) 1611 (let (result)
1611 (dolist (line inferior-octave-output-list) 1612 (dolist (line inferior-octave-output-list)
1612 ;; The help output has changed a few times in GNU Octave. 1613 ;; The help output has changed a few times in GNU Octave.
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 0ed5f1f907c..5b58090de02 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -631,6 +631,7 @@ DIRS must contain directory names."
631 (define-key map "g" 'project-find-regexp) 631 (define-key map "g" 'project-find-regexp)
632 (define-key map "G" 'project-or-external-find-regexp) 632 (define-key map "G" 'project-or-external-find-regexp)
633 (define-key map "r" 'project-query-replace-regexp) 633 (define-key map "r" 'project-query-replace-regexp)
634 (define-key map "x" 'project-execute-extended-command)
634 map) 635 map)
635 "Keymap for project commands.") 636 "Keymap for project commands.")
636 637
@@ -1246,31 +1247,67 @@ It's also possible to enter an arbitrary directory not in the list."
1246 (project--ensure-read-project-list) 1247 (project--ensure-read-project-list)
1247 (mapcar #'car project--list)) 1248 (mapcar #'car project--list))
1248 1249
1250;;;###autoload
1251(defun project-execute-extended-command ()
1252 "Execute an extended command in project root."
1253 (declare (interactive-only command-execute))
1254 (interactive)
1255 (let ((default-directory (project-root (project-current t))))
1256 (call-interactively #'execute-extended-command)))
1257
1249 1258
1250;;; Project switching 1259;;; Project switching
1251 1260
1252;;;###autoload 1261;;;###autoload
1253(defvar project-switch-commands 1262(defcustom project-switch-commands
1254 '((?f "Find file" project-find-file) 1263 '((project-find-file "Find file")
1255 (?g "Find regexp" project-find-regexp) 1264 (project-find-regexp "Find regexp")
1256 (?d "Dired" project-dired) 1265 (project-dired "Dired")
1257 (?v "VC-Dir" project-vc-dir) 1266 (project-vc-dir "VC-Dir")
1258 (?e "Eshell" project-eshell)) 1267 (project-eshell "Eshell"))
1259 "Alist mapping keys to project switching menu entries. 1268 "Alist mapping commands to descriptions.
1260Used by `project-switch-project' to construct a dispatch menu of 1269Used by `project-switch-project' to construct a dispatch menu of
1261commands available upon \"switching\" to another project. 1270commands available upon \"switching\" to another project.
1262 1271
1263Each element is of the form (KEY LABEL COMMAND), where COMMAND is the 1272Each element is of the form (COMMAND LABEL &optional KEY) where
1264command to run when KEY is pressed. LABEL is used to distinguish 1273COMMAND is the command to run when KEY is pressed. LABEL is used
1265the menu entries in the dispatch menu.") 1274to distinguish the menu entries in the dispatch menu. If KEY is
1275absent, COMMAND must be bound in `project-prefix-map', and the
1276key is looked up in that map."
1277 :version "28.1"
1278 :package-version '(project . "0.6.0")
1279 :type '(repeat
1280 (list
1281 (symbol :tag "Command")
1282 (string :tag "Label")
1283 (choice :tag "Key to press"
1284 (const :tag "Infer from the keymap" nil)
1285 (character :tag "Explicit key")))))
1286
1287(defcustom project-switch-use-entire-map nil
1288 "Make `project-switch-project' use entire `project-prefix-map'.
1289If nil, `project-switch-project' will only recognize commands
1290listed in `project-switch-commands' and signal an error when
1291others are invoked. Otherwise, all keys in `project-prefix-map'
1292are legal even if they aren't listed in the dispatch menu."
1293 :type 'boolean
1294 :version "28.1")
1266 1295
1267(defun project--keymap-prompt () 1296(defun project--keymap-prompt ()
1268 "Return a prompt for the project switching dispatch menu." 1297 "Return a prompt for the project switching dispatch menu."
1269 (mapconcat 1298 (mapconcat
1270 (pcase-lambda (`(,key ,label)) 1299 (pcase-lambda (`(,cmd ,label ,key))
1271 (format "[%s] %s" 1300 (when (characterp cmd) ; Old format, apparently user-customized.
1272 (propertize (key-description `(,key)) 'face 'bold) 1301 (let ((tmp cmd))
1273 label)) 1302 ;; TODO: Add a deprecation warning, probably.
1303 (setq cmd key
1304 key tmp)))
1305 (let ((key (if key
1306 (vector key)
1307 (where-is-internal cmd project-prefix-map t))))
1308 (format "[%s] %s"
1309 (propertize (key-description key) 'face 'bold)
1310 label)))
1274 project-switch-commands 1311 project-switch-commands
1275 " ")) 1312 " "))
1276 1313
@@ -1283,13 +1320,31 @@ made from `project-switch-commands'.
1283When called in a program, it will use the project corresponding 1320When called in a program, it will use the project corresponding
1284to directory DIR." 1321to directory DIR."
1285 (interactive (list (project-prompt-project-dir))) 1322 (interactive (list (project-prompt-project-dir)))
1286 (let ((choice nil)) 1323 (let ((commands-menu
1287 (while (not choice) 1324 (mapcar
1288 (setq choice (assq (read-event (project--keymap-prompt)) 1325 (lambda (row)
1289 project-switch-commands))) 1326 (if (characterp (car row))
1327 ;; Deprecated format.
1328 ;; XXX: Add a warning about it?
1329 (reverse row)
1330 row))
1331 project-switch-commands))
1332 command)
1333 (while (not command)
1334 (let ((choice (read-event (project--keymap-prompt))))
1335 (when (setq command
1336 (or (car
1337 (seq-find (lambda (row) (equal choice (nth 2 row)))
1338 commands-menu))
1339 (lookup-key project-prefix-map (vector choice))))
1340 (unless (or project-switch-use-entire-map
1341 (assq command commands-menu))
1342 ;; TODO: Add some hint to the prompt, like "key not
1343 ;; recognized" or something.
1344 (setq command nil)))))
1290 (let ((default-directory dir) 1345 (let ((default-directory dir)
1291 (project-current-inhibit-prompt t)) 1346 (project-current-inhibit-prompt t))
1292 (call-interactively (nth 2 choice))))) 1347 (call-interactively command))))
1293 1348
1294(provide 'project) 1349(provide 'project)
1295;;; project.el ends here 1350;;; project.el ends here
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index d75944a702f..d58b32f3c3c 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1404,7 +1404,7 @@ With positive ARG search backwards, else search forwards."
1404 (line-beg-pos (line-beginning-position)) 1404 (line-beg-pos (line-beginning-position))
1405 (line-content-start (+ line-beg-pos (current-indentation))) 1405 (line-content-start (+ line-beg-pos (current-indentation)))
1406 (pos (point-marker)) 1406 (pos (point-marker))
1407 (beg-indentation 1407 (body-indentation
1408 (and (> arg 0) 1408 (and (> arg 0)
1409 (save-excursion 1409 (save-excursion
1410 (while (and 1410 (while (and
@@ -1415,9 +1415,16 @@ With positive ARG search backwards, else search forwards."
1415 0)))) 1415 0))))
1416 (found 1416 (found
1417 (progn 1417 (progn
1418 (when (and (< arg 0) 1418 (when (and (python-info-looking-at-beginning-of-defun)
1419 (python-info-looking-at-beginning-of-defun)) 1419 (or (< arg 0)
1420 ;; If looking at beginning of defun, and if
1421 ;; pos is > line-content-start, ensure a
1422 ;; backward re search match this defun by
1423 ;; going to end of line before calling
1424 ;; re-search-fn bug#40563
1425 (and (> arg 0) (> pos line-content-start))))
1420 (end-of-line 1)) 1426 (end-of-line 1))
1427
1421 (while (and (funcall re-search-fn 1428 (while (and (funcall re-search-fn
1422 python-nav-beginning-of-defun-regexp nil t) 1429 python-nav-beginning-of-defun-regexp nil t)
1423 (or (python-syntax-context-type) 1430 (or (python-syntax-context-type)
@@ -1425,7 +1432,7 @@ With positive ARG search backwards, else search forwards."
1425 ;; backwards by checking indentation. 1432 ;; backwards by checking indentation.
1426 (and (> arg 0) 1433 (and (> arg 0)
1427 (not (= (current-indentation) 0)) 1434 (not (= (current-indentation) 0))
1428 (>= (current-indentation) beg-indentation))))) 1435 (>= (current-indentation) body-indentation)))))
1429 (and (python-info-looking-at-beginning-of-defun) 1436 (and (python-info-looking-at-beginning-of-defun)
1430 (or (not (= (line-number-at-pos pos) 1437 (or (not (= (line-number-at-pos pos)
1431 (line-number-at-pos))) 1438 (line-number-at-pos)))
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index fbc6e424eb1..8cb0350dc06 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -75,7 +75,7 @@
75 75
76(defconst ruby-block-mid-re 76(defconst ruby-block-mid-re
77 (regexp-opt ruby-block-mid-keywords) 77 (regexp-opt ruby-block-mid-keywords)
78 "Regexp to match where the indentation gets shallower in middle of block statements.") 78 "Regexp for where the indentation gets shallower in middle of block statements.")
79 79
80(defconst ruby-block-op-keywords 80(defconst ruby-block-op-keywords
81 '("and" "or" "not") 81 '("and" "or" "not")
diff --git a/lisp/progmodes/verilog-mode.el b/lisp/progmodes/verilog-mode.el
index b1abefe534e..f6e95b9cb6a 100644
--- a/lisp/progmodes/verilog-mode.el
+++ b/lisp/progmodes/verilog-mode.el
@@ -10112,7 +10112,8 @@ variables to build the path."
10112;; A modi is: [module-name-string file-name begin-point] 10112;; A modi is: [module-name-string file-name begin-point]
10113 10113
10114(defvar verilog-cache-enabled t 10114(defvar verilog-cache-enabled t
10115 "Non-nil enables caching of signals, etc. Set to nil for debugging to make things SLOW!") 10115 "Non-nil enables caching of signals, etc.
10116Set to nil for debugging to make things SLOW!")
10116 10117
10117(defvar verilog-modi-cache-list nil 10118(defvar verilog-modi-cache-list nil
10118 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)... 10119 "Cache of ((Module Function) Buf-Tick Buf-Modtime Func-Returns)...
diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el
index a524bbaa223..562a357a8cb 100644
--- a/lisp/progmodes/which-func.el
+++ b/lisp/progmodes/which-func.el
@@ -186,7 +186,7 @@ and you want to simplify them for the mode line
186 "Non-nil means display current function name in mode line. 186 "Non-nil means display current function name in mode line.
187This makes a difference only if `which-function-mode' is non-nil.") 187This makes a difference only if `which-function-mode' is non-nil.")
188 188
189(add-hook 'after-change-major-mode-hook 'which-func-ff-hook t) 189(add-hook 'after-change-major-mode-hook #'which-func-ff-hook t)
190 190
191(defun which-func-try-to-enable () 191(defun which-func-try-to-enable ()
192 (unless (or (not which-function-mode) 192 (unless (or (not which-function-mode)
@@ -216,7 +216,8 @@ It creates the Imenu index for the buffer, if necessary."
216(defun which-func-update () 216(defun which-func-update ()
217 ;; "Update the Which-Function mode display for all windows." 217 ;; "Update the Which-Function mode display for all windows."
218 ;; (walk-windows 'which-func-update-1 nil 'visible)) 218 ;; (walk-windows 'which-func-update-1 nil 'visible))
219 (which-func-update-1 (selected-window))) 219 (let ((non-essential t))
220 (which-func-update-1 (selected-window))))
220 221
221(defun which-func-update-1 (window) 222(defun which-func-update-1 (window)
222 "Update the Which Function mode display for window WINDOW." 223 "Update the Which Function mode display for window WINDOW."
@@ -356,7 +357,7 @@ This function is meant to be called from `ediff-select-hook'."
356 (when ediff-window-C 357 (when ediff-window-C
357 (which-func-update-1 ediff-window-C)))) 358 (which-func-update-1 ediff-window-C))))
358 359
359(add-hook 'ediff-select-hook 'which-func-update-ediff-windows) 360(add-hook 'ediff-select-hook #'which-func-update-ediff-windows)
360 361
361(provide 'which-func) 362(provide 'which-func)
362 363