diff options
| author | Paul Eggert | 2011-03-06 22:26:47 -0800 |
|---|---|---|
| committer | Paul Eggert | 2011-03-06 22:26:47 -0800 |
| commit | 07b48fa9daec2894ad549f44fb468b251896d829 (patch) | |
| tree | 2cde6971d6f14a05adb8b6585cb4fa334d4b73aa /lisp | |
| parent | d432397227a87fd18c33a27806cd2c0fbcd203af (diff) | |
| parent | ef272f1fc10a4f8464c886ccc02ea67b2c3b2769 (diff) | |
| download | emacs-07b48fa9daec2894ad549f44fb468b251896d829.tar.gz emacs-07b48fa9daec2894ad549f44fb468b251896d829.zip | |
Merge from mainline.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 39 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package-x.el | 253 | ||||
| -rw-r--r-- | lisp/isearch.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 2724 | ||||
| -rw-r--r-- | lisp/progmodes/gud.el | 4 |
5 files changed, 1546 insertions, 1477 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e34fde79543..6b7768fe93c 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,11 +1,40 @@ | |||
| 1 | 2011-03-06 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 2 | |||
| 3 | * progmodes/gud.el (gdb-script-syntax-propertize-function): | ||
| 4 | Don't change the syntax of a \n that closes a comment (bug#8169). | ||
| 5 | |||
| 6 | 2011-03-06 Chong Yidong <cyd@stupidchicken.com> | ||
| 7 | |||
| 8 | * emacs-lisp/package-x.el (package-archive-upload-base): Make it a | ||
| 9 | defcustom. | ||
| 10 | (package--update-file): Doc fix. Accept relative file names. | ||
| 11 | (package--archive-contents-from-file): Remove the argument, since | ||
| 12 | it's necessarily always "archive-contents". | ||
| 13 | (package-maint-add-news-item): Pass relative file name args to | ||
| 14 | package--update-file. | ||
| 15 | (package-upload-buffer-internal): Prompt for a destination if | ||
| 16 | package-archive-upload-base is invalid. Create the directory if | ||
| 17 | it does not exist. | ||
| 18 | (package-upload-buffer, package-upload-file): Doc fix. | ||
| 19 | |||
| 20 | 2011-03-06 Chong Yidong <cyd@stupidchicken.com> | ||
| 21 | |||
| 22 | * isearch.el (isearch-mode-map): Bind C-y to isearch-yank-kill, | ||
| 23 | and move isearch-yank-line to M-s C-e (Bug#8183). | ||
| 24 | |||
| 25 | 2011-03-06 Alan Mackenzie <acm@muc.de> | ||
| 26 | |||
| 27 | * progmodes/cc-engine.el (c-guess-basic-syntax): Reindent. | ||
| 28 | (c-guess-basic-syntax): Move CASE 19 to a different place, | ||
| 29 | correctly to process template-args-cont lines. | ||
| 30 | |||
| 1 | 2011-03-06 Jay Belanger <jay.p.belanger@gmail.com> | 31 | 2011-03-06 Jay Belanger <jay.p.belanger@gmail.com> |
| 2 | 32 | ||
| 3 | * calc/calc-ext.el (calc-init-extensions): | 33 | * calc/calc-ext.el (calc-init-extensions): |
| 4 | Rename calc-logunits-dblevel and calc-logunits-nplevel to | 34 | Rename calc-logunits-dblevel and calc-logunits-nplevel to calc-dblevel |
| 5 | calc-dblevel and calc-nplevel, respectively. | 35 | and calc-nplevel, respectively. Add keybindings for calc-spn, |
| 6 | Add keybindings for calc-spn, calc-midi and calc-freq. Add | 36 | calc-midi and calc-freq. Add autoloads for calcFunc-spn, |
| 7 | autoloads for calcFunc-spn, calcFunc-midi, calcFunc-freq, | 37 | calcFunc-midi, calcFunc-freq, calc-spn, calc-midi and calc-freq. |
| 8 | calc-spn, calc-midi and calc-freq. | ||
| 9 | 38 | ||
| 10 | * calc/calc-units.el (calc-dblevel): Rename from | 39 | * calc/calc-units.el (calc-dblevel): Rename from |
| 11 | calc-logunits-dblevel. | 40 | calc-logunits-dblevel. |
diff --git a/lisp/emacs-lisp/package-x.el b/lisp/emacs-lisp/package-x.el index 61f23abf0a7..4de95f65702 100644 --- a/lisp/emacs-lisp/package-x.el +++ b/lisp/emacs-lisp/package-x.el | |||
| @@ -27,21 +27,41 @@ | |||
| 27 | 27 | ||
| 28 | ;;; Commentary: | 28 | ;;; Commentary: |
| 29 | 29 | ||
| 30 | ;; This file currently contains parts of the package system most | 30 | ;; This file currently contains parts of the package system that many |
| 31 | ;; people won't need, such as package uploading. | 31 | ;; won't need, such as package uploading. |
| 32 | |||
| 33 | ;; To upload to an archive, first set `package-archive-upload-base' to | ||
| 34 | ;; some desired directory. For testing purposes, you can specify any | ||
| 35 | ;; directory you want, but if you want the archive to be accessible to | ||
| 36 | ;; others via http, this is typically a directory in the /var/www tree | ||
| 37 | ;; (possibly one on a remote machine, accessed via Tramp). | ||
| 38 | |||
| 39 | ;; Then call M-x package-upload-file, which prompts for a file to | ||
| 40 | ;; upload. Alternatively, M-x package-upload-buffer uploads the | ||
| 41 | ;; current buffer, if it's visiting a package file. | ||
| 42 | |||
| 43 | ;; Once a package is uploaded, users can access it via the Package | ||
| 44 | ;; Menu, by adding the archive to `package-archives'. | ||
| 32 | 45 | ||
| 33 | ;;; Code: | 46 | ;;; Code: |
| 34 | 47 | ||
| 35 | (require 'package) | 48 | (require 'package) |
| 36 | (defvar gnus-article-buffer) | 49 | (defvar gnus-article-buffer) |
| 37 | 50 | ||
| 38 | ;; Note that this only works if you have the password, which you | 51 | (defcustom package-archive-upload-base "/path/to/archive" |
| 39 | ;; probably don't :-). | 52 | "The base location of the archive to which packages are uploaded. |
| 40 | (defvar package-archive-upload-base nil | 53 | This should be an absolute directory name. If the archive is on |
| 41 | "Base location for uploading to package archive.") | 54 | another machine, you may specify a remote name in the usual way, |
| 55 | e.g. \"/ssh:foo@example.com:/var/www/packages/\". | ||
| 56 | See Info node `(emacs)Remote Files'. | ||
| 57 | |||
| 58 | Unlike `package-archives', you can't specify a HTTP URL." | ||
| 59 | :type 'directory | ||
| 60 | :group 'package | ||
| 61 | :version "24.1") | ||
| 42 | 62 | ||
| 43 | (defvar package-update-news-on-upload nil | 63 | (defvar package-update-news-on-upload nil |
| 44 | "Whether package upload should also update NEWS and RSS feeds.") | 64 | "Whether uploading a package should also update NEWS and RSS feeds.") |
| 45 | 65 | ||
| 46 | (defun package--encode (string) | 66 | (defun package--encode (string) |
| 47 | "Encode a string by replacing some characters with XML entities." | 67 | "Encode a string by replacing some characters with XML entities." |
| @@ -75,13 +95,18 @@ | |||
| 75 | title " - " (package--encode text) | 95 | title " - " (package--encode text) |
| 76 | " </li>\n")) | 96 | " </li>\n")) |
| 77 | 97 | ||
| 78 | (defun package--update-file (file location text) | 98 | (defun package--update-file (file tag text) |
| 99 | "Update the package archive file named FILE. | ||
| 100 | FILE should be relative to `package-archive-upload-base'. | ||
| 101 | TAG is a string that can be found within the file; TEXT is | ||
| 102 | inserted after its first occurrence in the file." | ||
| 103 | (setq file (expand-file-name file package-archive-upload-base)) | ||
| 79 | (save-excursion | 104 | (save-excursion |
| 80 | (let ((old-buffer (find-buffer-visiting file))) | 105 | (let ((old-buffer (find-buffer-visiting file))) |
| 81 | (with-current-buffer (let ((find-file-visit-truename t)) | 106 | (with-current-buffer (let ((find-file-visit-truename t)) |
| 82 | (or old-buffer (find-file-noselect file))) | 107 | (or old-buffer (find-file-noselect file))) |
| 83 | (goto-char (point-min)) | 108 | (goto-char (point-min)) |
| 84 | (search-forward location) | 109 | (search-forward tag) |
| 85 | (forward-line) | 110 | (forward-line) |
| 86 | (insert text) | 111 | (insert text) |
| 87 | (let ((file-precious-flag t)) | 112 | (let ((file-precious-flag t)) |
| @@ -105,30 +130,31 @@ Return the file contents, as a string, or nil if unsuccessful." | |||
| 105 | (buffer-substring-no-properties (point-min) (point-max))) | 130 | (buffer-substring-no-properties (point-min) (point-max))) |
| 106 | (kill-buffer buffer)))))) | 131 | (kill-buffer buffer)))))) |
| 107 | 132 | ||
| 108 | (defun package--archive-contents-from-file (file) | 133 | (defun package--archive-contents-from-file () |
| 109 | "Parse the given archive-contents file." | 134 | "Parse the archive-contents at `package-archive-upload-base'" |
| 110 | (if (not (file-exists-p file)) | 135 | (let ((file (expand-file-name "archive-contents" |
| 111 | ;; no existing archive-contents, possibly a new ELPA repo. | 136 | package-archive-upload-base))) |
| 112 | (list package-archive-version) | 137 | (if (not (file-exists-p file)) |
| 113 | (let ((dont-kill (find-buffer-visiting file))) | 138 | ;; No existing archive-contents means a new archive. |
| 114 | (with-current-buffer (let ((find-file-visit-truename t)) | 139 | (list package-archive-version) |
| 115 | (find-file-noselect file)) | 140 | (let ((dont-kill (find-buffer-visiting file))) |
| 116 | (prog1 | 141 | (with-current-buffer (let ((find-file-visit-truename t)) |
| 117 | (package-read-from-string | 142 | (find-file-noselect file)) |
| 118 | (buffer-substring-no-properties (point-min) (point-max))) | 143 | (prog1 |
| 119 | (unless dont-kill | 144 | (package-read-from-string |
| 120 | (kill-buffer (current-buffer)))))))) | 145 | (buffer-substring-no-properties (point-min) (point-max))) |
| 146 | (unless dont-kill | ||
| 147 | (kill-buffer (current-buffer))))))))) | ||
| 121 | 148 | ||
| 122 | (defun package-maint-add-news-item (title description archive-url) | 149 | (defun package-maint-add-news-item (title description archive-url) |
| 123 | "Add a news item to the ELPA web pages. | 150 | "Add a news item to the webpages associated with the package archive. |
| 124 | TITLE is the title of the news item. | 151 | TITLE is the title of the news item. |
| 125 | DESCRIPTION is the text of the news item. | 152 | DESCRIPTION is the text of the news item." |
| 126 | You need administrative access to ELPA to use this." | ||
| 127 | (interactive "sTitle: \nsText: ") | 153 | (interactive "sTitle: \nsText: ") |
| 128 | (package--update-file (concat package-archive-upload-base "elpa.rss") | 154 | (package--update-file "elpa.rss" |
| 129 | "<description>" | 155 | "<description>" |
| 130 | (package--make-rss-entry title description archive-url)) | 156 | (package--make-rss-entry title description archive-url)) |
| 131 | (package--update-file (concat package-archive-upload-base "news.html") | 157 | (package--update-file "news.html" |
| 132 | "New entries go here" | 158 | "New entries go here" |
| 133 | (package--make-html-entry title description))) | 159 | (package--make-html-entry title description))) |
| 134 | 160 | ||
| @@ -144,8 +170,8 @@ PKG-INFO is the package info, see `package-buffer-info'. | |||
| 144 | EXTENSION is the file extension, a string. It can be either | 170 | EXTENSION is the file extension, a string. It can be either |
| 145 | \"el\" or \"tar\". | 171 | \"el\" or \"tar\". |
| 146 | 172 | ||
| 147 | The variable `package-archive-upload-base' specifies the upload | 173 | The upload destination is given by `package-archive-upload-base'. |
| 148 | destination. If this is nil, signal an error. | 174 | If its value is invalid, prompt for a directory. |
| 149 | 175 | ||
| 150 | Optional arg ARCHIVE-URL is the URL of the destination archive. | 176 | Optional arg ARCHIVE-URL is the URL of the destination archive. |
| 151 | If it is non-nil, compute the new \"archive-contents\" file | 177 | If it is non-nil, compute the new \"archive-contents\" file |
| @@ -156,85 +182,97 @@ addition, if `package-update-news-on-upload' is non-nil, call | |||
| 156 | If ARCHIVE-URL is nil, compute the new \"archive-contents\" file | 182 | If ARCHIVE-URL is nil, compute the new \"archive-contents\" file |
| 157 | from the \"archive-contents\" at `package-archive-upload-base', | 183 | from the \"archive-contents\" at `package-archive-upload-base', |
| 158 | if it exists." | 184 | if it exists." |
| 159 | (unless package-archive-upload-base | 185 | (let ((package-archive-upload-base package-archive-upload-base)) |
| 160 | (error "No destination specified in `package-archive-upload-base'")) | 186 | ;; Check if `package-archive-upload-base' is valid. |
| 161 | (save-excursion | 187 | (when (or (not (stringp package-archive-upload-base)) |
| 162 | (save-restriction | 188 | (eq package-archive-upload-base |
| 163 | (let* ((file-type (cond | 189 | (car-safe |
| 164 | ((equal extension "el") 'single) | 190 | (get 'package-archive-upload-base 'standard-value)))) |
| 165 | ((equal extension "tar") 'tar) | 191 | (setq package-archive-upload-base |
| 166 | (t (error "Unknown extension `%s'" extension)))) | 192 | (read-directory-name |
| 167 | (file-name (aref pkg-info 0)) | 193 | "Base directory for package archive: "))) |
| 168 | (pkg-name (intern file-name)) | 194 | (unless (file-directory-p package-archive-upload-base) |
| 169 | (requires (aref pkg-info 1)) | 195 | (if (y-or-n-p (format "%s does not exist; create it? " |
| 170 | (desc (if (string= (aref pkg-info 2) "") | 196 | package-archive-upload-base)) |
| 171 | (read-string "Description of package: ") | 197 | (make-directory package-archive-upload-base t) |
| 172 | (aref pkg-info 2))) | 198 | (error "Aborted"))) |
| 173 | (pkg-version (aref pkg-info 3)) | 199 | (save-excursion |
| 174 | (commentary (aref pkg-info 4)) | 200 | (save-restriction |
| 175 | (split-version (version-to-list pkg-version)) | 201 | (let* ((file-type (cond |
| 176 | (pkg-buffer (current-buffer))) | 202 | ((equal extension "el") 'single) |
| 177 | 203 | ((equal extension "tar") 'tar) | |
| 178 | ;; Get archive-contents from ARCHIVE-URL if it's non-nil, or | 204 | (t (error "Unknown extension `%s'" extension)))) |
| 179 | ;; from `package-archive-upload-base' otherwise. | 205 | (file-name (aref pkg-info 0)) |
| 180 | (let ((contents (or (package--archive-contents-from-url archive-url) | 206 | (pkg-name (intern file-name)) |
| 181 | (package--archive-contents-from-file | 207 | (requires (aref pkg-info 1)) |
| 182 | (concat package-archive-upload-base | 208 | (desc (if (string= (aref pkg-info 2) "") |
| 183 | "archive-contents")))) | 209 | (read-string "Description of package: ") |
| 184 | (new-desc (vector split-version requires desc file-type))) | 210 | (aref pkg-info 2))) |
| 185 | (if (> (car contents) package-archive-version) | 211 | (pkg-version (aref pkg-info 3)) |
| 186 | (error "Unrecognized archive version %d" (car contents))) | 212 | (commentary (aref pkg-info 4)) |
| 187 | (let ((elt (assq pkg-name (cdr contents)))) | 213 | (split-version (version-to-list pkg-version)) |
| 188 | (if elt | 214 | (pkg-buffer (current-buffer))) |
| 189 | (if (version-list-<= split-version | 215 | |
| 190 | (package-desc-vers (cdr elt))) | 216 | ;; Get archive-contents from ARCHIVE-URL if it's non-nil, or |
| 191 | (error "New package has smaller version: %s" pkg-version) | 217 | ;; from `package-archive-upload-base' otherwise. |
| 192 | (setcdr elt new-desc)) | 218 | (let ((contents (or (package--archive-contents-from-url archive-url) |
| 193 | (setq contents (cons (car contents) | 219 | (package--archive-contents-from-file))) |
| 194 | (cons (cons pkg-name new-desc) | 220 | (new-desc (vector split-version requires desc file-type))) |
| 195 | (cdr contents)))))) | 221 | (if (> (car contents) package-archive-version) |
| 196 | 222 | (error "Unrecognized archive version %d" (car contents))) | |
| 197 | ;; Now CONTENTS is the updated archive contents. Upload | 223 | (let ((elt (assq pkg-name (cdr contents)))) |
| 198 | ;; this and the package itself. For now we assume ELPA is | 224 | (if elt |
| 199 | ;; writable via file primitives. | 225 | (if (version-list-<= split-version |
| 200 | (let ((print-level nil) | 226 | (package-desc-vers (cdr elt))) |
| 201 | (print-length nil)) | 227 | (error "New package has smaller version: %s" pkg-version) |
| 202 | (write-region (concat (pp-to-string contents) "\n") | 228 | (setcdr elt new-desc)) |
| 203 | nil | 229 | (setq contents (cons (car contents) |
| 204 | (concat package-archive-upload-base | 230 | (cons (cons pkg-name new-desc) |
| 205 | "archive-contents"))) | 231 | (cdr contents)))))) |
| 206 | 232 | ||
| 207 | ;; If there is a commentary section, write it. | 233 | ;; Now CONTENTS is the updated archive contents. Upload |
| 208 | (when commentary | 234 | ;; this and the package itself. For now we assume ELPA is |
| 209 | (write-region commentary nil | 235 | ;; writable via file primitives. |
| 210 | (concat package-archive-upload-base | 236 | (let ((print-level nil) |
| 211 | (symbol-name pkg-name) "-readme.txt"))) | 237 | (print-length nil)) |
| 212 | 238 | (write-region (concat (pp-to-string contents) "\n") | |
| 213 | (set-buffer pkg-buffer) | 239 | nil |
| 214 | (write-region (point-min) (point-max) | 240 | (expand-file-name "archive-contents" |
| 215 | (concat package-archive-upload-base | 241 | package-archive-upload-base))) |
| 216 | file-name "-" pkg-version | 242 | |
| 217 | "." extension) | 243 | ;; If there is a commentary section, write it. |
| 218 | nil nil nil 'excl) | 244 | (when commentary |
| 219 | 245 | (write-region commentary nil | |
| 220 | ;; Write a news entry. | 246 | (expand-file-name |
| 221 | (and package-update-news-on-upload | 247 | (concat (symbol-name pkg-name) "-readme.txt") |
| 222 | archive-url | 248 | package-archive-upload-base))) |
| 223 | (package--update-news (concat file-name "." extension) | 249 | |
| 224 | pkg-version desc archive-url)) | 250 | (set-buffer pkg-buffer) |
| 225 | 251 | (write-region (point-min) (point-max) | |
| 226 | ;; special-case "package": write a second copy so that the | 252 | (expand-file-name |
| 227 | ;; installer can easily find the latest version. | 253 | (concat file-name "-" pkg-version "." extension) |
| 228 | (if (string= file-name "package") | 254 | package-archive-upload-base) |
| 229 | (write-region (point-min) (point-max) | 255 | nil nil nil 'excl) |
| 230 | (concat package-archive-upload-base | 256 | |
| 231 | file-name "." extension) | 257 | ;; Write a news entry. |
| 232 | nil nil nil 'ask))))))) | 258 | (and package-update-news-on-upload |
| 259 | archive-url | ||
| 260 | (package--update-news (concat file-name "." extension) | ||
| 261 | pkg-version desc archive-url)) | ||
| 262 | |||
| 263 | ;; special-case "package": write a second copy so that the | ||
| 264 | ;; installer can easily find the latest version. | ||
| 265 | (if (string= file-name "package") | ||
| 266 | (write-region (point-min) (point-max) | ||
| 267 | (expand-file-name | ||
| 268 | (concat file-name "." extension) | ||
| 269 | package-archive-upload-base) | ||
| 270 | nil nil nil 'ask)))))))) | ||
| 233 | 271 | ||
| 234 | (defun package-upload-buffer () | 272 | (defun package-upload-buffer () |
| 235 | "Upload the current buffer as a single-file Emacs Lisp package. | 273 | "Upload the current buffer as a single-file Emacs Lisp package. |
| 236 | The variable `package-archive-upload-base' specifies the upload | 274 | If `package-archive-upload-base' does not specify a valid upload |
| 237 | destination." | 275 | destination, prompt for one." |
| 238 | (interactive) | 276 | (interactive) |
| 239 | (save-excursion | 277 | (save-excursion |
| 240 | (save-restriction | 278 | (save-restriction |
| @@ -247,9 +285,8 @@ destination." | |||
| 247 | Interactively, prompt for FILE. The package is considered a | 285 | Interactively, prompt for FILE. The package is considered a |
| 248 | single-file package if FILE ends in \".el\", and a multi-file | 286 | single-file package if FILE ends in \".el\", and a multi-file |
| 249 | package if FILE ends in \".tar\". | 287 | package if FILE ends in \".tar\". |
| 250 | 288 | If `package-archive-upload-base' does not specify a valid upload | |
| 251 | The variable `package-archive-upload-base' specifies the upload | 289 | destination, prompt for one." |
| 252 | destination." | ||
| 253 | (interactive "fPackage file name: ") | 290 | (interactive "fPackage file name: ") |
| 254 | (with-temp-buffer | 291 | (with-temp-buffer |
| 255 | (insert-file-contents-literally file) | 292 | (insert-file-contents-literally file) |
diff --git a/lisp/isearch.el b/lisp/isearch.el index 5aadac4a3b1..e13d9673514 100644 --- a/lisp/isearch.el +++ b/lisp/isearch.el | |||
| @@ -464,7 +464,8 @@ This is like `describe-bindings', but displays only Isearch keys." | |||
| 464 | (define-key map "\C-w" 'isearch-yank-word-or-char) | 464 | (define-key map "\C-w" 'isearch-yank-word-or-char) |
| 465 | (define-key map "\M-\C-w" 'isearch-del-char) | 465 | (define-key map "\M-\C-w" 'isearch-del-char) |
| 466 | (define-key map "\M-\C-y" 'isearch-yank-char) | 466 | (define-key map "\M-\C-y" 'isearch-yank-char) |
| 467 | (define-key map "\C-y" 'isearch-yank-line) | 467 | (define-key map "\C-y" 'isearch-yank-kill) |
| 468 | (define-key map "\M-s\C-e" 'isearch-yank-line) | ||
| 468 | 469 | ||
| 469 | (define-key map (char-to-string help-char) isearch-help-map) | 470 | (define-key map (char-to-string help-char) isearch-help-map) |
| 470 | (define-key map [help] isearch-help-map) | 471 | (define-key map [help] isearch-help-map) |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 654323e03e4..5ef12300195 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -8725,841 +8725,841 @@ comment at the start of cc-engine.el for more info." | |||
| 8725 | (defun c-guess-basic-syntax () | 8725 | (defun c-guess-basic-syntax () |
| 8726 | "Return the syntactic context of the current line." | 8726 | "Return the syntactic context of the current line." |
| 8727 | (save-excursion | 8727 | (save-excursion |
| 8728 | (beginning-of-line) | 8728 | (beginning-of-line) |
| 8729 | (c-save-buffer-state | 8729 | (c-save-buffer-state |
| 8730 | ((indent-point (point)) | 8730 | ((indent-point (point)) |
| 8731 | (case-fold-search nil) | 8731 | (case-fold-search nil) |
| 8732 | ;; A whole ugly bunch of various temporary variables. Have | 8732 | ;; A whole ugly bunch of various temporary variables. Have |
| 8733 | ;; to declare them here since it's not possible to declare | 8733 | ;; to declare them here since it's not possible to declare |
| 8734 | ;; a variable with only the scope of a cond test and the | 8734 | ;; a variable with only the scope of a cond test and the |
| 8735 | ;; following result clauses, and most of this function is a | 8735 | ;; following result clauses, and most of this function is a |
| 8736 | ;; single gigantic cond. :P | 8736 | ;; single gigantic cond. :P |
| 8737 | literal char-before-ip before-ws-ip char-after-ip macro-start | 8737 | literal char-before-ip before-ws-ip char-after-ip macro-start |
| 8738 | in-macro-expr c-syntactic-context placeholder c-in-literal-cache | 8738 | in-macro-expr c-syntactic-context placeholder c-in-literal-cache |
| 8739 | step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos | 8739 | step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos |
| 8740 | containing-< | 8740 | containing-< |
| 8741 | ;; The following record some positions for the containing | 8741 | ;; The following record some positions for the containing |
| 8742 | ;; declaration block if we're directly within one: | 8742 | ;; declaration block if we're directly within one: |
| 8743 | ;; `containing-decl-open' is the position of the open | 8743 | ;; `containing-decl-open' is the position of the open |
| 8744 | ;; brace. `containing-decl-start' is the start of the | 8744 | ;; brace. `containing-decl-start' is the start of the |
| 8745 | ;; declaration. `containing-decl-kwd' is the keyword | 8745 | ;; declaration. `containing-decl-kwd' is the keyword |
| 8746 | ;; symbol of the keyword that tells what kind of block it | 8746 | ;; symbol of the keyword that tells what kind of block it |
| 8747 | ;; is. | 8747 | ;; is. |
| 8748 | containing-decl-open | 8748 | containing-decl-open |
| 8749 | containing-decl-start | 8749 | containing-decl-start |
| 8750 | containing-decl-kwd | 8750 | containing-decl-kwd |
| 8751 | ;; The open paren of the closest surrounding sexp or nil if | 8751 | ;; The open paren of the closest surrounding sexp or nil if |
| 8752 | ;; there is none. | 8752 | ;; there is none. |
| 8753 | containing-sexp | 8753 | containing-sexp |
| 8754 | ;; The position after the closest preceding brace sexp | 8754 | ;; The position after the closest preceding brace sexp |
| 8755 | ;; (nested sexps are ignored), or the position after | 8755 | ;; (nested sexps are ignored), or the position after |
| 8756 | ;; `containing-sexp' if there is none, or (point-min) if | 8756 | ;; `containing-sexp' if there is none, or (point-min) if |
| 8757 | ;; `containing-sexp' is nil. | 8757 | ;; `containing-sexp' is nil. |
| 8758 | lim | 8758 | lim |
| 8759 | ;; The paren state outside `containing-sexp', or at | 8759 | ;; The paren state outside `containing-sexp', or at |
| 8760 | ;; `indent-point' if `containing-sexp' is nil. | 8760 | ;; `indent-point' if `containing-sexp' is nil. |
| 8761 | (paren-state (c-parse-state)) | 8761 | (paren-state (c-parse-state)) |
| 8762 | ;; There's always at most one syntactic element which got | 8762 | ;; There's always at most one syntactic element which got |
| 8763 | ;; an anchor pos. It's stored in syntactic-relpos. | 8763 | ;; an anchor pos. It's stored in syntactic-relpos. |
| 8764 | syntactic-relpos | 8764 | syntactic-relpos |
| 8765 | (c-stmt-delim-chars c-stmt-delim-chars)) | 8765 | (c-stmt-delim-chars c-stmt-delim-chars)) |
| 8766 | 8766 | ||
| 8767 | ;; Check if we're directly inside an enclosing declaration | 8767 | ;; Check if we're directly inside an enclosing declaration |
| 8768 | ;; level block. | 8768 | ;; level block. |
| 8769 | (when (and (setq containing-sexp | 8769 | (when (and (setq containing-sexp |
| 8770 | (c-most-enclosing-brace paren-state)) | 8770 | (c-most-enclosing-brace paren-state)) |
| 8771 | (progn | 8771 | (progn |
| 8772 | (goto-char containing-sexp) | 8772 | (goto-char containing-sexp) |
| 8773 | (eq (char-after) ?{)) | 8773 | (eq (char-after) ?{)) |
| 8774 | (setq placeholder | 8774 | (setq placeholder |
| 8775 | (c-looking-at-decl-block | 8775 | (c-looking-at-decl-block |
| 8776 | (c-most-enclosing-brace paren-state | 8776 | (c-most-enclosing-brace paren-state |
| 8777 | containing-sexp) | 8777 | containing-sexp) |
| 8778 | t))) | 8778 | t))) |
| 8779 | (setq containing-decl-open containing-sexp | 8779 | (setq containing-decl-open containing-sexp |
| 8780 | containing-decl-start (point) | 8780 | containing-decl-start (point) |
| 8781 | containing-sexp nil) | 8781 | containing-sexp nil) |
| 8782 | (goto-char placeholder) | 8782 | (goto-char placeholder) |
| 8783 | (setq containing-decl-kwd (and (looking-at c-keywords-regexp) | 8783 | (setq containing-decl-kwd (and (looking-at c-keywords-regexp) |
| 8784 | (c-keyword-sym (match-string 1))))) | 8784 | (c-keyword-sym (match-string 1))))) |
| 8785 | 8785 | ||
| 8786 | ;; Init some position variables. | 8786 | ;; Init some position variables. |
| 8787 | (if c-state-cache | 8787 | (if c-state-cache |
| 8788 | (progn | 8788 | (progn |
| 8789 | (setq containing-sexp (car paren-state) | 8789 | (setq containing-sexp (car paren-state) |
| 8790 | paren-state (cdr paren-state)) | 8790 | paren-state (cdr paren-state)) |
| 8791 | (if (consp containing-sexp) | 8791 | (if (consp containing-sexp) |
| 8792 | (progn | 8792 | (progn |
| 8793 | (setq lim (cdr containing-sexp)) | 8793 | (setq lim (cdr containing-sexp)) |
| 8794 | (if (cdr c-state-cache) | 8794 | (if (cdr c-state-cache) |
| 8795 | ;; Ignore balanced paren. The next entry | 8795 | ;; Ignore balanced paren. The next entry |
| 8796 | ;; can't be another one. | 8796 | ;; can't be another one. |
| 8797 | (setq containing-sexp (car (cdr c-state-cache)) | 8797 | (setq containing-sexp (car (cdr c-state-cache)) |
| 8798 | paren-state (cdr paren-state)) | 8798 | paren-state (cdr paren-state)) |
| 8799 | ;; If there is no surrounding open paren then | 8799 | ;; If there is no surrounding open paren then |
| 8800 | ;; put the last balanced pair back on paren-state. | 8800 | ;; put the last balanced pair back on paren-state. |
| 8801 | (setq paren-state (cons containing-sexp paren-state) | 8801 | (setq paren-state (cons containing-sexp paren-state) |
| 8802 | containing-sexp nil))) | 8802 | containing-sexp nil))) |
| 8803 | (setq lim (1+ containing-sexp)))) | 8803 | (setq lim (1+ containing-sexp)))) |
| 8804 | (setq lim (point-min))) | 8804 | (setq lim (point-min))) |
| 8805 | 8805 | ||
| 8806 | ;; If we're in a parenthesis list then ',' delimits the | 8806 | ;; If we're in a parenthesis list then ',' delimits the |
| 8807 | ;; "statements" rather than being an operator (with the | 8807 | ;; "statements" rather than being an operator (with the |
| 8808 | ;; exception of the "for" clause). This difference is | 8808 | ;; exception of the "for" clause). This difference is |
| 8809 | ;; typically only noticeable when statements are used in macro | 8809 | ;; typically only noticeable when statements are used in macro |
| 8810 | ;; arglists. | 8810 | ;; arglists. |
| 8811 | (when (and containing-sexp | 8811 | (when (and containing-sexp |
| 8812 | (eq (char-after containing-sexp) ?\()) | 8812 | (eq (char-after containing-sexp) ?\()) |
| 8813 | (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) | 8813 | (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) |
| 8814 | ;; cache char before and after indent point, and move point to | 8814 | ;; cache char before and after indent point, and move point to |
| 8815 | ;; the most likely position to perform the majority of tests | 8815 | ;; the most likely position to perform the majority of tests |
| 8816 | (goto-char indent-point) | 8816 | (goto-char indent-point) |
| 8817 | (c-backward-syntactic-ws lim) | 8817 | (c-backward-syntactic-ws lim) |
| 8818 | (setq before-ws-ip (point) | 8818 | (setq before-ws-ip (point) |
| 8819 | char-before-ip (char-before)) | 8819 | char-before-ip (char-before)) |
| 8820 | (goto-char indent-point) | 8820 | (goto-char indent-point) |
| 8821 | (skip-chars-forward " \t") | 8821 | (skip-chars-forward " \t") |
| 8822 | (setq char-after-ip (char-after)) | 8822 | (setq char-after-ip (char-after)) |
| 8823 | 8823 | ||
| 8824 | ;; are we in a literal? | 8824 | ;; are we in a literal? |
| 8825 | (setq literal (c-in-literal lim)) | 8825 | (setq literal (c-in-literal lim)) |
| 8826 | 8826 | ||
| 8827 | ;; now figure out syntactic qualities of the current line | 8827 | ;; now figure out syntactic qualities of the current line |
| 8828 | (cond | 8828 | (cond |
| 8829 | 8829 | ||
| 8830 | ;; CASE 1: in a string. | 8830 | ;; CASE 1: in a string. |
| 8831 | ((eq literal 'string) | 8831 | ((eq literal 'string) |
| 8832 | (c-add-syntax 'string (c-point 'bopl))) | 8832 | (c-add-syntax 'string (c-point 'bopl))) |
| 8833 | 8833 | ||
| 8834 | ;; CASE 2: in a C or C++ style comment. | 8834 | ;; CASE 2: in a C or C++ style comment. |
| 8835 | ((and (memq literal '(c c++)) | 8835 | ((and (memq literal '(c c++)) |
| 8836 | ;; This is a kludge for XEmacs where we use | 8836 | ;; This is a kludge for XEmacs where we use |
| 8837 | ;; `buffer-syntactic-context', which doesn't correctly | 8837 | ;; `buffer-syntactic-context', which doesn't correctly |
| 8838 | ;; recognize "\*/" to end a block comment. | 8838 | ;; recognize "\*/" to end a block comment. |
| 8839 | ;; `parse-partial-sexp' which is used by | 8839 | ;; `parse-partial-sexp' which is used by |
| 8840 | ;; `c-literal-limits' will however do that in most | 8840 | ;; `c-literal-limits' will however do that in most |
| 8841 | ;; versions, which results in that we get nil from | 8841 | ;; versions, which results in that we get nil from |
| 8842 | ;; `c-literal-limits' even when `c-in-literal' claims | 8842 | ;; `c-literal-limits' even when `c-in-literal' claims |
| 8843 | ;; we're inside a comment. | 8843 | ;; we're inside a comment. |
| 8844 | (setq placeholder (c-literal-limits lim))) | 8844 | (setq placeholder (c-literal-limits lim))) |
| 8845 | (c-add-syntax literal (car placeholder))) | 8845 | (c-add-syntax literal (car placeholder))) |
| 8846 | 8846 | ||
| 8847 | ;; CASE 3: in a cpp preprocessor macro continuation. | 8847 | ;; CASE 3: in a cpp preprocessor macro continuation. |
| 8848 | ((and (save-excursion | 8848 | ((and (save-excursion |
| 8849 | (when (c-beginning-of-macro) | 8849 | (when (c-beginning-of-macro) |
| 8850 | (setq macro-start (point)))) | 8850 | (setq macro-start (point)))) |
| 8851 | (/= macro-start (c-point 'boi)) | 8851 | (/= macro-start (c-point 'boi)) |
| 8852 | (progn | 8852 | (progn |
| 8853 | (setq tmpsymbol 'cpp-macro-cont) | 8853 | (setq tmpsymbol 'cpp-macro-cont) |
| 8854 | (or (not c-syntactic-indentation-in-macros) | 8854 | (or (not c-syntactic-indentation-in-macros) |
| 8855 | (save-excursion | 8855 | (save-excursion |
| 8856 | (goto-char macro-start) | 8856 | (goto-char macro-start) |
| 8857 | ;; If at the beginning of the body of a #define | 8857 | ;; If at the beginning of the body of a #define |
| 8858 | ;; directive then analyze as cpp-define-intro | 8858 | ;; directive then analyze as cpp-define-intro |
| 8859 | ;; only. Go on with the syntactic analysis | 8859 | ;; only. Go on with the syntactic analysis |
| 8860 | ;; otherwise. in-macro-expr is set if we're in a | 8860 | ;; otherwise. in-macro-expr is set if we're in a |
| 8861 | ;; cpp expression, i.e. before the #define body | 8861 | ;; cpp expression, i.e. before the #define body |
| 8862 | ;; or anywhere in a non-#define directive. | 8862 | ;; or anywhere in a non-#define directive. |
| 8863 | (if (c-forward-to-cpp-define-body) | 8863 | (if (c-forward-to-cpp-define-body) |
| 8864 | (let ((indent-boi (c-point 'boi indent-point))) | 8864 | (let ((indent-boi (c-point 'boi indent-point))) |
| 8865 | (setq in-macro-expr (> (point) indent-boi) | 8865 | (setq in-macro-expr (> (point) indent-boi) |
| 8866 | tmpsymbol 'cpp-define-intro) | 8866 | tmpsymbol 'cpp-define-intro) |
| 8867 | (= (point) indent-boi)) | 8867 | (= (point) indent-boi)) |
| 8868 | (setq in-macro-expr t) | 8868 | (setq in-macro-expr t) |
| 8869 | nil))))) | 8869 | nil))))) |
| 8870 | (c-add-syntax tmpsymbol macro-start) | 8870 | (c-add-syntax tmpsymbol macro-start) |
| 8871 | (setq macro-start nil)) | 8871 | (setq macro-start nil)) |
| 8872 | 8872 | ||
| 8873 | ;; CASE 11: an else clause? | 8873 | ;; CASE 11: an else clause? |
| 8874 | ((looking-at "else\\>[^_]") | 8874 | ((looking-at "else\\>[^_]") |
| 8875 | (c-beginning-of-statement-1 containing-sexp) | 8875 | (c-beginning-of-statement-1 containing-sexp) |
| 8876 | (c-add-stmt-syntax 'else-clause nil t | 8876 | (c-add-stmt-syntax 'else-clause nil t |
| 8877 | containing-sexp paren-state)) | 8877 | containing-sexp paren-state)) |
| 8878 | 8878 | ||
| 8879 | ;; CASE 12: while closure of a do/while construct? | 8879 | ;; CASE 12: while closure of a do/while construct? |
| 8880 | ((and (looking-at "while\\>[^_]") | 8880 | ((and (looking-at "while\\>[^_]") |
| 8881 | (save-excursion | 8881 | (save-excursion |
| 8882 | (prog1 (eq (c-beginning-of-statement-1 containing-sexp) | 8882 | (prog1 (eq (c-beginning-of-statement-1 containing-sexp) |
| 8883 | 'beginning) | 8883 | 'beginning) |
| 8884 | (setq placeholder (point))))) | 8884 | (setq placeholder (point))))) |
| 8885 | (goto-char placeholder) | 8885 | (goto-char placeholder) |
| 8886 | (c-add-stmt-syntax 'do-while-closure nil t | 8886 | (c-add-stmt-syntax 'do-while-closure nil t |
| 8887 | containing-sexp paren-state)) | 8887 | containing-sexp paren-state)) |
| 8888 | 8888 | ||
| 8889 | ;; CASE 13: A catch or finally clause? This case is simpler | 8889 | ;; CASE 13: A catch or finally clause? This case is simpler |
| 8890 | ;; than if-else and do-while, because a block is required | 8890 | ;; than if-else and do-while, because a block is required |
| 8891 | ;; after every try, catch and finally. | 8891 | ;; after every try, catch and finally. |
| 8892 | ((save-excursion | 8892 | ((save-excursion |
| 8893 | (and (cond ((c-major-mode-is 'c++-mode) | 8893 | (and (cond ((c-major-mode-is 'c++-mode) |
| 8894 | (looking-at "catch\\>[^_]")) | 8894 | (looking-at "catch\\>[^_]")) |
| 8895 | ((c-major-mode-is 'java-mode) | 8895 | ((c-major-mode-is 'java-mode) |
| 8896 | (looking-at "\\(catch\\|finally\\)\\>[^_]"))) | 8896 | (looking-at "\\(catch\\|finally\\)\\>[^_]"))) |
| 8897 | (and (c-safe (c-backward-syntactic-ws) | 8897 | (and (c-safe (c-backward-syntactic-ws) |
| 8898 | (c-backward-sexp) | 8898 | (c-backward-sexp) |
| 8899 | t) | 8899 | t) |
| 8900 | (eq (char-after) ?{) | 8900 | (eq (char-after) ?{) |
| 8901 | (c-safe (c-backward-syntactic-ws) | 8901 | (c-safe (c-backward-syntactic-ws) |
| 8902 | (c-backward-sexp) | 8902 | (c-backward-sexp) |
| 8903 | t) | 8903 | t) |
| 8904 | (if (eq (char-after) ?\() | 8904 | (if (eq (char-after) ?\() |
| 8905 | (c-safe (c-backward-sexp) t) | 8905 | (c-safe (c-backward-sexp) t) |
| 8906 | t)) | 8906 | t)) |
| 8907 | (looking-at "\\(try\\|catch\\)\\>[^_]") | 8907 | (looking-at "\\(try\\|catch\\)\\>[^_]") |
| 8908 | (setq placeholder (point)))) | 8908 | (setq placeholder (point)))) |
| 8909 | (goto-char placeholder) | 8909 | (goto-char placeholder) |
| 8910 | (c-add-stmt-syntax 'catch-clause nil t | 8910 | (c-add-stmt-syntax 'catch-clause nil t |
| 8911 | containing-sexp paren-state)) | 8911 | containing-sexp paren-state)) |
| 8912 | 8912 | ||
| 8913 | ;; CASE 18: A substatement we can recognize by keyword. | 8913 | ;; CASE 18: A substatement we can recognize by keyword. |
| 8914 | ((save-excursion | 8914 | ((save-excursion |
| 8915 | (and c-opt-block-stmt-key | 8915 | (and c-opt-block-stmt-key |
| 8916 | (not (eq char-before-ip ?\;)) | 8916 | (not (eq char-before-ip ?\;)) |
| 8917 | (not (c-at-vsemi-p before-ws-ip)) | 8917 | (not (c-at-vsemi-p before-ws-ip)) |
| 8918 | (not (memq char-after-ip '(?\) ?\] ?,))) | 8918 | (not (memq char-after-ip '(?\) ?\] ?,))) |
| 8919 | (or (not (eq char-before-ip ?})) | 8919 | (or (not (eq char-before-ip ?})) |
| 8920 | (c-looking-at-inexpr-block-backward c-state-cache)) | 8920 | (c-looking-at-inexpr-block-backward c-state-cache)) |
| 8921 | (> (point) | 8921 | (> (point) |
| 8922 | (progn | 8922 | (progn |
| 8923 | ;; Ought to cache the result from the | 8923 | ;; Ought to cache the result from the |
| 8924 | ;; c-beginning-of-statement-1 calls here. | 8924 | ;; c-beginning-of-statement-1 calls here. |
| 8925 | (setq placeholder (point)) | ||
| 8926 | (while (eq (setq step-type | ||
| 8927 | (c-beginning-of-statement-1 lim)) | ||
| 8928 | 'label)) | ||
| 8929 | (if (eq step-type 'previous) | ||
| 8930 | (goto-char placeholder) | ||
| 8925 | (setq placeholder (point)) | 8931 | (setq placeholder (point)) |
| 8926 | (while (eq (setq step-type | 8932 | (if (and (eq step-type 'same) |
| 8927 | (c-beginning-of-statement-1 lim)) | 8933 | (not (looking-at c-opt-block-stmt-key))) |
| 8928 | 'label)) | 8934 | ;; Step up to the containing statement if we |
| 8929 | (if (eq step-type 'previous) | 8935 | ;; stayed in the same one. |
| 8930 | (goto-char placeholder) | 8936 | (let (step) |
| 8931 | (setq placeholder (point)) | 8937 | (while (eq |
| 8932 | (if (and (eq step-type 'same) | 8938 | (setq step |
| 8933 | (not (looking-at c-opt-block-stmt-key))) | 8939 | (c-beginning-of-statement-1 lim)) |
| 8934 | ;; Step up to the containing statement if we | 8940 | 'label)) |
| 8935 | ;; stayed in the same one. | 8941 | (if (eq step 'up) |
| 8936 | (let (step) | 8942 | (setq placeholder (point)) |
| 8937 | (while (eq | 8943 | ;; There was no containing statement afterall. |
| 8938 | (setq step | 8944 | (goto-char placeholder))))) |
| 8939 | (c-beginning-of-statement-1 lim)) | 8945 | placeholder)) |
| 8940 | 'label)) | 8946 | (if (looking-at c-block-stmt-2-key) |
| 8941 | (if (eq step 'up) | 8947 | ;; Require a parenthesis after these keywords. |
| 8942 | (setq placeholder (point)) | 8948 | ;; Necessary to catch e.g. synchronized in Java, |
| 8943 | ;; There was no containing statement afterall. | 8949 | ;; which can be used both as statement and |
| 8944 | (goto-char placeholder))))) | 8950 | ;; modifier. |
| 8945 | placeholder)) | 8951 | (and (zerop (c-forward-token-2 1 nil)) |
| 8946 | (if (looking-at c-block-stmt-2-key) | 8952 | (eq (char-after) ?\()) |
| 8947 | ;; Require a parenthesis after these keywords. | 8953 | (looking-at c-opt-block-stmt-key)))) |
| 8948 | ;; Necessary to catch e.g. synchronized in Java, | 8954 | |
| 8949 | ;; which can be used both as statement and | 8955 | (if (eq step-type 'up) |
| 8950 | ;; modifier. | 8956 | ;; CASE 18A: Simple substatement. |
| 8951 | (and (zerop (c-forward-token-2 1 nil)) | 8957 | (progn |
| 8952 | (eq (char-after) ?\()) | 8958 | (goto-char placeholder) |
| 8953 | (looking-at c-opt-block-stmt-key)))) | 8959 | (cond |
| 8954 | 8960 | ((eq char-after-ip ?{) | |
| 8955 | (if (eq step-type 'up) | 8961 | (c-add-stmt-syntax 'substatement-open nil nil |
| 8956 | ;; CASE 18A: Simple substatement. | 8962 | containing-sexp paren-state)) |
| 8957 | (progn | 8963 | ((save-excursion |
| 8958 | (goto-char placeholder) | 8964 | (goto-char indent-point) |
| 8959 | (cond | 8965 | (back-to-indentation) |
| 8960 | ((eq char-after-ip ?{) | 8966 | (c-forward-label)) |
| 8961 | (c-add-stmt-syntax 'substatement-open nil nil | 8967 | (c-add-stmt-syntax 'substatement-label nil nil |
| 8962 | containing-sexp paren-state)) | 8968 | containing-sexp paren-state)) |
| 8963 | ((save-excursion | 8969 | (t |
| 8964 | (goto-char indent-point) | 8970 | (c-add-stmt-syntax 'substatement nil nil |
| 8965 | (back-to-indentation) | 8971 | containing-sexp paren-state)))) |
| 8966 | (c-forward-label)) | 8972 | |
| 8967 | (c-add-stmt-syntax 'substatement-label nil nil | 8973 | ;; CASE 18B: Some other substatement. This is shared |
| 8968 | containing-sexp paren-state)) | 8974 | ;; with case 10. |
| 8969 | (t | 8975 | (c-guess-continued-construct indent-point |
| 8970 | (c-add-stmt-syntax 'substatement nil nil | 8976 | char-after-ip |
| 8971 | containing-sexp paren-state)))) | 8977 | placeholder |
| 8972 | 8978 | lim | |
| 8973 | ;; CASE 18B: Some other substatement. This is shared | 8979 | paren-state))) |
| 8974 | ;; with case 10. | ||
| 8975 | (c-guess-continued-construct indent-point | ||
| 8976 | char-after-ip | ||
| 8977 | placeholder | ||
| 8978 | lim | ||
| 8979 | paren-state))) | ||
| 8980 | |||
| 8981 | ;; CASE 14: A case or default label | ||
| 8982 | ((looking-at c-label-kwds-regexp) | ||
| 8983 | (if containing-sexp | ||
| 8984 | (progn | ||
| 8985 | (goto-char containing-sexp) | ||
| 8986 | (setq lim (c-most-enclosing-brace c-state-cache | ||
| 8987 | containing-sexp)) | ||
| 8988 | (c-backward-to-block-anchor lim) | ||
| 8989 | (c-add-stmt-syntax 'case-label nil t lim paren-state)) | ||
| 8990 | ;; Got a bogus label at the top level. In lack of better | ||
| 8991 | ;; alternatives, anchor it on (point-min). | ||
| 8992 | (c-add-syntax 'case-label (point-min)))) | ||
| 8993 | |||
| 8994 | ;; CASE 15: any other label | ||
| 8995 | ((save-excursion | ||
| 8996 | (back-to-indentation) | ||
| 8997 | (and (not (looking-at c-syntactic-ws-start)) | ||
| 8998 | (c-forward-label))) | ||
| 8999 | (cond (containing-decl-open | ||
| 9000 | (setq placeholder (c-add-class-syntax 'inclass | ||
| 9001 | containing-decl-open | ||
| 9002 | containing-decl-start | ||
| 9003 | containing-decl-kwd | ||
| 9004 | paren-state)) | ||
| 9005 | ;; Append access-label with the same anchor point as | ||
| 9006 | ;; inclass gets. | ||
| 9007 | (c-append-syntax 'access-label placeholder)) | ||
| 9008 | |||
| 9009 | (containing-sexp | ||
| 9010 | (goto-char containing-sexp) | ||
| 9011 | (setq lim (c-most-enclosing-brace c-state-cache | ||
| 9012 | containing-sexp)) | ||
| 9013 | (save-excursion | ||
| 9014 | (setq tmpsymbol | ||
| 9015 | (if (and (eq (c-beginning-of-statement-1 lim) 'up) | ||
| 9016 | (looking-at "switch\\>[^_]")) | ||
| 9017 | ;; If the surrounding statement is a switch then | ||
| 9018 | ;; let's analyze all labels as switch labels, so | ||
| 9019 | ;; that they get lined up consistently. | ||
| 9020 | 'case-label | ||
| 9021 | 'label))) | ||
| 9022 | (c-backward-to-block-anchor lim) | ||
| 9023 | (c-add-stmt-syntax tmpsymbol nil t lim paren-state)) | ||
| 9024 | 8980 | ||
| 9025 | (t | 8981 | ;; CASE 14: A case or default label |
| 9026 | ;; A label on the top level. Treat it as a class | 8982 | ((looking-at c-label-kwds-regexp) |
| 9027 | ;; context. (point-min) is the closest we get to the | 8983 | (if containing-sexp |
| 9028 | ;; class open brace. | 8984 | (progn |
| 9029 | (c-add-syntax 'access-label (point-min))))) | 8985 | (goto-char containing-sexp) |
| 8986 | (setq lim (c-most-enclosing-brace c-state-cache | ||
| 8987 | containing-sexp)) | ||
| 8988 | (c-backward-to-block-anchor lim) | ||
| 8989 | (c-add-stmt-syntax 'case-label nil t lim paren-state)) | ||
| 8990 | ;; Got a bogus label at the top level. In lack of better | ||
| 8991 | ;; alternatives, anchor it on (point-min). | ||
| 8992 | (c-add-syntax 'case-label (point-min)))) | ||
| 9030 | 8993 | ||
| 9031 | ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and | 8994 | ;; CASE 15: any other label |
| 9032 | ;; 17E. | 8995 | ((save-excursion |
| 9033 | ((setq placeholder (c-looking-at-inexpr-block | ||
| 9034 | (c-safe-position containing-sexp paren-state) | ||
| 9035 | containing-sexp | ||
| 9036 | ;; Have to turn on the heuristics after | ||
| 9037 | ;; the point even though it doesn't work | ||
| 9038 | ;; very well. C.f. test case class-16.pike. | ||
| 9039 | t)) | ||
| 9040 | (setq tmpsymbol (assq (car placeholder) | ||
| 9041 | '((inexpr-class . class-open) | ||
| 9042 | (inexpr-statement . block-open)))) | ||
| 9043 | (if tmpsymbol | ||
| 9044 | ;; It's a statement block or an anonymous class. | ||
| 9045 | (setq tmpsymbol (cdr tmpsymbol)) | ||
| 9046 | ;; It's a Pike lambda. Check whether we are between the | ||
| 9047 | ;; lambda keyword and the argument list or at the defun | ||
| 9048 | ;; opener. | ||
| 9049 | (setq tmpsymbol (if (eq char-after-ip ?{) | ||
| 9050 | 'inline-open | ||
| 9051 | 'lambda-intro-cont))) | ||
| 9052 | (goto-char (cdr placeholder)) | ||
| 9053 | (back-to-indentation) | 8996 | (back-to-indentation) |
| 9054 | (c-add-stmt-syntax tmpsymbol nil t | 8997 | (and (not (looking-at c-syntactic-ws-start)) |
| 9055 | (c-most-enclosing-brace c-state-cache (point)) | 8998 | (c-forward-label))) |
| 9056 | paren-state) | 8999 | (cond (containing-decl-open |
| 9057 | (unless (eq (point) (cdr placeholder)) | 9000 | (setq placeholder (c-add-class-syntax 'inclass |
| 9058 | (c-add-syntax (car placeholder)))) | 9001 | containing-decl-open |
| 9059 | 9002 | containing-decl-start | |
| 9060 | ;; CASE 5: Line is inside a declaration level block or at top level. | 9003 | containing-decl-kwd |
| 9061 | ((or containing-decl-open (null containing-sexp)) | 9004 | paren-state)) |
| 9062 | (cond | 9005 | ;; Append access-label with the same anchor point as |
| 9063 | 9006 | ;; inclass gets. | |
| 9064 | ;; CASE 5A: we are looking at a defun, brace list, class, | 9007 | (c-append-syntax 'access-label placeholder)) |
| 9065 | ;; or inline-inclass method opening brace | 9008 | |
| 9066 | ((setq special-brace-list | 9009 | (containing-sexp |
| 9067 | (or (and c-special-brace-lists | 9010 | (goto-char containing-sexp) |
| 9068 | (c-looking-at-special-brace-list)) | 9011 | (setq lim (c-most-enclosing-brace c-state-cache |
| 9069 | (eq char-after-ip ?{))) | 9012 | containing-sexp)) |
| 9070 | (cond | 9013 | (save-excursion |
| 9014 | (setq tmpsymbol | ||
| 9015 | (if (and (eq (c-beginning-of-statement-1 lim) 'up) | ||
| 9016 | (looking-at "switch\\>[^_]")) | ||
| 9017 | ;; If the surrounding statement is a switch then | ||
| 9018 | ;; let's analyze all labels as switch labels, so | ||
| 9019 | ;; that they get lined up consistently. | ||
| 9020 | 'case-label | ||
| 9021 | 'label))) | ||
| 9022 | (c-backward-to-block-anchor lim) | ||
| 9023 | (c-add-stmt-syntax tmpsymbol nil t lim paren-state)) | ||
| 9071 | 9024 | ||
| 9072 | ;; CASE 5A.1: Non-class declaration block open. | 9025 | (t |
| 9073 | ((save-excursion | 9026 | ;; A label on the top level. Treat it as a class |
| 9074 | (let (tmp) | 9027 | ;; context. (point-min) is the closest we get to the |
| 9075 | (and (eq char-after-ip ?{) | 9028 | ;; class open brace. |
| 9076 | (setq tmp (c-looking-at-decl-block containing-sexp t)) | 9029 | (c-add-syntax 'access-label (point-min))))) |
| 9077 | (progn | 9030 | |
| 9078 | (setq placeholder (point)) | 9031 | ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and |
| 9079 | (goto-char tmp) | 9032 | ;; 17E. |
| 9080 | (looking-at c-symbol-key)) | 9033 | ((setq placeholder (c-looking-at-inexpr-block |
| 9081 | (c-keyword-member | 9034 | (c-safe-position containing-sexp paren-state) |
| 9082 | (c-keyword-sym (setq keyword (match-string 0))) | 9035 | containing-sexp |
| 9083 | 'c-other-block-decl-kwds)))) | 9036 | ;; Have to turn on the heuristics after |
| 9084 | (goto-char placeholder) | 9037 | ;; the point even though it doesn't work |
| 9085 | (c-add-stmt-syntax | 9038 | ;; very well. C.f. test case class-16.pike. |
| 9086 | (if (string-equal keyword "extern") | 9039 | t)) |
| 9087 | ;; Special case for extern-lang-open. | 9040 | (setq tmpsymbol (assq (car placeholder) |
| 9088 | 'extern-lang-open | 9041 | '((inexpr-class . class-open) |
| 9089 | (intern (concat keyword "-open"))) | 9042 | (inexpr-statement . block-open)))) |
| 9090 | nil t containing-sexp paren-state)) | 9043 | (if tmpsymbol |
| 9091 | 9044 | ;; It's a statement block or an anonymous class. | |
| 9092 | ;; CASE 5A.2: we are looking at a class opening brace | 9045 | (setq tmpsymbol (cdr tmpsymbol)) |
| 9093 | ((save-excursion | 9046 | ;; It's a Pike lambda. Check whether we are between the |
| 9094 | (goto-char indent-point) | 9047 | ;; lambda keyword and the argument list or at the defun |
| 9095 | (skip-chars-forward " \t") | 9048 | ;; opener. |
| 9096 | (and (eq (char-after) ?{) | 9049 | (setq tmpsymbol (if (eq char-after-ip ?{) |
| 9097 | (c-looking-at-decl-block containing-sexp t) | 9050 | 'inline-open |
| 9098 | (setq placeholder (point)))) | 9051 | 'lambda-intro-cont))) |
| 9099 | (c-add-syntax 'class-open placeholder)) | 9052 | (goto-char (cdr placeholder)) |
| 9100 | 9053 | (back-to-indentation) | |
| 9101 | ;; CASE 5A.3: brace list open | 9054 | (c-add-stmt-syntax tmpsymbol nil t |
| 9102 | ((save-excursion | 9055 | (c-most-enclosing-brace c-state-cache (point)) |
| 9103 | (c-beginning-of-decl-1 lim) | 9056 | paren-state) |
| 9104 | (while (looking-at c-specifier-key) | 9057 | (unless (eq (point) (cdr placeholder)) |
| 9105 | (goto-char (match-end 1)) | 9058 | (c-add-syntax (car placeholder)))) |
| 9106 | (c-forward-syntactic-ws indent-point)) | ||
| 9107 | (setq placeholder (c-point 'boi)) | ||
| 9108 | (or (consp special-brace-list) | ||
| 9109 | (and (or (save-excursion | ||
| 9110 | (goto-char indent-point) | ||
| 9111 | (setq tmpsymbol nil) | ||
| 9112 | (while (and (> (point) placeholder) | ||
| 9113 | (zerop (c-backward-token-2 1 t)) | ||
| 9114 | (/= (char-after) ?=)) | ||
| 9115 | (and c-opt-inexpr-brace-list-key | ||
| 9116 | (not tmpsymbol) | ||
| 9117 | (looking-at c-opt-inexpr-brace-list-key) | ||
| 9118 | (setq tmpsymbol 'topmost-intro-cont))) | ||
| 9119 | (eq (char-after) ?=)) | ||
| 9120 | (looking-at c-brace-list-key)) | ||
| 9121 | (save-excursion | ||
| 9122 | (while (and (< (point) indent-point) | ||
| 9123 | (zerop (c-forward-token-2 1 t)) | ||
| 9124 | (not (memq (char-after) '(?\; ?\())))) | ||
| 9125 | (not (memq (char-after) '(?\; ?\())) | ||
| 9126 | )))) | ||
| 9127 | (if (and (not c-auto-newline-analysis) | ||
| 9128 | (c-major-mode-is 'java-mode) | ||
| 9129 | (eq tmpsymbol 'topmost-intro-cont)) | ||
| 9130 | ;; We're in Java and have found that the open brace | ||
| 9131 | ;; belongs to a "new Foo[]" initialization list, | ||
| 9132 | ;; which means the brace list is part of an | ||
| 9133 | ;; expression and not a top level definition. We | ||
| 9134 | ;; therefore treat it as any topmost continuation | ||
| 9135 | ;; even though the semantically correct symbol still | ||
| 9136 | ;; is brace-list-open, on the same grounds as in | ||
| 9137 | ;; case B.2. | ||
| 9138 | (progn | ||
| 9139 | (c-beginning-of-statement-1 lim) | ||
| 9140 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) | ||
| 9141 | (c-add-syntax 'brace-list-open placeholder))) | ||
| 9142 | |||
| 9143 | ;; CASE 5A.4: inline defun open | ||
| 9144 | ((and containing-decl-open | ||
| 9145 | (not (c-keyword-member containing-decl-kwd | ||
| 9146 | 'c-other-block-decl-kwds))) | ||
| 9147 | (c-add-syntax 'inline-open) | ||
| 9148 | (c-add-class-syntax 'inclass | ||
| 9149 | containing-decl-open | ||
| 9150 | containing-decl-start | ||
| 9151 | containing-decl-kwd | ||
| 9152 | paren-state)) | ||
| 9153 | |||
| 9154 | ;; CASE 5A.5: ordinary defun open | ||
| 9155 | (t | ||
| 9156 | (save-excursion | ||
| 9157 | (c-beginning-of-decl-1 lim) | ||
| 9158 | (while (looking-at c-specifier-key) | ||
| 9159 | (goto-char (match-end 1)) | ||
| 9160 | (c-forward-syntactic-ws indent-point)) | ||
| 9161 | (c-add-syntax 'defun-open (c-point 'boi)) | ||
| 9162 | ;; Bogus to use bol here, but it's the legacy. (Resolved, | ||
| 9163 | ;; 2007-11-09) | ||
| 9164 | )))) | ||
| 9165 | |||
| 9166 | ;; CASE 5B: After a function header but before the body (or | ||
| 9167 | ;; the ending semicolon if there's no body). | ||
| 9168 | ((save-excursion | ||
| 9169 | (when (setq placeholder (c-just-after-func-arglist-p lim)) | ||
| 9170 | (setq tmp-pos (point)))) | ||
| 9171 | (cond | ||
| 9172 | 9059 | ||
| 9173 | ;; CASE 5B.1: Member init list. | 9060 | ;; CASE 5: Line is inside a declaration level block or at top level. |
| 9174 | ((eq (char-after tmp-pos) ?:) | 9061 | ((or containing-decl-open (null containing-sexp)) |
| 9175 | (if (or (> tmp-pos indent-point) | 9062 | (cond |
| 9176 | (= (c-point 'bosws) (1+ tmp-pos))) | ||
| 9177 | (progn | ||
| 9178 | ;; There is no preceding member init clause. | ||
| 9179 | ;; Indent relative to the beginning of indentation | ||
| 9180 | ;; for the topmost-intro line that contains the | ||
| 9181 | ;; prototype's open paren. | ||
| 9182 | (goto-char placeholder) | ||
| 9183 | (c-add-syntax 'member-init-intro (c-point 'boi))) | ||
| 9184 | ;; Indent relative to the first member init clause. | ||
| 9185 | (goto-char (1+ tmp-pos)) | ||
| 9186 | (c-forward-syntactic-ws) | ||
| 9187 | (c-add-syntax 'member-init-cont (point)))) | ||
| 9188 | 9063 | ||
| 9189 | ;; CASE 5B.2: K&R arg decl intro | 9064 | ;; CASE 5A: we are looking at a defun, brace list, class, |
| 9190 | ((and c-recognize-knr-p | 9065 | ;; or inline-inclass method opening brace |
| 9191 | (c-in-knr-argdecl lim)) | 9066 | ((setq special-brace-list |
| 9192 | (c-beginning-of-statement-1 lim) | 9067 | (or (and c-special-brace-lists |
| 9193 | (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) | 9068 | (c-looking-at-special-brace-list)) |
| 9194 | (if containing-decl-open | 9069 | (eq char-after-ip ?{))) |
| 9195 | (c-add-class-syntax 'inclass | 9070 | (cond |
| 9196 | containing-decl-open | ||
| 9197 | containing-decl-start | ||
| 9198 | containing-decl-kwd | ||
| 9199 | paren-state))) | ||
| 9200 | |||
| 9201 | ;; CASE 5B.4: Nether region after a C++ or Java func | ||
| 9202 | ;; decl, which could include a `throws' declaration. | ||
| 9203 | (t | ||
| 9204 | (c-beginning-of-statement-1 lim) | ||
| 9205 | (c-add-syntax 'func-decl-cont (c-point 'boi)) | ||
| 9206 | ))) | ||
| 9207 | 9071 | ||
| 9208 | ;; CASE 5C: inheritance line. could be first inheritance | 9072 | ;; CASE 5A.1: Non-class declaration block open. |
| 9209 | ;; line, or continuation of a multiple inheritance | 9073 | ((save-excursion |
| 9210 | ((or (and (c-major-mode-is 'c++-mode) | 9074 | (let (tmp) |
| 9075 | (and (eq char-after-ip ?{) | ||
| 9076 | (setq tmp (c-looking-at-decl-block containing-sexp t)) | ||
| 9211 | (progn | 9077 | (progn |
| 9212 | (when (eq char-after-ip ?,) | 9078 | (setq placeholder (point)) |
| 9213 | (skip-chars-forward " \t") | 9079 | (goto-char tmp) |
| 9214 | (forward-char)) | 9080 | (looking-at c-symbol-key)) |
| 9215 | (looking-at c-opt-postfix-decl-spec-key))) | 9081 | (c-keyword-member |
| 9216 | (and (or (eq char-before-ip ?:) | 9082 | (c-keyword-sym (setq keyword (match-string 0))) |
| 9217 | ;; watch out for scope operator | 9083 | 'c-other-block-decl-kwds)))) |
| 9218 | (save-excursion | 9084 | (goto-char placeholder) |
| 9219 | (and (eq char-after-ip ?:) | 9085 | (c-add-stmt-syntax |
| 9220 | (c-safe (forward-char 1) t) | 9086 | (if (string-equal keyword "extern") |
| 9221 | (not (eq (char-after) ?:)) | 9087 | ;; Special case for extern-lang-open. |
| 9222 | ))) | 9088 | 'extern-lang-open |
| 9223 | (save-excursion | 9089 | (intern (concat keyword "-open"))) |
| 9224 | (c-backward-syntactic-ws lim) | 9090 | nil t containing-sexp paren-state)) |
| 9225 | (if (eq char-before-ip ?:) | ||
| 9226 | (progn | ||
| 9227 | (forward-char -1) | ||
| 9228 | (c-backward-syntactic-ws lim))) | ||
| 9229 | (back-to-indentation) | ||
| 9230 | (looking-at c-class-key))) | ||
| 9231 | ;; for Java | ||
| 9232 | (and (c-major-mode-is 'java-mode) | ||
| 9233 | (let ((fence (save-excursion | ||
| 9234 | (c-beginning-of-statement-1 lim) | ||
| 9235 | (point))) | ||
| 9236 | cont done) | ||
| 9237 | (save-excursion | ||
| 9238 | (while (not done) | ||
| 9239 | (cond ((looking-at c-opt-postfix-decl-spec-key) | ||
| 9240 | (setq injava-inher (cons cont (point)) | ||
| 9241 | done t)) | ||
| 9242 | ((or (not (c-safe (c-forward-sexp -1) t)) | ||
| 9243 | (<= (point) fence)) | ||
| 9244 | (setq done t)) | ||
| 9245 | ) | ||
| 9246 | (setq cont t))) | ||
| 9247 | injava-inher) | ||
| 9248 | (not (c-crosses-statement-barrier-p (cdr injava-inher) | ||
| 9249 | (point))) | ||
| 9250 | )) | ||
| 9251 | (cond | ||
| 9252 | |||
| 9253 | ;; CASE 5C.1: non-hanging colon on an inher intro | ||
| 9254 | ((eq char-after-ip ?:) | ||
| 9255 | (c-beginning-of-statement-1 lim) | ||
| 9256 | (c-add-syntax 'inher-intro (c-point 'boi)) | ||
| 9257 | ;; don't add inclass symbol since relative point already | ||
| 9258 | ;; contains any class offset | ||
| 9259 | ) | ||
| 9260 | 9091 | ||
| 9261 | ;; CASE 5C.2: hanging colon on an inher intro | 9092 | ;; CASE 5A.2: we are looking at a class opening brace |
| 9262 | ((eq char-before-ip ?:) | ||
| 9263 | (c-beginning-of-statement-1 lim) | ||
| 9264 | (c-add-syntax 'inher-intro (c-point 'boi)) | ||
| 9265 | (if containing-decl-open | ||
| 9266 | (c-add-class-syntax 'inclass | ||
| 9267 | containing-decl-open | ||
| 9268 | containing-decl-start | ||
| 9269 | containing-decl-kwd | ||
| 9270 | paren-state))) | ||
| 9271 | |||
| 9272 | ;; CASE 5C.3: in a Java implements/extends | ||
| 9273 | (injava-inher | ||
| 9274 | (let ((where (cdr injava-inher)) | ||
| 9275 | (cont (car injava-inher))) | ||
| 9276 | (goto-char where) | ||
| 9277 | (cond ((looking-at "throws\\>[^_]") | ||
| 9278 | (c-add-syntax 'func-decl-cont | ||
| 9279 | (progn (c-beginning-of-statement-1 lim) | ||
| 9280 | (c-point 'boi)))) | ||
| 9281 | (cont (c-add-syntax 'inher-cont where)) | ||
| 9282 | (t (c-add-syntax 'inher-intro | ||
| 9283 | (progn (goto-char (cdr injava-inher)) | ||
| 9284 | (c-beginning-of-statement-1 lim) | ||
| 9285 | (point)))) | ||
| 9286 | ))) | ||
| 9287 | |||
| 9288 | ;; CASE 5C.4: a continued inheritance line | ||
| 9289 | (t | ||
| 9290 | (c-beginning-of-inheritance-list lim) | ||
| 9291 | (c-add-syntax 'inher-cont (point)) | ||
| 9292 | ;; don't add inclass symbol since relative point already | ||
| 9293 | ;; contains any class offset | ||
| 9294 | ))) | ||
| 9295 | |||
| 9296 | ;; CASE 5D: this could be a top-level initialization, a | ||
| 9297 | ;; member init list continuation, or a template argument | ||
| 9298 | ;; list continuation. | ||
| 9299 | ((save-excursion | 9093 | ((save-excursion |
| 9300 | ;; Note: We use the fact that lim is always after any | 9094 | (goto-char indent-point) |
| 9301 | ;; preceding brace sexp. | 9095 | (skip-chars-forward " \t") |
| 9302 | (if c-recognize-<>-arglists | 9096 | (and (eq (char-after) ?{) |
| 9303 | (while (and | 9097 | (c-looking-at-decl-block containing-sexp t) |
| 9304 | (progn | 9098 | (setq placeholder (point)))) |
| 9305 | (c-syntactic-skip-backward "^;,=<>" lim t) | 9099 | (c-add-syntax 'class-open placeholder)) |
| 9306 | (> (point) lim)) | 9100 | |
| 9307 | (or | 9101 | ;; CASE 5A.3: brace list open |
| 9308 | (when c-overloadable-operators-regexp | 9102 | ((save-excursion |
| 9309 | (when (setq placeholder (c-after-special-operator-id lim)) | 9103 | (c-beginning-of-decl-1 lim) |
| 9310 | (goto-char placeholder) | 9104 | (while (looking-at c-specifier-key) |
| 9311 | t)) | 9105 | (goto-char (match-end 1)) |
| 9312 | (cond | 9106 | (c-forward-syntactic-ws indent-point)) |
| 9313 | ((eq (char-before) ?>) | 9107 | (setq placeholder (c-point 'boi)) |
| 9314 | (or (c-backward-<>-arglist nil lim) | 9108 | (or (consp special-brace-list) |
| 9315 | (backward-char)) | 9109 | (and (or (save-excursion |
| 9316 | t) | 9110 | (goto-char indent-point) |
| 9317 | ((eq (char-before) ?<) | 9111 | (setq tmpsymbol nil) |
| 9318 | (backward-char) | 9112 | (while (and (> (point) placeholder) |
| 9319 | (if (save-excursion | 9113 | (zerop (c-backward-token-2 1 t)) |
| 9320 | (c-forward-<>-arglist nil)) | 9114 | (/= (char-after) ?=)) |
| 9321 | (progn (forward-char) | 9115 | (and c-opt-inexpr-brace-list-key |
| 9322 | nil) | 9116 | (not tmpsymbol) |
| 9323 | t)) | 9117 | (looking-at c-opt-inexpr-brace-list-key) |
| 9324 | (t nil))))) | 9118 | (setq tmpsymbol 'topmost-intro-cont))) |
| 9325 | ;; NB: No c-after-special-operator-id stuff in this | 9119 | (eq (char-after) ?=)) |
| 9326 | ;; clause - we assume only C++ needs it. | 9120 | (looking-at c-brace-list-key)) |
| 9327 | (c-syntactic-skip-backward "^;,=" lim t)) | 9121 | (save-excursion |
| 9328 | (memq (char-before) '(?, ?= ?<))) | 9122 | (while (and (< (point) indent-point) |
| 9329 | (cond | 9123 | (zerop (c-forward-token-2 1 t)) |
| 9330 | 9124 | (not (memq (char-after) '(?\; ?\())))) | |
| 9331 | ;; CASE 5D.3: perhaps a template list continuation? | 9125 | (not (memq (char-after) '(?\; ?\())) |
| 9332 | ((and (c-major-mode-is 'c++-mode) | 9126 | )))) |
| 9333 | (save-excursion | 9127 | (if (and (not c-auto-newline-analysis) |
| 9334 | (save-restriction | 9128 | (c-major-mode-is 'java-mode) |
| 9335 | (c-with-syntax-table c++-template-syntax-table | 9129 | (eq tmpsymbol 'topmost-intro-cont)) |
| 9336 | (goto-char indent-point) | 9130 | ;; We're in Java and have found that the open brace |
| 9337 | (setq placeholder (c-up-list-backward)) | 9131 | ;; belongs to a "new Foo[]" initialization list, |
| 9338 | (and placeholder | 9132 | ;; which means the brace list is part of an |
| 9339 | (eq (char-after placeholder) ?<)))))) | 9133 | ;; expression and not a top level definition. We |
| 9340 | (c-with-syntax-table c++-template-syntax-table | 9134 | ;; therefore treat it as any topmost continuation |
| 9341 | (goto-char placeholder) | 9135 | ;; even though the semantically correct symbol still |
| 9342 | (c-beginning-of-statement-1 lim t) | 9136 | ;; is brace-list-open, on the same grounds as in |
| 9343 | (if (save-excursion | 9137 | ;; case B.2. |
| 9344 | (c-backward-syntactic-ws lim) | 9138 | (progn |
| 9345 | (eq (char-before) ?<)) | 9139 | (c-beginning-of-statement-1 lim) |
| 9346 | ;; In a nested template arglist. | 9140 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) |
| 9347 | (progn | 9141 | (c-add-syntax 'brace-list-open placeholder))) |
| 9348 | (goto-char placeholder) | 9142 | |
| 9349 | (c-syntactic-skip-backward "^,;" lim t) | 9143 | ;; CASE 5A.4: inline defun open |
| 9350 | (c-forward-syntactic-ws)) | 9144 | ((and containing-decl-open |
| 9351 | (back-to-indentation))) | 9145 | (not (c-keyword-member containing-decl-kwd |
| 9352 | ;; FIXME: Should use c-add-stmt-syntax, but it's not yet | 9146 | 'c-other-block-decl-kwds))) |
| 9353 | ;; template aware. | 9147 | (c-add-syntax 'inline-open) |
| 9354 | (c-add-syntax 'template-args-cont (point) placeholder)) | 9148 | (c-add-class-syntax 'inclass |
| 9355 | |||
| 9356 | ;; CASE 5D.4: perhaps a multiple inheritance line? | ||
| 9357 | ((and (c-major-mode-is 'c++-mode) | ||
| 9358 | (save-excursion | ||
| 9359 | (c-beginning-of-statement-1 lim) | ||
| 9360 | (setq placeholder (point)) | ||
| 9361 | (if (looking-at "static\\>[^_]") | ||
| 9362 | (c-forward-token-2 1 nil indent-point)) | ||
| 9363 | (and (looking-at c-class-key) | ||
| 9364 | (zerop (c-forward-token-2 2 nil indent-point)) | ||
| 9365 | (if (eq (char-after) ?<) | ||
| 9366 | (c-with-syntax-table c++-template-syntax-table | ||
| 9367 | (zerop (c-forward-token-2 1 t indent-point))) | ||
| 9368 | t) | ||
| 9369 | (eq (char-after) ?:)))) | ||
| 9370 | (goto-char placeholder) | ||
| 9371 | (c-add-syntax 'inher-cont (c-point 'boi))) | ||
| 9372 | |||
| 9373 | ;; CASE 5D.5: Continuation of the "expression part" of a | ||
| 9374 | ;; top level construct. Or, perhaps, an unrecognised construct. | ||
| 9375 | (t | ||
| 9376 | (while (and (setq placeholder (point)) | ||
| 9377 | (eq (car (c-beginning-of-decl-1 containing-sexp)) | ||
| 9378 | 'same) | ||
| 9379 | (save-excursion | ||
| 9380 | (c-backward-syntactic-ws) | ||
| 9381 | (eq (char-before) ?})) | ||
| 9382 | (< (point) placeholder))) | ||
| 9383 | (c-add-stmt-syntax | ||
| 9384 | (cond | ||
| 9385 | ((eq (point) placeholder) 'statement) ; unrecognised construct | ||
| 9386 | ;; A preceding comma at the top level means that a | ||
| 9387 | ;; new variable declaration starts here. Use | ||
| 9388 | ;; topmost-intro-cont for it, for consistency with | ||
| 9389 | ;; the first variable declaration. C.f. case 5N. | ||
| 9390 | ((eq char-before-ip ?,) 'topmost-intro-cont) | ||
| 9391 | (t 'statement-cont)) | ||
| 9392 | nil nil containing-sexp paren-state)) | ||
| 9393 | )) | ||
| 9394 | |||
| 9395 | ;; CASE 5F: Close of a non-class declaration level block. | ||
| 9396 | ((and (eq char-after-ip ?}) | ||
| 9397 | (c-keyword-member containing-decl-kwd | ||
| 9398 | 'c-other-block-decl-kwds)) | ||
| 9399 | ;; This is inconsistent: Should use `containing-decl-open' | ||
| 9400 | ;; here if it's at boi, like in case 5J. | ||
| 9401 | (goto-char containing-decl-start) | ||
| 9402 | (c-add-stmt-syntax | ||
| 9403 | (if (string-equal (symbol-name containing-decl-kwd) "extern") | ||
| 9404 | ;; Special case for compatibility with the | ||
| 9405 | ;; extern-lang syntactic symbols. | ||
| 9406 | 'extern-lang-close | ||
| 9407 | (intern (concat (symbol-name containing-decl-kwd) | ||
| 9408 | "-close"))) | ||
| 9409 | nil t | ||
| 9410 | (c-most-enclosing-brace paren-state (point)) | ||
| 9411 | paren-state)) | ||
| 9412 | |||
| 9413 | ;; CASE 5G: we are looking at the brace which closes the | ||
| 9414 | ;; enclosing nested class decl | ||
| 9415 | ((and containing-sexp | ||
| 9416 | (eq char-after-ip ?}) | ||
| 9417 | (eq containing-decl-open containing-sexp)) | ||
| 9418 | (c-add-class-syntax 'class-close | ||
| 9419 | containing-decl-open | 9149 | containing-decl-open |
| 9420 | containing-decl-start | 9150 | containing-decl-start |
| 9421 | containing-decl-kwd | 9151 | containing-decl-kwd |
| 9422 | paren-state)) | 9152 | paren-state)) |
| 9423 | 9153 | ||
| 9424 | ;; CASE 5H: we could be looking at subsequent knr-argdecls | 9154 | ;; CASE 5A.5: ordinary defun open |
| 9155 | (t | ||
| 9156 | (save-excursion | ||
| 9157 | (c-beginning-of-decl-1 lim) | ||
| 9158 | (while (looking-at c-specifier-key) | ||
| 9159 | (goto-char (match-end 1)) | ||
| 9160 | (c-forward-syntactic-ws indent-point)) | ||
| 9161 | (c-add-syntax 'defun-open (c-point 'boi)) | ||
| 9162 | ;; Bogus to use bol here, but it's the legacy. (Resolved, | ||
| 9163 | ;; 2007-11-09) | ||
| 9164 | )))) | ||
| 9165 | |||
| 9166 | ;; CASE 5B: After a function header but before the body (or | ||
| 9167 | ;; the ending semicolon if there's no body). | ||
| 9168 | ((save-excursion | ||
| 9169 | (when (setq placeholder (c-just-after-func-arglist-p lim)) | ||
| 9170 | (setq tmp-pos (point)))) | ||
| 9171 | (cond | ||
| 9172 | |||
| 9173 | ;; CASE 5B.1: Member init list. | ||
| 9174 | ((eq (char-after tmp-pos) ?:) | ||
| 9175 | (if (or (> tmp-pos indent-point) | ||
| 9176 | (= (c-point 'bosws) (1+ tmp-pos))) | ||
| 9177 | (progn | ||
| 9178 | ;; There is no preceding member init clause. | ||
| 9179 | ;; Indent relative to the beginning of indentation | ||
| 9180 | ;; for the topmost-intro line that contains the | ||
| 9181 | ;; prototype's open paren. | ||
| 9182 | (goto-char placeholder) | ||
| 9183 | (c-add-syntax 'member-init-intro (c-point 'boi))) | ||
| 9184 | ;; Indent relative to the first member init clause. | ||
| 9185 | (goto-char (1+ tmp-pos)) | ||
| 9186 | (c-forward-syntactic-ws) | ||
| 9187 | (c-add-syntax 'member-init-cont (point)))) | ||
| 9188 | |||
| 9189 | ;; CASE 5B.2: K&R arg decl intro | ||
| 9425 | ((and c-recognize-knr-p | 9190 | ((and c-recognize-knr-p |
| 9426 | (not containing-sexp) ; can't be knr inside braces. | 9191 | (c-in-knr-argdecl lim)) |
| 9427 | (not (eq char-before-ip ?})) | 9192 | (c-beginning-of-statement-1 lim) |
| 9428 | (save-excursion | 9193 | (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) |
| 9429 | (setq placeholder (cdr (c-beginning-of-decl-1 lim))) | 9194 | (if containing-decl-open |
| 9430 | (and placeholder | 9195 | (c-add-class-syntax 'inclass |
| 9431 | ;; Do an extra check to avoid tripping up on | 9196 | containing-decl-open |
| 9432 | ;; statements that occur in invalid contexts | 9197 | containing-decl-start |
| 9433 | ;; (e.g. in macro bodies where we don't really | 9198 | containing-decl-kwd |
| 9434 | ;; know the context of what we're looking at). | 9199 | paren-state))) |
| 9435 | (not (and c-opt-block-stmt-key | 9200 | |
| 9436 | (looking-at c-opt-block-stmt-key))))) | 9201 | ;; CASE 5B.4: Nether region after a C++ or Java func |
| 9437 | (< placeholder indent-point)) | 9202 | ;; decl, which could include a `throws' declaration. |
| 9438 | (goto-char placeholder) | 9203 | (t |
| 9439 | (c-add-syntax 'knr-argdecl (point))) | 9204 | (c-beginning-of-statement-1 lim) |
| 9440 | 9205 | (c-add-syntax 'func-decl-cont (c-point 'boi)) | |
| 9441 | ;; CASE 5I: ObjC method definition. | 9206 | ))) |
| 9442 | ((and c-opt-method-key | 9207 | |
| 9443 | (looking-at c-opt-method-key)) | 9208 | ;; CASE 5C: inheritance line. could be first inheritance |
| 9444 | (c-beginning-of-statement-1 nil t) | 9209 | ;; line, or continuation of a multiple inheritance |
| 9445 | (if (= (point) indent-point) | 9210 | ((or (and (c-major-mode-is 'c++-mode) |
| 9446 | ;; Handle the case when it's the first (non-comment) | 9211 | (progn |
| 9447 | ;; thing in the buffer. Can't look for a 'same return | 9212 | (when (eq char-after-ip ?,) |
| 9448 | ;; value from cbos1 since ObjC directives currently | 9213 | (skip-chars-forward " \t") |
| 9449 | ;; aren't recognized fully, so that we get 'same | 9214 | (forward-char)) |
| 9450 | ;; instead of 'previous if it moved over a preceding | 9215 | (looking-at c-opt-postfix-decl-spec-key))) |
| 9451 | ;; directive. | 9216 | (and (or (eq char-before-ip ?:) |
| 9452 | (goto-char (point-min))) | 9217 | ;; watch out for scope operator |
| 9453 | (c-add-syntax 'objc-method-intro (c-point 'boi))) | 9218 | (save-excursion |
| 9454 | 9219 | (and (eq char-after-ip ?:) | |
| 9455 | ;; CASE 5P: AWK pattern or function or continuation | 9220 | (c-safe (forward-char 1) t) |
| 9456 | ;; thereof. | 9221 | (not (eq (char-after) ?:)) |
| 9457 | ((c-major-mode-is 'awk-mode) | 9222 | ))) |
| 9458 | (setq placeholder (point)) | ||
| 9459 | (c-add-stmt-syntax | ||
| 9460 | (if (and (eq (c-beginning-of-statement-1) 'same) | ||
| 9461 | (/= (point) placeholder)) | ||
| 9462 | 'topmost-intro-cont | ||
| 9463 | 'topmost-intro) | ||
| 9464 | nil nil | ||
| 9465 | containing-sexp paren-state)) | ||
| 9466 | |||
| 9467 | ;; CASE 5N: At a variable declaration that follows a class | ||
| 9468 | ;; definition or some other block declaration that doesn't | ||
| 9469 | ;; end at the closing '}'. C.f. case 5D.5. | ||
| 9470 | ((progn | ||
| 9471 | (c-backward-syntactic-ws lim) | ||
| 9472 | (and (eq (char-before) ?}) | ||
| 9473 | (save-excursion | 9223 | (save-excursion |
| 9474 | (let ((start (point))) | 9224 | (c-backward-syntactic-ws lim) |
| 9475 | (if (and c-state-cache | 9225 | (if (eq char-before-ip ?:) |
| 9476 | (consp (car c-state-cache)) | 9226 | (progn |
| 9477 | (eq (cdar c-state-cache) (point))) | 9227 | (forward-char -1) |
| 9478 | ;; Speed up the backward search a bit. | 9228 | (c-backward-syntactic-ws lim))) |
| 9479 | (goto-char (caar c-state-cache))) | 9229 | (back-to-indentation) |
| 9480 | (c-beginning-of-decl-1 containing-sexp) | 9230 | (looking-at c-class-key))) |
| 9481 | (setq placeholder (point)) | 9231 | ;; for Java |
| 9482 | (if (= start (point)) | 9232 | (and (c-major-mode-is 'java-mode) |
| 9483 | ;; The '}' is unbalanced. | 9233 | (let ((fence (save-excursion |
| 9484 | nil | 9234 | (c-beginning-of-statement-1 lim) |
| 9485 | (c-end-of-decl-1) | 9235 | (point))) |
| 9486 | (>= (point) indent-point)))))) | 9236 | cont done) |
| 9487 | (goto-char placeholder) | 9237 | (save-excursion |
| 9488 | (c-add-stmt-syntax 'topmost-intro-cont nil nil | 9238 | (while (not done) |
| 9489 | containing-sexp paren-state)) | 9239 | (cond ((looking-at c-opt-postfix-decl-spec-key) |
| 9240 | (setq injava-inher (cons cont (point)) | ||
| 9241 | done t)) | ||
| 9242 | ((or (not (c-safe (c-forward-sexp -1) t)) | ||
| 9243 | (<= (point) fence)) | ||
| 9244 | (setq done t)) | ||
| 9245 | ) | ||
| 9246 | (setq cont t))) | ||
| 9247 | injava-inher) | ||
| 9248 | (not (c-crosses-statement-barrier-p (cdr injava-inher) | ||
| 9249 | (point))) | ||
| 9250 | )) | ||
| 9251 | (cond | ||
| 9490 | 9252 | ||
| 9491 | ;; NOTE: The point is at the end of the previous token here. | 9253 | ;; CASE 5C.1: non-hanging colon on an inher intro |
| 9254 | ((eq char-after-ip ?:) | ||
| 9255 | (c-beginning-of-statement-1 lim) | ||
| 9256 | (c-add-syntax 'inher-intro (c-point 'boi)) | ||
| 9257 | ;; don't add inclass symbol since relative point already | ||
| 9258 | ;; contains any class offset | ||
| 9259 | ) | ||
| 9492 | 9260 | ||
| 9493 | ;; CASE 5J: we are at the topmost level, make | 9261 | ;; CASE 5C.2: hanging colon on an inher intro |
| 9494 | ;; sure we skip back past any access specifiers | 9262 | ((eq char-before-ip ?:) |
| 9495 | ((and | 9263 | (c-beginning-of-statement-1 lim) |
| 9496 | ;; A macro continuation line is never at top level. | 9264 | (c-add-syntax 'inher-intro (c-point 'boi)) |
| 9497 | (not (and macro-start | ||
| 9498 | (> indent-point macro-start))) | ||
| 9499 | (save-excursion | ||
| 9500 | (setq placeholder (point)) | ||
| 9501 | (or (memq char-before-ip '(?\; ?{ ?} nil)) | ||
| 9502 | (c-at-vsemi-p before-ws-ip) | ||
| 9503 | (when (and (eq char-before-ip ?:) | ||
| 9504 | (eq (c-beginning-of-statement-1 lim) | ||
| 9505 | 'label)) | ||
| 9506 | (c-backward-syntactic-ws lim) | ||
| 9507 | (setq placeholder (point))) | ||
| 9508 | (and (c-major-mode-is 'objc-mode) | ||
| 9509 | (catch 'not-in-directive | ||
| 9510 | (c-beginning-of-statement-1 lim) | ||
| 9511 | (setq placeholder (point)) | ||
| 9512 | (while (and (c-forward-objc-directive) | ||
| 9513 | (< (point) indent-point)) | ||
| 9514 | (c-forward-syntactic-ws) | ||
| 9515 | (if (>= (point) indent-point) | ||
| 9516 | (throw 'not-in-directive t)) | ||
| 9517 | (setq placeholder (point))) | ||
| 9518 | nil))))) | ||
| 9519 | ;; For historic reasons we anchor at bol of the last | ||
| 9520 | ;; line of the previous declaration. That's clearly | ||
| 9521 | ;; highly bogus and useless, and it makes our lives hard | ||
| 9522 | ;; to remain compatible. :P | ||
| 9523 | (goto-char placeholder) | ||
| 9524 | (c-add-syntax 'topmost-intro (c-point 'bol)) | ||
| 9525 | (if containing-decl-open | 9265 | (if containing-decl-open |
| 9526 | (if (c-keyword-member containing-decl-kwd | 9266 | (c-add-class-syntax 'inclass |
| 9527 | 'c-other-block-decl-kwds) | 9267 | containing-decl-open |
| 9528 | (progn | 9268 | containing-decl-start |
| 9529 | (goto-char (c-brace-anchor-point containing-decl-open)) | 9269 | containing-decl-kwd |
| 9530 | (c-add-stmt-syntax | 9270 | paren-state))) |
| 9531 | (if (string-equal (symbol-name containing-decl-kwd) | 9271 | |
| 9532 | "extern") | 9272 | ;; CASE 5C.3: in a Java implements/extends |
| 9533 | ;; Special case for compatibility with the | 9273 | (injava-inher |
| 9534 | ;; extern-lang syntactic symbols. | 9274 | (let ((where (cdr injava-inher)) |
| 9535 | 'inextern-lang | 9275 | (cont (car injava-inher))) |
| 9536 | (intern (concat "in" | 9276 | (goto-char where) |
| 9537 | (symbol-name containing-decl-kwd)))) | 9277 | (cond ((looking-at "throws\\>[^_]") |
| 9538 | nil t | 9278 | (c-add-syntax 'func-decl-cont |
| 9539 | (c-most-enclosing-brace paren-state (point)) | 9279 | (progn (c-beginning-of-statement-1 lim) |
| 9540 | paren-state)) | 9280 | (c-point 'boi)))) |
| 9541 | (c-add-class-syntax 'inclass | 9281 | (cont (c-add-syntax 'inher-cont where)) |
| 9542 | containing-decl-open | 9282 | (t (c-add-syntax 'inher-intro |
| 9543 | containing-decl-start | 9283 | (progn (goto-char (cdr injava-inher)) |
| 9544 | containing-decl-kwd | 9284 | (c-beginning-of-statement-1 lim) |
| 9545 | paren-state))) | 9285 | (point)))) |
| 9546 | (when (and c-syntactic-indentation-in-macros | 9286 | ))) |
| 9547 | macro-start | 9287 | |
| 9548 | (/= macro-start (c-point 'boi indent-point))) | 9288 | ;; CASE 5C.4: a continued inheritance line |
| 9549 | (c-add-syntax 'cpp-define-intro) | 9289 | (t |
| 9550 | (setq macro-start nil))) | 9290 | (c-beginning-of-inheritance-list lim) |
| 9551 | 9291 | (c-add-syntax 'inher-cont (point)) | |
| 9552 | ;; CASE 5K: we are at an ObjC method definition | 9292 | ;; don't add inclass symbol since relative point already |
| 9553 | ;; continuation line. | 9293 | ;; contains any class offset |
| 9554 | ((and c-opt-method-key | 9294 | ))) |
| 9295 | |||
| 9296 | ;; CASE 5D: this could be a top-level initialization, a | ||
| 9297 | ;; member init list continuation, or a template argument | ||
| 9298 | ;; list continuation. | ||
| 9299 | ((save-excursion | ||
| 9300 | ;; Note: We use the fact that lim is always after any | ||
| 9301 | ;; preceding brace sexp. | ||
| 9302 | (if c-recognize-<>-arglists | ||
| 9303 | (while (and | ||
| 9304 | (progn | ||
| 9305 | (c-syntactic-skip-backward "^;,=<>" lim t) | ||
| 9306 | (> (point) lim)) | ||
| 9307 | (or | ||
| 9308 | (when c-overloadable-operators-regexp | ||
| 9309 | (when (setq placeholder (c-after-special-operator-id lim)) | ||
| 9310 | (goto-char placeholder) | ||
| 9311 | t)) | ||
| 9312 | (cond | ||
| 9313 | ((eq (char-before) ?>) | ||
| 9314 | (or (c-backward-<>-arglist nil lim) | ||
| 9315 | (backward-char)) | ||
| 9316 | t) | ||
| 9317 | ((eq (char-before) ?<) | ||
| 9318 | (backward-char) | ||
| 9319 | (if (save-excursion | ||
| 9320 | (c-forward-<>-arglist nil)) | ||
| 9321 | (progn (forward-char) | ||
| 9322 | nil) | ||
| 9323 | t)) | ||
| 9324 | (t nil))))) | ||
| 9325 | ;; NB: No c-after-special-operator-id stuff in this | ||
| 9326 | ;; clause - we assume only C++ needs it. | ||
| 9327 | (c-syntactic-skip-backward "^;,=" lim t)) | ||
| 9328 | (memq (char-before) '(?, ?= ?<))) | ||
| 9329 | (cond | ||
| 9330 | |||
| 9331 | ;; CASE 5D.3: perhaps a template list continuation? | ||
| 9332 | ((and (c-major-mode-is 'c++-mode) | ||
| 9333 | (save-excursion | ||
| 9334 | (save-restriction | ||
| 9335 | (c-with-syntax-table c++-template-syntax-table | ||
| 9336 | (goto-char indent-point) | ||
| 9337 | (setq placeholder (c-up-list-backward)) | ||
| 9338 | (and placeholder | ||
| 9339 | (eq (char-after placeholder) ?<)))))) | ||
| 9340 | (c-with-syntax-table c++-template-syntax-table | ||
| 9341 | (goto-char placeholder) | ||
| 9342 | (c-beginning-of-statement-1 lim t) | ||
| 9343 | (if (save-excursion | ||
| 9344 | (c-backward-syntactic-ws lim) | ||
| 9345 | (eq (char-before) ?<)) | ||
| 9346 | ;; In a nested template arglist. | ||
| 9347 | (progn | ||
| 9348 | (goto-char placeholder) | ||
| 9349 | (c-syntactic-skip-backward "^,;" lim t) | ||
| 9350 | (c-forward-syntactic-ws)) | ||
| 9351 | (back-to-indentation))) | ||
| 9352 | ;; FIXME: Should use c-add-stmt-syntax, but it's not yet | ||
| 9353 | ;; template aware. | ||
| 9354 | (c-add-syntax 'template-args-cont (point) placeholder)) | ||
| 9355 | |||
| 9356 | ;; CASE 5D.4: perhaps a multiple inheritance line? | ||
| 9357 | ((and (c-major-mode-is 'c++-mode) | ||
| 9555 | (save-excursion | 9358 | (save-excursion |
| 9556 | (c-beginning-of-statement-1 lim) | 9359 | (c-beginning-of-statement-1 lim) |
| 9557 | (beginning-of-line) | 9360 | (setq placeholder (point)) |
| 9558 | (when (looking-at c-opt-method-key) | 9361 | (if (looking-at "static\\>[^_]") |
| 9559 | (setq placeholder (point))))) | 9362 | (c-forward-token-2 1 nil indent-point)) |
| 9560 | (c-add-syntax 'objc-method-args-cont placeholder)) | 9363 | (and (looking-at c-class-key) |
| 9364 | (zerop (c-forward-token-2 2 nil indent-point)) | ||
| 9365 | (if (eq (char-after) ?<) | ||
| 9366 | (c-with-syntax-table c++-template-syntax-table | ||
| 9367 | (zerop (c-forward-token-2 1 t indent-point))) | ||
| 9368 | t) | ||
| 9369 | (eq (char-after) ?:)))) | ||
| 9370 | (goto-char placeholder) | ||
| 9371 | (c-add-syntax 'inher-cont (c-point 'boi))) | ||
| 9372 | |||
| 9373 | ;; CASE 5D.5: Continuation of the "expression part" of a | ||
| 9374 | ;; top level construct. Or, perhaps, an unrecognised construct. | ||
| 9375 | (t | ||
| 9376 | (while (and (setq placeholder (point)) | ||
| 9377 | (eq (car (c-beginning-of-decl-1 containing-sexp)) | ||
| 9378 | 'same) | ||
| 9379 | (save-excursion | ||
| 9380 | (c-backward-syntactic-ws) | ||
| 9381 | (eq (char-before) ?})) | ||
| 9382 | (< (point) placeholder))) | ||
| 9383 | (c-add-stmt-syntax | ||
| 9384 | (cond | ||
| 9385 | ((eq (point) placeholder) 'statement) ; unrecognised construct | ||
| 9386 | ;; A preceding comma at the top level means that a | ||
| 9387 | ;; new variable declaration starts here. Use | ||
| 9388 | ;; topmost-intro-cont for it, for consistency with | ||
| 9389 | ;; the first variable declaration. C.f. case 5N. | ||
| 9390 | ((eq char-before-ip ?,) 'topmost-intro-cont) | ||
| 9391 | (t 'statement-cont)) | ||
| 9392 | nil nil containing-sexp paren-state)) | ||
| 9393 | )) | ||
| 9394 | |||
| 9395 | ;; CASE 5F: Close of a non-class declaration level block. | ||
| 9396 | ((and (eq char-after-ip ?}) | ||
| 9397 | (c-keyword-member containing-decl-kwd | ||
| 9398 | 'c-other-block-decl-kwds)) | ||
| 9399 | ;; This is inconsistent: Should use `containing-decl-open' | ||
| 9400 | ;; here if it's at boi, like in case 5J. | ||
| 9401 | (goto-char containing-decl-start) | ||
| 9402 | (c-add-stmt-syntax | ||
| 9403 | (if (string-equal (symbol-name containing-decl-kwd) "extern") | ||
| 9404 | ;; Special case for compatibility with the | ||
| 9405 | ;; extern-lang syntactic symbols. | ||
| 9406 | 'extern-lang-close | ||
| 9407 | (intern (concat (symbol-name containing-decl-kwd) | ||
| 9408 | "-close"))) | ||
| 9409 | nil t | ||
| 9410 | (c-most-enclosing-brace paren-state (point)) | ||
| 9411 | paren-state)) | ||
| 9412 | |||
| 9413 | ;; CASE 5G: we are looking at the brace which closes the | ||
| 9414 | ;; enclosing nested class decl | ||
| 9415 | ((and containing-sexp | ||
| 9416 | (eq char-after-ip ?}) | ||
| 9417 | (eq containing-decl-open containing-sexp)) | ||
| 9418 | (c-add-class-syntax 'class-close | ||
| 9419 | containing-decl-open | ||
| 9420 | containing-decl-start | ||
| 9421 | containing-decl-kwd | ||
| 9422 | paren-state)) | ||
| 9423 | |||
| 9424 | ;; CASE 5H: we could be looking at subsequent knr-argdecls | ||
| 9425 | ((and c-recognize-knr-p | ||
| 9426 | (not containing-sexp) ; can't be knr inside braces. | ||
| 9427 | (not (eq char-before-ip ?})) | ||
| 9428 | (save-excursion | ||
| 9429 | (setq placeholder (cdr (c-beginning-of-decl-1 lim))) | ||
| 9430 | (and placeholder | ||
| 9431 | ;; Do an extra check to avoid tripping up on | ||
| 9432 | ;; statements that occur in invalid contexts | ||
| 9433 | ;; (e.g. in macro bodies where we don't really | ||
| 9434 | ;; know the context of what we're looking at). | ||
| 9435 | (not (and c-opt-block-stmt-key | ||
| 9436 | (looking-at c-opt-block-stmt-key))))) | ||
| 9437 | (< placeholder indent-point)) | ||
| 9438 | (goto-char placeholder) | ||
| 9439 | (c-add-syntax 'knr-argdecl (point))) | ||
| 9440 | |||
| 9441 | ;; CASE 5I: ObjC method definition. | ||
| 9442 | ((and c-opt-method-key | ||
| 9443 | (looking-at c-opt-method-key)) | ||
| 9444 | (c-beginning-of-statement-1 nil t) | ||
| 9445 | (if (= (point) indent-point) | ||
| 9446 | ;; Handle the case when it's the first (non-comment) | ||
| 9447 | ;; thing in the buffer. Can't look for a 'same return | ||
| 9448 | ;; value from cbos1 since ObjC directives currently | ||
| 9449 | ;; aren't recognized fully, so that we get 'same | ||
| 9450 | ;; instead of 'previous if it moved over a preceding | ||
| 9451 | ;; directive. | ||
| 9452 | (goto-char (point-min))) | ||
| 9453 | (c-add-syntax 'objc-method-intro (c-point 'boi))) | ||
| 9454 | |||
| 9455 | ;; CASE 5P: AWK pattern or function or continuation | ||
| 9456 | ;; thereof. | ||
| 9457 | ((c-major-mode-is 'awk-mode) | ||
| 9458 | (setq placeholder (point)) | ||
| 9459 | (c-add-stmt-syntax | ||
| 9460 | (if (and (eq (c-beginning-of-statement-1) 'same) | ||
| 9461 | (/= (point) placeholder)) | ||
| 9462 | 'topmost-intro-cont | ||
| 9463 | 'topmost-intro) | ||
| 9464 | nil nil | ||
| 9465 | containing-sexp paren-state)) | ||
| 9466 | |||
| 9467 | ;; CASE 5N: At a variable declaration that follows a class | ||
| 9468 | ;; definition or some other block declaration that doesn't | ||
| 9469 | ;; end at the closing '}'. C.f. case 5D.5. | ||
| 9470 | ((progn | ||
| 9471 | (c-backward-syntactic-ws lim) | ||
| 9472 | (and (eq (char-before) ?}) | ||
| 9473 | (save-excursion | ||
| 9474 | (let ((start (point))) | ||
| 9475 | (if (and c-state-cache | ||
| 9476 | (consp (car c-state-cache)) | ||
| 9477 | (eq (cdar c-state-cache) (point))) | ||
| 9478 | ;; Speed up the backward search a bit. | ||
| 9479 | (goto-char (caar c-state-cache))) | ||
| 9480 | (c-beginning-of-decl-1 containing-sexp) | ||
| 9481 | (setq placeholder (point)) | ||
| 9482 | (if (= start (point)) | ||
| 9483 | ;; The '}' is unbalanced. | ||
| 9484 | nil | ||
| 9485 | (c-end-of-decl-1) | ||
| 9486 | (>= (point) indent-point)))))) | ||
| 9487 | (goto-char placeholder) | ||
| 9488 | (c-add-stmt-syntax 'topmost-intro-cont nil nil | ||
| 9489 | containing-sexp paren-state)) | ||
| 9490 | |||
| 9491 | ;; NOTE: The point is at the end of the previous token here. | ||
| 9492 | |||
| 9493 | ;; CASE 5J: we are at the topmost level, make | ||
| 9494 | ;; sure we skip back past any access specifiers | ||
| 9495 | ((and | ||
| 9496 | ;; A macro continuation line is never at top level. | ||
| 9497 | (not (and macro-start | ||
| 9498 | (> indent-point macro-start))) | ||
| 9499 | (save-excursion | ||
| 9500 | (setq placeholder (point)) | ||
| 9501 | (or (memq char-before-ip '(?\; ?{ ?} nil)) | ||
| 9502 | (c-at-vsemi-p before-ws-ip) | ||
| 9503 | (when (and (eq char-before-ip ?:) | ||
| 9504 | (eq (c-beginning-of-statement-1 lim) | ||
| 9505 | 'label)) | ||
| 9506 | (c-backward-syntactic-ws lim) | ||
| 9507 | (setq placeholder (point))) | ||
| 9508 | (and (c-major-mode-is 'objc-mode) | ||
| 9509 | (catch 'not-in-directive | ||
| 9510 | (c-beginning-of-statement-1 lim) | ||
| 9511 | (setq placeholder (point)) | ||
| 9512 | (while (and (c-forward-objc-directive) | ||
| 9513 | (< (point) indent-point)) | ||
| 9514 | (c-forward-syntactic-ws) | ||
| 9515 | (if (>= (point) indent-point) | ||
| 9516 | (throw 'not-in-directive t)) | ||
| 9517 | (setq placeholder (point))) | ||
| 9518 | nil))))) | ||
| 9519 | ;; For historic reasons we anchor at bol of the last | ||
| 9520 | ;; line of the previous declaration. That's clearly | ||
| 9521 | ;; highly bogus and useless, and it makes our lives hard | ||
| 9522 | ;; to remain compatible. :P | ||
| 9523 | (goto-char placeholder) | ||
| 9524 | (c-add-syntax 'topmost-intro (c-point 'bol)) | ||
| 9525 | (if containing-decl-open | ||
| 9526 | (if (c-keyword-member containing-decl-kwd | ||
| 9527 | 'c-other-block-decl-kwds) | ||
| 9528 | (progn | ||
| 9529 | (goto-char (c-brace-anchor-point containing-decl-open)) | ||
| 9530 | (c-add-stmt-syntax | ||
| 9531 | (if (string-equal (symbol-name containing-decl-kwd) | ||
| 9532 | "extern") | ||
| 9533 | ;; Special case for compatibility with the | ||
| 9534 | ;; extern-lang syntactic symbols. | ||
| 9535 | 'inextern-lang | ||
| 9536 | (intern (concat "in" | ||
| 9537 | (symbol-name containing-decl-kwd)))) | ||
| 9538 | nil t | ||
| 9539 | (c-most-enclosing-brace paren-state (point)) | ||
| 9540 | paren-state)) | ||
| 9541 | (c-add-class-syntax 'inclass | ||
| 9542 | containing-decl-open | ||
| 9543 | containing-decl-start | ||
| 9544 | containing-decl-kwd | ||
| 9545 | paren-state))) | ||
| 9546 | (when (and c-syntactic-indentation-in-macros | ||
| 9547 | macro-start | ||
| 9548 | (/= macro-start (c-point 'boi indent-point))) | ||
| 9549 | (c-add-syntax 'cpp-define-intro) | ||
| 9550 | (setq macro-start nil))) | ||
| 9551 | |||
| 9552 | ;; CASE 5K: we are at an ObjC method definition | ||
| 9553 | ;; continuation line. | ||
| 9554 | ((and c-opt-method-key | ||
| 9555 | (save-excursion | ||
| 9556 | (c-beginning-of-statement-1 lim) | ||
| 9557 | (beginning-of-line) | ||
| 9558 | (when (looking-at c-opt-method-key) | ||
| 9559 | (setq placeholder (point))))) | ||
| 9560 | (c-add-syntax 'objc-method-args-cont placeholder)) | ||
| 9561 | 9561 | ||
| 9562 | ;; CASE 5L: we are at the first argument of a template | 9562 | ;; CASE 5L: we are at the first argument of a template |
| 9563 | ;; arglist that begins on the previous line. | 9563 | ;; arglist that begins on the previous line. |
| 9564 | ((and c-recognize-<>-arglists | 9564 | ((and c-recognize-<>-arglists |
| 9565 | (eq (char-before) ?<) | 9565 | (eq (char-before) ?<) |
| @@ -9573,32 +9573,32 @@ comment at the start of cc-engine.el for more info." | |||
| 9573 | (c-beginning-of-statement-1 containing-sexp) | 9573 | (c-beginning-of-statement-1 containing-sexp) |
| 9574 | (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) | 9574 | (c-add-stmt-syntax 'statement nil t containing-sexp paren-state)) |
| 9575 | 9575 | ||
| 9576 | ;;CASE 5N: We are at a tompmost continuation line and the only | 9576 | ;;CASE 5N: We are at a tompmost continuation line and the only |
| 9577 | ;;preceding items are annotations. | 9577 | ;;preceding items are annotations. |
| 9578 | ((and (c-major-mode-is 'java-mode) | 9578 | ((and (c-major-mode-is 'java-mode) |
| 9579 | (setq placeholder (point)) | 9579 | (setq placeholder (point)) |
| 9580 | (c-beginning-of-statement-1) | 9580 | (c-beginning-of-statement-1) |
| 9581 | (progn | 9581 | (progn |
| 9582 | (while (and (c-forward-annotation)) | 9582 | (while (and (c-forward-annotation)) |
| 9583 | (c-forward-syntactic-ws)) | 9583 | (c-forward-syntactic-ws)) |
| 9584 | t) | 9584 | t) |
| 9585 | (prog1 | 9585 | (prog1 |
| 9586 | (>= (point) placeholder) | 9586 | (>= (point) placeholder) |
| 9587 | (goto-char placeholder))) | 9587 | (goto-char placeholder))) |
| 9588 | (c-add-syntax 'annotation-top-cont (c-point 'boi))) | 9588 | (c-add-syntax 'annotation-top-cont (c-point 'boi))) |
| 9589 | 9589 | ||
| 9590 | ;; CASE 5M: we are at a topmost continuation line | 9590 | ;; CASE 5M: we are at a topmost continuation line |
| 9591 | (t | 9591 | (t |
| 9592 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) | 9592 | (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |
| 9593 | (when (c-major-mode-is 'objc-mode) | 9593 | (when (c-major-mode-is 'objc-mode) |
| 9594 | (setq placeholder (point)) | 9594 | (setq placeholder (point)) |
| 9595 | (while (and (c-forward-objc-directive) | 9595 | (while (and (c-forward-objc-directive) |
| 9596 | (< (point) indent-point)) | 9596 | (< (point) indent-point)) |
| 9597 | (c-forward-syntactic-ws) | 9597 | (c-forward-syntactic-ws) |
| 9598 | (setq placeholder (point))) | 9598 | (setq placeholder (point))) |
| 9599 | (goto-char placeholder)) | 9599 | (goto-char placeholder)) |
| 9600 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) | 9600 | (c-add-syntax 'topmost-intro-cont (c-point 'boi))) |
| 9601 | )) | 9601 | )) |
| 9602 | 9602 | ||
| 9603 | 9603 | ||
| 9604 | ;; (CASE 6 has been removed.) | 9604 | ;; (CASE 6 has been removed.) |
| @@ -9614,576 +9614,576 @@ comment at the start of cc-engine.el for more info." | |||
| 9614 | (cond | 9614 | (cond |
| 9615 | 9615 | ||
| 9616 | ;; CASE 7A: we are looking at the arglist closing paren. | 9616 | ;; CASE 7A: we are looking at the arglist closing paren. |
| 9617 | ;; C.f. case 7F. | 9617 | ;; C.f. case 7F. |
| 9618 | ((memq char-after-ip '(?\) ?\])) | 9618 | ((memq char-after-ip '(?\) ?\])) |
| 9619 | (goto-char containing-sexp) | 9619 | (goto-char containing-sexp) |
| 9620 | (setq placeholder (c-point 'boi)) | 9620 | (setq placeholder (c-point 'boi)) |
| 9621 | (if (and (c-safe (backward-up-list 1) t) | 9621 | (if (and (c-safe (backward-up-list 1) t) |
| 9622 | (>= (point) placeholder)) | 9622 | (>= (point) placeholder)) |
| 9623 | (progn | 9623 | (progn |
| 9624 | (forward-char) | 9624 | (forward-char) |
| 9625 | (skip-chars-forward " \t")) | 9625 | (skip-chars-forward " \t")) |
| 9626 | (goto-char placeholder)) | 9626 | (goto-char placeholder)) |
| 9627 | (c-add-stmt-syntax 'arglist-close (list containing-sexp) t | 9627 | (c-add-stmt-syntax 'arglist-close (list containing-sexp) t |
| 9628 | (c-most-enclosing-brace paren-state (point)) | 9628 | (c-most-enclosing-brace paren-state (point)) |
| 9629 | paren-state)) | 9629 | paren-state)) |
| 9630 | 9630 | ||
| 9631 | ;; CASE 19: line is an expression, not a statement, and is directly | ||
| 9632 | ;; contained by a template delimiter. Most likely, we are in a | ||
| 9633 | ;; template arglist within a statement. This case is based on CASE | ||
| 9634 | ;; 7. At some point in the future, we may wish to create more | ||
| 9635 | ;; syntactic symbols such as `template-intro', | ||
| 9636 | ;; `template-cont-nonempty', etc., and distinguish between them as we | ||
| 9637 | ;; do for `arglist-intro' etc. (2009-12-07). | ||
| 9638 | ((and c-recognize-<>-arglists | ||
| 9639 | (setq containing-< (c-up-list-backward indent-point containing-sexp)) | ||
| 9640 | (eq (char-after containing-<) ?\<)) | ||
| 9641 | (setq placeholder (c-point 'boi containing-<)) | ||
| 9642 | (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not | ||
| 9643 | ; '<') before indent-point. | ||
| 9644 | (if (>= (point) placeholder) | ||
| 9645 | (progn | ||
| 9646 | (forward-char) | ||
| 9647 | (skip-chars-forward " \t")) | ||
| 9648 | (goto-char placeholder)) | ||
| 9649 | (c-add-stmt-syntax 'template-args-cont (list containing-<) t | ||
| 9650 | (c-most-enclosing-brace c-state-cache (point)) | ||
| 9651 | paren-state)) | ||
| 9652 | |||
| 9653 | ;; CASE 7B: Looking at the opening brace of an | 9631 | ;; CASE 7B: Looking at the opening brace of an |
| 9654 | ;; in-expression block or brace list. C.f. cases 4, 16A | 9632 | ;; in-expression block or brace list. C.f. cases 4, 16A |
| 9655 | ;; and 17E. | 9633 | ;; and 17E. |
| 9656 | ((and (eq char-after-ip ?{) | 9634 | ((and (eq char-after-ip ?{) |
| 9657 | (progn | 9635 | (progn |
| 9658 | (setq placeholder (c-inside-bracelist-p (point) | 9636 | (setq placeholder (c-inside-bracelist-p (point) |
| 9659 | paren-state)) | 9637 | paren-state)) |
| 9660 | (if placeholder | 9638 | (if placeholder |
| 9661 | (setq tmpsymbol '(brace-list-open . inexpr-class)) | 9639 | (setq tmpsymbol '(brace-list-open . inexpr-class)) |
| 9662 | (setq tmpsymbol '(block-open . inexpr-statement) | 9640 | (setq tmpsymbol '(block-open . inexpr-statement) |
| 9663 | placeholder | 9641 | placeholder |
| 9664 | (cdr-safe (c-looking-at-inexpr-block | 9642 | (cdr-safe (c-looking-at-inexpr-block |
| 9665 | (c-safe-position containing-sexp | 9643 | (c-safe-position containing-sexp |
| 9666 | paren-state) | 9644 | paren-state) |
| 9667 | containing-sexp))) | 9645 | containing-sexp))) |
| 9668 | ;; placeholder is nil if it's a block directly in | 9646 | ;; placeholder is nil if it's a block directly in |
| 9669 | ;; a function arglist. That makes us skip out of | 9647 | ;; a function arglist. That makes us skip out of |
| 9670 | ;; this case. | 9648 | ;; this case. |
| 9671 | ))) | 9649 | ))) |
| 9672 | (goto-char placeholder) | 9650 | (goto-char placeholder) |
| 9673 | (back-to-indentation) | 9651 | (back-to-indentation) |
| 9674 | (c-add-stmt-syntax (car tmpsymbol) nil t | 9652 | (c-add-stmt-syntax (car tmpsymbol) nil t |
| 9675 | (c-most-enclosing-brace paren-state (point)) | 9653 | (c-most-enclosing-brace paren-state (point)) |
| 9676 | paren-state) | 9654 | paren-state) |
| 9677 | (if (/= (point) placeholder) | 9655 | (if (/= (point) placeholder) |
| 9678 | (c-add-syntax (cdr tmpsymbol)))) | 9656 | (c-add-syntax (cdr tmpsymbol)))) |
| 9657 | |||
| 9658 | ;; CASE 7C: we are looking at the first argument in an empty | ||
| 9659 | ;; argument list. Use arglist-close if we're actually | ||
| 9660 | ;; looking at a close paren or bracket. | ||
| 9661 | ((memq char-before-ip '(?\( ?\[)) | ||
| 9662 | (goto-char containing-sexp) | ||
| 9663 | (setq placeholder (c-point 'boi)) | ||
| 9664 | (if (and (c-safe (backward-up-list 1) t) | ||
| 9665 | (>= (point) placeholder)) | ||
| 9666 | (progn | ||
| 9667 | (forward-char) | ||
| 9668 | (skip-chars-forward " \t")) | ||
| 9669 | (goto-char placeholder)) | ||
| 9670 | (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t | ||
| 9671 | (c-most-enclosing-brace paren-state (point)) | ||
| 9672 | paren-state)) | ||
| 9679 | 9673 | ||
| 9680 | ;; CASE 7C: we are looking at the first argument in an empty | 9674 | ;; CASE 7D: we are inside a conditional test clause. treat |
| 9681 | ;; argument list. Use arglist-close if we're actually | 9675 | ;; these things as statements |
| 9682 | ;; looking at a close paren or bracket. | 9676 | ((progn |
| 9683 | ((memq char-before-ip '(?\( ?\[)) | ||
| 9684 | (goto-char containing-sexp) | 9677 | (goto-char containing-sexp) |
| 9685 | (setq placeholder (c-point 'boi)) | 9678 | (and (c-safe (c-forward-sexp -1) t) |
| 9686 | (if (and (c-safe (backward-up-list 1) t) | 9679 | (looking-at "\\<for\\>[^_]"))) |
| 9687 | (>= (point) placeholder)) | 9680 | (goto-char (1+ containing-sexp)) |
| 9688 | (progn | 9681 | (c-forward-syntactic-ws indent-point) |
| 9689 | (forward-char) | 9682 | (if (eq char-before-ip ?\;) |
| 9690 | (skip-chars-forward " \t")) | 9683 | (c-add-syntax 'statement (point)) |
| 9691 | (goto-char placeholder)) | 9684 | (c-add-syntax 'statement-cont (point)) |
| 9692 | (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t | 9685 | )) |
| 9693 | (c-most-enclosing-brace paren-state (point)) | 9686 | |
| 9694 | paren-state)) | 9687 | ;; CASE 7E: maybe a continued ObjC method call. This is the |
| 9688 | ;; case when we are inside a [] bracketed exp, and what | ||
| 9689 | ;; precede the opening bracket is not an identifier. | ||
| 9690 | ((and c-opt-method-key | ||
| 9691 | (eq (char-after containing-sexp) ?\[) | ||
| 9692 | (progn | ||
| 9693 | (goto-char (1- containing-sexp)) | ||
| 9694 | (c-backward-syntactic-ws (c-point 'bod)) | ||
| 9695 | (if (not (looking-at c-symbol-key)) | ||
| 9696 | (c-add-syntax 'objc-method-call-cont containing-sexp)) | ||
| 9697 | ))) | ||
| 9695 | 9698 | ||
| 9696 | ;; CASE 7D: we are inside a conditional test clause. treat | 9699 | ;; CASE 7F: we are looking at an arglist continuation line, |
| 9697 | ;; these things as statements | 9700 | ;; but the preceding argument is on the same line as the |
| 9698 | ((progn | 9701 | ;; opening paren. This case includes multi-line |
| 9699 | (goto-char containing-sexp) | 9702 | ;; mathematical paren groupings, but we could be on a |
| 9700 | (and (c-safe (c-forward-sexp -1) t) | 9703 | ;; for-list continuation line. C.f. case 7A. |
| 9701 | (looking-at "\\<for\\>[^_]"))) | 9704 | ((progn |
| 9702 | (goto-char (1+ containing-sexp)) | 9705 | (goto-char (1+ containing-sexp)) |
| 9703 | (c-forward-syntactic-ws indent-point) | 9706 | (< (save-excursion |
| 9704 | (if (eq char-before-ip ?\;) | 9707 | (c-forward-syntactic-ws) |
| 9705 | (c-add-syntax 'statement (point)) | 9708 | (point)) |
| 9706 | (c-add-syntax 'statement-cont (point)) | 9709 | (c-point 'bonl))) |
| 9707 | )) | 9710 | (goto-char containing-sexp) ; paren opening the arglist |
| 9708 | 9711 | (setq placeholder (c-point 'boi)) | |
| 9709 | ;; CASE 7E: maybe a continued ObjC method call. This is the | 9712 | (if (and (c-safe (backward-up-list 1) t) |
| 9710 | ;; case when we are inside a [] bracketed exp, and what | 9713 | (>= (point) placeholder)) |
| 9711 | ;; precede the opening bracket is not an identifier. | 9714 | (progn |
| 9712 | ((and c-opt-method-key | 9715 | (forward-char) |
| 9713 | (eq (char-after containing-sexp) ?\[) | 9716 | (skip-chars-forward " \t")) |
| 9714 | (progn | 9717 | (goto-char placeholder)) |
| 9715 | (goto-char (1- containing-sexp)) | 9718 | (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t |
| 9716 | (c-backward-syntactic-ws (c-point 'bod)) | 9719 | (c-most-enclosing-brace c-state-cache (point)) |
| 9717 | (if (not (looking-at c-symbol-key)) | 9720 | paren-state)) |
| 9718 | (c-add-syntax 'objc-method-call-cont containing-sexp)) | ||
| 9719 | ))) | ||
| 9720 | 9721 | ||
| 9721 | ;; CASE 7F: we are looking at an arglist continuation line, | 9722 | ;; CASE 7G: we are looking at just a normal arglist |
| 9722 | ;; but the preceding argument is on the same line as the | 9723 | ;; continuation line |
| 9723 | ;; opening paren. This case includes multi-line | 9724 | (t (c-forward-syntactic-ws indent-point) |
| 9724 | ;; mathematical paren groupings, but we could be on a | 9725 | (c-add-syntax 'arglist-cont (c-point 'boi))) |
| 9725 | ;; for-list continuation line. C.f. case 7A. | 9726 | )) |
| 9726 | ((progn | ||
| 9727 | (goto-char (1+ containing-sexp)) | ||
| 9728 | (< (save-excursion | ||
| 9729 | (c-forward-syntactic-ws) | ||
| 9730 | (point)) | ||
| 9731 | (c-point 'bonl))) | ||
| 9732 | (goto-char containing-sexp) ; paren opening the arglist | ||
| 9733 | (setq placeholder (c-point 'boi)) | ||
| 9734 | (if (and (c-safe (backward-up-list 1) t) | ||
| 9735 | (>= (point) placeholder)) | ||
| 9736 | (progn | ||
| 9737 | (forward-char) | ||
| 9738 | (skip-chars-forward " \t")) | ||
| 9739 | (goto-char placeholder)) | ||
| 9740 | (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t | ||
| 9741 | (c-most-enclosing-brace c-state-cache (point)) | ||
| 9742 | paren-state)) | ||
| 9743 | 9727 | ||
| 9744 | ;; CASE 7G: we are looking at just a normal arglist | 9728 | ;; CASE 8: func-local multi-inheritance line |
| 9745 | ;; continuation line | 9729 | ((and (c-major-mode-is 'c++-mode) |
| 9746 | (t (c-forward-syntactic-ws indent-point) | 9730 | (save-excursion |
| 9747 | (c-add-syntax 'arglist-cont (c-point 'boi))) | 9731 | (goto-char indent-point) |
| 9748 | )) | 9732 | (skip-chars-forward " \t") |
| 9733 | (looking-at c-opt-postfix-decl-spec-key))) | ||
| 9734 | (goto-char indent-point) | ||
| 9735 | (skip-chars-forward " \t") | ||
| 9736 | (cond | ||
| 9749 | 9737 | ||
| 9750 | ;; CASE 8: func-local multi-inheritance line | 9738 | ;; CASE 8A: non-hanging colon on an inher intro |
| 9751 | ((and (c-major-mode-is 'c++-mode) | 9739 | ((eq char-after-ip ?:) |
| 9752 | (save-excursion | 9740 | (c-backward-syntactic-ws lim) |
| 9753 | (goto-char indent-point) | 9741 | (c-add-syntax 'inher-intro (c-point 'boi))) |
| 9754 | (skip-chars-forward " \t") | ||
| 9755 | (looking-at c-opt-postfix-decl-spec-key))) | ||
| 9756 | (goto-char indent-point) | ||
| 9757 | (skip-chars-forward " \t") | ||
| 9758 | (cond | ||
| 9759 | 9742 | ||
| 9760 | ;; CASE 8A: non-hanging colon on an inher intro | 9743 | ;; CASE 8B: hanging colon on an inher intro |
| 9761 | ((eq char-after-ip ?:) | 9744 | ((eq char-before-ip ?:) |
| 9762 | (c-backward-syntactic-ws lim) | 9745 | (c-add-syntax 'inher-intro (c-point 'boi))) |
| 9763 | (c-add-syntax 'inher-intro (c-point 'boi))) | ||
| 9764 | 9746 | ||
| 9765 | ;; CASE 8B: hanging colon on an inher intro | 9747 | ;; CASE 8C: a continued inheritance line |
| 9766 | ((eq char-before-ip ?:) | 9748 | (t |
| 9767 | (c-add-syntax 'inher-intro (c-point 'boi))) | 9749 | (c-beginning-of-inheritance-list lim) |
| 9750 | (c-add-syntax 'inher-cont (point)) | ||
| 9751 | ))) | ||
| 9752 | |||
| 9753 | ;; CASE 9: we are inside a brace-list | ||
| 9754 | ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29) | ||
| 9755 | (setq special-brace-list | ||
| 9756 | (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!! | ||
| 9757 | (save-excursion | ||
| 9758 | (goto-char containing-sexp) | ||
| 9759 | (c-looking-at-special-brace-list))) | ||
| 9760 | (c-inside-bracelist-p containing-sexp paren-state)))) | ||
| 9761 | (cond | ||
| 9768 | 9762 | ||
| 9769 | ;; CASE 8C: a continued inheritance line | 9763 | ;; CASE 9A: In the middle of a special brace list opener. |
| 9770 | (t | 9764 | ((and (consp special-brace-list) |
| 9771 | (c-beginning-of-inheritance-list lim) | 9765 | (save-excursion |
| 9772 | (c-add-syntax 'inher-cont (point)) | 9766 | (goto-char containing-sexp) |
| 9773 | ))) | 9767 | (eq (char-after) ?\()) |
| 9768 | (eq char-after-ip (car (cdr special-brace-list)))) | ||
| 9769 | (goto-char (car (car special-brace-list))) | ||
| 9770 | (skip-chars-backward " \t") | ||
| 9771 | (if (and (bolp) | ||
| 9772 | (assoc 'statement-cont | ||
| 9773 | (setq placeholder (c-guess-basic-syntax)))) | ||
| 9774 | (setq c-syntactic-context placeholder) | ||
| 9775 | (c-beginning-of-statement-1 | ||
| 9776 | (c-safe-position (1- containing-sexp) paren-state)) | ||
| 9777 | (c-forward-token-2 0) | ||
| 9778 | (while (looking-at c-specifier-key) | ||
| 9779 | (goto-char (match-end 1)) | ||
| 9780 | (c-forward-syntactic-ws)) | ||
| 9781 | (c-add-syntax 'brace-list-open (c-point 'boi)))) | ||
| 9782 | |||
| 9783 | ;; CASE 9B: brace-list-close brace | ||
| 9784 | ((if (consp special-brace-list) | ||
| 9785 | ;; Check special brace list closer. | ||
| 9786 | (progn | ||
| 9787 | (goto-char (car (car special-brace-list))) | ||
| 9788 | (save-excursion | ||
| 9789 | (goto-char indent-point) | ||
| 9790 | (back-to-indentation) | ||
| 9791 | (or | ||
| 9792 | ;; We were between the special close char and the `)'. | ||
| 9793 | (and (eq (char-after) ?\)) | ||
| 9794 | (eq (1+ (point)) (cdr (car special-brace-list)))) | ||
| 9795 | ;; We were before the special close char. | ||
| 9796 | (and (eq (char-after) (cdr (cdr special-brace-list))) | ||
| 9797 | (zerop (c-forward-token-2)) | ||
| 9798 | (eq (1+ (point)) (cdr (car special-brace-list))))))) | ||
| 9799 | ;; Normal brace list check. | ||
| 9800 | (and (eq char-after-ip ?}) | ||
| 9801 | (c-safe (goto-char (c-up-list-backward (point))) t) | ||
| 9802 | (= (point) containing-sexp))) | ||
| 9803 | (if (eq (point) (c-point 'boi)) | ||
| 9804 | (c-add-syntax 'brace-list-close (point)) | ||
| 9805 | (setq lim (c-most-enclosing-brace c-state-cache (point))) | ||
| 9806 | (c-beginning-of-statement-1 lim) | ||
| 9807 | (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) | ||
| 9774 | 9808 | ||
| 9775 | ;; CASE 9: we are inside a brace-list | 9809 | (t |
| 9776 | ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29) | 9810 | ;; Prepare for the rest of the cases below by going to the |
| 9777 | (setq special-brace-list | 9811 | ;; token following the opening brace |
| 9778 | (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!! | 9812 | (if (consp special-brace-list) |
| 9779 | (save-excursion | 9813 | (progn |
| 9780 | (goto-char containing-sexp) | 9814 | (goto-char (car (car special-brace-list))) |
| 9781 | (c-looking-at-special-brace-list))) | 9815 | (c-forward-token-2 1 nil indent-point)) |
| 9782 | (c-inside-bracelist-p containing-sexp paren-state)))) | 9816 | (goto-char containing-sexp)) |
| 9817 | (forward-char) | ||
| 9818 | (let ((start (point))) | ||
| 9819 | (c-forward-syntactic-ws indent-point) | ||
| 9820 | (goto-char (max start (c-point 'bol)))) | ||
| 9821 | (c-skip-ws-forward indent-point) | ||
| 9783 | (cond | 9822 | (cond |
| 9784 | 9823 | ||
| 9785 | ;; CASE 9A: In the middle of a special brace list opener. | 9824 | ;; CASE 9C: we're looking at the first line in a brace-list |
| 9786 | ((and (consp special-brace-list) | 9825 | ((= (point) indent-point) |
| 9787 | (save-excursion | 9826 | (if (consp special-brace-list) |
| 9788 | (goto-char containing-sexp) | 9827 | (goto-char (car (car special-brace-list))) |
| 9789 | (eq (char-after) ?\()) | 9828 | (goto-char containing-sexp)) |
| 9790 | (eq char-after-ip (car (cdr special-brace-list)))) | ||
| 9791 | (goto-char (car (car special-brace-list))) | ||
| 9792 | (skip-chars-backward " \t") | ||
| 9793 | (if (and (bolp) | ||
| 9794 | (assoc 'statement-cont | ||
| 9795 | (setq placeholder (c-guess-basic-syntax)))) | ||
| 9796 | (setq c-syntactic-context placeholder) | ||
| 9797 | (c-beginning-of-statement-1 | ||
| 9798 | (c-safe-position (1- containing-sexp) paren-state)) | ||
| 9799 | (c-forward-token-2 0) | ||
| 9800 | (while (looking-at c-specifier-key) | ||
| 9801 | (goto-char (match-end 1)) | ||
| 9802 | (c-forward-syntactic-ws)) | ||
| 9803 | (c-add-syntax 'brace-list-open (c-point 'boi)))) | ||
| 9804 | |||
| 9805 | ;; CASE 9B: brace-list-close brace | ||
| 9806 | ((if (consp special-brace-list) | ||
| 9807 | ;; Check special brace list closer. | ||
| 9808 | (progn | ||
| 9809 | (goto-char (car (car special-brace-list))) | ||
| 9810 | (save-excursion | ||
| 9811 | (goto-char indent-point) | ||
| 9812 | (back-to-indentation) | ||
| 9813 | (or | ||
| 9814 | ;; We were between the special close char and the `)'. | ||
| 9815 | (and (eq (char-after) ?\)) | ||
| 9816 | (eq (1+ (point)) (cdr (car special-brace-list)))) | ||
| 9817 | ;; We were before the special close char. | ||
| 9818 | (and (eq (char-after) (cdr (cdr special-brace-list))) | ||
| 9819 | (zerop (c-forward-token-2)) | ||
| 9820 | (eq (1+ (point)) (cdr (car special-brace-list))))))) | ||
| 9821 | ;; Normal brace list check. | ||
| 9822 | (and (eq char-after-ip ?}) | ||
| 9823 | (c-safe (goto-char (c-up-list-backward (point))) t) | ||
| 9824 | (= (point) containing-sexp))) | ||
| 9825 | (if (eq (point) (c-point 'boi)) | 9829 | (if (eq (point) (c-point 'boi)) |
| 9826 | (c-add-syntax 'brace-list-close (point)) | 9830 | (c-add-syntax 'brace-list-intro (point)) |
| 9827 | (setq lim (c-most-enclosing-brace c-state-cache (point))) | 9831 | (setq lim (c-most-enclosing-brace c-state-cache (point))) |
| 9828 | (c-beginning-of-statement-1 lim) | 9832 | (c-beginning-of-statement-1 lim) |
| 9829 | (c-add-stmt-syntax 'brace-list-close nil t lim paren-state))) | 9833 | (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) |
| 9830 | 9834 | ||
| 9831 | (t | 9835 | ;; CASE 9D: this is just a later brace-list-entry or |
| 9832 | ;; Prepare for the rest of the cases below by going to the | 9836 | ;; brace-entry-open |
| 9833 | ;; token following the opening brace | 9837 | (t (if (or (eq char-after-ip ?{) |
| 9834 | (if (consp special-brace-list) | 9838 | (and c-special-brace-lists |
| 9835 | (progn | 9839 | (save-excursion |
| 9836 | (goto-char (car (car special-brace-list))) | 9840 | (goto-char indent-point) |
| 9837 | (c-forward-token-2 1 nil indent-point)) | 9841 | (c-forward-syntactic-ws (c-point 'eol)) |
| 9838 | (goto-char containing-sexp)) | 9842 | (c-looking-at-special-brace-list (point))))) |
| 9839 | (forward-char) | 9843 | (c-add-syntax 'brace-entry-open (point)) |
| 9840 | (let ((start (point))) | 9844 | (c-add-syntax 'brace-list-entry (point)) |
| 9841 | (c-forward-syntactic-ws indent-point) | 9845 | )) |
| 9842 | (goto-char (max start (c-point 'bol)))) | 9846 | )))) |
| 9843 | (c-skip-ws-forward indent-point) | 9847 | |
| 9844 | (cond | 9848 | ;; CASE 10: A continued statement or top level construct. |
| 9849 | ((and (not (memq char-before-ip '(?\; ?:))) | ||
| 9850 | (not (c-at-vsemi-p before-ws-ip)) | ||
| 9851 | (or (not (eq char-before-ip ?})) | ||
| 9852 | (c-looking-at-inexpr-block-backward c-state-cache)) | ||
| 9853 | (> (point) | ||
| 9854 | (save-excursion | ||
| 9855 | (c-beginning-of-statement-1 containing-sexp) | ||
| 9856 | (setq placeholder (point)))) | ||
| 9857 | (/= placeholder containing-sexp)) | ||
| 9858 | ;; This is shared with case 18. | ||
| 9859 | (c-guess-continued-construct indent-point | ||
| 9860 | char-after-ip | ||
| 9861 | placeholder | ||
| 9862 | containing-sexp | ||
| 9863 | paren-state)) | ||
| 9864 | |||
| 9865 | ;; CASE 16: block close brace, possibly closing the defun or | ||
| 9866 | ;; the class | ||
| 9867 | ((eq char-after-ip ?}) | ||
| 9868 | ;; From here on we have the next containing sexp in lim. | ||
| 9869 | (setq lim (c-most-enclosing-brace paren-state)) | ||
| 9870 | (goto-char containing-sexp) | ||
| 9871 | (cond | ||
| 9845 | 9872 | ||
| 9846 | ;; CASE 9C: we're looking at the first line in a brace-list | 9873 | ;; CASE 16E: Closing a statement block? This catches |
| 9847 | ((= (point) indent-point) | 9874 | ;; cases where it's preceded by a statement keyword, |
| 9848 | (if (consp special-brace-list) | 9875 | ;; which works even when used in an "invalid" context, |
| 9849 | (goto-char (car (car special-brace-list))) | 9876 | ;; e.g. a macro argument. |
| 9850 | (goto-char containing-sexp)) | 9877 | ((c-after-conditional) |
| 9851 | (if (eq (point) (c-point 'boi)) | 9878 | (c-backward-to-block-anchor lim) |
| 9852 | (c-add-syntax 'brace-list-intro (point)) | 9879 | (c-add-stmt-syntax 'block-close nil t lim paren-state)) |
| 9853 | (setq lim (c-most-enclosing-brace c-state-cache (point))) | 9880 | |
| 9854 | (c-beginning-of-statement-1 lim) | 9881 | ;; CASE 16A: closing a lambda defun or an in-expression |
| 9855 | (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state))) | 9882 | ;; block? C.f. cases 4, 7B and 17E. |
| 9856 | 9883 | ((setq placeholder (c-looking-at-inexpr-block | |
| 9857 | ;; CASE 9D: this is just a later brace-list-entry or | 9884 | (c-safe-position containing-sexp paren-state) |
| 9858 | ;; brace-entry-open | 9885 | nil)) |
| 9859 | (t (if (or (eq char-after-ip ?{) | 9886 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) |
| 9860 | (and c-special-brace-lists | 9887 | 'inline-close |
| 9861 | (save-excursion | 9888 | 'block-close)) |
| 9862 | (goto-char indent-point) | ||
| 9863 | (c-forward-syntactic-ws (c-point 'eol)) | ||
| 9864 | (c-looking-at-special-brace-list (point))))) | ||
| 9865 | (c-add-syntax 'brace-entry-open (point)) | ||
| 9866 | (c-add-syntax 'brace-list-entry (point)) | ||
| 9867 | )) | ||
| 9868 | )))) | ||
| 9869 | |||
| 9870 | ;; CASE 10: A continued statement or top level construct. | ||
| 9871 | ((and (not (memq char-before-ip '(?\; ?:))) | ||
| 9872 | (not (c-at-vsemi-p before-ws-ip)) | ||
| 9873 | (or (not (eq char-before-ip ?})) | ||
| 9874 | (c-looking-at-inexpr-block-backward c-state-cache)) | ||
| 9875 | (> (point) | ||
| 9876 | (save-excursion | ||
| 9877 | (c-beginning-of-statement-1 containing-sexp) | ||
| 9878 | (setq placeholder (point)))) | ||
| 9879 | (/= placeholder containing-sexp)) | ||
| 9880 | ;; This is shared with case 18. | ||
| 9881 | (c-guess-continued-construct indent-point | ||
| 9882 | char-after-ip | ||
| 9883 | placeholder | ||
| 9884 | containing-sexp | ||
| 9885 | paren-state)) | ||
| 9886 | |||
| 9887 | ;; CASE 16: block close brace, possibly closing the defun or | ||
| 9888 | ;; the class | ||
| 9889 | ((eq char-after-ip ?}) | ||
| 9890 | ;; From here on we have the next containing sexp in lim. | ||
| 9891 | (setq lim (c-most-enclosing-brace paren-state)) | ||
| 9892 | (goto-char containing-sexp) | 9889 | (goto-char containing-sexp) |
| 9893 | (cond | 9890 | (back-to-indentation) |
| 9891 | (if (= containing-sexp (point)) | ||
| 9892 | (c-add-syntax tmpsymbol (point)) | ||
| 9893 | (goto-char (cdr placeholder)) | ||
| 9894 | (back-to-indentation) | ||
| 9895 | (c-add-stmt-syntax tmpsymbol nil t | ||
| 9896 | (c-most-enclosing-brace paren-state (point)) | ||
| 9897 | paren-state) | ||
| 9898 | (if (/= (point) (cdr placeholder)) | ||
| 9899 | (c-add-syntax (car placeholder))))) | ||
| 9894 | 9900 | ||
| 9895 | ;; CASE 16E: Closing a statement block? This catches | 9901 | ;; CASE 16B: does this close an inline or a function in |
| 9896 | ;; cases where it's preceded by a statement keyword, | 9902 | ;; a non-class declaration level block? |
| 9897 | ;; which works even when used in an "invalid" context, | 9903 | ((save-excursion |
| 9898 | ;; e.g. a macro argument. | 9904 | (and lim |
| 9899 | ((c-after-conditional) | 9905 | (progn |
| 9900 | (c-backward-to-block-anchor lim) | 9906 | (goto-char lim) |
| 9901 | (c-add-stmt-syntax 'block-close nil t lim paren-state)) | 9907 | (c-looking-at-decl-block |
| 9902 | 9908 | (c-most-enclosing-brace paren-state lim) | |
| 9903 | ;; CASE 16A: closing a lambda defun or an in-expression | 9909 | nil)) |
| 9904 | ;; block? C.f. cases 4, 7B and 17E. | 9910 | (setq placeholder (point)))) |
| 9905 | ((setq placeholder (c-looking-at-inexpr-block | 9911 | (c-backward-to-decl-anchor lim) |
| 9906 | (c-safe-position containing-sexp paren-state) | 9912 | (back-to-indentation) |
| 9907 | nil)) | 9913 | (if (save-excursion |
| 9908 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) | 9914 | (goto-char placeholder) |
| 9909 | 'inline-close | 9915 | (looking-at c-other-decl-block-key)) |
| 9910 | 'block-close)) | 9916 | (c-add-syntax 'defun-close (point)) |
| 9911 | (goto-char containing-sexp) | 9917 | (c-add-syntax 'inline-close (point)))) |
| 9912 | (back-to-indentation) | 9918 | |
| 9913 | (if (= containing-sexp (point)) | 9919 | ;; CASE 16F: Can be a defun-close of a function declared |
| 9914 | (c-add-syntax tmpsymbol (point)) | 9920 | ;; in a statement block, e.g. in Pike or when using gcc |
| 9915 | (goto-char (cdr placeholder)) | 9921 | ;; extensions, but watch out for macros followed by |
| 9916 | (back-to-indentation) | 9922 | ;; blocks. Let it through to be handled below. |
| 9917 | (c-add-stmt-syntax tmpsymbol nil t | 9923 | ;; C.f. cases B.3 and 17G. |
| 9918 | (c-most-enclosing-brace paren-state (point)) | 9924 | ((save-excursion |
| 9919 | paren-state) | 9925 | (and (not (c-at-statement-start-p)) |
| 9920 | (if (/= (point) (cdr placeholder)) | 9926 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
| 9921 | (c-add-syntax (car placeholder))))) | 9927 | (setq placeholder (point)) |
| 9922 | 9928 | (let ((c-recognize-typeless-decls nil)) | |
| 9923 | ;; CASE 16B: does this close an inline or a function in | 9929 | ;; Turn off recognition of constructs that |
| 9924 | ;; a non-class declaration level block? | 9930 | ;; lacks a type in this case, since that's more |
| 9925 | ((save-excursion | 9931 | ;; likely to be a macro followed by a block. |
| 9926 | (and lim | 9932 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) |
| 9927 | (progn | 9933 | (back-to-indentation) |
| 9928 | (goto-char lim) | 9934 | (if (/= (point) containing-sexp) |
| 9929 | (c-looking-at-decl-block | 9935 | (goto-char placeholder)) |
| 9930 | (c-most-enclosing-brace paren-state lim) | 9936 | (c-add-stmt-syntax 'defun-close nil t lim paren-state)) |
| 9931 | nil)) | 9937 | |
| 9932 | (setq placeholder (point)))) | 9938 | ;; CASE 16C: If there is an enclosing brace then this is |
| 9933 | (c-backward-to-decl-anchor lim) | 9939 | ;; a block close since defun closes inside declaration |
| 9934 | (back-to-indentation) | 9940 | ;; level blocks have been handled above. |
| 9935 | (if (save-excursion | 9941 | (lim |
| 9936 | (goto-char placeholder) | 9942 | ;; If the block is preceded by a case/switch label on |
| 9937 | (looking-at c-other-decl-block-key)) | 9943 | ;; the same line, we anchor at the first preceding label |
| 9938 | (c-add-syntax 'defun-close (point)) | 9944 | ;; at boi. The default handling in c-add-stmt-syntax |
| 9939 | (c-add-syntax 'inline-close (point)))) | 9945 | ;; really fixes it better, but we do like this to keep |
| 9940 | 9946 | ;; the indentation compatible with version 5.28 and | |
| 9941 | ;; CASE 16F: Can be a defun-close of a function declared | 9947 | ;; earlier. C.f. case 17H. |
| 9942 | ;; in a statement block, e.g. in Pike or when using gcc | 9948 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) |
| 9943 | ;; extensions, but watch out for macros followed by | 9949 | (eq (c-beginning-of-statement-1 lim) 'label))) |
| 9944 | ;; blocks. Let it through to be handled below. | 9950 | (goto-char placeholder) |
| 9945 | ;; C.f. cases B.3 and 17G. | 9951 | (if (looking-at c-label-kwds-regexp) |
| 9946 | ((save-excursion | 9952 | (c-add-syntax 'block-close (point)) |
| 9947 | (and (not (c-at-statement-start-p)) | 9953 | (goto-char containing-sexp) |
| 9948 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) | 9954 | ;; c-backward-to-block-anchor not necessary here; those |
| 9949 | (setq placeholder (point)) | 9955 | ;; situations are handled in case 16E above. |
| 9950 | (let ((c-recognize-typeless-decls nil)) | 9956 | (c-add-stmt-syntax 'block-close nil t lim paren-state))) |
| 9951 | ;; Turn off recognition of constructs that | ||
| 9952 | ;; lacks a type in this case, since that's more | ||
| 9953 | ;; likely to be a macro followed by a block. | ||
| 9954 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) | ||
| 9955 | (back-to-indentation) | ||
| 9956 | (if (/= (point) containing-sexp) | ||
| 9957 | (goto-char placeholder)) | ||
| 9958 | (c-add-stmt-syntax 'defun-close nil t lim paren-state)) | ||
| 9959 | |||
| 9960 | ;; CASE 16C: If there is an enclosing brace then this is | ||
| 9961 | ;; a block close since defun closes inside declaration | ||
| 9962 | ;; level blocks have been handled above. | ||
| 9963 | (lim | ||
| 9964 | ;; If the block is preceded by a case/switch label on | ||
| 9965 | ;; the same line, we anchor at the first preceding label | ||
| 9966 | ;; at boi. The default handling in c-add-stmt-syntax | ||
| 9967 | ;; really fixes it better, but we do like this to keep | ||
| 9968 | ;; the indentation compatible with version 5.28 and | ||
| 9969 | ;; earlier. C.f. case 17H. | ||
| 9970 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) | ||
| 9971 | (eq (c-beginning-of-statement-1 lim) 'label))) | ||
| 9972 | (goto-char placeholder) | ||
| 9973 | (if (looking-at c-label-kwds-regexp) | ||
| 9974 | (c-add-syntax 'block-close (point)) | ||
| 9975 | (goto-char containing-sexp) | ||
| 9976 | ;; c-backward-to-block-anchor not necessary here; those | ||
| 9977 | ;; situations are handled in case 16E above. | ||
| 9978 | (c-add-stmt-syntax 'block-close nil t lim paren-state))) | ||
| 9979 | |||
| 9980 | ;; CASE 16D: Only top level defun close left. | ||
| 9981 | (t | ||
| 9982 | (goto-char containing-sexp) | ||
| 9983 | (c-backward-to-decl-anchor lim) | ||
| 9984 | (c-add-stmt-syntax 'defun-close nil nil | ||
| 9985 | (c-most-enclosing-brace paren-state) | ||
| 9986 | paren-state)) | ||
| 9987 | )) | ||
| 9988 | 9957 | ||
| 9989 | ;; CASE 17: Statement or defun catchall. | 9958 | ;; CASE 16D: Only top level defun close left. |
| 9990 | (t | 9959 | (t |
| 9991 | (goto-char indent-point) | 9960 | (goto-char containing-sexp) |
| 9992 | ;; Back up statements until we find one that starts at boi. | 9961 | (c-backward-to-decl-anchor lim) |
| 9993 | (while (let* ((prev-point (point)) | 9962 | (c-add-stmt-syntax 'defun-close nil nil |
| 9994 | (last-step-type (c-beginning-of-statement-1 | 9963 | (c-most-enclosing-brace paren-state) |
| 9995 | containing-sexp))) | 9964 | paren-state)) |
| 9996 | (if (= (point) prev-point) | 9965 | )) |
| 9997 | (progn | 9966 | |
| 9998 | (setq step-type (or step-type last-step-type)) | 9967 | ;; CASE 19: line is an expression, not a statement, and is directly |
| 9999 | nil) | 9968 | ;; contained by a template delimiter. Most likely, we are in a |
| 10000 | (setq step-type last-step-type) | 9969 | ;; template arglist within a statement. This case is based on CASE |
| 10001 | (/= (point) (c-point 'boi))))) | 9970 | ;; 7. At some point in the future, we may wish to create more |
| 10002 | (cond | 9971 | ;; syntactic symbols such as `template-intro', |
| 9972 | ;; `template-cont-nonempty', etc., and distinguish between them as we | ||
| 9973 | ;; do for `arglist-intro' etc. (2009-12-07). | ||
| 9974 | ((and c-recognize-<>-arglists | ||
| 9975 | (setq containing-< (c-up-list-backward indent-point containing-sexp)) | ||
| 9976 | (eq (char-after containing-<) ?\<)) | ||
| 9977 | (setq placeholder (c-point 'boi containing-<)) | ||
| 9978 | (goto-char containing-sexp) ; Most nested Lbrace/Lparen (but not | ||
| 9979 | ; '<') before indent-point. | ||
| 9980 | (if (>= (point) placeholder) | ||
| 9981 | (progn | ||
| 9982 | (forward-char) | ||
| 9983 | (skip-chars-forward " \t")) | ||
| 9984 | (goto-char placeholder)) | ||
| 9985 | (c-add-stmt-syntax 'template-args-cont (list containing-<) t | ||
| 9986 | (c-most-enclosing-brace c-state-cache (point)) | ||
| 9987 | paren-state)) | ||
| 10003 | 9988 | ||
| 10004 | ;; CASE 17B: continued statement | 9989 | ;; CASE 17: Statement or defun catchall. |
| 10005 | ((and (eq step-type 'same) | 9990 | (t |
| 10006 | (/= (point) indent-point)) | 9991 | (goto-char indent-point) |
| 10007 | (c-add-stmt-syntax 'statement-cont nil nil | 9992 | ;; Back up statements until we find one that starts at boi. |
| 10008 | containing-sexp paren-state)) | 9993 | (while (let* ((prev-point (point)) |
| 10009 | 9994 | (last-step-type (c-beginning-of-statement-1 | |
| 10010 | ;; CASE 17A: After a case/default label? | 9995 | containing-sexp))) |
| 10011 | ((progn | 9996 | (if (= (point) prev-point) |
| 10012 | (while (and (eq step-type 'label) | 9997 | (progn |
| 10013 | (not (looking-at c-label-kwds-regexp))) | 9998 | (setq step-type (or step-type last-step-type)) |
| 10014 | (setq step-type | 9999 | nil) |
| 10015 | (c-beginning-of-statement-1 containing-sexp))) | 10000 | (setq step-type last-step-type) |
| 10016 | (eq step-type 'label)) | 10001 | (/= (point) (c-point 'boi))))) |
| 10017 | (c-add-stmt-syntax (if (eq char-after-ip ?{) | 10002 | (cond |
| 10018 | 'statement-case-open | ||
| 10019 | 'statement-case-intro) | ||
| 10020 | nil t containing-sexp paren-state)) | ||
| 10021 | |||
| 10022 | ;; CASE 17D: any old statement | ||
| 10023 | ((progn | ||
| 10024 | (while (eq step-type 'label) | ||
| 10025 | (setq step-type | ||
| 10026 | (c-beginning-of-statement-1 containing-sexp))) | ||
| 10027 | (eq step-type 'previous)) | ||
| 10028 | (c-add-stmt-syntax 'statement nil t | ||
| 10029 | containing-sexp paren-state) | ||
| 10030 | (if (eq char-after-ip ?{) | ||
| 10031 | (c-add-syntax 'block-open))) | ||
| 10032 | |||
| 10033 | ;; CASE 17I: Inside a substatement block. | ||
| 10034 | ((progn | ||
| 10035 | ;; The following tests are all based on containing-sexp. | ||
| 10036 | (goto-char containing-sexp) | ||
| 10037 | ;; From here on we have the next containing sexp in lim. | ||
| 10038 | (setq lim (c-most-enclosing-brace paren-state containing-sexp)) | ||
| 10039 | (c-after-conditional)) | ||
| 10040 | (c-backward-to-block-anchor lim) | ||
| 10041 | (c-add-stmt-syntax 'statement-block-intro nil t | ||
| 10042 | lim paren-state) | ||
| 10043 | (if (eq char-after-ip ?{) | ||
| 10044 | (c-add-syntax 'block-open))) | ||
| 10045 | |||
| 10046 | ;; CASE 17E: first statement in an in-expression block. | ||
| 10047 | ;; C.f. cases 4, 7B and 16A. | ||
| 10048 | ((setq placeholder (c-looking-at-inexpr-block | ||
| 10049 | (c-safe-position containing-sexp paren-state) | ||
| 10050 | nil)) | ||
| 10051 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) | ||
| 10052 | 'defun-block-intro | ||
| 10053 | 'statement-block-intro)) | ||
| 10054 | (back-to-indentation) | ||
| 10055 | (if (= containing-sexp (point)) | ||
| 10056 | (c-add-syntax tmpsymbol (point)) | ||
| 10057 | (goto-char (cdr placeholder)) | ||
| 10058 | (back-to-indentation) | ||
| 10059 | (c-add-stmt-syntax tmpsymbol nil t | ||
| 10060 | (c-most-enclosing-brace c-state-cache (point)) | ||
| 10061 | paren-state) | ||
| 10062 | (if (/= (point) (cdr placeholder)) | ||
| 10063 | (c-add-syntax (car placeholder)))) | ||
| 10064 | (if (eq char-after-ip ?{) | ||
| 10065 | (c-add-syntax 'block-open))) | ||
| 10066 | |||
| 10067 | ;; CASE 17F: first statement in an inline, or first | ||
| 10068 | ;; statement in a top-level defun. we can tell this is it | ||
| 10069 | ;; if there are no enclosing braces that haven't been | ||
| 10070 | ;; narrowed out by a class (i.e. don't use bod here). | ||
| 10071 | ((save-excursion | ||
| 10072 | (or (not (setq placeholder (c-most-enclosing-brace | ||
| 10073 | paren-state))) | ||
| 10074 | (and (progn | ||
| 10075 | (goto-char placeholder) | ||
| 10076 | (eq (char-after) ?{)) | ||
| 10077 | (c-looking-at-decl-block (c-most-enclosing-brace | ||
| 10078 | paren-state (point)) | ||
| 10079 | nil)))) | ||
| 10080 | (c-backward-to-decl-anchor lim) | ||
| 10081 | (back-to-indentation) | ||
| 10082 | (c-add-syntax 'defun-block-intro (point))) | ||
| 10083 | 10003 | ||
| 10084 | ;; CASE 17G: First statement in a function declared inside | 10004 | ;; CASE 17B: continued statement |
| 10085 | ;; a normal block. This can occur in Pike and with | 10005 | ((and (eq step-type 'same) |
| 10086 | ;; e.g. the gcc extensions, but watch out for macros | 10006 | (/= (point) indent-point)) |
| 10087 | ;; followed by blocks. C.f. cases B.3 and 16F. | 10007 | (c-add-stmt-syntax 'statement-cont nil nil |
| 10088 | ((save-excursion | 10008 | containing-sexp paren-state)) |
| 10089 | (and (not (c-at-statement-start-p)) | 10009 | |
| 10090 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) | 10010 | ;; CASE 17A: After a case/default label? |
| 10091 | (setq placeholder (point)) | 10011 | ((progn |
| 10092 | (let ((c-recognize-typeless-decls nil)) | 10012 | (while (and (eq step-type 'label) |
| 10093 | ;; Turn off recognition of constructs that lacks | 10013 | (not (looking-at c-label-kwds-regexp))) |
| 10094 | ;; a type in this case, since that's more likely | 10014 | (setq step-type |
| 10095 | ;; to be a macro followed by a block. | 10015 | (c-beginning-of-statement-1 containing-sexp))) |
| 10096 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) | 10016 | (eq step-type 'label)) |
| 10017 | (c-add-stmt-syntax (if (eq char-after-ip ?{) | ||
| 10018 | 'statement-case-open | ||
| 10019 | 'statement-case-intro) | ||
| 10020 | nil t containing-sexp paren-state)) | ||
| 10021 | |||
| 10022 | ;; CASE 17D: any old statement | ||
| 10023 | ((progn | ||
| 10024 | (while (eq step-type 'label) | ||
| 10025 | (setq step-type | ||
| 10026 | (c-beginning-of-statement-1 containing-sexp))) | ||
| 10027 | (eq step-type 'previous)) | ||
| 10028 | (c-add-stmt-syntax 'statement nil t | ||
| 10029 | containing-sexp paren-state) | ||
| 10030 | (if (eq char-after-ip ?{) | ||
| 10031 | (c-add-syntax 'block-open))) | ||
| 10032 | |||
| 10033 | ;; CASE 17I: Inside a substatement block. | ||
| 10034 | ((progn | ||
| 10035 | ;; The following tests are all based on containing-sexp. | ||
| 10036 | (goto-char containing-sexp) | ||
| 10037 | ;; From here on we have the next containing sexp in lim. | ||
| 10038 | (setq lim (c-most-enclosing-brace paren-state containing-sexp)) | ||
| 10039 | (c-after-conditional)) | ||
| 10040 | (c-backward-to-block-anchor lim) | ||
| 10041 | (c-add-stmt-syntax 'statement-block-intro nil t | ||
| 10042 | lim paren-state) | ||
| 10043 | (if (eq char-after-ip ?{) | ||
| 10044 | (c-add-syntax 'block-open))) | ||
| 10045 | |||
| 10046 | ;; CASE 17E: first statement in an in-expression block. | ||
| 10047 | ;; C.f. cases 4, 7B and 16A. | ||
| 10048 | ((setq placeholder (c-looking-at-inexpr-block | ||
| 10049 | (c-safe-position containing-sexp paren-state) | ||
| 10050 | nil)) | ||
| 10051 | (setq tmpsymbol (if (eq (car placeholder) 'inlambda) | ||
| 10052 | 'defun-block-intro | ||
| 10053 | 'statement-block-intro)) | ||
| 10054 | (back-to-indentation) | ||
| 10055 | (if (= containing-sexp (point)) | ||
| 10056 | (c-add-syntax tmpsymbol (point)) | ||
| 10057 | (goto-char (cdr placeholder)) | ||
| 10097 | (back-to-indentation) | 10058 | (back-to-indentation) |
| 10098 | (if (/= (point) containing-sexp) | 10059 | (c-add-stmt-syntax tmpsymbol nil t |
| 10099 | (goto-char placeholder)) | 10060 | (c-most-enclosing-brace c-state-cache (point)) |
| 10100 | (c-add-stmt-syntax 'defun-block-intro nil t | 10061 | paren-state) |
| 10101 | lim paren-state)) | 10062 | (if (/= (point) (cdr placeholder)) |
| 10063 | (c-add-syntax (car placeholder)))) | ||
| 10064 | (if (eq char-after-ip ?{) | ||
| 10065 | (c-add-syntax 'block-open))) | ||
| 10066 | |||
| 10067 | ;; CASE 17F: first statement in an inline, or first | ||
| 10068 | ;; statement in a top-level defun. we can tell this is it | ||
| 10069 | ;; if there are no enclosing braces that haven't been | ||
| 10070 | ;; narrowed out by a class (i.e. don't use bod here). | ||
| 10071 | ((save-excursion | ||
| 10072 | (or (not (setq placeholder (c-most-enclosing-brace | ||
| 10073 | paren-state))) | ||
| 10074 | (and (progn | ||
| 10075 | (goto-char placeholder) | ||
| 10076 | (eq (char-after) ?{)) | ||
| 10077 | (c-looking-at-decl-block (c-most-enclosing-brace | ||
| 10078 | paren-state (point)) | ||
| 10079 | nil)))) | ||
| 10080 | (c-backward-to-decl-anchor lim) | ||
| 10081 | (back-to-indentation) | ||
| 10082 | (c-add-syntax 'defun-block-intro (point))) | ||
| 10102 | 10083 | ||
| 10103 | ;; CASE 17H: First statement in a block. | 10084 | ;; CASE 17G: First statement in a function declared inside |
| 10104 | (t | 10085 | ;; a normal block. This can occur in Pike and with |
| 10105 | ;; If the block is preceded by a case/switch label on the | 10086 | ;; e.g. the gcc extensions, but watch out for macros |
| 10106 | ;; same line, we anchor at the first preceding label at | 10087 | ;; followed by blocks. C.f. cases B.3 and 16F. |
| 10107 | ;; boi. The default handling in c-add-stmt-syntax is | 10088 | ((save-excursion |
| 10108 | ;; really fixes it better, but we do like this to keep the | 10089 | (and (not (c-at-statement-start-p)) |
| 10109 | ;; indentation compatible with version 5.28 and earlier. | 10090 | (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
| 10110 | ;; C.f. case 16C. | 10091 | (setq placeholder (point)) |
| 10111 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) | 10092 | (let ((c-recognize-typeless-decls nil)) |
| 10112 | (eq (c-beginning-of-statement-1 lim) 'label))) | 10093 | ;; Turn off recognition of constructs that lacks |
| 10113 | (goto-char placeholder) | 10094 | ;; a type in this case, since that's more likely |
| 10114 | (if (looking-at c-label-kwds-regexp) | 10095 | ;; to be a macro followed by a block. |
| 10115 | (c-add-syntax 'statement-block-intro (point)) | 10096 | (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))) |
| 10116 | (goto-char containing-sexp) | 10097 | (back-to-indentation) |
| 10117 | ;; c-backward-to-block-anchor not necessary here; those | 10098 | (if (/= (point) containing-sexp) |
| 10118 | ;; situations are handled in case 17I above. | 10099 | (goto-char placeholder)) |
| 10119 | (c-add-stmt-syntax 'statement-block-intro nil t | 10100 | (c-add-stmt-syntax 'defun-block-intro nil t |
| 10120 | lim paren-state)) | 10101 | lim paren-state)) |
| 10121 | (if (eq char-after-ip ?{) | ||
| 10122 | (c-add-syntax 'block-open))) | ||
| 10123 | )) | ||
| 10124 | ) | ||
| 10125 | 10102 | ||
| 10126 | ;; now we need to look at any modifiers | 10103 | ;; CASE 17H: First statement in a block. |
| 10127 | (goto-char indent-point) | 10104 | (t |
| 10128 | (skip-chars-forward " \t") | 10105 | ;; If the block is preceded by a case/switch label on the |
| 10106 | ;; same line, we anchor at the first preceding label at | ||
| 10107 | ;; boi. The default handling in c-add-stmt-syntax is | ||
| 10108 | ;; really fixes it better, but we do like this to keep the | ||
| 10109 | ;; indentation compatible with version 5.28 and earlier. | ||
| 10110 | ;; C.f. case 16C. | ||
| 10111 | (while (and (/= (setq placeholder (point)) (c-point 'boi)) | ||
| 10112 | (eq (c-beginning-of-statement-1 lim) 'label))) | ||
| 10113 | (goto-char placeholder) | ||
| 10114 | (if (looking-at c-label-kwds-regexp) | ||
| 10115 | (c-add-syntax 'statement-block-intro (point)) | ||
| 10116 | (goto-char containing-sexp) | ||
| 10117 | ;; c-backward-to-block-anchor not necessary here; those | ||
| 10118 | ;; situations are handled in case 17I above. | ||
| 10119 | (c-add-stmt-syntax 'statement-block-intro nil t | ||
| 10120 | lim paren-state)) | ||
| 10121 | (if (eq char-after-ip ?{) | ||
| 10122 | (c-add-syntax 'block-open))) | ||
| 10123 | )) | ||
| 10124 | ) | ||
| 10125 | |||
| 10126 | ;; now we need to look at any modifiers | ||
| 10127 | (goto-char indent-point) | ||
| 10128 | (skip-chars-forward " \t") | ||
| 10129 | |||
| 10130 | ;; are we looking at a comment only line? | ||
| 10131 | (when (and (looking-at c-comment-start-regexp) | ||
| 10132 | (/= (c-forward-token-2 0 nil (c-point 'eol)) 0)) | ||
| 10133 | (c-append-syntax 'comment-intro)) | ||
| 10134 | |||
| 10135 | ;; we might want to give additional offset to friends (in C++). | ||
| 10136 | (when (and c-opt-friend-key | ||
| 10137 | (looking-at c-opt-friend-key)) | ||
| 10138 | (c-append-syntax 'friend)) | ||
| 10139 | |||
| 10140 | ;; Set syntactic-relpos. | ||
| 10141 | (let ((p c-syntactic-context)) | ||
| 10142 | (while (and p | ||
| 10143 | (if (integerp (c-langelem-pos (car p))) | ||
| 10144 | (progn | ||
| 10145 | (setq syntactic-relpos (c-langelem-pos (car p))) | ||
| 10146 | nil) | ||
| 10147 | t)) | ||
| 10148 | (setq p (cdr p)))) | ||
| 10129 | 10149 | ||
| 10130 | ;; are we looking at a comment only line? | 10150 | ;; Start of or a continuation of a preprocessor directive? |
| 10131 | (when (and (looking-at c-comment-start-regexp) | 10151 | (if (and macro-start |
| 10132 | (/= (c-forward-token-2 0 nil (c-point 'eol)) 0)) | 10152 | (eq macro-start (c-point 'boi)) |
| 10133 | (c-append-syntax 'comment-intro)) | 10153 | (not (and (c-major-mode-is 'pike-mode) |
| 10134 | 10154 | (eq (char-after (1+ macro-start)) ?\")))) | |
| 10135 | ;; we might want to give additional offset to friends (in C++). | 10155 | (c-append-syntax 'cpp-macro) |
| 10136 | (when (and c-opt-friend-key | 10156 | (when (and c-syntactic-indentation-in-macros macro-start) |
| 10137 | (looking-at c-opt-friend-key)) | 10157 | (if in-macro-expr |
| 10138 | (c-append-syntax 'friend)) | 10158 | (when (or |
| 10139 | 10159 | (< syntactic-relpos macro-start) | |
| 10140 | ;; Set syntactic-relpos. | 10160 | (not (or |
| 10141 | (let ((p c-syntactic-context)) | 10161 | (assq 'arglist-intro c-syntactic-context) |
| 10142 | (while (and p | 10162 | (assq 'arglist-cont c-syntactic-context) |
| 10143 | (if (integerp (c-langelem-pos (car p))) | 10163 | (assq 'arglist-cont-nonempty c-syntactic-context) |
| 10144 | (progn | 10164 | (assq 'arglist-close c-syntactic-context)))) |
| 10145 | (setq syntactic-relpos (c-langelem-pos (car p))) | 10165 | ;; If inside a cpp expression, i.e. anywhere in a |
| 10146 | nil) | 10166 | ;; cpp directive except a #define body, we only let |
| 10147 | t)) | 10167 | ;; through the syntactic analysis that is internal |
| 10148 | (setq p (cdr p)))) | 10168 | ;; in the expression. That means the arglist |
| 10149 | 10169 | ;; elements, if they are anchored inside the cpp | |
| 10150 | ;; Start of or a continuation of a preprocessor directive? | 10170 | ;; expression. |
| 10151 | (if (and macro-start | 10171 | (setq c-syntactic-context nil) |
| 10152 | (eq macro-start (c-point 'boi)) | 10172 | (c-add-syntax 'cpp-macro-cont macro-start)) |
| 10153 | (not (and (c-major-mode-is 'pike-mode) | 10173 | (when (and (eq macro-start syntactic-relpos) |
| 10154 | (eq (char-after (1+ macro-start)) ?\")))) | 10174 | (not (assq 'cpp-define-intro c-syntactic-context)) |
| 10155 | (c-append-syntax 'cpp-macro) | 10175 | (save-excursion |
| 10156 | (when (and c-syntactic-indentation-in-macros macro-start) | 10176 | (goto-char macro-start) |
| 10157 | (if in-macro-expr | 10177 | (or (not (c-forward-to-cpp-define-body)) |
| 10158 | (when (or | 10178 | (<= (point) (c-point 'boi indent-point))))) |
| 10159 | (< syntactic-relpos macro-start) | 10179 | ;; Inside a #define body and the syntactic analysis is |
| 10160 | (not (or | 10180 | ;; anchored on the start of the #define. In this case |
| 10161 | (assq 'arglist-intro c-syntactic-context) | 10181 | ;; we add cpp-define-intro to get the extra |
| 10162 | (assq 'arglist-cont c-syntactic-context) | 10182 | ;; indentation of the #define body. |
| 10163 | (assq 'arglist-cont-nonempty c-syntactic-context) | 10183 | (c-add-syntax 'cpp-define-intro))))) |
| 10164 | (assq 'arglist-close c-syntactic-context)))) | 10184 | |
| 10165 | ;; If inside a cpp expression, i.e. anywhere in a | 10185 | ;; return the syntax |
| 10166 | ;; cpp directive except a #define body, we only let | 10186 | c-syntactic-context))) |
| 10167 | ;; through the syntactic analysis that is internal | ||
| 10168 | ;; in the expression. That means the arglist | ||
| 10169 | ;; elements, if they are anchored inside the cpp | ||
| 10170 | ;; expression. | ||
| 10171 | (setq c-syntactic-context nil) | ||
| 10172 | (c-add-syntax 'cpp-macro-cont macro-start)) | ||
| 10173 | (when (and (eq macro-start syntactic-relpos) | ||
| 10174 | (not (assq 'cpp-define-intro c-syntactic-context)) | ||
| 10175 | (save-excursion | ||
| 10176 | (goto-char macro-start) | ||
| 10177 | (or (not (c-forward-to-cpp-define-body)) | ||
| 10178 | (<= (point) (c-point 'boi indent-point))))) | ||
| 10179 | ;; Inside a #define body and the syntactic analysis is | ||
| 10180 | ;; anchored on the start of the #define. In this case | ||
| 10181 | ;; we add cpp-define-intro to get the extra | ||
| 10182 | ;; indentation of the #define body. | ||
| 10183 | (c-add-syntax 'cpp-define-intro))))) | ||
| 10184 | |||
| 10185 | ;; return the syntax | ||
| 10186 | c-syntactic-context))) | ||
| 10187 | 10187 | ||
| 10188 | 10188 | ||
| 10189 | ;; Indentation calculation. | 10189 | ;; Indentation calculation. |
diff --git a/lisp/progmodes/gud.el b/lisp/progmodes/gud.el index 53918b903ee..47cbdf19ed2 100644 --- a/lisp/progmodes/gud.el +++ b/lisp/progmodes/gud.el | |||
| @@ -3127,7 +3127,9 @@ class of the file (using s to separate nested class ids)." | |||
| 3127 | ("^document\\s-.*\\(\n\\)" (1 "< b")) | 3127 | ("^document\\s-.*\\(\n\\)" (1 "< b")) |
| 3128 | ("^end\\(\\>\\)" | 3128 | ("^end\\(\\>\\)" |
| 3129 | (1 (ignore | 3129 | (1 (ignore |
| 3130 | (unless (eq (match-beginning 0) (point-min)) | 3130 | (when (and (> (match-beginning 0) (point-min)) |
| 3131 | (eq 1 (nth 7 (save-excursion | ||
| 3132 | (syntax-ppss (1- (match-beginning 0))))))) | ||
| 3131 | ;; We change the \n in front, which is more difficult, but results | 3133 | ;; We change the \n in front, which is more difficult, but results |
| 3132 | ;; in better highlighting. If the doc is empty, the single \n is | 3134 | ;; in better highlighting. If the doc is empty, the single \n is |
| 3133 | ;; both the beginning and the end of the docstring, which can't be | 3135 | ;; both the beginning and the end of the docstring, which can't be |