Annotation of OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el, Revision 1.13
1.1 takayama 1: ;; -*- mode: emacs-lisp -*-
2: ;;
3: ;; asir-mode.el -- asir mode
4: ;;
1.13 ! ohara 5: ;; $OpenXM: OpenXM_contrib2/windows/post-msg-asirgui/asir-mode.el,v 1.12 2013/11/27 13:39:08 ohara Exp $
1.10 takayama 6:
1.1 takayama 7: ;; This program is free software: you can redistribute it and/or modify
8: ;; it under the terms of the GNU General Public License as published by
9: ;; the Free Software Foundation, either version 3 of the License, or
10: ;; (at your option) any later version.
1.12 ohara 11:
1.10 takayama 12: ;; 1. Install
13: ;;
14: ;; **(for Windows) Write the following configuration to your .emacs file.
15: ;;
16: ;; (setq load-path (append load-path '((concat (getenv "ASIR_ROOTDIR") "/share/editor"))))
17: ;; (setq auto-mode-alist (cons '("\\.rr$" . asir-mode) auto-mode-alist))
18: ;; (autoload 'asir-mode "asir-mode" "Asir mode" t)
19: ;;
20: ;; **(for unix) Copy this file to your emacs site-lisp folder and
21: ;; write the following configuration to your .emacs file.
22: ;;
23: ;; (setq auto-mode-alist (cons '("\\.rr$" . asir-mode) auto-mode-alist))
24: ;; (autoload 'asir-mode "asir-mode" "Asir mode" t)
25: ;;
26: ;; Please run byte-compile for speed up.
27: ;;
28: ;; 2. Use
29: ;;
30: ;; If you open Risa/Asir source file (*.rr) by emacs, then asir-mode starts up automatically.
31: ;; The following key binding can be used:
32: ;; C-c s Asir starts up in another window.
33: ;; C-c t Asir terminates.
1.13 ! ohara 34: ;; C-c a Abort current calculation.
1.10 takayama 35: ;; C-c l The current buffer is loaded to Asir as a file.
36: ;; C-c r Selected region is loaded to Asir as a file.
37: ;; C-c p Selected region is pasted to Asir.
38:
39: (require 'shell)
1.1 takayama 40:
1.9 takayama 41: ;;;; AsirGUI for Windows
1.10 takayama 42: (defvar asir-exec-path '("~/Desktop/asir/bin" "c:/Program Files/asir/bin" "c:/Program Files (x64)/asir/bin" "c:/asir/bin")
43: "Default search path for asir binary in Windows")
1.1 takayama 44:
1.10 takayama 45: (defun asir-effective-exec-path ()
1.1 takayama 46: "Search path for command"
47: (let* ((dir (getenv "ASIR_ROOTDIR"))
1.10 takayama 48: (path (append asir-exec-path exec-path)))
49: (if dir (cons (concat dir "/bin") path) path)))
1.1 takayama 50:
1.10 takayama 51: (defun asir-executable-find (command)
1.1 takayama 52: "Search for command"
53: (let* ((exec-path (asir-effective-exec-path)))
1.10 takayama 54: (executable-find command)))
55:
56: ;;;; Asir for UNIX
57: (defvar asir-cmd-buffer-name "*asir-cmd*")
58:
59: (defun asir-cmd-load (filename)
60: "Send `load' command to running asir process"
61: (if (eq system-type 'windows-nt)
62: (let ((exec-path (asir-effective-exec-path)))
63: (start-process "asir-proc-cmdasir" nil "cmdasir" filename))
64: (save-excursion
65: (if (get-buffer asir-cmd-buffer-name)
66: (progn
67: (set-buffer asir-cmd-buffer-name)
68: (goto-char (point-max))
69: (insert (format "load(\"%s\");" filename))
70: (comint-send-input))))))
71:
72: (defun asir-start ()
73: "Start asir process"
74: (interactive)
75: (if (eq system-type 'windows-nt)
76: ;; for Windows
77: (let ((exec-path (asir-effective-exec-path)))
78: (start-process "asir-proc-asirgui" nil "asirgui"))
79: ;; for UNIX
80: (save-excursion
81: (if (not (get-buffer asir-cmd-buffer-name))
82: (let ((current-frame (selected-frame)))
83: (if window-system
84: (progn
85: (select-frame (make-frame))
86: (shell (get-buffer-create asir-cmd-buffer-name)) ;; Switch to new buffer automatically
87: (delete-other-windows))
88: (if (>= emacs-major-version 24)
89: (progn
90: (split-window)
91: (other-window -1)))
92: (shell (get-buffer-create asir-cmd-buffer-name)))
93: (sleep-for 1)
94: (goto-char (point-max))
95: (insert "asir")
96: (comint-send-input)
97: (select-frame current-frame))))))
1.1 takayama 98:
1.10 takayama 99: (defun asir-terminate ()
100: "Terminate asir process"
1.1 takayama 101: (interactive)
1.10 takayama 102: (if (eq system-type 'windows-nt)
103: ;; for Windows
104: (let ((exec-path (asir-effective-exec-path)))
105: (start-process "asir-proc-cmdasir" nil "cmdasir" "--quit"))
106: ;; for UNIX
107: (if (get-buffer asir-cmd-buffer-name)
108: (if (not window-system)
109: (let ((asir-cmd-window (get-buffer-window asir-cmd-buffer-name)))
110: (and (kill-buffer asir-cmd-buffer-name)
111: (or (not asir-cmd-window) (delete-window asir-cmd-window))))
112: (let ((asir-cmd-frame (window-frame (get-buffer-window asir-cmd-buffer-name 0))))
113: (and (kill-buffer asir-cmd-buffer-name)
114: (delete-frame asir-cmd-frame)))))))
1.1 takayama 115:
1.10 takayama 116: (defun asir-execute-current-buffer ()
117: "Execute current buffer on asir"
1.1 takayama 118: (interactive)
1.9 takayama 119: (let ((exec-path (asir-effective-exec-path)))
1.10 takayama 120: (asir-cmd-load (buffer-file-name))))
1.1 takayama 121:
1.10 takayama 122: (defun asir-execute-region ()
123: "Execute region on asir"
1.1 takayama 124: (interactive)
1.10 takayama 125: (if mark-active
126: (save-excursion
127: (let ((temp-file (make-temp-file (format "%s/cmdasir-" (or (getenv "TEMP") "/var/tmp"))))
128: (temp-buffer (generate-new-buffer " *asir-temp*")))
129: (write-region (region-beginning) (region-end) temp-file)
130: (set-buffer temp-buffer)
131: (insert " end$")
132: (write-region (point-min) (point-max) temp-file t) ;; append
133: (kill-buffer temp-buffer)
134: (asir-cmd-load temp-file)))))
1.1 takayama 135:
1.10 takayama 136: (defun asir-paste-region ()
137: "Paste region to asir"
1.1 takayama 138: (interactive)
1.10 takayama 139: (if mark-active
140: (if (eq system-type 'windows-nt)
141: (let ((temp-file (make-temp-file (format "%s/cmdasir-" (getenv "TEMP"))))
142: (exec-path (asir-effective-exec-path)))
143: (write-region (region-beginning) (region-end) temp-file)
144: (start-process "asir-proc-cmdasir" nil "cmdasir" "--paste-contents" temp-file))
145: (save-excursion
146: (let ((buffer (current-buffer))
147: (start (region-beginning))
148: (end (region-end)))
149: (set-buffer asir-cmd-buffer-name)
150: (goto-char (point-max))
151: (insert-buffer-substring buffer start end)
152: (comint-send-input))))))
1.4 ohara 153:
1.13 ! ohara 154: (defun asir-abort ()
! 155: "Abort calculation on asir"
! 156: (interactive)
! 157: (if (eq system-type 'windows-nt)
! 158: ;; for Windows
! 159: (let ((exec-path (asir-effective-exec-path)))
! 160: (start-process "asir-proc-cmdasir" nil "cmdasir" "--abort"))
! 161: ;; for UNIX
! 162: (save-excursion
! 163: (if (get-buffer asir-cmd-buffer-name)
! 164: (progn
! 165: (set-buffer asir-cmd-buffer-name)
! 166: (comint-kill-input)
! 167: (comint-interrupt-subjob)
! 168: (goto-char (point-max))
! 169: (insert "t\ny")
! 170: (comint-send-input)
! 171: )))))
! 172:
1.1 takayama 173: ;;;; Extension for CC-mode.
174:
175: (require 'cc-mode)
176:
177: (eval-when-compile
178: (require 'cc-langs)
179: (require 'cc-engine)
180: (require 'cc-fonts))
181:
182: (eval-and-compile
183: ;; Make our mode known to the language constant system. Use Java
184: ;; mode as the fallback for the constants we don't change here.
185: ;; This needs to be done also at compile time since the language
186: ;; constants are evaluated then.
187: (c-add-language 'asir-mode 'c++-mode))
188:
189: (c-lang-defconst c-stmt-delim-chars asir "^;${}?:")
190: (c-lang-defconst c-stmt-delim-chars-with-comma asir "^;$,{}?:")
191: (c-lang-defconst c-other-op-syntax-tokens
192: asir (cons "$" (c-lang-const c-other-op-syntax-tokens c)))
193: (c-lang-defconst c-identifier-syntax-modifications
194: asir (remove '(?$ . "w") (c-lang-const c-identifier-syntax-modifications c)))
195: (c-lang-defconst c-symbol-chars asir (concat c-alnum "_"))
196:
197: (c-lang-defconst c-primitive-type-kwds asir '("def" "extern" "static" "localf" "function"))
198: (c-lang-defconst c-primitive-type-prefix-kwds asir nil)
199: (c-lang-defconst c-type-list-kwds asir nil)
200: (c-lang-defconst c-class-decl-kwds asir '("module"))
201: (c-lang-defconst c-othe-decl-kwds asir '("endmodule" "end"))
202: (c-lang-defconst c-type-modifier-kwds asir nil)
203: (c-lang-defconst c-modifier-kwds asir nil)
204:
205: (c-lang-defconst c-mode-menu
206: asir
207: (append (c-lang-const c-mode-menu c)
208: '("----"
1.10 takayama 209: ["Start Asir" asir-start t]
210: ["Terminate Asir" asir-terminate t]
1.13 ! ohara 211: ["Abort calcuration on Asir" asir-abort t]
1.10 takayama 212: ["Execute Current Buffer on Asir" asir-execute-current-buffer (buffer-file-name)]
213: ["Execute Region on Asir" asir-execute-region mark-active]
214: ["Paste Region to Asir" asir-paste-region mark-active]
1.1 takayama 215: )))
216:
217: (defvar asir-font-lock-extra-types nil
218: "*List of extra types (aside from the type keywords) to recognize in asir mode.
219: Each list item should be a regexp matching a single identifier.")
220:
221: (defconst asir-font-lock-keywords-1 (c-lang-const c-matchers-1 asir)
222: "Minimal highlighting for asir mode.")
223:
224: (defconst asir-font-lock-keywords-2 (c-lang-const c-matchers-2 asir)
225: "Fast normal highlighting for asir mode.")
226:
227: (defconst asir-font-lock-keywords-3 (c-lang-const c-matchers-3 asir)
228: "Accurate normal highlighting for asir mode.")
229:
230: (defvar asir-font-lock-keywords asir-font-lock-keywords-3
231: "Default expressions to highlight in asir mode.")
232:
233: (defvar asir-mode-syntax-table nil
234: "Syntax table used in asir-mode buffers.")
235: (or asir-mode-syntax-table
236: (setq asir-mode-syntax-table
237: (funcall (c-lang-const c-make-mode-syntax-table asir))))
238:
239: (defvar asir-mode-abbrev-table nil
240: "Abbreviation table used in asir-mode buffers.")
241:
242: (defvar asir-mode-map (let ((map (c-make-inherited-keymap)))
243: ;; Add bindings which are only useful for asir
244: map)
245: "Keymap used in asir-mode buffers.")
246:
1.10 takayama 247: ;; Key binding for asir-mode
248: (define-key asir-mode-map (kbd "C-c s") 'asir-start)
249: (define-key asir-mode-map (kbd "C-c t") 'asir-terminate)
1.13 ! ohara 250: (define-key asir-mode-map (kbd "C-c a") 'asir-abort)
1.10 takayama 251: (define-key asir-mode-map (kbd "C-c l") 'asir-execute-current-buffer)
252: (define-key asir-mode-map (kbd "C-c r") 'asir-execute-region)
253: (define-key asir-mode-map (kbd "C-c p") 'asir-paste-region)
254:
1.1 takayama 255: (easy-menu-define asir-menu asir-mode-map "asir Mode Commands"
256: ;; Can use `asir' as the language for `c-mode-menu'
257: ;; since its definition covers any language. In
258: ;; this case the language is used to adapt to the
259: ;; nonexistence of a cpp pass and thus removing some
260: ;; irrelevant menu alternatives.
261: (cons "Asir" (c-lang-const c-mode-menu asir)))
262:
263: (defun asir-mode ()
264: "Major mode for editing asir code.
265: This is a simple example of a separate mode derived from CC Mode to
266: support a language with syntax similar to C/C++/ObjC/Java/IDL/Pike.
267:
268: The hook `c-mode-common-hook' is run with no args at mode
269: initialization, then `asir-mode-hook'.
270:
271: Key bindings:
272: \\{asir-mode-map}"
273: (interactive)
274: (kill-all-local-variables)
275: (c-initialize-cc-mode t)
276: (set-syntax-table asir-mode-syntax-table)
277: (setq major-mode 'asir-mode
278: mode-name "asir"
279: local-abbrev-table asir-mode-abbrev-table
280: abbrev-mode t)
281: (use-local-map asir-mode-map)
282: ;; `c-init-language-vars' is a macro that is expanded at compile
283: ;; time to a large `setq' with all the language variables and their
284: ;; customized values for our language.
285: (c-init-language-vars asir-mode)
286: ;; `c-common-init' initializes most of the components of a CC Mode
287: ;; buffer, including setup of the mode menu, font-lock, etc.
288: ;; There's also a lower level routine `c-basic-common-init' that
289: ;; only makes the necessary initialization to get the syntactic
290: ;; analysis and similar things working.
291: (c-common-init 'asir-mode)
292: ;;(easy-menu-add asir-menu)
293: (run-hooks 'c-mode-common-hook)
294: (run-hooks 'asir-mode-hook)
295: (c-update-modeline))
296:
297: (if (fboundp 'asir-backup:c-guess-basic-syntax)
298: nil
299: (fset 'asir-backup:c-guess-basic-syntax (symbol-function 'c-guess-basic-syntax))
300: (defun c-guess-basic-syntax ()
301: "A modified c-guess-basic-syntax for asir-mode"
302: (if (eq major-mode 'asir-mode)
303: (asir-c-guess-basic-syntax)
304: (asir-backup:c-guess-basic-syntax))))
305:
306: ;; Meadow 3 does not have `c-brace-anchor-point'
307: ;; This function was copied from cc-engine.el of Emacs 23.4
308: (if (and (featurep 'meadow) (not (fboundp 'c-brace-anchor-point)))
309: (defun c-brace-anchor-point (bracepos)
310: ;; BRACEPOS is the position of a brace in a construct like "namespace
311: ;; Bar {". Return the anchor point in this construct; this is the
312: ;; earliest symbol on the brace's line which isn't earlier than
313: ;; "namespace".
314: ;;
315: ;; Currently (2007-08-17), "like namespace" means "matches
316: ;; c-other-block-decl-kwds". It doesn't work with "class" or "struct"
317: ;; or anything like that.
318: (save-excursion
319: (let ((boi (c-point 'boi bracepos)))
320: (goto-char bracepos)
321: (while (and (> (point) boi)
322: (not (looking-at c-other-decl-block-key)))
323: (c-backward-token-2))
324: (if (> (point) boi) (point) boi))))
325: )
326:
327: ;; The function `c-guess-basic-syntax' was copied from cc-engine.el of Emacs 23.4 and
328: ;; was modified for Risa/Asir.
329: ;; CASE 5D, 5J, 18 are corrected.
330:
331: ;;;; Beginning of `asir-c-guess-basic-syntax'
332: (defun asir-c-guess-basic-syntax ()
333: "Return the syntactic context of the current line."
334: (save-excursion
335: (beginning-of-line)
336: (c-save-buffer-state
337: ((indent-point (point))
338: (case-fold-search nil)
339: ;; A whole ugly bunch of various temporary variables. Have
340: ;; to declare them here since it's not possible to declare
341: ;; a variable with only the scope of a cond test and the
342: ;; following result clauses, and most of this function is a
343: ;; single gigantic cond. :P
344: literal char-before-ip before-ws-ip char-after-ip macro-start
345: in-macro-expr c-syntactic-context placeholder c-in-literal-cache
346: step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos
347: containing-<
348: ;; The following record some positions for the containing
349: ;; declaration block if we're directly within one:
350: ;; `containing-decl-open' is the position of the open
351: ;; brace. `containing-decl-start' is the start of the
352: ;; declaration. `containing-decl-kwd' is the keyword
353: ;; symbol of the keyword that tells what kind of block it
354: ;; is.
355: containing-decl-open
356: containing-decl-start
357: containing-decl-kwd
358: ;; The open paren of the closest surrounding sexp or nil if
359: ;; there is none.
360: containing-sexp
361: ;; The position after the closest preceding brace sexp
362: ;; (nested sexps are ignored), or the position after
363: ;; `containing-sexp' if there is none, or (point-min) if
364: ;; `containing-sexp' is nil.
365: lim
366: ;; The paren state outside `containing-sexp', or at
367: ;; `indent-point' if `containing-sexp' is nil.
368: (paren-state (c-parse-state))
369: ;; There's always at most one syntactic element which got
370: ;; an anchor pos. It's stored in syntactic-relpos.
371: syntactic-relpos
372: (c-stmt-delim-chars c-stmt-delim-chars))
373:
374: ;; Check if we're directly inside an enclosing declaration
375: ;; level block.
376: (when (and (setq containing-sexp
377: (c-most-enclosing-brace paren-state))
378: (progn
379: (goto-char containing-sexp)
380: (eq (char-after) ?{))
381: (setq placeholder
382: (c-looking-at-decl-block
383: (c-most-enclosing-brace paren-state
384: containing-sexp)
385: t)))
386: (setq containing-decl-open containing-sexp
387: containing-decl-start (point)
388: containing-sexp nil)
389: (goto-char placeholder)
390: (setq containing-decl-kwd (and (looking-at c-keywords-regexp)
391: (c-keyword-sym (match-string 1)))))
392:
393: ;; Init some position variables.
394: (if c-state-cache
395: (progn
396: (setq containing-sexp (car paren-state)
397: paren-state (cdr paren-state))
398: (if (consp containing-sexp)
399: (progn
400: (setq lim (cdr containing-sexp))
401: (if (cdr c-state-cache)
402: ;; Ignore balanced paren. The next entry
403: ;; can't be another one.
404: (setq containing-sexp (car (cdr c-state-cache))
405: paren-state (cdr paren-state))
406: ;; If there is no surrounding open paren then
407: ;; put the last balanced pair back on paren-state.
408: (setq paren-state (cons containing-sexp paren-state)
409: containing-sexp nil)))
410: (setq lim (1+ containing-sexp))))
411: (setq lim (point-min)))
412:
413: ;; If we're in a parenthesis list then ',' delimits the
414: ;; "statements" rather than being an operator (with the
415: ;; exception of the "for" clause). This difference is
416: ;; typically only noticeable when statements are used in macro
417: ;; arglists.
418: (when (and containing-sexp
419: (eq (char-after containing-sexp) ?\())
420: (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma))
421:
422: ;; cache char before and after indent point, and move point to
423: ;; the most likely position to perform the majority of tests
424: (goto-char indent-point)
425: (c-backward-syntactic-ws lim)
426: (setq before-ws-ip (point)
427: char-before-ip (char-before))
428: (goto-char indent-point)
429: (skip-chars-forward " \t")
430: (setq char-after-ip (char-after))
431:
432: ;; are we in a literal?
433: (setq literal (c-in-literal lim))
434:
435: ;; now figure out syntactic qualities of the current line
436: (cond
437:
438: ;; CASE 1: in a string.
439: ((eq literal 'string)
440: (c-add-syntax 'string (c-point 'bopl)))
441:
442: ;; CASE 2: in a C or C++ style comment.
443: ((and (memq literal '(c c++))
444: ;; This is a kludge for XEmacs where we use
445: ;; `buffer-syntactic-context', which doesn't correctly
446: ;; recognize "\*/" to end a block comment.
447: ;; `parse-partial-sexp' which is used by
448: ;; `c-literal-limits' will however do that in most
449: ;; versions, which results in that we get nil from
450: ;; `c-literal-limits' even when `c-in-literal' claims
451: ;; we're inside a comment.
452: (setq placeholder (c-literal-limits lim)))
453: (c-add-syntax literal (car placeholder)))
454:
455: ;; CASE 3: in a cpp preprocessor macro continuation.
456: ((and (save-excursion
457: (when (c-beginning-of-macro)
458: (setq macro-start (point))))
459: (/= macro-start (c-point 'boi))
460: (progn
461: (setq tmpsymbol 'cpp-macro-cont)
462: (or (not c-syntactic-indentation-in-macros)
463: (save-excursion
464: (goto-char macro-start)
465: ;; If at the beginning of the body of a #define
466: ;; directive then analyze as cpp-define-intro
467: ;; only. Go on with the syntactic analysis
468: ;; otherwise. in-macro-expr is set if we're in a
469: ;; cpp expression, i.e. before the #define body
470: ;; or anywhere in a non-#define directive.
471: (if (c-forward-to-cpp-define-body)
472: (let ((indent-boi (c-point 'boi indent-point)))
473: (setq in-macro-expr (> (point) indent-boi)
474: tmpsymbol 'cpp-define-intro)
475: (= (point) indent-boi))
476: (setq in-macro-expr t)
477: nil)))))
478: (c-add-syntax tmpsymbol macro-start)
479: (setq macro-start nil))
480:
481: ;; CASE 11: an else clause?
482: ((looking-at "else\\>[^_]")
483: (c-beginning-of-statement-1 containing-sexp)
484: (c-add-stmt-syntax 'else-clause nil t
485: containing-sexp paren-state))
486:
487: ;; CASE 12: while closure of a do/while construct?
488: ((and (looking-at "while\\>[^_]")
489: (save-excursion
490: (prog1 (eq (c-beginning-of-statement-1 containing-sexp)
491: 'beginning)
492: (setq placeholder (point)))))
493: (goto-char placeholder)
494: (c-add-stmt-syntax 'do-while-closure nil t
495: containing-sexp paren-state))
496:
497: ;; CASE 13: A catch or finally clause? This case is simpler
498: ;; than if-else and do-while, because a block is required
499: ;; after every try, catch and finally.
500: ((save-excursion
501: (and (cond ((c-major-mode-is 'c++-mode)
502: (looking-at "catch\\>[^_]"))
503: ((c-major-mode-is 'java-mode)
504: (looking-at "\\(catch\\|finally\\)\\>[^_]")))
505: (and (c-safe (c-backward-syntactic-ws)
506: (c-backward-sexp)
507: t)
508: (eq (char-after) ?{)
509: (c-safe (c-backward-syntactic-ws)
510: (c-backward-sexp)
511: t)
512: (if (eq (char-after) ?\()
513: (c-safe (c-backward-sexp) t)
514: t))
515: (looking-at "\\(try\\|catch\\)\\>[^_]")
516: (setq placeholder (point))))
517: (goto-char placeholder)
518: (c-add-stmt-syntax 'catch-clause nil t
519: containing-sexp paren-state))
520:
521: ;; CASE 18: A substatement we can recognize by keyword.
522: ((save-excursion
523: (and c-opt-block-stmt-key
524: (not (eq char-before-ip ?\;))
525: (not (c-at-vsemi-p before-ws-ip))
526: (not (memq char-after-ip '(?\) ?\] ?,)))
527: (or (not (eq char-before-ip ?}))
528: (c-looking-at-inexpr-block-backward c-state-cache))
529: (> (point)
530: (progn
531: ;; Ought to cache the result from the
532: ;; c-beginning-of-statement-1 calls here.
533: (setq placeholder (point))
534: (while (eq (setq step-type
535: (c-beginning-of-statement-1 lim))
536: 'label))
537: (if (eq step-type 'previous)
538: (goto-char placeholder)
539: (setq placeholder (point))
540: (if (and (eq step-type 'same)
541: (not (looking-at c-opt-block-stmt-key)))
542: ;; Step up to the containing statement if we
543: ;; stayed in the same one.
544: (let (step)
545: (while (eq
546: (setq step
547: (c-beginning-of-statement-1 lim))
548: 'label))
549: (if (eq step 'up)
550: (setq placeholder (point))
551: ;; There was no containing statement after all.
552: (goto-char placeholder)))))
553: placeholder))
554: (if (looking-at c-block-stmt-2-key)
555: ;; Require a parenthesis after these keywords.
556: ;; Necessary to catch e.g. synchronized in Java,
557: ;; which can be used both as statement and
558: ;; modifier.
559: (and (zerop (c-forward-token-2 1 nil))
560: (eq (char-after) ?\())
561: (looking-at c-opt-block-stmt-key))))
562:
563: (if (eq step-type 'up)
564: ;; CASE 18A: Simple substatement.
565: (progn
566: (goto-char placeholder)
567: (cond
568: ((eq char-after-ip ?{)
569: (c-add-stmt-syntax 'substatement-open nil nil
570: containing-sexp paren-state))
571: ((save-excursion
572: (goto-char indent-point)
573: (back-to-indentation)
574: (c-forward-label))
575: (c-add-stmt-syntax 'substatement-label nil nil
576: containing-sexp paren-state))
577: (t
578: (c-add-stmt-syntax 'substatement nil nil
579: containing-sexp paren-state))))
580:
581: ;; CASE 18B: Some other substatement. This is shared
582: ;; with case 10.
583: (c-guess-continued-construct indent-point
584: char-after-ip
585: placeholder
586: lim
587: paren-state)))
588:
589: ;; CASE 14: A case or default label
590: ((looking-at c-label-kwds-regexp)
591: (if containing-sexp
592: (progn
593: (goto-char containing-sexp)
594: (setq lim (c-most-enclosing-brace c-state-cache
595: containing-sexp))
596: (c-backward-to-block-anchor lim)
597: (c-add-stmt-syntax 'case-label nil t lim paren-state))
598: ;; Got a bogus label at the top level. In lack of better
599: ;; alternatives, anchor it on (point-min).
600: (c-add-syntax 'case-label (point-min))))
601:
602: ;; CASE 15: any other label
603: ((save-excursion
604: (back-to-indentation)
605: (and (not (looking-at c-syntactic-ws-start))
606: (c-forward-label)))
607: (cond (containing-decl-open
608: (setq placeholder (c-add-class-syntax 'inclass
609: containing-decl-open
610: containing-decl-start
611: containing-decl-kwd
612: paren-state))
613: ;; Append access-label with the same anchor point as
614: ;; inclass gets.
615: (c-append-syntax 'access-label placeholder))
616:
617: (containing-sexp
618: (goto-char containing-sexp)
619: (setq lim (c-most-enclosing-brace c-state-cache
620: containing-sexp))
621: (save-excursion
622: (setq tmpsymbol
623: (if (and (eq (c-beginning-of-statement-1 lim) 'up)
624: (looking-at "switch\\>[^_]"))
625: ;; If the surrounding statement is a switch then
626: ;; let's analyze all labels as switch labels, so
627: ;; that they get lined up consistently.
628: 'case-label
629: 'label)))
630: (c-backward-to-block-anchor lim)
631: (c-add-stmt-syntax tmpsymbol nil t lim paren-state))
632:
633: (t
634: ;; A label on the top level. Treat it as a class
635: ;; context. (point-min) is the closest we get to the
636: ;; class open brace.
637: (c-add-syntax 'access-label (point-min)))))
638:
639: ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and
640: ;; 17E.
641: ((setq placeholder (c-looking-at-inexpr-block
642: (c-safe-position containing-sexp paren-state)
643: containing-sexp
644: ;; Have to turn on the heuristics after
645: ;; the point even though it doesn't work
646: ;; very well. C.f. test case class-16.pike.
647: t))
648: (setq tmpsymbol (assq (car placeholder)
649: '((inexpr-class . class-open)
650: (inexpr-statement . block-open))))
651: (if tmpsymbol
652: ;; It's a statement block or an anonymous class.
653: (setq tmpsymbol (cdr tmpsymbol))
654: ;; It's a Pike lambda. Check whether we are between the
655: ;; lambda keyword and the argument list or at the defun
656: ;; opener.
657: (setq tmpsymbol (if (eq char-after-ip ?{)
658: 'inline-open
659: 'lambda-intro-cont)))
660: (goto-char (cdr placeholder))
661: (back-to-indentation)
662: (c-add-stmt-syntax tmpsymbol nil t
663: (c-most-enclosing-brace c-state-cache (point))
664: paren-state)
665: (unless (eq (point) (cdr placeholder))
666: (c-add-syntax (car placeholder))))
667:
668: ;; CASE 5: Line is inside a declaration level block or at top level.
669: ((or containing-decl-open (null containing-sexp))
670: (cond
671:
672: ;; CASE 5A: we are looking at a defun, brace list, class,
673: ;; or inline-inclass method opening brace
674: ((setq special-brace-list
675: (or (and c-special-brace-lists
676: (c-looking-at-special-brace-list))
677: (eq char-after-ip ?{)))
678: (cond
679:
680: ;; CASE 5A.1: Non-class declaration block open.
681: ((save-excursion
682: (let (tmp)
683: (and (eq char-after-ip ?{)
684: (setq tmp (c-looking-at-decl-block containing-sexp t))
685: (progn
686: (setq placeholder (point))
687: (goto-char tmp)
688: (looking-at c-symbol-key))
689: (c-keyword-member
690: (c-keyword-sym (setq keyword (match-string 0)))
691: 'c-other-block-decl-kwds))))
692: (goto-char placeholder)
693: (c-add-stmt-syntax
694: (if (string-equal keyword "extern")
695: ;; Special case for extern-lang-open.
696: 'extern-lang-open
697: (intern (concat keyword "-open")))
698: nil t containing-sexp paren-state))
699:
700: ;; CASE 5A.2: we are looking at a class opening brace
701: ((save-excursion
702: (goto-char indent-point)
703: (skip-chars-forward " \t")
704: (and (eq (char-after) ?{)
705: (c-looking-at-decl-block containing-sexp t)
706: (setq placeholder (point))))
707: (c-add-syntax 'class-open placeholder))
708:
709: ;; CASE 5A.3: brace list open
710: ((save-excursion
711: (c-beginning-of-decl-1 lim)
712: (while (looking-at c-specifier-key)
713: (goto-char (match-end 1))
714: (c-forward-syntactic-ws indent-point))
715: (setq placeholder (c-point 'boi))
716: (or (consp special-brace-list)
717: (and (or (save-excursion
718: (goto-char indent-point)
719: (setq tmpsymbol nil)
720: (while (and (> (point) placeholder)
721: (zerop (c-backward-token-2 1 t))
722: (/= (char-after) ?=))
723: (and c-opt-inexpr-brace-list-key
724: (not tmpsymbol)
725: (looking-at c-opt-inexpr-brace-list-key)
726: (setq tmpsymbol 'topmost-intro-cont)))
727: (eq (char-after) ?=))
728: (looking-at c-brace-list-key))
729: (save-excursion
730: (while (and (< (point) indent-point)
731: (zerop (c-forward-token-2 1 t))
732: (not (memq (char-after) '(?\; ?\()))))
733: (not (memq (char-after) '(?\; ?\()))
734: ))))
735: (if (and (not c-auto-newline-analysis)
736: (c-major-mode-is 'java-mode)
737: (eq tmpsymbol 'topmost-intro-cont))
738: ;; We're in Java and have found that the open brace
739: ;; belongs to a "new Foo[]" initialization list,
740: ;; which means the brace list is part of an
741: ;; expression and not a top level definition. We
742: ;; therefore treat it as any topmost continuation
743: ;; even though the semantically correct symbol still
744: ;; is brace-list-open, on the same grounds as in
745: ;; case B.2.
746: (progn
747: (c-beginning-of-statement-1 lim)
748: (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
749: (c-add-syntax 'brace-list-open placeholder)))
750:
751: ;; CASE 5A.4: inline defun open
752: ((and containing-decl-open
753: (not (c-keyword-member containing-decl-kwd
754: 'c-other-block-decl-kwds)))
755: (c-add-syntax 'inline-open)
756: (c-add-class-syntax 'inclass
757: containing-decl-open
758: containing-decl-start
759: containing-decl-kwd
760: paren-state))
761:
762: ;; CASE 5A.5: ordinary defun open
763: (t
764: (save-excursion
765: (c-beginning-of-decl-1 lim)
766: (while (looking-at c-specifier-key)
767: (goto-char (match-end 1))
768: (c-forward-syntactic-ws indent-point))
769: (c-add-syntax 'defun-open (c-point 'boi))
770: ;; Bogus to use bol here, but it's the legacy. (Resolved,
771: ;; 2007-11-09)
772: ))))
773:
774: ;; CASE 5B: After a function header but before the body (or
775: ;; the ending semicolon if there's no body).
776: ((save-excursion
777: (when (setq placeholder (c-just-after-func-arglist-p lim))
778: (setq tmp-pos (point))))
779: (cond
780:
781: ;; CASE 5B.1: Member init list.
782: ((eq (char-after tmp-pos) ?:)
783: (if (or (> tmp-pos indent-point)
784: (= (c-point 'bosws) (1+ tmp-pos)))
785: (progn
786: ;; There is no preceding member init clause.
787: ;; Indent relative to the beginning of indentation
788: ;; for the topmost-intro line that contains the
789: ;; prototype's open paren.
790: (goto-char placeholder)
791: (c-add-syntax 'member-init-intro (c-point 'boi)))
792: ;; Indent relative to the first member init clause.
793: (goto-char (1+ tmp-pos))
794: (c-forward-syntactic-ws)
795: (c-add-syntax 'member-init-cont (point))))
796:
797: ;; CASE 5B.2: K&R arg decl intro
798: ((and c-recognize-knr-p
799: (c-in-knr-argdecl lim))
800: (c-beginning-of-statement-1 lim)
801: (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
802: (if containing-decl-open
803: (c-add-class-syntax 'inclass
804: containing-decl-open
805: containing-decl-start
806: containing-decl-kwd
807: paren-state)))
808:
809: ;; CASE 5B.4: Nether region after a C++ or Java func
810: ;; decl, which could include a `throws' declaration.
811: (t
812: (c-beginning-of-statement-1 lim)
813: (c-add-syntax 'func-decl-cont (c-point 'boi))
814: )))
815:
816: ;; CASE 5C: inheritance line. could be first inheritance
817: ;; line, or continuation of a multiple inheritance
818: ((or (and (c-major-mode-is 'c++-mode)
819: (progn
820: (when (eq char-after-ip ?,)
821: (skip-chars-forward " \t")
822: (forward-char))
823: (looking-at c-opt-postfix-decl-spec-key)))
824: (and (or (eq char-before-ip ?:)
825: ;; watch out for scope operator
826: (save-excursion
827: (and (eq char-after-ip ?:)
828: (c-safe (forward-char 1) t)
829: (not (eq (char-after) ?:))
830: )))
831: (save-excursion
832: (c-backward-syntactic-ws lim)
833: (if (eq char-before-ip ?:)
834: (progn
835: (forward-char -1)
836: (c-backward-syntactic-ws lim)))
837: (back-to-indentation)
838: (looking-at c-class-key)))
839: ;; for Java
840: (and (c-major-mode-is 'java-mode)
841: (let ((fence (save-excursion
842: (c-beginning-of-statement-1 lim)
843: (point)))
844: cont done)
845: (save-excursion
846: (while (not done)
847: (cond ((looking-at c-opt-postfix-decl-spec-key)
848: (setq injava-inher (cons cont (point))
849: done t))
850: ((or (not (c-safe (c-forward-sexp -1) t))
851: (<= (point) fence))
852: (setq done t))
853: )
854: (setq cont t)))
855: injava-inher)
856: (not (c-crosses-statement-barrier-p (cdr injava-inher)
857: (point)))
858: ))
859: (cond
860:
861: ;; CASE 5C.1: non-hanging colon on an inher intro
862: ((eq char-after-ip ?:)
863: (c-beginning-of-statement-1 lim)
864: (c-add-syntax 'inher-intro (c-point 'boi))
865: ;; don't add inclass symbol since relative point already
866: ;; contains any class offset
867: )
868:
869: ;; CASE 5C.2: hanging colon on an inher intro
870: ((eq char-before-ip ?:)
871: (c-beginning-of-statement-1 lim)
872: (c-add-syntax 'inher-intro (c-point 'boi))
873: (if containing-decl-open
874: (c-add-class-syntax 'inclass
875: containing-decl-open
876: containing-decl-start
877: containing-decl-kwd
878: paren-state)))
879:
880: ;; CASE 5C.3: in a Java implements/extends
881: (injava-inher
882: (let ((where (cdr injava-inher))
883: (cont (car injava-inher)))
884: (goto-char where)
885: (cond ((looking-at "throws\\>[^_]")
886: (c-add-syntax 'func-decl-cont
887: (progn (c-beginning-of-statement-1 lim)
888: (c-point 'boi))))
889: (cont (c-add-syntax 'inher-cont where))
890: (t (c-add-syntax 'inher-intro
891: (progn (goto-char (cdr injava-inher))
892: (c-beginning-of-statement-1 lim)
893: (point))))
894: )))
895:
896: ;; CASE 5C.4: a continued inheritance line
897: (t
898: (c-beginning-of-inheritance-list lim)
899: (c-add-syntax 'inher-cont (point))
900: ;; don't add inclass symbol since relative point already
901: ;; contains any class offset
902: )))
903:
904: ;; CASE 5D: this could be a top-level initialization, a
905: ;; member init list continuation, or a template argument
906: ;; list continuation.
907: ((save-excursion
908: ;; Note: We use the fact that lim is always after any
909: ;; preceding brace sexp.
910: (if c-recognize-<>-arglists
911: (while (and
912: (progn
913: (c-syntactic-skip-backward "^;$,=<>" lim t)
914: (> (point) lim))
915: (or
916: (when c-overloadable-operators-regexp
917: (when (setq placeholder (c-after-special-operator-id lim))
918: (goto-char placeholder)
919: t))
920: (cond
921: ((eq (char-before) ?>)
922: (or (c-backward-<>-arglist nil lim)
923: (backward-char))
924: t)
925: ((eq (char-before) ?<)
926: (backward-char)
927: (if (save-excursion
928: (c-forward-<>-arglist nil))
929: (progn (forward-char)
930: nil)
931: t))
932: (t nil)))))
933: ;; NB: No c-after-special-operator-id stuff in this
934: ;; clause - we assume only C++ needs it.
935: (c-syntactic-skip-backward "^;$,=" lim t))
936: (memq (char-before) '(?, ?= ?<)))
937: (cond
938:
939: ;; CASE 5D.3: perhaps a template list continuation?
940: ((and (c-major-mode-is 'c++-mode)
941: (save-excursion
942: (save-restriction
943: (c-with-syntax-table c++-template-syntax-table
944: (goto-char indent-point)
945: (setq placeholder (c-up-list-backward))
946: (and placeholder
947: (eq (char-after placeholder) ?<))))))
948: (c-with-syntax-table c++-template-syntax-table
949: (goto-char placeholder)
950: (c-beginning-of-statement-1 lim t)
951: (if (save-excursion
952: (c-backward-syntactic-ws lim)
953: (eq (char-before) ?<))
954: ;; In a nested template arglist.
955: (progn
956: (goto-char placeholder)
957: (c-syntactic-skip-backward "^,;" lim t)
958: (c-forward-syntactic-ws))
959: (back-to-indentation)))
960: ;; FIXME: Should use c-add-stmt-syntax, but it's not yet
961: ;; template aware.
962: (c-add-syntax 'template-args-cont (point) placeholder))
963:
964: ;; CASE 5D.4: perhaps a multiple inheritance line?
965: ((and (c-major-mode-is 'c++-mode)
966: (save-excursion
967: (c-beginning-of-statement-1 lim)
968: (setq placeholder (point))
969: (if (looking-at "static\\>[^_]")
970: (c-forward-token-2 1 nil indent-point))
971: (and (looking-at c-class-key)
972: (zerop (c-forward-token-2 2 nil indent-point))
973: (if (eq (char-after) ?<)
974: (c-with-syntax-table c++-template-syntax-table
975: (zerop (c-forward-token-2 1 t indent-point)))
976: t)
977: (eq (char-after) ?:))))
978: (goto-char placeholder)
979: (c-add-syntax 'inher-cont (c-point 'boi)))
980:
981: ;; CASE 5D.5: Continuation of the "expression part" of a
982: ;; top level construct. Or, perhaps, an unrecognized construct.
983: (t
984: (while (and (setq placeholder (point))
985: (eq (car (c-beginning-of-decl-1 containing-sexp))
986: 'same)
987: (save-excursion
988: (c-backward-syntactic-ws)
989: (eq (char-before) ?}))
990: (< (point) placeholder)))
991: (c-add-stmt-syntax
992: (cond
993: ((eq (point) placeholder) 'statement) ; unrecognized construct
994: ;; A preceding comma at the top level means that a
995: ;; new variable declaration starts here. Use
996: ;; topmost-intro-cont for it, for consistency with
997: ;; the first variable declaration. C.f. case 5N.
998: ((eq char-before-ip ?,) 'topmost-intro-cont)
999: (t 'statement-cont))
1000: nil nil containing-sexp paren-state))
1001: ))
1002:
1003: ;; CASE 5F: Close of a non-class declaration level block.
1004: ((and (eq char-after-ip ?})
1005: (c-keyword-member containing-decl-kwd
1006: 'c-other-block-decl-kwds))
1007: ;; This is inconsistent: Should use `containing-decl-open'
1008: ;; here if it's at boi, like in case 5J.
1009: (goto-char containing-decl-start)
1010: (c-add-stmt-syntax
1011: (if (string-equal (symbol-name containing-decl-kwd) "extern")
1012: ;; Special case for compatibility with the
1013: ;; extern-lang syntactic symbols.
1014: 'extern-lang-close
1015: (intern (concat (symbol-name containing-decl-kwd)
1016: "-close")))
1017: nil t
1018: (c-most-enclosing-brace paren-state (point))
1019: paren-state))
1020:
1021: ;; CASE 5G: we are looking at the brace which closes the
1022: ;; enclosing nested class decl
1023: ((and containing-sexp
1024: (eq char-after-ip ?})
1025: (eq containing-decl-open containing-sexp))
1026: (c-add-class-syntax 'class-close
1027: containing-decl-open
1028: containing-decl-start
1029: containing-decl-kwd
1030: paren-state))
1031:
1032: ;; CASE 5H: we could be looking at subsequent knr-argdecls
1033: ((and c-recognize-knr-p
1034: (not containing-sexp) ; can't be knr inside braces.
1035: (not (eq char-before-ip ?}))
1036: (save-excursion
1037: (setq placeholder (cdr (c-beginning-of-decl-1 lim)))
1038: (and placeholder
1039: ;; Do an extra check to avoid tripping up on
1040: ;; statements that occur in invalid contexts
1041: ;; (e.g. in macro bodies where we don't really
1042: ;; know the context of what we're looking at).
1043: (not (and c-opt-block-stmt-key
1044: (looking-at c-opt-block-stmt-key)))))
1045: (< placeholder indent-point))
1046: (goto-char placeholder)
1047: (c-add-syntax 'knr-argdecl (point)))
1048:
1049: ;; CASE 5I: ObjC method definition.
1050: ((and c-opt-method-key
1051: (looking-at c-opt-method-key))
1052: (c-beginning-of-statement-1 nil t)
1053: (if (= (point) indent-point)
1054: ;; Handle the case when it's the first (non-comment)
1055: ;; thing in the buffer. Can't look for a 'same return
1056: ;; value from cbos1 since ObjC directives currently
1057: ;; aren't recognized fully, so that we get 'same
1058: ;; instead of 'previous if it moved over a preceding
1059: ;; directive.
1060: (goto-char (point-min)))
1061: (c-add-syntax 'objc-method-intro (c-point 'boi)))
1062:
1063: ;; CASE 5P: AWK pattern or function or continuation
1064: ;; thereof.
1065: ((c-major-mode-is 'awk-mode)
1066: (setq placeholder (point))
1067: (c-add-stmt-syntax
1068: (if (and (eq (c-beginning-of-statement-1) 'same)
1069: (/= (point) placeholder))
1070: 'topmost-intro-cont
1071: 'topmost-intro)
1072: nil nil
1073: containing-sexp paren-state))
1074:
1075: ;; CASE 5N: At a variable declaration that follows a class
1076: ;; definition or some other block declaration that doesn't
1077: ;; end at the closing '}'. C.f. case 5D.5.
1078: ((progn
1079: (c-backward-syntactic-ws lim)
1080: (and (eq (char-before) ?})
1081: (save-excursion
1082: (let ((start (point)))
1083: (if (and c-state-cache
1084: (consp (car c-state-cache))
1085: (eq (cdar c-state-cache) (point)))
1086: ;; Speed up the backward search a bit.
1087: (goto-char (caar c-state-cache)))
1088: (c-beginning-of-decl-1 containing-sexp)
1089: (setq placeholder (point))
1090: (if (= start (point))
1091: ;; The '}' is unbalanced.
1092: nil
1093: (c-end-of-decl-1)
1094: (>= (point) indent-point))))))
1095: (goto-char placeholder)
1096: (c-add-stmt-syntax 'topmost-intro-cont nil nil
1097: containing-sexp paren-state))
1098:
1099: ;; NOTE: The point is at the end of the previous token here.
1100:
1101: ;; CASE 5J: we are at the topmost level, make
1102: ;; sure we skip back past any access specifiers
1103: ((and
1104: ;; A macro continuation line is never at top level.
1105: (not (and macro-start
1106: (> indent-point macro-start)))
1107: (save-excursion
1108: (setq placeholder (point))
1109: (or (memq char-before-ip '(?\; ?$ ?{ ?} nil))
1110: (c-at-vsemi-p before-ws-ip)
1111: (when (and (eq char-before-ip ?:)
1112: (eq (c-beginning-of-statement-1 lim)
1113: 'label))
1114: (c-backward-syntactic-ws lim)
1115: (setq placeholder (point)))
1116: (and (c-major-mode-is 'objc-mode)
1117: (catch 'not-in-directive
1118: (c-beginning-of-statement-1 lim)
1119: (setq placeholder (point))
1120: (while (and (c-forward-objc-directive)
1121: (< (point) indent-point))
1122: (c-forward-syntactic-ws)
1123: (if (>= (point) indent-point)
1124: (throw 'not-in-directive t))
1125: (setq placeholder (point)))
1126: nil)))))
1127: ;; For historic reasons we anchor at bol of the last
1128: ;; line of the previous declaration. That's clearly
1129: ;; highly bogus and useless, and it makes our lives hard
1130: ;; to remain compatible. :P
1131: (goto-char placeholder)
1132: (c-add-syntax 'topmost-intro (c-point 'bol))
1133: (if containing-decl-open
1134: (if (c-keyword-member containing-decl-kwd
1135: 'c-other-block-decl-kwds)
1136: (progn
1137: (goto-char (c-brace-anchor-point containing-decl-open))
1138: (c-add-stmt-syntax
1139: (if (string-equal (symbol-name containing-decl-kwd)
1140: "extern")
1141: ;; Special case for compatibility with the
1142: ;; extern-lang syntactic symbols.
1143: 'inextern-lang
1144: (intern (concat "in"
1145: (symbol-name containing-decl-kwd))))
1146: nil t
1147: (c-most-enclosing-brace paren-state (point))
1148: paren-state))
1149: (c-add-class-syntax 'inclass
1150: containing-decl-open
1151: containing-decl-start
1152: containing-decl-kwd
1153: paren-state)))
1154: (when (and c-syntactic-indentation-in-macros
1155: macro-start
1156: (/= macro-start (c-point 'boi indent-point)))
1157: (c-add-syntax 'cpp-define-intro)
1158: (setq macro-start nil)))
1159:
1160: ;; CASE 5K: we are at an ObjC method definition
1161: ;; continuation line.
1162: ((and c-opt-method-key
1163: (save-excursion
1164: (c-beginning-of-statement-1 lim)
1165: (beginning-of-line)
1166: (when (looking-at c-opt-method-key)
1167: (setq placeholder (point)))))
1168: (c-add-syntax 'objc-method-args-cont placeholder))
1169:
1170: ;; CASE 5L: we are at the first argument of a template
1171: ;; arglist that begins on the previous line.
1172: ((and c-recognize-<>-arglists
1173: (eq (char-before) ?<)
1174: (setq placeholder (1- (point)))
1175: (not (and c-overloadable-operators-regexp
1176: (c-after-special-operator-id lim))))
1177: (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
1178: (c-add-syntax 'template-args-cont (c-point 'boi) placeholder))
1179:
1180: ;; CASE 5Q: we are at a statement within a macro.
1181: (macro-start
1182: (c-beginning-of-statement-1 containing-sexp)
1183: (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
1184:
1185: ;; CASE 5M: we are at a topmost continuation line
1186: (t
1187: (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
1188: (when (c-major-mode-is 'objc-mode)
1189: (setq placeholder (point))
1190: (while (and (c-forward-objc-directive)
1191: (< (point) indent-point))
1192: (c-forward-syntactic-ws)
1193: (setq placeholder (point)))
1194: (goto-char placeholder))
1195: (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
1196: ))
1197:
1198: ;; (CASE 6 has been removed.)
1199:
1200: ;; CASE 19: line is an expression, not a statement, and is directly
1201: ;; contained by a template delimiter. Most likely, we are in a
1202: ;; template arglist within a statement. This case is based on CASE
1203: ;; 7. At some point in the future, we may wish to create more
1204: ;; syntactic symbols such as `template-intro',
1205: ;; `template-cont-nonempty', etc., and distinguish between them as we
1206: ;; do for `arglist-intro' etc. (2009-12-07).
1207: ((and c-recognize-<>-arglists
1208: (setq containing-< (c-up-list-backward indent-point containing-sexp))
1209: (eq (char-after containing-<) ?\<))
1210: (setq placeholder (c-point 'boi containing-<))
1211: (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not
1212: ; '<') before indent-point.
1213: (if (>= (point) placeholder)
1214: (progn
1215: (forward-char)
1216: (skip-chars-forward " \t"))
1217: (goto-char placeholder))
1218: (c-add-stmt-syntax 'template-args-cont (list containing-<) t
1219: (c-most-enclosing-brace c-state-cache (point))
1220: paren-state))
1221:
1222:
1223: ;; CASE 7: line is an expression, not a statement. Most
1224: ;; likely we are either in a function prototype or a function
1225: ;; call argument list, or a template argument list.
1226: ((not (or (and c-special-brace-lists
1227: (save-excursion
1228: (goto-char containing-sexp)
1229: (c-looking-at-special-brace-list)))
1230: (eq (char-after containing-sexp) ?{)
1231: (eq (char-after containing-sexp) ?<)))
1232: (cond
1233:
1234: ;; CASE 7A: we are looking at the arglist closing paren.
1235: ;; C.f. case 7F.
1236: ((memq char-after-ip '(?\) ?\]))
1237: (goto-char containing-sexp)
1238: (setq placeholder (c-point 'boi))
1239: (if (and (c-safe (backward-up-list 1) t)
1240: (>= (point) placeholder))
1241: (progn
1242: (forward-char)
1243: (skip-chars-forward " \t"))
1244: (goto-char placeholder))
1245: (c-add-stmt-syntax 'arglist-close (list containing-sexp) t
1246: (c-most-enclosing-brace paren-state (point))
1247: paren-state))
1248:
1249: ;; CASE 7B: Looking at the opening brace of an
1250: ;; in-expression block or brace list. C.f. cases 4, 16A
1251: ;; and 17E.
1252: ((and (eq char-after-ip ?{)
1253: (progn
1254: (setq placeholder (c-inside-bracelist-p (point)
1255: paren-state))
1256: (if placeholder
1257: (setq tmpsymbol '(brace-list-open . inexpr-class))
1258: (setq tmpsymbol '(block-open . inexpr-statement)
1259: placeholder
1260: (cdr-safe (c-looking-at-inexpr-block
1261: (c-safe-position containing-sexp
1262: paren-state)
1263: containing-sexp)))
1264: ;; placeholder is nil if it's a block directly in
1265: ;; a function arglist. That makes us skip out of
1266: ;; this case.
1267: )))
1268: (goto-char placeholder)
1269: (back-to-indentation)
1270: (c-add-stmt-syntax (car tmpsymbol) nil t
1271: (c-most-enclosing-brace paren-state (point))
1272: paren-state)
1273: (if (/= (point) placeholder)
1274: (c-add-syntax (cdr tmpsymbol))))
1275:
1276: ;; CASE 7C: we are looking at the first argument in an empty
1277: ;; argument list. Use arglist-close if we're actually
1278: ;; looking at a close paren or bracket.
1279: ((memq char-before-ip '(?\( ?\[))
1280: (goto-char containing-sexp)
1281: (setq placeholder (c-point 'boi))
1282: (if (and (c-safe (backward-up-list 1) t)
1283: (>= (point) placeholder))
1284: (progn
1285: (forward-char)
1286: (skip-chars-forward " \t"))
1287: (goto-char placeholder))
1288: (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t
1289: (c-most-enclosing-brace paren-state (point))
1290: paren-state))
1291:
1292: ;; CASE 7D: we are inside a conditional test clause. treat
1293: ;; these things as statements
1294: ((progn
1295: (goto-char containing-sexp)
1296: (and (c-safe (c-forward-sexp -1) t)
1297: (looking-at "\\<for\\>[^_]")))
1298: (goto-char (1+ containing-sexp))
1299: (c-forward-syntactic-ws indent-point)
1300: (if (eq char-before-ip ?\;)
1301: (c-add-syntax 'statement (point))
1302: (c-add-syntax 'statement-cont (point))
1303: ))
1304:
1305: ;; CASE 7E: maybe a continued ObjC method call. This is the
1306: ;; case when we are inside a [] bracketed exp, and what
1307: ;; precede the opening bracket is not an identifier.
1308: ((and c-opt-method-key
1309: (eq (char-after containing-sexp) ?\[)
1310: (progn
1311: (goto-char (1- containing-sexp))
1312: (c-backward-syntactic-ws (c-point 'bod))
1313: (if (not (looking-at c-symbol-key))
1314: (c-add-syntax 'objc-method-call-cont containing-sexp))
1315: )))
1316:
1317: ;; CASE 7F: we are looking at an arglist continuation line,
1318: ;; but the preceding argument is on the same line as the
1319: ;; opening paren. This case includes multi-line
1320: ;; mathematical paren groupings, but we could be on a
1321: ;; for-list continuation line. C.f. case 7A.
1322: ((progn
1323: (goto-char (1+ containing-sexp))
1324: (< (save-excursion
1325: (c-forward-syntactic-ws)
1326: (point))
1327: (c-point 'bonl)))
1328: (goto-char containing-sexp) ; paren opening the arglist
1329: (setq placeholder (c-point 'boi))
1330: (if (and (c-safe (backward-up-list 1) t)
1331: (>= (point) placeholder))
1332: (progn
1333: (forward-char)
1334: (skip-chars-forward " \t"))
1335: (goto-char placeholder))
1336: (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t
1337: (c-most-enclosing-brace c-state-cache (point))
1338: paren-state))
1339:
1340: ;; CASE 7G: we are looking at just a normal arglist
1341: ;; continuation line
1342: (t (c-forward-syntactic-ws indent-point)
1343: (c-add-syntax 'arglist-cont (c-point 'boi)))
1344: ))
1345:
1346: ;; CASE 8: func-local multi-inheritance line
1347: ((and (c-major-mode-is 'c++-mode)
1348: (save-excursion
1349: (goto-char indent-point)
1350: (skip-chars-forward " \t")
1351: (looking-at c-opt-postfix-decl-spec-key)))
1352: (goto-char indent-point)
1353: (skip-chars-forward " \t")
1354: (cond
1355:
1356: ;; CASE 8A: non-hanging colon on an inher intro
1357: ((eq char-after-ip ?:)
1358: (c-backward-syntactic-ws lim)
1359: (c-add-syntax 'inher-intro (c-point 'boi)))
1360:
1361: ;; CASE 8B: hanging colon on an inher intro
1362: ((eq char-before-ip ?:)
1363: (c-add-syntax 'inher-intro (c-point 'boi)))
1364:
1365: ;; CASE 8C: a continued inheritance line
1366: (t
1367: (c-beginning-of-inheritance-list lim)
1368: (c-add-syntax 'inher-cont (point))
1369: )))
1370:
1371: ;; CASE 9: we are inside a brace-list
1372: ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29)
1373: (setq special-brace-list
1374: (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!!
1375: (save-excursion
1376: (goto-char containing-sexp)
1377: (c-looking-at-special-brace-list)))
1378: (c-inside-bracelist-p containing-sexp paren-state))))
1379: (cond
1380:
1381: ;; CASE 9A: In the middle of a special brace list opener.
1382: ((and (consp special-brace-list)
1383: (save-excursion
1384: (goto-char containing-sexp)
1385: (eq (char-after) ?\())
1386: (eq char-after-ip (car (cdr special-brace-list))))
1387: (goto-char (car (car special-brace-list)))
1388: (skip-chars-backward " \t")
1389: (if (and (bolp)
1390: (assoc 'statement-cont
1391: (setq placeholder (c-guess-basic-syntax))))
1392: (setq c-syntactic-context placeholder)
1393: (c-beginning-of-statement-1
1394: (c-safe-position (1- containing-sexp) paren-state))
1395: (c-forward-token-2 0)
1396: (while (looking-at c-specifier-key)
1397: (goto-char (match-end 1))
1398: (c-forward-syntactic-ws))
1399: (c-add-syntax 'brace-list-open (c-point 'boi))))
1400:
1401: ;; CASE 9B: brace-list-close brace
1402: ((if (consp special-brace-list)
1403: ;; Check special brace list closer.
1404: (progn
1405: (goto-char (car (car special-brace-list)))
1406: (save-excursion
1407: (goto-char indent-point)
1408: (back-to-indentation)
1409: (or
1410: ;; We were between the special close char and the `)'.
1411: (and (eq (char-after) ?\))
1412: (eq (1+ (point)) (cdr (car special-brace-list))))
1413: ;; We were before the special close char.
1414: (and (eq (char-after) (cdr (cdr special-brace-list)))
1415: (zerop (c-forward-token-2))
1416: (eq (1+ (point)) (cdr (car special-brace-list)))))))
1417: ;; Normal brace list check.
1418: (and (eq char-after-ip ?})
1419: (c-safe (goto-char (c-up-list-backward (point))) t)
1420: (= (point) containing-sexp)))
1421: (if (eq (point) (c-point 'boi))
1422: (c-add-syntax 'brace-list-close (point))
1423: (setq lim (c-most-enclosing-brace c-state-cache (point)))
1424: (c-beginning-of-statement-1 lim)
1425: (c-add-stmt-syntax 'brace-list-close nil t lim paren-state)))
1426:
1427: (t
1428: ;; Prepare for the rest of the cases below by going to the
1429: ;; token following the opening brace
1430: (if (consp special-brace-list)
1431: (progn
1432: (goto-char (car (car special-brace-list)))
1433: (c-forward-token-2 1 nil indent-point))
1434: (goto-char containing-sexp))
1435: (forward-char)
1436: (let ((start (point)))
1437: (c-forward-syntactic-ws indent-point)
1438: (goto-char (max start (c-point 'bol))))
1439: (c-skip-ws-forward indent-point)
1440: (cond
1441:
1442: ;; CASE 9C: we're looking at the first line in a brace-list
1443: ((= (point) indent-point)
1444: (if (consp special-brace-list)
1445: (goto-char (car (car special-brace-list)))
1446: (goto-char containing-sexp))
1447: (if (eq (point) (c-point 'boi))
1448: (c-add-syntax 'brace-list-intro (point))
1449: (setq lim (c-most-enclosing-brace c-state-cache (point)))
1450: (c-beginning-of-statement-1 lim)
1451: (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state)))
1452:
1453: ;; CASE 9D: this is just a later brace-list-entry or
1454: ;; brace-entry-open
1455: (t (if (or (eq char-after-ip ?{)
1456: (and c-special-brace-lists
1457: (save-excursion
1458: (goto-char indent-point)
1459: (c-forward-syntactic-ws (c-point 'eol))
1460: (c-looking-at-special-brace-list (point)))))
1461: (c-add-syntax 'brace-entry-open (point))
1462: (c-add-syntax 'brace-list-entry (point))
1463: ))
1464: ))))
1465:
1466: ;; CASE 10: A continued statement or top level construct.
1467: ((and (not (memq char-before-ip '(?\; ?:)))
1468: (not (c-at-vsemi-p before-ws-ip))
1469: (or (not (eq char-before-ip ?}))
1470: (c-looking-at-inexpr-block-backward c-state-cache))
1471: (> (point)
1472: (save-excursion
1473: (c-beginning-of-statement-1 containing-sexp)
1474: (setq placeholder (point))))
1475: (/= placeholder containing-sexp))
1476: ;; This is shared with case 18.
1477: (c-guess-continued-construct indent-point
1478: char-after-ip
1479: placeholder
1480: containing-sexp
1481: paren-state))
1482:
1483: ;; CASE 16: block close brace, possibly closing the defun or
1484: ;; the class
1485: ((eq char-after-ip ?})
1486: ;; From here on we have the next containing sexp in lim.
1487: (setq lim (c-most-enclosing-brace paren-state))
1488: (goto-char containing-sexp)
1489: (cond
1490:
1491: ;; CASE 16E: Closing a statement block? This catches
1492: ;; cases where it's preceded by a statement keyword,
1493: ;; which works even when used in an "invalid" context,
1494: ;; e.g. a macro argument.
1495: ((c-after-conditional)
1496: (c-backward-to-block-anchor lim)
1497: (c-add-stmt-syntax 'block-close nil t lim paren-state))
1498:
1499: ;; CASE 16A: closing a lambda defun or an in-expression
1500: ;; block? C.f. cases 4, 7B and 17E.
1501: ((setq placeholder (c-looking-at-inexpr-block
1502: (c-safe-position containing-sexp paren-state)
1503: nil))
1504: (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
1505: 'inline-close
1506: 'block-close))
1507: (goto-char containing-sexp)
1508: (back-to-indentation)
1509: (if (= containing-sexp (point))
1510: (c-add-syntax tmpsymbol (point))
1511: (goto-char (cdr placeholder))
1512: (back-to-indentation)
1513: (c-add-stmt-syntax tmpsymbol nil t
1514: (c-most-enclosing-brace paren-state (point))
1515: paren-state)
1516: (if (/= (point) (cdr placeholder))
1517: (c-add-syntax (car placeholder)))))
1518:
1519: ;; CASE 16B: does this close an inline or a function in
1520: ;; a non-class declaration level block?
1521: ((save-excursion
1522: (and lim
1523: (progn
1524: (goto-char lim)
1525: (c-looking-at-decl-block
1526: (c-most-enclosing-brace paren-state lim)
1527: nil))
1528: (setq placeholder (point))))
1529: (c-backward-to-decl-anchor lim)
1530: (back-to-indentation)
1531: (if (save-excursion
1532: (goto-char placeholder)
1533: (looking-at c-other-decl-block-key))
1534: (c-add-syntax 'defun-close (point))
1535: (c-add-syntax 'inline-close (point))))
1536:
1537: ;; CASE 16F: Can be a defun-close of a function declared
1538: ;; in a statement block, e.g. in Pike or when using gcc
1539: ;; extensions, but watch out for macros followed by
1540: ;; blocks. Let it through to be handled below.
1541: ;; C.f. cases B.3 and 17G.
1542: ((save-excursion
1543: (and (not (c-at-statement-start-p))
1544: (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
1545: (setq placeholder (point))
1546: (let ((c-recognize-typeless-decls nil))
1547: ;; Turn off recognition of constructs that
1548: ;; lacks a type in this case, since that's more
1549: ;; likely to be a macro followed by a block.
1550: (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
1551: (back-to-indentation)
1552: (if (/= (point) containing-sexp)
1553: (goto-char placeholder))
1554: (c-add-stmt-syntax 'defun-close nil t lim paren-state))
1555:
1556: ;; CASE 16C: If there is an enclosing brace then this is
1557: ;; a block close since defun closes inside declaration
1558: ;; level blocks have been handled above.
1559: (lim
1560: ;; If the block is preceded by a case/switch label on
1561: ;; the same line, we anchor at the first preceding label
1562: ;; at boi. The default handling in c-add-stmt-syntax
1563: ;; really fixes it better, but we do like this to keep
1564: ;; the indentation compatible with version 5.28 and
1565: ;; earlier. C.f. case 17H.
1566: (while (and (/= (setq placeholder (point)) (c-point 'boi))
1567: (eq (c-beginning-of-statement-1 lim) 'label)))
1568: (goto-char placeholder)
1569: (if (looking-at c-label-kwds-regexp)
1570: (c-add-syntax 'block-close (point))
1571: (goto-char containing-sexp)
1572: ;; c-backward-to-block-anchor not necessary here; those
1573: ;; situations are handled in case 16E above.
1574: (c-add-stmt-syntax 'block-close nil t lim paren-state)))
1575:
1576: ;; CASE 16D: Only top level defun close left.
1577: (t
1578: (goto-char containing-sexp)
1579: (c-backward-to-decl-anchor lim)
1580: (c-add-stmt-syntax 'defun-close nil nil
1581: (c-most-enclosing-brace paren-state)
1582: paren-state))
1583: ))
1584:
1585: ;; CASE 17: Statement or defun catchall.
1586: (t
1587: (goto-char indent-point)
1588: ;; Back up statements until we find one that starts at boi.
1589: (while (let* ((prev-point (point))
1590: (last-step-type (c-beginning-of-statement-1
1591: containing-sexp)))
1592: (if (= (point) prev-point)
1593: (progn
1594: (setq step-type (or step-type last-step-type))
1595: nil)
1596: (setq step-type last-step-type)
1597: (/= (point) (c-point 'boi)))))
1598: (cond
1599:
1600: ;; CASE 17B: continued statement
1601: ((and (eq step-type 'same)
1602: (/= (point) indent-point))
1603: (c-add-stmt-syntax 'statement-cont nil nil
1604: containing-sexp paren-state))
1605:
1606: ;; CASE 17A: After a case/default label?
1607: ((progn
1608: (while (and (eq step-type 'label)
1609: (not (looking-at c-label-kwds-regexp)))
1610: (setq step-type
1611: (c-beginning-of-statement-1 containing-sexp)))
1612: (eq step-type 'label))
1613: (c-add-stmt-syntax (if (eq char-after-ip ?{)
1614: 'statement-case-open
1615: 'statement-case-intro)
1616: nil t containing-sexp paren-state))
1617:
1618: ;; CASE 17D: any old statement
1619: ((progn
1620: (while (eq step-type 'label)
1621: (setq step-type
1622: (c-beginning-of-statement-1 containing-sexp)))
1623: (eq step-type 'previous))
1624: (c-add-stmt-syntax 'statement nil t
1625: containing-sexp paren-state)
1626: (if (eq char-after-ip ?{)
1627: (c-add-syntax 'block-open)))
1628:
1629: ;; CASE 17I: Inside a substatement block.
1630: ((progn
1631: ;; The following tests are all based on containing-sexp.
1632: (goto-char containing-sexp)
1633: ;; From here on we have the next containing sexp in lim.
1634: (setq lim (c-most-enclosing-brace paren-state containing-sexp))
1635: (c-after-conditional))
1636: (c-backward-to-block-anchor lim)
1637: (c-add-stmt-syntax 'statement-block-intro nil t
1638: lim paren-state)
1639: (if (eq char-after-ip ?{)
1640: (c-add-syntax 'block-open)))
1641:
1642: ;; CASE 17E: first statement in an in-expression block.
1643: ;; C.f. cases 4, 7B and 16A.
1644: ((setq placeholder (c-looking-at-inexpr-block
1645: (c-safe-position containing-sexp paren-state)
1646: nil))
1647: (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
1648: 'defun-block-intro
1649: 'statement-block-intro))
1650: (back-to-indentation)
1651: (if (= containing-sexp (point))
1652: (c-add-syntax tmpsymbol (point))
1653: (goto-char (cdr placeholder))
1654: (back-to-indentation)
1655: (c-add-stmt-syntax tmpsymbol nil t
1656: (c-most-enclosing-brace c-state-cache (point))
1657: paren-state)
1658: (if (/= (point) (cdr placeholder))
1659: (c-add-syntax (car placeholder))))
1660: (if (eq char-after-ip ?{)
1661: (c-add-syntax 'block-open)))
1662:
1663: ;; CASE 17F: first statement in an inline, or first
1664: ;; statement in a top-level defun. we can tell this is it
1665: ;; if there are no enclosing braces that haven't been
1666: ;; narrowed out by a class (i.e. don't use bod here).
1667: ((save-excursion
1668: (or (not (setq placeholder (c-most-enclosing-brace
1669: paren-state)))
1670: (and (progn
1671: (goto-char placeholder)
1672: (eq (char-after) ?{))
1673: (c-looking-at-decl-block (c-most-enclosing-brace
1674: paren-state (point))
1675: nil))))
1676: (c-backward-to-decl-anchor lim)
1677: (back-to-indentation)
1678: (c-add-syntax 'defun-block-intro (point)))
1679:
1680: ;; CASE 17G: First statement in a function declared inside
1681: ;; a normal block. This can occur in Pike and with
1682: ;; e.g. the gcc extensions, but watch out for macros
1683: ;; followed by blocks. C.f. cases B.3 and 16F.
1684: ((save-excursion
1685: (and (not (c-at-statement-start-p))
1686: (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
1687: (setq placeholder (point))
1688: (let ((c-recognize-typeless-decls nil))
1689: ;; Turn off recognition of constructs that lacks
1690: ;; a type in this case, since that's more likely
1691: ;; to be a macro followed by a block.
1692: (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
1693: (back-to-indentation)
1694: (if (/= (point) containing-sexp)
1695: (goto-char placeholder))
1696: (c-add-stmt-syntax 'defun-block-intro nil t
1697: lim paren-state))
1698:
1699: ;; CASE 17H: First statement in a block.
1700: (t
1701: ;; If the block is preceded by a case/switch label on the
1702: ;; same line, we anchor at the first preceding label at
1703: ;; boi. The default handling in c-add-stmt-syntax is
1704: ;; really fixes it better, but we do like this to keep the
1705: ;; indentation compatible with version 5.28 and earlier.
1706: ;; C.f. case 16C.
1707: (while (and (/= (setq placeholder (point)) (c-point 'boi))
1708: (eq (c-beginning-of-statement-1 lim) 'label)))
1709: (goto-char placeholder)
1710: (if (looking-at c-label-kwds-regexp)
1711: (c-add-syntax 'statement-block-intro (point))
1712: (goto-char containing-sexp)
1713: ;; c-backward-to-block-anchor not necessary here; those
1714: ;; situations are handled in case 17I above.
1715: (c-add-stmt-syntax 'statement-block-intro nil t
1716: lim paren-state))
1717: (if (eq char-after-ip ?{)
1718: (c-add-syntax 'block-open)))
1719: ))
1720: )
1721:
1722: ;; now we need to look at any modifiers
1723: (goto-char indent-point)
1724: (skip-chars-forward " \t")
1725:
1726: ;; are we looking at a comment only line?
1727: (when (and (looking-at c-comment-start-regexp)
1728: (/= (c-forward-token-2 0 nil (c-point 'eol)) 0))
1729: (c-append-syntax 'comment-intro))
1730:
1731: ;; we might want to give additional offset to friends (in C++).
1732: (when (and c-opt-friend-key
1733: (looking-at c-opt-friend-key))
1734: (c-append-syntax 'friend))
1735:
1736: ;; Set syntactic-relpos.
1737: (let ((p c-syntactic-context))
1738: (while (and p
1739: (if (integerp (c-langelem-pos (car p)))
1740: (progn
1741: (setq syntactic-relpos (c-langelem-pos (car p)))
1742: nil)
1743: t))
1744: (setq p (cdr p))))
1745:
1746: ;; Start of or a continuation of a preprocessor directive?
1747: (if (and macro-start
1748: (eq macro-start (c-point 'boi))
1749: (not (and (c-major-mode-is 'pike-mode)
1750: (eq (char-after (1+ macro-start)) ?\"))))
1751: (c-append-syntax 'cpp-macro)
1752: (when (and c-syntactic-indentation-in-macros macro-start)
1753: (if in-macro-expr
1754: (when (or
1755: (< syntactic-relpos macro-start)
1756: (not (or
1757: (assq 'arglist-intro c-syntactic-context)
1758: (assq 'arglist-cont c-syntactic-context)
1759: (assq 'arglist-cont-nonempty c-syntactic-context)
1760: (assq 'arglist-close c-syntactic-context))))
1761: ;; If inside a cpp expression, i.e. anywhere in a
1762: ;; cpp directive except a #define body, we only let
1763: ;; through the syntactic analysis that is internal
1764: ;; in the expression. That means the arglist
1765: ;; elements, if they are anchored inside the cpp
1766: ;; expression.
1767: (setq c-syntactic-context nil)
1768: (c-add-syntax 'cpp-macro-cont macro-start))
1769: (when (and (eq macro-start syntactic-relpos)
1770: (not (assq 'cpp-define-intro c-syntactic-context))
1771: (save-excursion
1772: (goto-char macro-start)
1773: (or (not (c-forward-to-cpp-define-body))
1774: (<= (point) (c-point 'boi indent-point)))))
1775: ;; Inside a #define body and the syntactic analysis is
1776: ;; anchored on the start of the #define. In this case
1777: ;; we add cpp-define-intro to get the extra
1778: ;; indentation of the #define body.
1779: (c-add-syntax 'cpp-define-intro)))))
1780:
1781: ;; return the syntax
1782: c-syntactic-context)))
1783:
1784: ;;;; End of `asir-c-guess-basic-syntax'
1785:
1786: (provide 'asir-mode)
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>