diff options
| author | Paul Eggert | 2011-10-29 10:33:13 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-10-29 10:33:13 -0700 |
| commit | 8d0eb4c275581847990b85dbb350caa3df9e653f (patch) | |
| tree | c161f977d59ac3103b04dc0f4aea57c83436a456 /lisp | |
| parent | 929bb973dd3faf1655f03ac758942d5b009354ad (diff) | |
| parent | 196e41e4aec1a44ec5b6e9bed485185ba872ae67 (diff) | |
| download | emacs-8d0eb4c275581847990b85dbb350caa3df9e653f.tar.gz emacs-8d0eb4c275581847990b85dbb350caa3df9e653f.zip | |
Merge from trunk.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 105 | ||||
| -rw-r--r-- | lisp/doc-view.el | 16 | ||||
| -rw-r--r-- | lisp/emacs-lisp/cl.el | 2 | ||||
| -rw-r--r-- | lisp/emacs-lisp/package.el | 1 | ||||
| -rw-r--r-- | lisp/mail/rmail.el | 1 | ||||
| -rw-r--r-- | lisp/mouse.el | 11 | ||||
| -rw-r--r-- | lisp/net/rcirc.el | 1 | ||||
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 284 | ||||
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 21 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 182 | ||||
| -rw-r--r-- | lisp/progmodes/cc-fonts.el | 8 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 72 | ||||
| -rw-r--r-- | lisp/progmodes/cc-mode.el | 3 | ||||
| -rw-r--r-- | lisp/progmodes/cc-vars.el | 62 | ||||
| -rw-r--r-- | lisp/progmodes/gdb-mi.el | 42 | ||||
| -rw-r--r-- | lisp/subr.el | 26 | ||||
| -rw-r--r-- | lisp/textmodes/flyspell.el | 2 | ||||
| -rw-r--r-- | lisp/vc/log-edit.el | 14 |
18 files changed, 643 insertions, 210 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6aa1bddb9f3..8309d3256bf 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,104 @@ | |||
| 1 | 2011-10-29 Chong Yidong <cyd@gnu.org> | ||
| 2 | |||
| 3 | * subr.el (y-or-n-p): Add code for batch mode (Bug#9818). | ||
| 4 | |||
| 5 | * mouse.el (mouse-yank-primary): Push the mark (Bug#9894). | ||
| 6 | |||
| 7 | * textmodes/flyspell.el (flyspell-word): Fix char offset for | ||
| 8 | forged Ispell output (Bug#7904). | ||
| 9 | |||
| 10 | * emacs-lisp/package.el (package-refresh-contents): Add autoload. | ||
| 11 | |||
| 12 | 2011-10-28 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 13 | |||
| 14 | * doc-view.el: Avoid ugly errors about not finding nil. | ||
| 15 | (doc-view-ghostscript-program, doc-view-dvipdfm-program) | ||
| 16 | (doc-view-dvipdf-program, doc-view-unoconv-program) | ||
| 17 | (doc-view-ps2pdf-program, doc-view-pdftotext-program): | ||
| 18 | Avoid nil or absolute file name as default value. | ||
| 19 | (doc-view-pdf->txt, doc-view-ps->pdf): Use executable-find here. | ||
| 20 | |||
| 21 | 2011-10-28 Alan Mackenzie <acm@muc.de> | ||
| 22 | |||
| 23 | * progmodes/cc-defs.el (c-version). -> 5.32.2. | ||
| 24 | |||
| 25 | 2011-10-28 Alan Mackenzie <acm@muc.de> | ||
| 26 | |||
| 27 | Amend the handling of c-beginning/end-of-defun in nested declaration | ||
| 28 | scopes. | ||
| 29 | |||
| 30 | * progmodes/cc-vars.el (c-defun-tactic): Move here from | ||
| 31 | cc-langs.el. Change it to a defcustom. | ||
| 32 | |||
| 33 | * progmodes/cc-langs.el (c-defun-tactic): Move this variable to | ||
| 34 | cc-vars.el. | ||
| 35 | (c-nonlabel-token-2-key): New variable for change in cc-engine.el. | ||
| 36 | |||
| 37 | * progmodes/cc-engine.el (c-beginning-of-statement-1): | ||
| 38 | Prevent "class foo : bar" being spuriously recognized as a label. | ||
| 39 | |||
| 40 | * progmodes/cc-cmds.el (c-narrow-to-most-enclosing-decl-block): | ||
| 41 | Add parameter `inclusive' (to include enclosing braces in the | ||
| 42 | region). | ||
| 43 | (c-widen-to-enclosing-decl-scope): New function. | ||
| 44 | (c-while-widening-to-decl-block): New macro. | ||
| 45 | (c-beginning-of-defun, c-end-of-defun): Change algorithm to keep going | ||
| 46 | outward for defun boundaries, and correspondingly change symbol | ||
| 47 | `respect-enclosure' to `go-outward'. | ||
| 48 | (c-declaration-limits): Change algorithm to report only the "innermost" | ||
| 49 | defun's boundaries. | ||
| 50 | |||
| 51 | 2011-10-28 Deniz Dogan <deniz@dogan.se> | ||
| 52 | |||
| 53 | * net/rcirc.el (rcirc-mode): Use hard newlines. | ||
| 54 | |||
| 55 | 2011-10-28 Alan Mackenzie <acm@muc.de> | ||
| 56 | |||
| 57 | Amend to indent and fontify macros "which include their own semicolon" | ||
| 58 | correctly, using the "virtual semicolon" mechanism. | ||
| 59 | |||
| 60 | * progmodes/cc-defs.el: Update "virtual semicolon" comments. | ||
| 61 | |||
| 62 | * progmodes/cc-engine.el (c-crosses-statement-barrier-p): | ||
| 63 | Recoded to scan one line at at time rather than having \n and \r | ||
| 64 | explicitly in c-stmt-delim-chars | ||
| 65 | (for some modes, e.g. AWK). | ||
| 66 | (c-forward-label): Amend for virtual semicolons. | ||
| 67 | (c-at-macro-vsemi-p, c-macro-vsemi-status-unknown-p): New functions | ||
| 68 | |||
| 69 | * progmodes/cc-fonts.el (c-font-lock-declarations): Take account | ||
| 70 | of the new C macros. | ||
| 71 | |||
| 72 | * progmodes/cc-langs.el (c-at-vsemi-p-fn): | ||
| 73 | (c-vsemi-status-unknown-p-fn): move to earlier in the file. | ||
| 74 | (c-opt-cpp-symbol, c-line-comment-start-regexp): New language variables. | ||
| 75 | (c-opt-cpp-macro-define): Make into a full language variable. | ||
| 76 | (c-stmt-delim-chars, c-stmt-delim-chars-with-comma): Special value for | ||
| 77 | AWK Mode (including \n, \r) removed, no longer needed. | ||
| 78 | |||
| 79 | * progmodes/cc-mode.el (c-mode, c++-mode, objc-mode): | ||
| 80 | Invoke c-make-macro-with-semi-re. | ||
| 81 | |||
| 82 | * progmodes/cc-vars.el (c-macro-with-semi-re): | ||
| 83 | (c-macro-names-with-semicolon): New variables. | ||
| 84 | (c-make-macro-with-semi-re): New function | ||
| 85 | |||
| 86 | 2011-10-28 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 87 | |||
| 88 | * vc/log-edit.el: Fill empty field rather than adding new one. | ||
| 89 | (log-edit-add-field): New function. | ||
| 90 | (log-edit-insert-changelog): Use it. | ||
| 91 | |||
| 92 | 2011-10-28 Mark Lillibridge <mark.lillibridge@hp.com> (tiny change) | ||
| 93 | |||
| 94 | * mail/rmail.el (rmail-mode-map): Add M-C-f as in rmailsum (bug#9802). | ||
| 95 | |||
| 96 | 2011-10-28 Stefan Monnier <monnier@iro.umontreal.ca> | ||
| 97 | |||
| 98 | * progmodes/gdb-mi.el: Warn the user when -i=mi is missing. | ||
| 99 | (gdb--check-interpreter): New function. | ||
| 100 | (gdb): Use it. | ||
| 101 | |||
| 1 | 2011-10-27 Glenn Morris <rgm@gnu.org> | 102 | 2011-10-27 Glenn Morris <rgm@gnu.org> |
| 2 | 103 | ||
| 3 | * emacs-lisp/cl-extra.el (most-positive-float, most-negative-float) | 104 | * emacs-lisp/cl-extra.el (most-positive-float, most-negative-float) |
| @@ -21,8 +122,8 @@ | |||
| 21 | * subr.el (change-major-mode-after-body-hook): New hook. | 122 | * subr.el (change-major-mode-after-body-hook): New hook. |
| 22 | (run-mode-hooks): Run it. | 123 | (run-mode-hooks): Run it. |
| 23 | 124 | ||
| 24 | * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): Use | 125 | * emacs-lisp/easy-mmode.el (define-globalized-minor-mode): |
| 25 | change-major-mode-before-body-hook. | 126 | Use change-major-mode-before-body-hook. |
| 26 | 127 | ||
| 27 | * simple.el (fundamental-mode): | 128 | * simple.el (fundamental-mode): |
| 28 | * emacs-lisp/derived.el (define-derived-mode): Revert 2010-04-28 | 129 | * emacs-lisp/derived.el (define-derived-mode): Revert 2010-04-28 |
diff --git a/lisp/doc-view.el b/lisp/doc-view.el index ceaad83cd7c..d16d8c6f62d 100644 --- a/lisp/doc-view.el +++ b/lisp/doc-view.el | |||
| @@ -149,7 +149,7 @@ | |||
| 149 | :group 'multimedia | 149 | :group 'multimedia |
| 150 | :prefix "doc-view-") | 150 | :prefix "doc-view-") |
| 151 | 151 | ||
| 152 | (defcustom doc-view-ghostscript-program (executable-find "gs") | 152 | (defcustom doc-view-ghostscript-program "gs" |
| 153 | "Program to convert PS and PDF files to PNG." | 153 | "Program to convert PS and PDF files to PNG." |
| 154 | :type 'file | 154 | :type 'file |
| 155 | :group 'doc-view) | 155 | :group 'doc-view) |
| @@ -175,7 +175,7 @@ Has only an effect if imagemagick support is compiled into emacs." | |||
| 175 | :type 'number | 175 | :type 'number |
| 176 | :group 'doc-view) | 176 | :group 'doc-view) |
| 177 | 177 | ||
| 178 | (defcustom doc-view-dvipdfm-program (executable-find "dvipdfm") | 178 | (defcustom doc-view-dvipdfm-program "dvipdfm" |
| 179 | "Program to convert DVI files to PDF. | 179 | "Program to convert DVI files to PDF. |
| 180 | 180 | ||
| 181 | DVI file will be converted to PDF before the resulting PDF is | 181 | DVI file will be converted to PDF before the resulting PDF is |
| @@ -186,7 +186,7 @@ If this and `doc-view-dvipdf-program' are set, | |||
| 186 | :type 'file | 186 | :type 'file |
| 187 | :group 'doc-view) | 187 | :group 'doc-view) |
| 188 | 188 | ||
| 189 | (defcustom doc-view-dvipdf-program (executable-find "dvipdf") | 189 | (defcustom doc-view-dvipdf-program "dvipdf" |
| 190 | "Program to convert DVI files to PDF. | 190 | "Program to convert DVI files to PDF. |
| 191 | 191 | ||
| 192 | DVI file will be converted to PDF before the resulting PDF is | 192 | DVI file will be converted to PDF before the resulting PDF is |
| @@ -197,21 +197,21 @@ If this and `doc-view-dvipdfm-program' are set, | |||
| 197 | :type 'file | 197 | :type 'file |
| 198 | :group 'doc-view) | 198 | :group 'doc-view) |
| 199 | 199 | ||
| 200 | (defcustom doc-view-unoconv-program (executable-find "unoconv") | 200 | (defcustom doc-view-unoconv-program "unoconv" |
| 201 | "Program to convert any file type readable by OpenOffice.org to PDF. | 201 | "Program to convert any file type readable by OpenOffice.org to PDF. |
| 202 | 202 | ||
| 203 | Needed for viewing OpenOffice.org (and MS Office) files." | 203 | Needed for viewing OpenOffice.org (and MS Office) files." |
| 204 | :type 'file | 204 | :type 'file |
| 205 | :group 'doc-view) | 205 | :group 'doc-view) |
| 206 | 206 | ||
| 207 | (defcustom doc-view-ps2pdf-program (executable-find "ps2pdf") | 207 | (defcustom doc-view-ps2pdf-program "ps2pdf" |
| 208 | "Program to convert PS files to PDF. | 208 | "Program to convert PS files to PDF. |
| 209 | 209 | ||
| 210 | PS files will be converted to PDF before searching is possible." | 210 | PS files will be converted to PDF before searching is possible." |
| 211 | :type 'file | 211 | :type 'file |
| 212 | :group 'doc-view) | 212 | :group 'doc-view) |
| 213 | 213 | ||
| 214 | (defcustom doc-view-pdftotext-program (executable-find "pdftotext") | 214 | (defcustom doc-view-pdftotext-program "pdftotext" |
| 215 | "Program to convert PDF files to plain text. | 215 | "Program to convert PDF files to plain text. |
| 216 | 216 | ||
| 217 | Needed for searching." | 217 | Needed for searching." |
| @@ -881,7 +881,7 @@ Start by converting PAGES, and then the rest." | |||
| 881 | 881 | ||
| 882 | (defun doc-view-pdf->txt (pdf txt callback) | 882 | (defun doc-view-pdf->txt (pdf txt callback) |
| 883 | "Convert PDF to TXT asynchronously and call CALLBACK when finished." | 883 | "Convert PDF to TXT asynchronously and call CALLBACK when finished." |
| 884 | (or doc-view-pdftotext-program | 884 | (or (executable-find doc-view-pdftotext-program) |
| 885 | (error "You need the `pdftotext' program to convert a PDF to text")) | 885 | (error "You need the `pdftotext' program to convert a PDF to text")) |
| 886 | (doc-view-start-process "pdf->txt" doc-view-pdftotext-program | 886 | (doc-view-start-process "pdf->txt" doc-view-pdftotext-program |
| 887 | (list "-raw" pdf txt) | 887 | (list "-raw" pdf txt) |
| @@ -917,7 +917,7 @@ Start by converting PAGES, and then the rest." | |||
| 917 | 917 | ||
| 918 | (defun doc-view-ps->pdf (ps pdf callback) | 918 | (defun doc-view-ps->pdf (ps pdf callback) |
| 919 | "Convert PS to PDF asynchronously and call CALLBACK when finished." | 919 | "Convert PS to PDF asynchronously and call CALLBACK when finished." |
| 920 | (or doc-view-ps2pdf-program | 920 | (or (executable-find doc-view-ps2pdf-program) |
| 921 | (error "You need the `ps2pdf' program to convert PS to PDF")) | 921 | (error "You need the `ps2pdf' program to convert PS to PDF")) |
| 922 | (doc-view-start-process "ps->pdf" doc-view-ps2pdf-program | 922 | (doc-view-start-process "ps->pdf" doc-view-ps2pdf-program |
| 923 | (list | 923 | (list |
diff --git a/lisp/emacs-lisp/cl.el b/lisp/emacs-lisp/cl.el index 0b34e9f27f7..16eb31c1209 100644 --- a/lisp/emacs-lisp/cl.el +++ b/lisp/emacs-lisp/cl.el | |||
| @@ -341,7 +341,7 @@ Call `cl-float-limits' to set this.") | |||
| 341 | 341 | ||
| 342 | (defconst most-negative-float nil | 342 | (defconst most-negative-float nil |
| 343 | "The largest negative value that a Lisp float can hold. | 343 | "The largest negative value that a Lisp float can hold. |
| 344 | This is simply -`most-negative-float'. | 344 | This is simply -`most-positive-float'. |
| 345 | Call `cl-float-limits' to set this.") | 345 | Call `cl-float-limits' to set this.") |
| 346 | 346 | ||
| 347 | (defconst least-positive-float nil | 347 | (defconst least-positive-float nil |
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 2e340a442a6..0bd37ce1d49 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el | |||
| @@ -1076,6 +1076,7 @@ similar to an entry in `package-alist'. Save the cached copy to | |||
| 1076 | (let ((version-control 'never)) | 1076 | (let ((version-control 'never)) |
| 1077 | (save-buffer)))))) | 1077 | (save-buffer)))))) |
| 1078 | 1078 | ||
| 1079 | ;;;###autoload | ||
| 1079 | (defun package-refresh-contents () | 1080 | (defun package-refresh-contents () |
| 1080 | "Download the ELPA archive description if needed. | 1081 | "Download the ELPA archive description if needed. |
| 1081 | This informs Emacs about the latest versions of all packages, and | 1082 | This informs Emacs about the latest versions of all packages, and |
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 770050efb08..603a615192a 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -1008,6 +1008,7 @@ The buffer is expected to be narrowed to just the header of the message." | |||
| 1008 | (define-key map "\e\C-l" 'rmail-summary-by-labels) | 1008 | (define-key map "\e\C-l" 'rmail-summary-by-labels) |
| 1009 | (define-key map "\e\C-r" 'rmail-summary-by-recipients) | 1009 | (define-key map "\e\C-r" 'rmail-summary-by-recipients) |
| 1010 | (define-key map "\e\C-s" 'rmail-summary-by-regexp) | 1010 | (define-key map "\e\C-s" 'rmail-summary-by-regexp) |
| 1011 | (define-key map "\e\C-f" 'rmail-summary-by-senders) | ||
| 1011 | (define-key map "\e\C-t" 'rmail-summary-by-topic) | 1012 | (define-key map "\e\C-t" 'rmail-summary-by-topic) |
| 1012 | (define-key map "m" 'rmail-mail) | 1013 | (define-key map "m" 'rmail-mail) |
| 1013 | (define-key map "\em" 'rmail-retry-failure) | 1014 | (define-key map "\em" 'rmail-retry-failure) |
diff --git a/lisp/mouse.el b/lisp/mouse.el index 9b1cf48ccdc..615062dc031 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el | |||
| @@ -1133,8 +1133,8 @@ regardless of where you click." | |||
| 1133 | 1133 | ||
| 1134 | (defun mouse-yank-primary (click) | 1134 | (defun mouse-yank-primary (click) |
| 1135 | "Insert the primary selection at the position clicked on. | 1135 | "Insert the primary selection at the position clicked on. |
| 1136 | Move point to the end of the inserted text. | 1136 | Move point to the end of the inserted text, and set mark at |
| 1137 | If `mouse-yank-at-point' is non-nil, insert at point | 1137 | beginning. If `mouse-yank-at-point' is non-nil, insert at point |
| 1138 | regardless of where you click." | 1138 | regardless of where you click." |
| 1139 | (interactive "e") | 1139 | (interactive "e") |
| 1140 | ;; Give temporary modes such as isearch a chance to turn off. | 1140 | ;; Give temporary modes such as isearch a chance to turn off. |
| @@ -1162,9 +1162,10 @@ regardless of where you click." | |||
| 1162 | ;; FIXME: What about xterm-mouse-mode etc.? | 1162 | ;; FIXME: What about xterm-mouse-mode etc.? |
| 1163 | (t | 1163 | (t |
| 1164 | (x-get-selection 'PRIMARY))))) | 1164 | (x-get-selection 'PRIMARY))))) |
| 1165 | (if primary | 1165 | (unless primary |
| 1166 | (insert primary) | 1166 | (error "No selection is available")) |
| 1167 | (error "No selection is available")))) | 1167 | (push-mark (point)) |
| 1168 | (insert primary))) | ||
| 1168 | 1169 | ||
| 1169 | (defun mouse-kill-ring-save (click) | 1170 | (defun mouse-kill-ring-save (click) |
| 1170 | "Copy the region between point and the mouse click in the kill ring. | 1171 | "Copy the region between point and the mouse click in the kill ring. |
diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 6a912cd6273..f6981aeabd9 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el | |||
| @@ -979,6 +979,7 @@ This number is independent of the number of lines in the buffer.") | |||
| 979 | (set (make-local-variable 'rcirc-recent-quit-alist) nil) | 979 | (set (make-local-variable 'rcirc-recent-quit-alist) nil) |
| 980 | (set (make-local-variable 'rcirc-current-line) 0) | 980 | (set (make-local-variable 'rcirc-current-line) 0) |
| 981 | 981 | ||
| 982 | (use-hard-newlines t) | ||
| 982 | (set (make-local-variable 'rcirc-short-buffer-name) nil) | 983 | (set (make-local-variable 'rcirc-short-buffer-name) nil) |
| 983 | (set (make-local-variable 'rcirc-urls) nil) | 984 | (set (make-local-variable 'rcirc-urls) nil) |
| 984 | 985 | ||
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 0f873e678c3..e59fdc16af7 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -1485,6 +1485,78 @@ No indentation or other \"electric\" behavior is performed." | |||
| 1485 | (setq n (1- n)))) | 1485 | (setq n (1- n)))) |
| 1486 | n) | 1486 | n) |
| 1487 | 1487 | ||
| 1488 | (defun c-narrow-to-most-enclosing-decl-block (&optional inclusive) | ||
| 1489 | ;; If we are inside a decl-block (in the sense of c-looking-at-decl-block), | ||
| 1490 | ;; i.e. something like namespace{} or extern{}, narrow to the insides of | ||
| 1491 | ;; that block (NOT including the enclosing braces) if INCLUSIVE is nil, | ||
| 1492 | ;; otherwise include the braces. If the closing brace is missing, | ||
| 1493 | ;; (point-max) is used instead. | ||
| 1494 | (let ((paren-state (c-parse-state)) | ||
| 1495 | encl-decl) | ||
| 1496 | (setq encl-decl (and paren-state (c-most-enclosing-decl-block paren-state))) | ||
| 1497 | (if encl-decl | ||
| 1498 | (save-excursion | ||
| 1499 | (narrow-to-region | ||
| 1500 | (if inclusive | ||
| 1501 | (progn (goto-char encl-decl) | ||
| 1502 | (c-beginning-of-decl-1) | ||
| 1503 | (point)) | ||
| 1504 | (1+ encl-decl)) | ||
| 1505 | (progn | ||
| 1506 | (goto-char encl-decl) | ||
| 1507 | (or (c-safe (forward-list) | ||
| 1508 | (if inclusive | ||
| 1509 | (point) | ||
| 1510 | (1- (point)))) | ||
| 1511 | (point-max)))))))) | ||
| 1512 | |||
| 1513 | (defun c-widen-to-enclosing-decl-scope (paren-state orig-point-min orig-point-max) | ||
| 1514 | ;; Narrow the buffer to the innermost declaration scope (e.g. a class, a | ||
| 1515 | ;; namespace or the "whole buffer") recorded in PAREN-STATE, the bounding | ||
| 1516 | ;; braces NOT being included in the resulting region. On no account may the | ||
| 1517 | ;; final region exceed that bounded by ORIG-POINT-MIN, ORIG-POINT-MAX. | ||
| 1518 | ;; PAREN-STATE is a list of buffer positions in the style of | ||
| 1519 | ;; (c-parse-state), one of which will be that of the desired opening brace, | ||
| 1520 | ;; if there is one. | ||
| 1521 | ;; | ||
| 1522 | ;; Return the position of the enclosing opening brace, or nil | ||
| 1523 | (let (encl-decl) ; putative position of decl-scope's opening brace. | ||
| 1524 | (save-restriction | ||
| 1525 | (narrow-to-region orig-point-min orig-point-max) | ||
| 1526 | (setq encl-decl (and paren-state | ||
| 1527 | (c-most-enclosing-decl-block paren-state)))) | ||
| 1528 | (if encl-decl | ||
| 1529 | (progn | ||
| 1530 | (widen) | ||
| 1531 | (narrow-to-region (1+ encl-decl) | ||
| 1532 | (save-excursion | ||
| 1533 | (goto-char encl-decl) | ||
| 1534 | (or (c-safe (forward-list) | ||
| 1535 | (1- (point))) | ||
| 1536 | orig-point-max))) | ||
| 1537 | encl-decl) | ||
| 1538 | (narrow-to-region orig-point-min orig-point-max) | ||
| 1539 | nil))) | ||
| 1540 | |||
| 1541 | (eval-and-compile | ||
| 1542 | (defmacro c-while-widening-to-decl-block (condition) | ||
| 1543 | ;; Repeatedly evaluate CONDITION until it returns nil. After each | ||
| 1544 | ;; evaluation, if `c-defun-tactic' is set appropriately, widen to innards | ||
| 1545 | ;; of the next enclosing declaration block (e.g. namespace, class), or the | ||
| 1546 | ;; buffer's original restriction. | ||
| 1547 | ;; | ||
| 1548 | ;; This is a very special purpose macro, which assumes the existence of | ||
| 1549 | ;; several variables. It is for use only in c-beginning-of-defun and | ||
| 1550 | ;; c-end-of-defun. | ||
| 1551 | `(while | ||
| 1552 | (and ,condition | ||
| 1553 | (eq c-defun-tactic 'go-outward) | ||
| 1554 | lim) | ||
| 1555 | (setq paren-state (c-whack-state-after lim paren-state)) | ||
| 1556 | (setq lim (c-widen-to-enclosing-decl-scope | ||
| 1557 | paren-state orig-point-min orig-point-max)) | ||
| 1558 | (setq where 'in-block)))) | ||
| 1559 | |||
| 1488 | (defun c-beginning-of-defun (&optional arg) | 1560 | (defun c-beginning-of-defun (&optional arg) |
| 1489 | "Move backward to the beginning of a defun. | 1561 | "Move backward to the beginning of a defun. |
| 1490 | Every top level declaration that contains a brace paren block is | 1562 | Every top level declaration that contains a brace paren block is |
| @@ -1509,50 +1581,66 @@ defun." | |||
| 1509 | (c-save-buffer-state | 1581 | (c-save-buffer-state |
| 1510 | (beginning-of-defun-function end-of-defun-function | 1582 | (beginning-of-defun-function end-of-defun-function |
| 1511 | (start (point)) | 1583 | (start (point)) |
| 1512 | where paren-state pos) | 1584 | (paren-state (copy-tree (c-parse-state))) ; This must not share list |
| 1585 | ; structure with other users of c-state-cache. | ||
| 1586 | (orig-point-min (point-min)) (orig-point-max (point-max)) | ||
| 1587 | lim ; Position of { which has been widened to. | ||
| 1588 | where pos) | ||
| 1513 | 1589 | ||
| 1514 | ;; Move back out of any macro/comment/string we happen to be in. | 1590 | (save-restriction |
| 1515 | (c-beginning-of-macro) | 1591 | (if (eq c-defun-tactic 'go-outward) |
| 1516 | (setq pos (c-literal-limits)) | 1592 | (setq lim (c-widen-to-enclosing-decl-scope ; e.g. class, namespace. |
| 1517 | (if pos (goto-char (car pos))) | 1593 | paren-state orig-point-min orig-point-max))) |
| 1518 | |||
| 1519 | (setq where (c-where-wrt-brace-construct)) | ||
| 1520 | |||
| 1521 | (if (< arg 0) | ||
| 1522 | ;; Move forward to the closing brace of a function. | ||
| 1523 | (progn | ||
| 1524 | (if (memq where '(at-function-end outwith-function)) | ||
| 1525 | (setq arg (1+ arg))) | ||
| 1526 | (if (< arg 0) | ||
| 1527 | (setq arg (c-forward-to-nth-EOF-} (- arg) where))) | ||
| 1528 | ;; Move forward to the next opening brace.... | ||
| 1529 | (when (and (= arg 0) | ||
| 1530 | (c-syntactic-re-search-forward "{" nil 'eob)) | ||
| 1531 | (backward-char) | ||
| 1532 | ;; ... and backward to the function header. | ||
| 1533 | (c-beginning-of-decl-1) | ||
| 1534 | t)) | ||
| 1535 | |||
| 1536 | ;; Move backward to the opening brace of a function. | ||
| 1537 | (when (and (> arg 0) | ||
| 1538 | (eq (setq arg (c-backward-to-nth-BOF-{ arg where)) 0)) | ||
| 1539 | 1594 | ||
| 1540 | ;; Go backward to this function's header. | 1595 | ;; Move back out of any macro/comment/string we happen to be in. |
| 1541 | (c-beginning-of-decl-1) | 1596 | (c-beginning-of-macro) |
| 1597 | (setq pos (c-literal-limits)) | ||
| 1598 | (if pos (goto-char (car pos))) | ||
| 1542 | 1599 | ||
| 1543 | (setq pos (point)) | 1600 | (setq where (c-where-wrt-brace-construct)) |
| 1544 | ;; We're now there, modulo comments and whitespace. | ||
| 1545 | ;; Try to be line oriented; position point at the closest | ||
| 1546 | ;; preceding boi that isn't inside a comment, but if we hit | ||
| 1547 | ;; the previous declaration then we use the current point | ||
| 1548 | ;; instead. | ||
| 1549 | (while (and (/= (point) (c-point 'boi)) | ||
| 1550 | (c-backward-single-comment))) | ||
| 1551 | (if (/= (point) (c-point 'boi)) | ||
| 1552 | (goto-char pos))) | ||
| 1553 | 1601 | ||
| 1554 | (c-keep-region-active) | 1602 | (if (< arg 0) |
| 1555 | (= arg 0)))) | 1603 | ;; Move forward to the closing brace of a function. |
| 1604 | (progn | ||
| 1605 | (if (memq where '(at-function-end outwith-function)) | ||
| 1606 | (setq arg (1+ arg))) | ||
| 1607 | (if (< arg 0) | ||
| 1608 | (c-while-widening-to-decl-block | ||
| 1609 | (< (setq arg (- (c-forward-to-nth-EOF-} (- arg) where))) 0))) | ||
| 1610 | ;; Move forward to the next opening brace.... | ||
| 1611 | (when (and (= arg 0) | ||
| 1612 | (progn | ||
| 1613 | (c-while-widening-to-decl-block | ||
| 1614 | (not (c-syntactic-re-search-forward "{" nil 'eob))) | ||
| 1615 | (eq (char-before) ?{))) | ||
| 1616 | (backward-char) | ||
| 1617 | ;; ... and backward to the function header. | ||
| 1618 | (c-beginning-of-decl-1) | ||
| 1619 | t)) | ||
| 1620 | |||
| 1621 | ;; Move backward to the opening brace of a function, making successively | ||
| 1622 | ;; larger portions of the buffer visible as necessary. | ||
| 1623 | (when (> arg 0) | ||
| 1624 | (c-while-widening-to-decl-block | ||
| 1625 | (> (setq arg (c-backward-to-nth-BOF-{ arg where)) 0))) | ||
| 1626 | |||
| 1627 | (when (eq arg 0) | ||
| 1628 | ;; Go backward to this function's header. | ||
| 1629 | (c-beginning-of-decl-1) | ||
| 1630 | |||
| 1631 | (setq pos (point)) | ||
| 1632 | ;; We're now there, modulo comments and whitespace. | ||
| 1633 | ;; Try to be line oriented; position point at the closest | ||
| 1634 | ;; preceding boi that isn't inside a comment, but if we hit | ||
| 1635 | ;; the previous declaration then we use the current point | ||
| 1636 | ;; instead. | ||
| 1637 | (while (and (/= (point) (c-point 'boi)) | ||
| 1638 | (c-backward-single-comment))) | ||
| 1639 | (if (/= (point) (c-point 'boi)) | ||
| 1640 | (goto-char pos))) | ||
| 1641 | |||
| 1642 | (c-keep-region-active) | ||
| 1643 | (= arg 0))))) | ||
| 1556 | 1644 | ||
| 1557 | (defun c-forward-to-nth-EOF-} (n where) | 1645 | (defun c-forward-to-nth-EOF-} (n where) |
| 1558 | ;; Skip to the closing brace of the Nth function after point. If | 1646 | ;; Skip to the closing brace of the Nth function after point. If |
| @@ -1617,50 +1705,62 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'." | |||
| 1617 | (c-save-buffer-state | 1705 | (c-save-buffer-state |
| 1618 | (beginning-of-defun-function end-of-defun-function | 1706 | (beginning-of-defun-function end-of-defun-function |
| 1619 | (start (point)) | 1707 | (start (point)) |
| 1620 | where paren-state pos) | 1708 | (paren-state (copy-tree (c-parse-state))) ; This must not share list |
| 1709 | ; structure with other users of c-state-cache. | ||
| 1710 | (orig-point-min (point-min)) (orig-point-max (point-max)) | ||
| 1711 | lim | ||
| 1712 | where pos) | ||
| 1713 | (save-restriction | ||
| 1714 | (if (eq c-defun-tactic 'go-outward) | ||
| 1715 | (setq lim (c-widen-to-enclosing-decl-scope ; e.g. class, namespace | ||
| 1716 | paren-state orig-point-min orig-point-max))) | ||
| 1621 | 1717 | ||
| 1622 | ;; Move back out of any macro/comment/string we happen to be in. | 1718 | ;; Move back out of any macro/comment/string we happen to be in. |
| 1623 | (c-beginning-of-macro) | 1719 | (c-beginning-of-macro) |
| 1624 | (setq pos (c-literal-limits)) | 1720 | (setq pos (c-literal-limits)) |
| 1625 | (if pos (goto-char (car pos))) | 1721 | (if pos (goto-char (car pos))) |
| 1626 | 1722 | ||
| 1627 | (setq where (c-where-wrt-brace-construct)) | 1723 | (setq where (c-where-wrt-brace-construct)) |
| 1628 | 1724 | ||
| 1629 | (if (< arg 0) | 1725 | (if (< arg 0) |
| 1630 | ;; Move backwards to the } of a function | 1726 | ;; Move backwards to the } of a function |
| 1631 | (progn | 1727 | (progn |
| 1632 | (if (memq where '(at-header outwith-function)) | 1728 | (if (memq where '(at-header outwith-function)) |
| 1633 | (setq arg (1+ arg))) | 1729 | (setq arg (1+ arg))) |
| 1634 | (if (< arg 0) | 1730 | (if (< arg 0) |
| 1635 | (setq arg (c-backward-to-nth-BOF-{ (- arg) where))) | 1731 | (c-while-widening-to-decl-block |
| 1636 | (if (= arg 0) | 1732 | (< (setq arg (- (c-backward-to-nth-BOF-{ (- arg) where))) 0))) |
| 1637 | (c-syntactic-skip-backward "^}"))) | 1733 | (if (= arg 0) |
| 1638 | 1734 | (c-while-widening-to-decl-block | |
| 1639 | ;; Move forward to the } of a function | 1735 | (progn (c-syntactic-skip-backward "^}") |
| 1640 | (if (> arg 0) | 1736 | (not (eq (char-before) ?})))))) |
| 1641 | (setq arg (c-forward-to-nth-EOF-} arg where)))) | 1737 | |
| 1642 | 1738 | ;; Move forward to the } of a function | |
| 1643 | ;; Do we need to move forward from the brace to the semicolon? | 1739 | (if (> arg 0) |
| 1644 | (when (eq arg 0) | 1740 | (c-while-widening-to-decl-block |
| 1645 | (if (c-in-function-trailer-p) ; after "}" of struct/enum, etc. | 1741 | (> (setq arg (c-forward-to-nth-EOF-} arg where)) 0)))) |
| 1646 | (c-syntactic-re-search-forward ";")) | 1742 | |
| 1647 | 1743 | ;; Do we need to move forward from the brace to the semicolon? | |
| 1648 | (setq pos (point)) | 1744 | (when (eq arg 0) |
| 1649 | ;; We're there now, modulo comments and whitespace. | 1745 | (if (c-in-function-trailer-p) ; after "}" of struct/enum, etc. |
| 1650 | ;; Try to be line oriented; position point after the next | 1746 | (c-syntactic-re-search-forward ";")) |
| 1651 | ;; newline that isn't inside a comment, but if we hit the | ||
| 1652 | ;; next declaration then we use the current point instead. | ||
| 1653 | (while (and (not (bolp)) | ||
| 1654 | (not (looking-at "\\s *$")) | ||
| 1655 | (c-forward-single-comment))) | ||
| 1656 | (cond ((bolp)) | ||
| 1657 | ((looking-at "\\s *$") | ||
| 1658 | (forward-line 1)) | ||
| 1659 | (t | ||
| 1660 | (goto-char pos)))) | ||
| 1661 | 1747 | ||
| 1662 | (c-keep-region-active) | 1748 | (setq pos (point)) |
| 1663 | (= arg 0))) | 1749 | ;; We're there now, modulo comments and whitespace. |
| 1750 | ;; Try to be line oriented; position point after the next | ||
| 1751 | ;; newline that isn't inside a comment, but if we hit the | ||
| 1752 | ;; next declaration then we use the current point instead. | ||
| 1753 | (while (and (not (bolp)) | ||
| 1754 | (not (looking-at "\\s *$")) | ||
| 1755 | (c-forward-single-comment))) | ||
| 1756 | (cond ((bolp)) | ||
| 1757 | ((looking-at "\\s *$") | ||
| 1758 | (forward-line 1)) | ||
| 1759 | (t | ||
| 1760 | (goto-char pos)))) | ||
| 1761 | |||
| 1762 | (c-keep-region-active) | ||
| 1763 | (= arg 0)))) | ||
| 1664 | 1764 | ||
| 1665 | (defun c-defun-name () | 1765 | (defun c-defun-name () |
| 1666 | "Return the name of the current defun, or NIL if there isn't one. | 1766 | "Return the name of the current defun, or NIL if there isn't one. |
| @@ -1746,6 +1846,11 @@ with a brace block." | |||
| 1746 | ;; | 1846 | ;; |
| 1747 | ;; This function might do hidden buffer changes. | 1847 | ;; This function might do hidden buffer changes. |
| 1748 | (save-excursion | 1848 | (save-excursion |
| 1849 | (save-restriction | ||
| 1850 | (when (eq c-defun-tactic 'go-outward) | ||
| 1851 | (c-narrow-to-most-enclosing-decl-block t) ; e.g. class, namespace | ||
| 1852 | (or (save-restriction | ||
| 1853 | (c-narrow-to-most-enclosing-decl-block nil) | ||
| 1749 | 1854 | ||
| 1750 | ;; Note: Some code duplication in `c-beginning-of-defun' and | 1855 | ;; Note: Some code duplication in `c-beginning-of-defun' and |
| 1751 | ;; `c-end-of-defun'. | 1856 | ;; `c-end-of-defun'. |
| @@ -1755,11 +1860,12 @@ with a brace block." | |||
| 1755 | lim pos end-pos) | 1860 | lim pos end-pos) |
| 1756 | (unless (c-safe | 1861 | (unless (c-safe |
| 1757 | (goto-char (c-least-enclosing-brace paren-state)) | 1862 | (goto-char (c-least-enclosing-brace paren-state)) |
| 1758 | ;; If we moved to the outermost enclosing paren then we | 1863 | ;; If we moved to the outermost enclosing paren |
| 1759 | ;; can use c-safe-position to set the limit. Can't do | 1864 | ;; then we can use c-safe-position to set the |
| 1760 | ;; that otherwise since the earlier paren pair on | 1865 | ;; limit. Can't do that otherwise since the |
| 1761 | ;; paren-state might very well be part of the | 1866 | ;; earlier paren pair on paren-state might very |
| 1762 | ;; declaration we should go to. | 1867 | ;; well be part of the declaration we should go |
| 1868 | ;; to. | ||
| 1763 | (setq lim (c-safe-position (point) paren-state)) | 1869 | (setq lim (c-safe-position (point) paren-state)) |
| 1764 | t) | 1870 | t) |
| 1765 | ;; At top level. Make sure we aren't inside a literal. | 1871 | ;; At top level. Make sure we aren't inside a literal. |
| @@ -1843,8 +1949,12 @@ with a brace block." | |||
| 1843 | (forward-line 1) | 1949 | (forward-line 1) |
| 1844 | (point)) | 1950 | (point)) |
| 1845 | (t | 1951 | (t |
| 1846 | pos))))) | 1952 | pos)))))))) |
| 1847 | )))) | 1953 | (and (not near) |
| 1954 | (goto-char (point-min)) | ||
| 1955 | (c-forward-decl-or-cast-1 -1 nil nil) | ||
| 1956 | (eq (char-after) ?\{) | ||
| 1957 | (cons (point-min) (point-max)))))))) | ||
| 1848 | 1958 | ||
| 1849 | (defun c-mark-function () | 1959 | (defun c-mark-function () |
| 1850 | "Put mark at end of the current top-level declaration or macro, point at beginning. | 1960 | "Put mark at end of the current top-level declaration or macro, point at beginning. |
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index e5b4d7e35a4..8632807f2b8 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -93,7 +93,7 @@ | |||
| 93 | 93 | ||
| 94 | ;;; Variables also used at compile time. | 94 | ;;; Variables also used at compile time. |
| 95 | 95 | ||
| 96 | (defconst c-version "5.31.9" | 96 | (defconst c-version "5.32.2" |
| 97 | "CC Mode version number.") | 97 | "CC Mode version number.") |
| 98 | 98 | ||
| 99 | (defconst c-version-sym (intern c-version)) | 99 | (defconst c-version-sym (intern c-version)) |
| @@ -744,19 +744,20 @@ be after it." | |||
| 744 | ;; V i r t u a l S e m i c o l o n s | 744 | ;; V i r t u a l S e m i c o l o n s |
| 745 | ;; | 745 | ;; |
| 746 | ;; In most CC Mode languages, statements are terminated explicitly by | 746 | ;; In most CC Mode languages, statements are terminated explicitly by |
| 747 | ;; semicolons or closing braces. In some of the CC modes (currently only AWK | 747 | ;; semicolons or closing braces. In some of the CC modes (currently AWK Mode |
| 748 | ;; Mode (April 2004)), statements are (or can be) terminated by EOLs. Such a | 748 | ;; and certain user-specified #define macros in C, C++, etc. (November 2008)), |
| 749 | ;; statement is said to be terminated by a "virtual semicolon" (VS). A | 749 | ;; statements are (or can be) terminated by EOLs. Such a statement is said to |
| 750 | ;; statement terminated by an actual semicolon or brace is never considered to | 750 | ;; be terminated by a "virtual semicolon" (VS). A statement terminated by an |
| 751 | ;; have a VS. | 751 | ;; actual semicolon or brace is never considered to have a VS. |
| 752 | ;; | 752 | ;; |
| 753 | ;; The indentation engine (or whatever) tests for a VS at a specific position | 753 | ;; The indentation engine (or whatever) tests for a VS at a specific position |
| 754 | ;; by invoking the macro `c-at-vsemi-p', which in its turn calls the mode | 754 | ;; by invoking the macro `c-at-vsemi-p', which in its turn calls the mode |
| 755 | ;; specific function (if any) which is the value of the language variable | 755 | ;; specific function (if any) which is the value of the language variable |
| 756 | ;; `c-at-vsemi-p-fn'. The actual details of what constitutes a VS in a | 756 | ;; `c-at-vsemi-p-fn'. This function should only use "low-level" features of |
| 757 | ;; language are thus encapsulated in code specific to that language | 757 | ;; CC Mode, i.e. features which won't trigger infinite recursion. ;-) The |
| 758 | ;; (e.g. cc-awk.el). `c-at-vsemi-p' returns non-nil if point (or the optional | 758 | ;; actual details of what constitutes a VS in a language are thus encapsulated |
| 759 | ;; parameter POS) is at a VS, nil otherwise. | 759 | ;; in code specific to that language (e.g. cc-awk.el). `c-at-vsemi-p' returns |
| 760 | ;; non-nil if point (or the optional parameter POS) is at a VS, nil otherwise. | ||
| 760 | ;; | 761 | ;; |
| 761 | ;; The language specific function might well do extensive analysis of the | 762 | ;; The language specific function might well do extensive analysis of the |
| 762 | ;; source text, and may use a cacheing scheme to speed up repeated calls. | 763 | ;; source text, and may use a cacheing scheme to speed up repeated calls. |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index b2c548847c3..ea0a8f2d3b3 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -705,7 +705,7 @@ comment at the start of cc-engine.el for more info." | |||
| 705 | ;; The last position where a label is possible provided the | 705 | ;; The last position where a label is possible provided the |
| 706 | ;; statement started there. It's nil as long as no invalid | 706 | ;; statement started there. It's nil as long as no invalid |
| 707 | ;; label content has been found (according to | 707 | ;; label content has been found (according to |
| 708 | ;; `c-nonlabel-token-key'. It's `start' if no valid label | 708 | ;; `c-nonlabel-token-key'). It's `start' if no valid label |
| 709 | ;; content was found in the label. Note that we might still | 709 | ;; content was found in the label. Note that we might still |
| 710 | ;; regard it a label if it starts with `c-label-kwds'. | 710 | ;; regard it a label if it starts with `c-label-kwds'. |
| 711 | label-good-pos | 711 | label-good-pos |
| @@ -1035,7 +1035,12 @@ comment at the start of cc-engine.el for more info." | |||
| 1035 | ;; (including a case label) or something like C++'s "public:"? | 1035 | ;; (including a case label) or something like C++'s "public:"? |
| 1036 | ;; A case label might use an expression rather than a token. | 1036 | ;; A case label might use an expression rather than a token. |
| 1037 | (setq after-case:-pos (or tok start)) | 1037 | (setq after-case:-pos (or tok start)) |
| 1038 | (if (looking-at c-nonlabel-token-key) ; e.g. "while" or "'a'" | 1038 | (if (or (looking-at c-nonlabel-token-key) ; e.g. "while" or "'a'" |
| 1039 | ;; Catch C++'s inheritance construct "class foo : bar". | ||
| 1040 | (save-excursion | ||
| 1041 | (and | ||
| 1042 | (c-safe (c-backward-sexp) t) | ||
| 1043 | (looking-at c-nonlabel-token-2-key)))) | ||
| 1039 | (setq c-maybe-labelp nil) | 1044 | (setq c-maybe-labelp nil) |
| 1040 | (if after-labels-pos ; Have we already encountered a label? | 1045 | (if after-labels-pos ; Have we already encountered a label? |
| 1041 | (if (not last-label-pos) | 1046 | (if (not last-label-pos) |
| @@ -1149,42 +1154,65 @@ the line. If this virtual semicolon is _at_ from, the function recognizes it. | |||
| 1149 | 1154 | ||
| 1150 | Note that this function might do hidden buffer changes. See the | 1155 | Note that this function might do hidden buffer changes. See the |
| 1151 | comment at the start of cc-engine.el for more info." | 1156 | comment at the start of cc-engine.el for more info." |
| 1152 | (let ((skip-chars c-stmt-delim-chars) | 1157 | (let* ((skip-chars |
| 1153 | lit-range) | 1158 | ;; If the current language has CPP macros, insert # into skip-chars. |
| 1154 | (save-excursion | 1159 | (if c-opt-cpp-symbol |
| 1155 | (catch 'done | 1160 | (concat (substring c-stmt-delim-chars 0 1) ; "^" |
| 1156 | (goto-char from) | 1161 | c-opt-cpp-symbol ; usually "#" |
| 1157 | (while (progn (skip-chars-forward skip-chars to) | 1162 | (substring c-stmt-delim-chars 1)) ; e.g. ";{}?:" |
| 1158 | (< (point) to)) | 1163 | c-stmt-delim-chars)) |
| 1159 | (cond | 1164 | (non-skip-list |
| 1160 | ((setq lit-range (c-literal-limits from)) ; Have we landed in a string/comment? | 1165 | (append (substring skip-chars 1) nil)) ; e.g. (?# ?\; ?{ ?} ?? ?:) |
| 1161 | (goto-char (cdr lit-range))) | 1166 | lit-range vsemi-pos) |
| 1162 | ((eq (char-after) ?:) | 1167 | (save-restriction |
| 1163 | (forward-char) | 1168 | (widen) |
| 1164 | (if (and (eq (char-after) ?:) | 1169 | (save-excursion |
| 1165 | (< (point) to)) | 1170 | (catch 'done |
| 1166 | ;; Ignore scope operators. | 1171 | (goto-char from) |
| 1167 | (forward-char) | 1172 | (while (progn (skip-chars-forward |
| 1168 | (setq c-maybe-labelp (1- (point))))) | 1173 | skip-chars |
| 1169 | ((eq (char-after) ??) | 1174 | (min to (c-point 'bonl))) |
| 1170 | ;; A question mark. Can't be a label, so stop | 1175 | (< (point) to)) |
| 1171 | ;; looking for more : and ?. | 1176 | (cond |
| 1172 | (setq c-maybe-labelp nil | 1177 | ;; Virtual semicolon? |
| 1173 | skip-chars (substring c-stmt-delim-chars 0 -2))) | 1178 | ((and (bolp) |
| 1174 | ((memq (char-after) '(?# ?\n ?\r)) ; A virtual semicolon? | 1179 | (save-excursion |
| 1175 | (if (and (eq (char-before) ?\\) (memq (char-after) '(?\n ?\r))) | 1180 | (progn |
| 1176 | (backward-char)) | 1181 | (if (setq lit-range (c-literal-limits from)) ; Have we landed in a string/comment? |
| 1177 | (skip-chars-backward " \t" from) | 1182 | (goto-char (car lit-range))) |
| 1178 | (if (c-at-vsemi-p) | 1183 | (c-backward-syntactic-ws) ; ? put a limit here, maybe? |
| 1179 | (throw 'done (point)) | 1184 | (setq vsemi-pos (point)) |
| 1180 | (forward-line))) | 1185 | (c-at-vsemi-p)))) |
| 1181 | (t (throw 'done (point))))) | 1186 | (throw 'done vsemi-pos)) |
| 1182 | ;; In trailing space after an as yet undetected virtual semicolon? | 1187 | ;; In a string/comment? |
| 1183 | (c-backward-syntactic-ws from) | 1188 | ((setq lit-range (c-literal-limits)) |
| 1184 | (if (and (< (point) to) | 1189 | (goto-char (cdr lit-range))) |
| 1185 | (c-at-vsemi-p)) | 1190 | ((eq (char-after) ?:) |
| 1186 | (point) | 1191 | (forward-char) |
| 1187 | nil))))) | 1192 | (if (and (eq (char-after) ?:) |
| 1193 | (< (point) to)) | ||
| 1194 | ;; Ignore scope operators. | ||
| 1195 | (forward-char) | ||
| 1196 | (setq c-maybe-labelp (1- (point))))) | ||
| 1197 | ((eq (char-after) ??) | ||
| 1198 | ;; A question mark. Can't be a label, so stop | ||
| 1199 | ;; looking for more : and ?. | ||
| 1200 | (setq c-maybe-labelp nil | ||
| 1201 | skip-chars (substring c-stmt-delim-chars 0 -2))) | ||
| 1202 | ;; At a CPP construct? | ||
| 1203 | ((and c-opt-cpp-symbol (looking-at c-opt-cpp-symbol) | ||
| 1204 | (save-excursion | ||
| 1205 | (forward-line 0) | ||
| 1206 | (looking-at c-opt-cpp-prefix))) | ||
| 1207 | (c-end-of-macro)) | ||
| 1208 | ((memq (char-after) non-skip-list) | ||
| 1209 | (throw 'done (point))))) | ||
| 1210 | ;; In trailing space after an as yet undetected virtual semicolon? | ||
| 1211 | (c-backward-syntactic-ws from) | ||
| 1212 | (if (and (< (point) to) | ||
| 1213 | (c-at-vsemi-p)) | ||
| 1214 | (point) | ||
| 1215 | nil)))))) | ||
| 1188 | 1216 | ||
| 1189 | (defun c-at-statement-start-p () | 1217 | (defun c-at-statement-start-p () |
| 1190 | "Return non-nil if the point is at the first token in a statement | 1218 | "Return non-nil if the point is at the first token in a statement |
| @@ -7158,12 +7186,14 @@ comment at the start of cc-engine.el for more info." | |||
| 7158 | ;; Check that we're not after a token that can't precede a label. | 7186 | ;; Check that we're not after a token that can't precede a label. |
| 7159 | (or | 7187 | (or |
| 7160 | ;; Trivially succeeds when there's no preceding token. | 7188 | ;; Trivially succeeds when there's no preceding token. |
| 7189 | ;; Succeeds when we're at a virtual semicolon. | ||
| 7161 | (if preceding-token-end | 7190 | (if preceding-token-end |
| 7162 | (<= preceding-token-end (point-min)) | 7191 | (<= preceding-token-end (point-min)) |
| 7163 | (save-excursion | 7192 | (save-excursion |
| 7164 | (c-backward-syntactic-ws) | 7193 | (c-backward-syntactic-ws) |
| 7165 | (setq preceding-token-end (point)) | 7194 | (setq preceding-token-end (point)) |
| 7166 | (bobp))) | 7195 | (or (bobp) |
| 7196 | (c-at-vsemi-p)))) | ||
| 7167 | 7197 | ||
| 7168 | ;; Check if we're after a label, if we're after a closing | 7198 | ;; Check if we're after a label, if we're after a closing |
| 7169 | ;; paren that belong to statement, and with | 7199 | ;; paren that belong to statement, and with |
| @@ -8037,6 +8067,29 @@ comment at the start of cc-engine.el for more info." | |||
| 8037 | (back-to-indentation) | 8067 | (back-to-indentation) |
| 8038 | (vector (point) open-paren-pos)))))) | 8068 | (vector (point) open-paren-pos)))))) |
| 8039 | 8069 | ||
| 8070 | (defmacro c-pull-open-brace (ps) | ||
| 8071 | ;; Pull the next open brace from PS (which has the form of paren-state), | ||
| 8072 | ;; skipping over any brace pairs. Returns NIL when PS is exhausted. | ||
| 8073 | `(progn | ||
| 8074 | (while (consp (car ,ps)) | ||
| 8075 | (setq ,ps (cdr ,ps))) | ||
| 8076 | (prog1 (car ,ps) | ||
| 8077 | (setq ,ps (cdr ,ps))))) | ||
| 8078 | |||
| 8079 | (defun c-most-enclosing-decl-block (paren-state) | ||
| 8080 | ;; Return the buffer position of the most enclosing decl-block brace (in the | ||
| 8081 | ;; sense of c-looking-at-decl-block) in the PAREN-STATE structure, or nil if | ||
| 8082 | ;; none was found. | ||
| 8083 | (let* ((open-brace (c-pull-open-brace paren-state)) | ||
| 8084 | (next-open-brace (c-pull-open-brace paren-state))) | ||
| 8085 | (while (and open-brace | ||
| 8086 | (save-excursion | ||
| 8087 | (goto-char open-brace) | ||
| 8088 | (not (c-looking-at-decl-block next-open-brace nil)))) | ||
| 8089 | (setq open-brace next-open-brace | ||
| 8090 | next-open-brace (c-pull-open-brace paren-state))) | ||
| 8091 | open-brace)) | ||
| 8092 | |||
| 8040 | (defun c-inside-bracelist-p (containing-sexp paren-state) | 8093 | (defun c-inside-bracelist-p (containing-sexp paren-state) |
| 8041 | ;; return the buffer position of the beginning of the brace list | 8094 | ;; return the buffer position of the beginning of the brace list |
| 8042 | ;; statement if we're inside a brace list, otherwise return nil. | 8095 | ;; statement if we're inside a brace list, otherwise return nil. |
| @@ -8372,6 +8425,57 @@ comment at the start of cc-engine.el for more info." | |||
| 8372 | paren-state) | 8425 | paren-state) |
| 8373 | containing-sexp))))) | 8426 | containing-sexp))))) |
| 8374 | 8427 | ||
| 8428 | (defun c-at-macro-vsemi-p (&optional pos) | ||
| 8429 | ;; Is there a "virtual semicolon" at POS or point? | ||
| 8430 | ;; (See cc-defs.el for full details of "virtual semicolons".) | ||
| 8431 | ;; | ||
| 8432 | ;; This is true when point is at the last non syntactic WS position on the | ||
| 8433 | ;; line, there is a macro call last on the line, and this particular macro's | ||
| 8434 | ;; name is defined by the regexp `c-vs-macro-regexp' as not needing a | ||
| 8435 | ;; semicolon. | ||
| 8436 | (save-excursion | ||
| 8437 | (save-restriction | ||
| 8438 | (widen) | ||
| 8439 | (if pos | ||
| 8440 | (goto-char pos) | ||
| 8441 | (setq pos (point))) | ||
| 8442 | (and | ||
| 8443 | c-macro-with-semi-re | ||
| 8444 | (not (c-in-literal)) | ||
| 8445 | (eq (skip-chars-backward " \t") 0) | ||
| 8446 | |||
| 8447 | ;; Check we've got nothing after this except comments and empty lines | ||
| 8448 | ;; joined by escaped EOLs. | ||
| 8449 | (skip-chars-forward " \t") ; always returns non-nil. | ||
| 8450 | (progn | ||
| 8451 | (while ; go over 1 block comment per iteration. | ||
| 8452 | (and | ||
| 8453 | (looking-at "\\(\\\\[\n\r][ \t]*\\)*") | ||
| 8454 | (goto-char (match-end 0)) | ||
| 8455 | (cond | ||
| 8456 | ((looking-at c-block-comment-start-regexp) | ||
| 8457 | (and (forward-comment 1) | ||
| 8458 | (skip-chars-forward " \t"))) ; always returns non-nil | ||
| 8459 | ((looking-at c-line-comment-start-regexp) | ||
| 8460 | (end-of-line) | ||
| 8461 | nil) | ||
| 8462 | (t nil)))) | ||
| 8463 | (eolp)) | ||
| 8464 | |||
| 8465 | (goto-char pos) | ||
| 8466 | (progn (c-backward-syntactic-ws) | ||
| 8467 | (eq (point) pos)) | ||
| 8468 | |||
| 8469 | ;; Check for one of the listed macros being before point. | ||
| 8470 | (or (not (eq (char-before) ?\))) | ||
| 8471 | (when (c-go-list-backward) | ||
| 8472 | (c-backward-syntactic-ws) | ||
| 8473 | t)) | ||
| 8474 | (c-simple-skip-symbol-backward) | ||
| 8475 | (looking-at c-macro-with-semi-re))))) | ||
| 8476 | |||
| 8477 | (defun c-macro-vsemi-status-unknown-p () t) ; See cc-defs.el. | ||
| 8478 | |||
| 8375 | 8479 | ||
| 8376 | ;; `c-guess-basic-syntax' and the functions that precedes it below | 8480 | ;; `c-guess-basic-syntax' and the functions that precedes it below |
| 8377 | ;; implements the main decision tree for determining the syntactic | 8481 | ;; implements the main decision tree for determining the syntactic |
diff --git a/lisp/progmodes/cc-fonts.el b/lisp/progmodes/cc-fonts.el index fd817e3b4f4..9a83d5196db 100644 --- a/lisp/progmodes/cc-fonts.el +++ b/lisp/progmodes/cc-fonts.el | |||
| @@ -1277,9 +1277,11 @@ casts and declarations are fontified. Used on level 2 and higher." | |||
| 1277 | (when | 1277 | (when |
| 1278 | ;; The result of the form below is true when we don't recognize a | 1278 | ;; The result of the form below is true when we don't recognize a |
| 1279 | ;; declaration or cast. | 1279 | ;; declaration or cast. |
| 1280 | (if (and (eq (get-text-property (point) 'face) | 1280 | (if (or (and (eq (get-text-property (point) 'face) |
| 1281 | 'font-lock-keyword-face) | 1281 | 'font-lock-keyword-face) |
| 1282 | (looking-at c-not-decl-init-keywords)) | 1282 | (looking-at c-not-decl-init-keywords)) |
| 1283 | (and c-macro-with-semi-re | ||
| 1284 | (looking-at c-macro-with-semi-re))) ; 2008-11-04 | ||
| 1283 | ;; Don't do anything more if we're looking at a keyword that | 1285 | ;; Don't do anything more if we're looking at a keyword that |
| 1284 | ;; can't start a declaration. | 1286 | ;; can't start a declaration. |
| 1285 | t | 1287 | t |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index 279c5e46c46..09f8b318378 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -509,6 +509,31 @@ parameters \(point-min), \(point-max) and <buffer size>." | |||
| 509 | (c-lang-const c-before-font-lock-function)) | 509 | (c-lang-const c-before-font-lock-function)) |
| 510 | 510 | ||
| 511 | 511 | ||
| 512 | ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK). | ||
| 513 | (c-lang-defconst c-at-vsemi-p-fn | ||
| 514 | "Contains a function \"Is there a virtual semicolon at POS or point?\". | ||
| 515 | Such a function takes one optional parameter, a buffer position (defaults to | ||
| 516 | point), and returns nil or t. This variable contains nil for languages which | ||
| 517 | don't have EOL terminated statements. " | ||
| 518 | t nil | ||
| 519 | (c c++ objc) 'c-at-macro-vsemi-p | ||
| 520 | awk 'c-awk-at-vsemi-p) | ||
| 521 | (c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn)) | ||
| 522 | |||
| 523 | (c-lang-defconst c-vsemi-status-unknown-p-fn | ||
| 524 | "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\". | ||
| 525 | The (admittedly kludgey) purpose of such a function is to prevent an infinite | ||
| 526 | recursion in c-beginning-of-statement-1 when point starts at a `while' token. | ||
| 527 | The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1, | ||
| 528 | even indirectly. This variable contains nil for languages which don't have | ||
| 529 | EOL terminated statements." | ||
| 530 | t nil | ||
| 531 | (c c++ objc) 'c-macro-vsemi-status-unknown-p | ||
| 532 | awk 'c-awk-vsemi-status-unknown-p) | ||
| 533 | (c-lang-defvar c-vsemi-status-unknown-p-fn | ||
| 534 | (c-lang-const c-vsemi-status-unknown-p-fn)) | ||
| 535 | |||
| 536 | |||
| 512 | ;;; Lexer-level syntax (identifiers, tokens etc). | 537 | ;;; Lexer-level syntax (identifiers, tokens etc). |
| 513 | 538 | ||
| 514 | (c-lang-defconst c-has-bitfields | 539 | (c-lang-defconst c-has-bitfields |
| @@ -737,6 +762,12 @@ literal are multiline." | |||
| 737 | (c-lang-defvar c-multiline-string-start-char | 762 | (c-lang-defvar c-multiline-string-start-char |
| 738 | (c-lang-const c-multiline-string-start-char)) | 763 | (c-lang-const c-multiline-string-start-char)) |
| 739 | 764 | ||
| 765 | (c-lang-defconst c-opt-cpp-symbol | ||
| 766 | "The symbol which starts preprocessor constructs when in the margin." | ||
| 767 | t "#" | ||
| 768 | (java awk) nil) | ||
| 769 | (c-lang-defvar c-opt-cpp-symbol (c-lang-const c-opt-cpp-symbol)) | ||
| 770 | |||
| 740 | (c-lang-defconst c-opt-cpp-prefix | 771 | (c-lang-defconst c-opt-cpp-prefix |
| 741 | "Regexp matching the prefix of a cpp directive in the languages that | 772 | "Regexp matching the prefix of a cpp directive in the languages that |
| 742 | normally use that macro preprocessor. Tested at bol or at boi. | 773 | normally use that macro preprocessor. Tested at bol or at boi. |
| @@ -785,6 +816,8 @@ file name in angle brackets or quotes." | |||
| 785 | definition, or nil if the language doesn't have any." | 816 | definition, or nil if the language doesn't have any." |
| 786 | t (if (c-lang-const c-opt-cpp-prefix) | 817 | t (if (c-lang-const c-opt-cpp-prefix) |
| 787 | "define")) | 818 | "define")) |
| 819 | (c-lang-defvar c-opt-cpp-macro-define | ||
| 820 | (c-lang-const c-opt-cpp-macro-define)) | ||
| 788 | 821 | ||
| 789 | (c-lang-defconst c-opt-cpp-macro-define-start | 822 | (c-lang-defconst c-opt-cpp-macro-define-start |
| 790 | ;; Regexp matching everything up to the macro body of a cpp define, or the | 823 | ;; Regexp matching everything up to the macro body of a cpp define, or the |
| @@ -1171,14 +1204,12 @@ operators." | |||
| 1171 | ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to | 1204 | ;; optimize `c-crosses-statement-barrier-p' somewhat, it's assumed to |
| 1172 | ;; begin with "^" to negate the set. If ? : operators should be | 1205 | ;; begin with "^" to negate the set. If ? : operators should be |
| 1173 | ;; detected then the string must end with "?:". | 1206 | ;; detected then the string must end with "?:". |
| 1174 | t "^;{}?:" | 1207 | t "^;{}?:") |
| 1175 | awk "^;{}#\n\r?:") ; The newline chars gets special treatment. | ||
| 1176 | (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars)) | 1208 | (c-lang-defvar c-stmt-delim-chars (c-lang-const c-stmt-delim-chars)) |
| 1177 | 1209 | ||
| 1178 | (c-lang-defconst c-stmt-delim-chars-with-comma | 1210 | (c-lang-defconst c-stmt-delim-chars-with-comma |
| 1179 | ;; Variant of `c-stmt-delim-chars' that additionally contains ','. | 1211 | ;; Variant of `c-stmt-delim-chars' that additionally contains ','. |
| 1180 | t "^;,{}?:" | 1212 | t "^;,{}?:") |
| 1181 | awk "^;,{}\n\r?:") ; The newline chars gets special treatment. | ||
| 1182 | (c-lang-defvar c-stmt-delim-chars-with-comma | 1213 | (c-lang-defvar c-stmt-delim-chars-with-comma |
| 1183 | (c-lang-const c-stmt-delim-chars-with-comma)) | 1214 | (c-lang-const c-stmt-delim-chars-with-comma)) |
| 1184 | 1215 | ||
| @@ -1238,7 +1269,6 @@ properly." | |||
| 1238 | re))) | 1269 | re))) |
| 1239 | (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp)) | 1270 | (c-lang-defvar c-comment-start-regexp (c-lang-const c-comment-start-regexp)) |
| 1240 | 1271 | ||
| 1241 | ;;;; Added by ACM, 2003/9/18. | ||
| 1242 | (c-lang-defconst c-block-comment-start-regexp | 1272 | (c-lang-defconst c-block-comment-start-regexp |
| 1243 | ;; Regexp which matches the start of a block comment (if such exists in the | 1273 | ;; Regexp which matches the start of a block comment (if such exists in the |
| 1244 | ;; language) | 1274 | ;; language) |
| @@ -1248,6 +1278,15 @@ properly." | |||
| 1248 | (c-lang-defvar c-block-comment-start-regexp | 1278 | (c-lang-defvar c-block-comment-start-regexp |
| 1249 | (c-lang-const c-block-comment-start-regexp)) | 1279 | (c-lang-const c-block-comment-start-regexp)) |
| 1250 | 1280 | ||
| 1281 | (c-lang-defconst c-line-comment-start-regexp | ||
| 1282 | ;; Regexp which matches the start of a line comment (if such exists in the | ||
| 1283 | ;; language; it does in all 7 CC Mode languages). | ||
| 1284 | t (if (c-lang-const c-line-comment-starter) | ||
| 1285 | (regexp-quote (c-lang-const c-line-comment-starter)) | ||
| 1286 | "\\<\\>")) | ||
| 1287 | (c-lang-defvar c-line-comment-start-regexp | ||
| 1288 | (c-lang-const c-line-comment-start-regexp)) | ||
| 1289 | |||
| 1251 | (c-lang-defconst c-literal-start-regexp | 1290 | (c-lang-defconst c-literal-start-regexp |
| 1252 | ;; Regexp to match the start of comments and string literals. | 1291 | ;; Regexp to match the start of comments and string literals. |
| 1253 | t (concat (c-lang-const c-comment-start-regexp) | 1292 | t (concat (c-lang-const c-comment-start-regexp) |
| @@ -1475,29 +1514,6 @@ properly." | |||
| 1475 | (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol)) | 1514 | (c-lang-defvar c-syntactic-eol (c-lang-const c-syntactic-eol)) |
| 1476 | 1515 | ||
| 1477 | 1516 | ||
| 1478 | ;;; Syntactic analysis ("virtual semicolons") for line-oriented languages (AWK). | ||
| 1479 | (c-lang-defconst c-at-vsemi-p-fn | ||
| 1480 | "Contains a function \"Is there a virtual semicolon at POS or point?\". | ||
| 1481 | Such a function takes one optional parameter, a buffer position (defaults to | ||
| 1482 | point), and returns nil or t. This variable contains nil for languages which | ||
| 1483 | don't have EOL terminated statements. " | ||
| 1484 | t nil | ||
| 1485 | awk 'c-awk-at-vsemi-p) | ||
| 1486 | (c-lang-defvar c-at-vsemi-p-fn (c-lang-const c-at-vsemi-p-fn)) | ||
| 1487 | |||
| 1488 | (c-lang-defconst c-vsemi-status-unknown-p-fn | ||
| 1489 | "Contains a function \"are we unsure whether there is a virtual semicolon on this line?\". | ||
| 1490 | The (admittedly kludgey) purpose of such a function is to prevent an infinite | ||
| 1491 | recursion in c-beginning-of-statement-1 when point starts at a `while' token. | ||
| 1492 | The function MUST NOT UNDER ANY CIRCUMSTANCES call c-beginning-of-statement-1, | ||
| 1493 | even indirectly. This variable contains nil for languages which don't have | ||
| 1494 | EOL terminated statements." | ||
| 1495 | t nil | ||
| 1496 | awk 'c-awk-vsemi-status-unknown-p) | ||
| 1497 | (c-lang-defvar c-vsemi-status-unknown-p-fn | ||
| 1498 | (c-lang-const c-vsemi-status-unknown-p-fn)) | ||
| 1499 | |||
| 1500 | |||
| 1501 | ;;; Defun functions | 1517 | ;;; Defun functions |
| 1502 | 1518 | ||
| 1503 | ;; The Emacs variables beginning-of-defun-function and | 1519 | ;; The Emacs variables beginning-of-defun-function and |
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el index eec63b4fa3b..a6bf241f0db 100644 --- a/lisp/progmodes/cc-mode.el +++ b/lisp/progmodes/cc-mode.el | |||
| @@ -1187,6 +1187,7 @@ Key bindings: | |||
| 1187 | abbrev-mode t) | 1187 | abbrev-mode t) |
| 1188 | (use-local-map c-mode-map) | 1188 | (use-local-map c-mode-map) |
| 1189 | (c-init-language-vars-for 'c-mode) | 1189 | (c-init-language-vars-for 'c-mode) |
| 1190 | (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ; | ||
| 1190 | (c-common-init 'c-mode) | 1191 | (c-common-init 'c-mode) |
| 1191 | (easy-menu-add c-c-menu) | 1192 | (easy-menu-add c-c-menu) |
| 1192 | (cc-imenu-init cc-imenu-c-generic-expression) | 1193 | (cc-imenu-init cc-imenu-c-generic-expression) |
| @@ -1246,6 +1247,7 @@ Key bindings: | |||
| 1246 | abbrev-mode t) | 1247 | abbrev-mode t) |
| 1247 | (use-local-map c++-mode-map) | 1248 | (use-local-map c++-mode-map) |
| 1248 | (c-init-language-vars-for 'c++-mode) | 1249 | (c-init-language-vars-for 'c++-mode) |
| 1250 | (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ; | ||
| 1249 | (c-common-init 'c++-mode) | 1251 | (c-common-init 'c++-mode) |
| 1250 | (easy-menu-add c-c++-menu) | 1252 | (easy-menu-add c-c++-menu) |
| 1251 | (cc-imenu-init cc-imenu-c++-generic-expression) | 1253 | (cc-imenu-init cc-imenu-c++-generic-expression) |
| @@ -1303,6 +1305,7 @@ Key bindings: | |||
| 1303 | abbrev-mode t) | 1305 | abbrev-mode t) |
| 1304 | (use-local-map objc-mode-map) | 1306 | (use-local-map objc-mode-map) |
| 1305 | (c-init-language-vars-for 'objc-mode) | 1307 | (c-init-language-vars-for 'objc-mode) |
| 1308 | (c-make-macro-with-semi-re) ; matches macro names whose expansion ends with ; | ||
| 1306 | (c-common-init 'objc-mode) | 1309 | (c-common-init 'objc-mode) |
| 1307 | (easy-menu-add c-objc-menu) | 1310 | (easy-menu-add c-objc-menu) |
| 1308 | (cc-imenu-init nil 'cc-imenu-objc-function) | 1311 | (cc-imenu-init nil 'cc-imenu-objc-function) |
diff --git a/lisp/progmodes/cc-vars.el b/lisp/progmodes/cc-vars.el index 58dc1737c5a..24361e3667a 100644 --- a/lisp/progmodes/cc-vars.el +++ b/lisp/progmodes/cc-vars.el | |||
| @@ -340,6 +340,20 @@ better with the \"do { ... } while \(0)\" trick)." | |||
| 340 | :group 'c) | 340 | :group 'c) |
| 341 | (put 'c-syntactic-indentation-in-macros 'safe-local-variable 'booleanp) | 341 | (put 'c-syntactic-indentation-in-macros 'safe-local-variable 'booleanp) |
| 342 | 342 | ||
| 343 | (defcustom c-defun-tactic 'go-outward | ||
| 344 | "*Whether functions are recognized inside, e.g., a class. | ||
| 345 | This is used by `c-beginning-of-defun' and like functions. | ||
| 346 | |||
| 347 | Its value is one of: | ||
| 348 | t -- Functions are recognized only at the top level. | ||
| 349 | go-outward -- Nested functions are also recognized. Should a function | ||
| 350 | command hit the beginning/end of a nested scope, it will | ||
| 351 | carry on at the less nested level." | ||
| 352 | :type '(radio | ||
| 353 | (const :tag "Functions are at the top-level" t) | ||
| 354 | (const :tag "Functions are also recognized inside declaration scopes" go-outward)) | ||
| 355 | :group 'c) | ||
| 356 | |||
| 343 | (defcustom-c-stylevar c-comment-only-line-offset 0 | 357 | (defcustom-c-stylevar c-comment-only-line-offset 0 |
| 344 | "*Extra offset for line which contains only the start of a comment. | 358 | "*Extra offset for line which contains only the start of a comment. |
| 345 | Can contain an integer or a cons cell of the form: | 359 | Can contain an integer or a cons cell of the form: |
| @@ -1608,6 +1622,54 @@ names).")) | |||
| 1608 | 1622 | ||
| 1609 | 1623 | ||
| 1610 | ;; Non-customizable variables, still part of the interface to CC Mode | 1624 | ;; Non-customizable variables, still part of the interface to CC Mode |
| 1625 | (defvar c-macro-with-semi-re nil | ||
| 1626 | ;; Regular expression which matches a (#define'd) symbol whose expansion | ||
| 1627 | ;; ends with a semicolon. | ||
| 1628 | ;; | ||
| 1629 | ;; This variable should be set by `c-make-macros-with-semi-re' rather than | ||
| 1630 | ;; directly. | ||
| 1631 | ) | ||
| 1632 | (make-variable-buffer-local 'c-macro-with-semi-re) | ||
| 1633 | |||
| 1634 | (defun c-make-macro-with-semi-re () | ||
| 1635 | ;; Convert `c-macro-names-with-semicolon' into the regexp | ||
| 1636 | ;; `c-macro-with-semi-re' (or just copy it if it's already a re). | ||
| 1637 | (setq c-macro-with-semi-re | ||
| 1638 | (and | ||
| 1639 | c-opt-cpp-macro-define | ||
| 1640 | (cond | ||
| 1641 | ((stringp c-macro-names-with-semicolon) | ||
| 1642 | (copy-sequence c-macro-names-with-semicolon)) | ||
| 1643 | ((consp c-macro-names-with-semicolon) | ||
| 1644 | (concat | ||
| 1645 | "\\<" | ||
| 1646 | (regexp-opt c-macro-names-with-semicolon) | ||
| 1647 | "\\>")) ; N.B. the PAREN param of regexp-opt isn't supported by | ||
| 1648 | ; all XEmacsen. | ||
| 1649 | ((null c-macro-names-with-semicolon) | ||
| 1650 | nil) | ||
| 1651 | (t (error "c-make-macro-with-semi-re: invalid \ | ||
| 1652 | c-macro-names-with-semicolon: %s" | ||
| 1653 | c-macro-names-with-semicolon)))))) | ||
| 1654 | |||
| 1655 | (defvar c-macro-names-with-semicolon | ||
| 1656 | '("Q_OBJECT" "Q_PROPERTY" "Q_DECLARE" "Q_ENUMS") | ||
| 1657 | "List of #defined symbols whose expansion ends with a semicolon. | ||
| 1658 | Alternatively it can be a string, a regular expression which | ||
| 1659 | matches all such symbols. | ||
| 1660 | |||
| 1661 | The \"symbols\" must be syntactically valid identifiers in the | ||
| 1662 | target language \(C, C++, Objective C), or \(as the case may be) | ||
| 1663 | the regular expression must match only valid identifiers. | ||
| 1664 | |||
| 1665 | If you change this variable's value, call the function | ||
| 1666 | `c-make-macros-with-semi-re' to set the necessary internal | ||
| 1667 | variables. | ||
| 1668 | |||
| 1669 | Note that currently \(2008-11-04) this variable is a prototype, | ||
| 1670 | and is likely to disappear or change its form soon.") | ||
| 1671 | (make-variable-buffer-local 'c-macro-names-with-semicolon) | ||
| 1672 | |||
| 1611 | (defvar c-file-style nil | 1673 | (defvar c-file-style nil |
| 1612 | "Variable interface for setting style via File Local Variables. | 1674 | "Variable interface for setting style via File Local Variables. |
| 1613 | In a file's Local Variable section, you can set this variable to a | 1675 | In a file's Local Variable section, you can set this variable to a |
diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 22db7b2e5f4..dde00d753ac 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el | |||
| @@ -43,21 +43,10 @@ | |||
| 43 | 43 | ||
| 44 | ;; M-x gdb will start the debugger. | 44 | ;; M-x gdb will start the debugger. |
| 45 | 45 | ||
| 46 | ;; This file uses GDB/MI as the primary interface to GDB. It is still under | 46 | ;; This file uses GDB/MI as the primary interface to GDB. It runs gdb with |
| 47 | ;; development and is part of a process to migrate Emacs from annotations (as | 47 | ;; GDB/MI (-interp=mi) and access CLI using "-interpreter-exec console |
| 48 | ;; used in gdb-ui.el) to GDB/MI. It runs gdb with GDB/MI (-interp=mi) and | 48 | ;; cli-command". This code works without gdb-ui.el and uses MI tokens instead |
| 49 | ;; access CLI using "-interpreter-exec console cli-command". This code works | 49 | ;; of queues. Eventually MI should be asynchronous. |
| 50 | ;; without gdb-ui.el and uses MI tokens instead of queues. Eventually MI | ||
| 51 | ;; should be asynchronous. | ||
| 52 | |||
| 53 | ;; This mode will PARTLY WORK WITH RECENT GDB RELEASES (status in modeline | ||
| 54 | ;; doesn't update properly when execution commands are issued from GUD buffer) | ||
| 55 | ;; and WORKS BEST when GDB runs asynchronously: maint set linux-async on. | ||
| 56 | ;; | ||
| 57 | ;; You need development version of GDB 7.0 for the thread buffer to work. | ||
| 58 | |||
| 59 | ;; This file replaces gdb-ui.el and is for development with GDB. Use the | ||
| 60 | ;; release branch of Emacs 22 for the latest version of gdb-ui.el. | ||
| 61 | 50 | ||
| 62 | ;; Windows Platforms: | 51 | ;; Windows Platforms: |
| 63 | 52 | ||
| @@ -599,6 +588,22 @@ NOARG must be t when this macro is used outside `gud-def'" | |||
| 599 | (concat (gdb-gud-context-command ,cmd1 ,noall) " " ,cmd2) | 588 | (concat (gdb-gud-context-command ,cmd1 ,noall) " " ,cmd2) |
| 600 | ,(when (not noarg) 'arg))) | 589 | ,(when (not noarg) 'arg))) |
| 601 | 590 | ||
| 591 | (defun gdb--check-interpreter (proc string) | ||
| 592 | (unless (zerop (length string)) | ||
| 593 | (let ((filter (process-get proc 'gud-normal-filter))) | ||
| 594 | (set-process-filter proc filter) | ||
| 595 | (unless (memq (aref string 0) '(?^ ?~ ?@ ?& ?* ?=)) | ||
| 596 | ;; Apparently we're not running with -i=mi. | ||
| 597 | (let ((msg "Error: you did not specify -i=mi on GDB's command line!")) | ||
| 598 | (message msg) | ||
| 599 | (setq string (concat (propertize msg 'font-lock-face 'error) | ||
| 600 | "\n" string))) | ||
| 601 | ;; Use the old gud-gbd filter, not because it works, but because it | ||
| 602 | ;; will properly display GDB's answers rather than hanging waiting for | ||
| 603 | ;; answers that aren't coming. | ||
| 604 | (set (make-local-variable 'gud-marker-filter) #'gud-gdb-marker-filter)) | ||
| 605 | (funcall filter proc string)))) | ||
| 606 | |||
| 602 | ;;;###autoload | 607 | ;;;###autoload |
| 603 | (defun gdb (command-line) | 608 | (defun gdb (command-line) |
| 604 | "Run gdb on program FILE in buffer *gud-FILE*. | 609 | "Run gdb on program FILE in buffer *gud-FILE*. |
| @@ -665,6 +670,13 @@ detailed description of this mode. | |||
| 665 | "Multiple debugging requires restarting in text command mode")) | 670 | "Multiple debugging requires restarting in text command mode")) |
| 666 | ;; | 671 | ;; |
| 667 | (gud-common-init command-line nil 'gud-gdbmi-marker-filter) | 672 | (gud-common-init command-line nil 'gud-gdbmi-marker-filter) |
| 673 | |||
| 674 | ;; Setup a temporary process filter to warn when GDB was not started | ||
| 675 | ;; with -i=mi. | ||
| 676 | (let ((proc (get-buffer-process gud-comint-buffer))) | ||
| 677 | (process-put proc 'gud-normal-filter (process-filter proc)) | ||
| 678 | (set-process-filter proc #'gdb--check-interpreter)) | ||
| 679 | |||
| 668 | (set (make-local-variable 'gud-minor-mode) 'gdbmi) | 680 | (set (make-local-variable 'gud-minor-mode) 'gdbmi) |
| 669 | (setq comint-input-sender 'gdb-send) | 681 | (setq comint-input-sender 'gdb-send) |
| 670 | (when (ring-empty-p comint-input-ring) ; cf shell-mode | 682 | (when (ring-empty-p comint-input-ring) ; cf shell-mode |
diff --git a/lisp/subr.el b/lisp/subr.el index f3cd4dabe20..50ea49bd8c9 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -2262,11 +2262,25 @@ is nil and `use-dialog-box' is non-nil." | |||
| 2262 | ;; where all the keys were unbound (i.e. it somehow got triggered | 2262 | ;; where all the keys were unbound (i.e. it somehow got triggered |
| 2263 | ;; within read-key, apparently). I had to kill it. | 2263 | ;; within read-key, apparently). I had to kill it. |
| 2264 | (let ((answer 'recenter)) | 2264 | (let ((answer 'recenter)) |
| 2265 | (if (and (display-popup-menus-p) | 2265 | (cond |
| 2266 | (listp last-nonmenu-event) | 2266 | (noninteractive |
| 2267 | use-dialog-box) | 2267 | (setq prompt (concat prompt |
| 2268 | (setq answer | 2268 | (if (eq ?\s (aref prompt (1- (length prompt)))) |
| 2269 | (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip)))) | 2269 | "" " ") |
| 2270 | "(y or n) ")) | ||
| 2271 | (let ((temp-prompt prompt)) | ||
| 2272 | (while (not (memq answer '(act skip))) | ||
| 2273 | (let ((str (read-string temp-prompt))) | ||
| 2274 | (cond ((member str '("y" "Y")) (setq answer 'act)) | ||
| 2275 | ((member str '("n" "N")) (setq answer 'skip)) | ||
| 2276 | (t (setq temp-prompt (concat "Please answer y or n. " | ||
| 2277 | prompt)))))))) | ||
| 2278 | ((and (display-popup-menus-p) | ||
| 2279 | (listp last-nonmenu-event) | ||
| 2280 | use-dialog-box) | ||
| 2281 | (setq answer | ||
| 2282 | (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip))))) | ||
| 2283 | (t | ||
| 2270 | (setq prompt (concat prompt | 2284 | (setq prompt (concat prompt |
| 2271 | (if (eq ?\s (aref prompt (1- (length prompt)))) | 2285 | (if (eq ?\s (aref prompt (1- (length prompt)))) |
| 2272 | "" " ") | 2286 | "" " ") |
| @@ -2288,7 +2302,7 @@ is nil and `use-dialog-box' is non-nil." | |||
| 2288 | ((memq answer '(exit-prefix quit)) (signal 'quit nil) t) | 2302 | ((memq answer '(exit-prefix quit)) (signal 'quit nil) t) |
| 2289 | (t t))) | 2303 | (t t))) |
| 2290 | (ding) | 2304 | (ding) |
| 2291 | (discard-input))) | 2305 | (discard-input)))) |
| 2292 | (let ((ret (eq answer 'act))) | 2306 | (let ((ret (eq answer 'act))) |
| 2293 | (unless noninteractive | 2307 | (unless noninteractive |
| 2294 | (message "%s %s" prompt (if ret "y" "n"))) | 2308 | (message "%s %s" prompt (if ret "y" "n"))) |
diff --git a/lisp/textmodes/flyspell.el b/lisp/textmodes/flyspell.el index 4a57d00d702..a5099311307 100644 --- a/lisp/textmodes/flyspell.el +++ b/lisp/textmodes/flyspell.el | |||
| @@ -1121,7 +1121,7 @@ misspelling and skips redundant spell-checking step." | |||
| 1121 | (setq poss (ispell-parse-output (car ispell-filter))))) | 1121 | (setq poss (ispell-parse-output (car ispell-filter))))) |
| 1122 | ;; Else, this was a known misspelling to begin with, and | 1122 | ;; Else, this was a known misspelling to begin with, and |
| 1123 | ;; we should forge an ispell return value. | 1123 | ;; we should forge an ispell return value. |
| 1124 | (setq poss (list word 0 '() '()))) | 1124 | (setq poss (list word 1 nil nil))) |
| 1125 | (let ((res (cond ((eq poss t) | 1125 | (let ((res (cond ((eq poss t) |
| 1126 | ;; correct | 1126 | ;; correct |
| 1127 | (setq flyspell-word-cache-result t) | 1127 | (setq flyspell-word-cache-result t) |
diff --git a/lisp/vc/log-edit.el b/lisp/vc/log-edit.el index c421304442f..f57429c76c7 100644 --- a/lisp/vc/log-edit.el +++ b/lisp/vc/log-edit.el | |||
| @@ -593,6 +593,13 @@ to build the Fixes: header.") | |||
| 593 | (put 'log-edit-rewrite-fixes 'safe-local-variable | 593 | (put 'log-edit-rewrite-fixes 'safe-local-variable |
| 594 | (lambda (v) (and (stringp (car-safe v)) (stringp (cdr v))))) | 594 | (lambda (v) (and (stringp (car-safe v)) (stringp (cdr v))))) |
| 595 | 595 | ||
| 596 | (defun log-edit-add-field (field value) | ||
| 597 | (rfc822-goto-eoh) | ||
| 598 | (if (save-excursion (re-search-backward (concat "^" field ":\\([ \t]*\\)$") | ||
| 599 | nil t)) | ||
| 600 | (replace-match (concat " " value) t t nil 1) | ||
| 601 | (insert field ": " value "\n" (if (looking-at "\n") "" "\n")))) | ||
| 602 | |||
| 596 | (defun log-edit-insert-changelog (&optional use-first) | 603 | (defun log-edit-insert-changelog (&optional use-first) |
| 597 | "Insert a log message by looking at the ChangeLog. | 604 | "Insert a log message by looking at the ChangeLog. |
| 598 | The idea is to write your ChangeLog entries first, and then use this | 605 | The idea is to write your ChangeLog entries first, and then use this |
| @@ -620,9 +627,7 @@ regardless of user name or time." | |||
| 620 | (log-edit-insert-changelog-entries (log-edit-files))))) | 627 | (log-edit-insert-changelog-entries (log-edit-files))))) |
| 621 | (log-edit-set-common-indentation) | 628 | (log-edit-set-common-indentation) |
| 622 | ;; Add an Author: field if appropriate. | 629 | ;; Add an Author: field if appropriate. |
| 623 | (when author | 630 | (when author (log-edit-add-field "Author" author)) |
| 624 | (rfc822-goto-eoh) | ||
| 625 | (insert "Author: " author "\n" (if (looking-at "\n") "" "\n"))) | ||
| 626 | ;; Add a Fixes: field if applicable. | 631 | ;; Add a Fixes: field if applicable. |
| 627 | (when (consp log-edit-rewrite-fixes) | 632 | (when (consp log-edit-rewrite-fixes) |
| 628 | (rfc822-goto-eoh) | 633 | (rfc822-goto-eoh) |
| @@ -632,8 +637,7 @@ regardless of user name or time." | |||
| 632 | (fixes (match-substitute-replacement | 637 | (fixes (match-substitute-replacement |
| 633 | (cdr log-edit-rewrite-fixes)))) | 638 | (cdr log-edit-rewrite-fixes)))) |
| 634 | (delete-region start end) | 639 | (delete-region start end) |
| 635 | (rfc822-goto-eoh) | 640 | (log-edit-add-field "Fixes" fixes)))) |
| 636 | (insert "Fixes: " fixes "\n" (if (looking-at "\n") "" "\n"))))) | ||
| 637 | (and log-edit-strip-single-file-name | 641 | (and log-edit-strip-single-file-name |
| 638 | (progn (rfc822-goto-eoh) | 642 | (progn (rfc822-goto-eoh) |
| 639 | (if (looking-at "\n") (forward-char 1)) | 643 | (if (looking-at "\n") (forward-char 1)) |