Mercurial > emacs
comparison lisp/obsolete/cplus-md.el @ 41609:f1391a41ece3
fixed {}() quoting
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Tue, 27 Nov 2001 17:00:12 +0000 |
parents | 45db352a0971 |
children | 5223683cd329 |
comparison
equal
deleted
inserted
replaced
41608:45db352a0971 | 41609:f1391a41ece3 |
---|---|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 ;; Boston, MA 02111-1307, USA. | 23 ;; Boston, MA 02111-1307, USA. |
24 | 24 |
25 ;;; Commentary: | 25 ;;; Commentary: |
26 | 26 |
27 ;; 1987 Dave Detlefs <dld@cs.cmu.edu> | 27 ;; 1987 Dave Detlefs <dld@cs.cmu.edu> |
28 ;; and Stewart Clamen <clamen@cs.cmu.edu>. | 28 ;; and Stewart Clamen <clamen@cs.cmu.edu>. |
29 ;; Done by fairly faithful modification of: | 29 ;; Done by fairly faithful modification of: |
30 | 30 |
31 ;;; Change Log: | 31 ;;; Change Log: |
32 | 32 |
33 ;; Feb, 1990 (Dave Detlefs, dld@cs.cmu.edu) | 33 ;; Feb, 1990 (Dave Detlefs, dld@cs.cmu.edu) |
34 ;; Fixed electric-c++-terminator to handle double colons, at the | 34 ;; Fixed electric-c++-terminator to handle double colons, at the |
35 ;; request of John Hagerman. | 35 ;; request of John Hagerman. |
36 ;; | 36 ;; |
37 ;; Jan, 1990 (Doug Lea, dl@oswego.edu) | 37 ;; Jan, 1990 (Doug Lea, dl@oswego.edu) |
38 ;; Replaced c++-comment-region and c++-uncomment-region with | 38 ;; Replaced c++-comment-region and c++-uncomment-region with |
39 ;; versions from Igor Metz that avoid potential infinite loops. | 39 ;; versions from Igor Metz that avoid potential infinite loops. |
40 ;; | 40 ;; |
41 ;; Oct, 1989 (Dave Detlefs, dld@cs.cmu.edu) | 41 ;; Oct, 1989 (Dave Detlefs, dld@cs.cmu.edu) |
42 ;; Added contribution from Igor Metz <metz@iam.unibe.ch>: | 42 ;; Added contribution from Igor Metz <metz@iam.unibe.ch>: |
43 ;; functions c++-comment-region and c++-uncomment-region and | 43 ;; functions c++-comment-region and c++-uncomment-region and |
44 ;; corresponding key-binding. | 44 ;; corresponding key-binding. |
45 ;; Also fixed bug in indentation of second line after an empty | 45 ;; Also fixed bug in indentation of second line after an empty |
46 ;; arglist with empty-arglist non-null. | 46 ;; arglist with empty-arglist non-null. |
47 ;; | 47 ;; |
48 ;; Sept, 1989 (Glen Ditchfield, gjditchfield@violet.uwaterloo.ca): | 48 ;; Sept, 1989 (Glen Ditchfield, gjditchfield@violet.uwaterloo.ca): |
49 ;; Textual changes to more closely imitate Emacs 18.55's c-mode. | 49 ;; Textual changes to more closely imitate Emacs 18.55's c-mode. |
50 ;; Fixed handling of "default:", where ":" was the last character in the | 50 ;; Fixed handling of "default:", where ":" was the last character in the |
51 ;; buffer. Fixed indentation of comments starting in column 0, and when | 51 ;; buffer. Fixed indentation of comments starting in column 0, and when |
52 ;; previous line contained more than one comment start string. Fixed | 52 ;; previous line contained more than one comment start string. Fixed |
178 ,(concat | 178 ,(concat |
179 "^" ; beginning of line is required | 179 "^" ; beginning of line is required |
180 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" | 180 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
181 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no | 181 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no |
182 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? | 182 "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? |
183 | 183 |
184 "\\(" ; last type spec including */& | 184 "\\(" ; last type spec including */& |
185 "[a-zA-Z0-9_:]+" | 185 "[a-zA-Z0-9_:]+" |
186 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace | 186 "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace |
187 "\\)?" ; if there is a last type spec | 187 "\\)?" ; if there is a last type spec |
188 "\\(" ; name; take that into the imenu entry | 188 "\\(" ; name; take that into the imenu entry |
189 "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... | 189 "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... |
190 ; (may not contain * because then | 190 ; (may not contain * because then |
191 ; "a::operator char*" would become "char*"!) | 191 ; "a::operator char*" would become "char*"!) |
192 "\\|" | 192 "\\|" |
193 "\\([a-zA-Z0-9_:~]*::\\)?operator" | 193 "\\([a-zA-Z0-9_:~]*::\\)?operator" |
194 "[^a-zA-Z1-9_][^(]*" ; ...or operator | 194 "[^a-zA-Z1-9_][^(]*" ; ...or operator |
195 " \\)" | 195 " \\)" |
196 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after | 196 "[ \t]*([^)]*)[ \t\n]*[^ ;]" ; require something other than a ; after |
197 ; the (...) to avoid prototypes. Can't | 197 ; the (...) to avoid prototypes. Can't |
198 ; catch cases with () inside the parentheses | 198 ; catch cases with () inside the parentheses |
199 ; surrounding the parameters | 199 ; surrounding the parameters |
200 ; (like "int foo(int a=bar()) {...}" | 200 ; (like "int foo(int a=bar()) {...}" |
201 | 201 |
202 ) 6) | 202 ) 6) |
203 ("Class" | 203 ("Class" |
204 ,(concat | 204 ,(concat |
205 "^" ; beginning of line is required | 205 "^" ; beginning of line is required |
206 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" | 206 "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
207 "class[ \t]+" | 207 "class[ \t]+" |
208 "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get | 208 "\\([a-zA-Z0-9_]+\\)" ; this is the string we want to get |
209 "[ \t]*[:{]" | 209 "[ \t]*[:{]" |
210 ) 2) | 210 ) 2) |
211 ;; Example of generic expression for finding prototypes, structs, unions, enums. | 211 ;; Example of generic expression for finding prototypes, structs, unions, enums. |
212 ;; Uncomment if you want to find these too. It will be a bit slower gathering | 212 ;; Uncomment if you want to find these too. It will be a bit slower gathering |
213 ;; the indexes. | 213 ;; the indexes. |
214 ; ("Prototypes" | 214 ; ("Prototypes" |
215 ; (, | 215 ; (, |
216 ; (concat | 216 ; (concat |
217 ; "^" ; beginning of line is required | 217 ; "^" ; beginning of line is required |
218 ; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" | 218 ; "\\(template[ \t]*<[^>]+>[ \t]*\\)?" ; there may be a "template <...>" |
219 ; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no | 219 ; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; type specs; there can be no |
220 ; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? | 220 ; "\\([a-zA-Z0-9_:]+[ \t]+\\)?" ; more than 3 tokens, right? |
221 | 221 |
222 ; "\\(" ; last type spec including */& | 222 ; "\\(" ; last type spec including */& |
223 ; "[a-zA-Z0-9_:]+" | 223 ; "[a-zA-Z0-9_:]+" |
224 ; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace | 224 ; "\\([ \t]*[*&]+[ \t]*\\|[ \t]+\\)" ; either pointer/ref sign or whitespace |
225 ; "\\)?" ; if there is a last type spec | 225 ; "\\)?" ; if there is a last type spec |
226 ; "\\(" ; name; take that into the imenu entry | 226 ; "\\(" ; name; take that into the imenu entry |
227 ; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... | 227 ; "[a-zA-Z0-9_:~]+" ; member function, ctor or dtor... |
228 ; ; (may not contain * because then | 228 ; ; (may not contain * because then |
229 ; ; "a::operator char*" would become "char*"!) | 229 ; ; "a::operator char*" would become "char*"!) |
230 ; "\\|" | 230 ; "\\|" |
231 ; "\\([a-zA-Z0-9_:~]*::\\)?operator" | 231 ; "\\([a-zA-Z0-9_:~]*::\\)?operator" |
232 ; "[^a-zA-Z1-9_][^(]*" ; ...or operator | 232 ; "[^a-zA-Z1-9_][^(]*" ; ...or operator |
233 ; " \\)" | 233 ; " \\)" |
234 ; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after | 234 ; "[ \t]*([^)]*)[ \t\n]*;" ; require ';' after |
235 ; ; the (...) Can't | 235 ; ; the (...) Can't |
236 ; ; catch cases with () inside the parentheses | 236 ; ; catch cases with () inside the parentheses |
237 ; ; surrounding the parameters | 237 ; ; surrounding the parameters |
238 ; ; (like "int foo(int a=bar());" | 238 ; ; (like "int foo(int a=bar());" |
239 ; )) 6) | 239 ; )) 6) |
240 ; ("Struct" | 240 ; ("Struct" |
241 ; (, (concat | 241 ; (, (concat |
242 ; "^" ; beginning of line is required | 242 ; "^" ; beginning of line is required |
243 ; "\\(static[ \t]+\\)?" ; there may be static or const. | 243 ; "\\(static[ \t]+\\)?" ; there may be static or const. |
244 ; "\\(const[ \t]+\\)?" | 244 ; "\\(const[ \t]+\\)?" |
528 (setq indent (save-excursion | 528 (setq indent (save-excursion |
529 (c-backward-to-start-of-if) | 529 (c-backward-to-start-of-if) |
530 (current-indentation)))) | 530 (current-indentation)))) |
531 ((looking-at "friend\[ \t]") | 531 ((looking-at "friend\[ \t]") |
532 (setq indent (+ indent c++-friend-offset))) | 532 (setq indent (+ indent c++-friend-offset))) |
533 ((= (following-char) ?}) | 533 ((= (following-char) ?\}) |
534 (setq indent (- indent c-indent-level))) | 534 (setq indent (- indent c-indent-level))) |
535 ((= (following-char) ?{) | 535 ((= (following-char) ?\{) |
536 (setq indent (+ indent c-brace-offset)))))) | 536 (setq indent (+ indent c-brace-offset)))))) |
537 (skip-chars-forward " \t") | 537 (skip-chars-forward " \t") |
538 (setq shift-amt (- indent (current-column))) | 538 (setq shift-amt (- indent (current-column))) |
539 (if (zerop shift-amt) | 539 (if (zerop shift-amt) |
540 (if (> (- (point-max) pos) (point)) | 540 (if (> (- (point-max) pos) (point)) |
577 ;; (2) the previous line begins with a colon, | 577 ;; (2) the previous line begins with a colon, |
578 ;; in which case this is the second line of member inits. | 578 ;; in which case this is the second line of member inits. |
579 ;; It is assumed that arg decls and member inits are not mixed. | 579 ;; It is assumed that arg decls and member inits are not mixed. |
580 (goto-char indent-point) | 580 (goto-char indent-point) |
581 (skip-chars-forward " \t") | 581 (skip-chars-forward " \t") |
582 (if (= (following-char) ?{) | 582 (if (= (following-char) ?\{) |
583 0 ; Unless it starts a function body | 583 0 ; Unless it starts a function body |
584 (c++-backward-to-noncomment (or parse-start (point-min))) | 584 (c++-backward-to-noncomment (or parse-start (point-min))) |
585 (if (= (preceding-char) ?\)) | 585 (if (= (preceding-char) ?\)) |
586 (progn ; first arg decl or member init | 586 (progn ; first arg decl or member init |
587 (goto-char indent-point) | 587 (goto-char indent-point) |
589 (if (= (following-char) ?:) | 589 (if (= (following-char) ?:) |
590 c++-member-init-indent | 590 c++-member-init-indent |
591 c-argdecl-indent)) | 591 c-argdecl-indent)) |
592 (if (= (preceding-char) ?\;) | 592 (if (= (preceding-char) ?\;) |
593 (backward-char 1)) | 593 (backward-char 1)) |
594 (if (= (preceding-char) ?}) | 594 (if (= (preceding-char) ?\}) |
595 0 | 595 0 |
596 (if (= (preceding-char) ?\)) | 596 (if (= (preceding-char) ?\)) |
597 (forward-list -1)) | 597 (forward-list -1)) |
598 (beginning-of-line) ; continued arg decls or member inits | 598 (beginning-of-line) ; continued arg decls or member inits |
599 (skip-chars-forward " \t") | 599 (skip-chars-forward " \t") |
605 (forward-char 1) | 605 (forward-char 1) |
606 (skip-chars-forward " \t") | 606 (skip-chars-forward " \t") |
607 (current-column))) | 607 (current-column))) |
608 (current-indentation))) | 608 (current-indentation))) |
609 ))) | 609 ))) |
610 ((/= (char-after containing-sexp) ?{) | 610 ((/= (char-after containing-sexp) ?\{) |
611 ;; line is expression, not statement: | 611 ;; line is expression, not statement: |
612 ;; indent to just after the surrounding open -- unless | 612 ;; indent to just after the surrounding open -- unless |
613 ;; empty arg list, in which case we do what | 613 ;; empty arg list, in which case we do what |
614 ;; c++-empty-arglist-indent says to do. | 614 ;; c++-empty-arglist-indent says to do. |
615 (if (and c++-empty-arglist-indent | 615 (if (and c++-empty-arglist-indent |
645 ;; as a continuation. It is probably the | 645 ;; as a continuation. It is probably the |
646 ;; end of an enum type declaration. | 646 ;; end of an enum type declaration. |
647 (save-excursion | 647 (save-excursion |
648 (goto-char indent-point) | 648 (goto-char indent-point) |
649 (skip-chars-forward " \t") | 649 (skip-chars-forward " \t") |
650 (not (= (following-char) ?})))) | 650 (not (= (following-char) ?\})))) |
651 ;; This line is continuation of preceding line's statement; | 651 ;; This line is continuation of preceding line's statement; |
652 ;; indent c-continued-statement-offset more than the | 652 ;; indent c-continued-statement-offset more than the |
653 ;; previous line of the statement. | 653 ;; previous line of the statement. |
654 (progn | 654 (progn |
655 (c-backward-to-start-of-continued-exp containing-sexp) | 655 (c-backward-to-start-of-continued-exp containing-sexp) |
656 (+ c-continued-statement-offset (current-column) | 656 (+ c-continued-statement-offset (current-column) |
657 (if (save-excursion (goto-char indent-point) | 657 (if (save-excursion (goto-char indent-point) |
658 (skip-chars-forward " \t") | 658 (skip-chars-forward " \t") |
659 (eq (following-char) ?{)) | 659 (eq (following-char) ?\{)) |
660 c-continued-brace-offset 0))) | 660 c-continued-brace-offset 0))) |
661 ;; This line starts a new statement. | 661 ;; This line starts a new statement. |
662 ;; Position following last unclosed open. | 662 ;; Position following last unclosed open. |
663 (goto-char containing-sexp) | 663 (goto-char containing-sexp) |
664 ;; Is line first statement after an open-brace? | 664 ;; Is line first statement after an open-brace? |
686 (setq colon-line-end (point))) | 686 (setq colon-line-end (point))) |
687 (search-forward ":")))) | 687 (search-forward ":")))) |
688 ;; The first following code counts | 688 ;; The first following code counts |
689 ;; if it is before the line we want to indent. | 689 ;; if it is before the line we want to indent. |
690 (and (< (point) indent-point) | 690 (and (< (point) indent-point) |
691 (- | 691 (- |
692 (if (> colon-line-end (point)) | 692 (if (> colon-line-end (point)) |
693 (- (current-indentation) c-label-offset) | 693 (- (current-indentation) c-label-offset) |
694 (current-column)) | 694 (current-column)) |
695 ;; If prev stmt starts with open-brace, that | 695 ;; If prev stmt starts with open-brace, that |
696 ;; open brace was offset by c-brace-offset. | 696 ;; open brace was offset by c-brace-offset. |
717 ;; possibly a different line | 717 ;; possibly a different line |
718 (progn | 718 (progn |
719 (if (eq (preceding-char) ?\)) | 719 (if (eq (preceding-char) ?\)) |
720 (forward-sexp -1)) | 720 (forward-sexp -1)) |
721 ;; Get initial indentation of the line we are on. | 721 ;; Get initial indentation of the line we are on. |
722 (current-indentation))))))))))) | 722 (current-indentation)))))))))) |
723 | 723 |
724 (defun c++-backward-to-noncomment (lim) | 724 (defun c++-backward-to-noncomment (lim) |
725 (let (opoint stop) | 725 (let (opoint stop) |
726 (while (not stop) | 726 (while (not stop) |
727 (skip-chars-backward " \t\n\r\f" lim) | 727 (skip-chars-backward " \t\n\r\f" lim) |
813 ;; Lines inside parens are handled specially. | 813 ;; Lines inside parens are handled specially. |
814 nil | 814 nil |
815 ;; Just started a new nesting level. | 815 ;; Just started a new nesting level. |
816 ;; Compute the standard indent for this level. | 816 ;; Compute the standard indent for this level. |
817 (let (val) | 817 (let (val) |
818 (if (= (char-after (car contain-stack)) ?{) | 818 (if (= (char-after (car contain-stack)) ?\{) |
819 (save-excursion | 819 (save-excursion |
820 (goto-char (car contain-stack)) | 820 (goto-char (car contain-stack)) |
821 (setq val (calculate-c-indent-after-brace))) | 821 (setq val (calculate-c-indent-after-brace))) |
822 (setq val (calculate-c++-indent | 822 (setq val (calculate-c++-indent |
823 (if (car indent-stack) | 823 (if (car indent-stack) |
876 (if (re-search-forward comment-start-skip | 876 (if (re-search-forward comment-start-skip |
877 (save-excursion (end-of-line) | 877 (save-excursion (end-of-line) |
878 (point)) t) | 878 (point)) t) |
879 (progn | 879 (progn |
880 (indent-for-comment) | 880 (indent-for-comment) |
881 (beginning-of-line))))))))))) | 881 (beginning-of-line)))))))))) |
882 | 882 |
883 (defun fill-c++-comment () | 883 (defun fill-c++-comment () |
884 "Fill a comment contained in consecutive lines containing point. | 884 "Fill a comment contained in consecutive lines containing point. |
885 The fill lines remain a comment." | 885 The fill lines remain a comment." |
886 (interactive) | 886 (interactive) |
939 ;;; determines which to use; the default is the weak one. | 939 ;;; determines which to use; the default is the weak one. |
940 | 940 |
941 ;; (defvar c++-match-header-strongly nil | 941 ;; (defvar c++-match-header-strongly nil |
942 ;; "*If nil, use `c++-defun-header-weak' to identify beginning of definitions. | 942 ;; "*If nil, use `c++-defun-header-weak' to identify beginning of definitions. |
943 ;; If non-nil, use `c++-defun-header-strong'.") | 943 ;; If non-nil, use `c++-defun-header-strong'.") |
944 ;; | 944 ;; |
945 ;; (defvar c++-defun-header-strong-struct-equivs "\\(class\\|struct\\|enum\\)" | 945 ;; (defvar c++-defun-header-strong-struct-equivs "\\(class\\|struct\\|enum\\)" |
946 ;; "Regexp to match names of structure declaration blocks in C++.") | 946 ;; "Regexp to match names of structure declaration blocks in C++.") |
947 ;; | 947 ;; |
948 ;; (defconst c++-defun-header-strong | 948 ;; (defconst c++-defun-header-strong |
949 ;; (let* | 949 ;; (let* |
950 ;; (; valid identifiers | 950 ;; (; valid identifiers |
951 ;; ;; There's a real weirdness here -- if I switch the below | 951 ;; ;; There's a real weirdness here -- if I switch the below |
952 ;; (id "\\(\\w\\|_\\)+") | 952 ;; (id "\\(\\w\\|_\\)+") |
953 ;; ;; to be | 953 ;; ;; to be |
954 ;; ;; (id "\\(_\\|\\w\\)+") | 954 ;; ;; (id "\\(_\\|\\w\\)+") |
955 ;; ;; things no longer work right. Try it and see! | 955 ;; ;; things no longer work right. Try it and see! |
956 ;; | 956 ;; |
957 ;; ; overloadable operators | 957 ;; ; overloadable operators |
958 ;; (op-sym1 | 958 ;; (op-sym1 |
959 ;; "[-+*/%^&|~!=<>]\\|[-+*/%^&|<>=!]=\\|<<=?\\|>>=?") | 959 ;; "[-+*/%^&|~!=<>]\\|[-+*/%^&|<>=!]=\\|<<=?\\|>>=?") |
960 ;; (op-sym2 | 960 ;; (op-sym2 |
961 ;; "&&\\|||\\|\\+\\+\\|--\\|()\\|\\[\\]") | 961 ;; "&&\\|||\\|\\+\\+\\|--\\|()\\|\\[\\]") |
962 ;; (op-sym (concat "\\(" op-sym1 "\\|" op-sym2 "\\)")) | 962 ;; (op-sym (concat "\\(" op-sym1 "\\|" op-sym2 "\\)")) |
963 ;; ; whitespace | 963 ;; ; whitespace |
964 ;; (middle "[^\\*]*\\(\\*+[^/\\*][^\\*]*\\)*") | 964 ;; (middle "[^\\*]*\\(\\*+[^/\\*][^\\*]*\\)*") |
965 ;; (c-comment (concat "/\\*" middle "\\*+/")) | 965 ;; (c-comment (concat "/\\*" middle "\\*+/")) |
966 ;; (wh (concat "\\(\\s \\|\n\\|//.*$\\|" c-comment "\\)")) | 966 ;; (wh (concat "\\(\\s \\|\n\\|//.*$\\|" c-comment "\\)")) |
991 ;; (cs-header (concat | 991 ;; (cs-header (concat |
992 ;; c++-defun-header-strong-struct-equivs | 992 ;; c++-defun-header-strong-struct-equivs |
993 ;; wh-nec id wh-opt inherit "?" wh-opt "{"))) | 993 ;; wh-nec id wh-opt inherit "?" wh-opt "{"))) |
994 ;; (concat "^\\(" func-header "\\|" cs-header "\\)")) | 994 ;; (concat "^\\(" func-header "\\|" cs-header "\\)")) |
995 ;; "Strongly-defined regexp to match beginning of structure or function def.") | 995 ;; "Strongly-defined regexp to match beginning of structure or function def.") |
996 ;; | 996 ;; |
997 ;; | 997 ;; |
998 ;; ;; This part has to do with recognizing defuns. | 998 ;; ;; This part has to do with recognizing defuns. |
999 ;; | 999 ;; |
1000 ;; ;; The weak convention we will use is that a defun begins any time | 1000 ;; ;; The weak convention we will use is that a defun begins any time |
1001 ;; ;; there is a left curly brace, or some identifier on the left margin, | 1001 ;; ;; there is a left curly brace, or some identifier on the left margin, |
1002 ;; ;; followed by a left curly somewhere on the line. (This will also | 1002 ;; ;; followed by a left curly somewhere on the line. (This will also |
1003 ;; ;; incorrectly match some continued strings, but this is after all | 1003 ;; ;; incorrectly match some continued strings, but this is after all |
1004 ;; ;; just a weak heuristic.) Suggestions for improvement (short of the | 1004 ;; ;; just a weak heuristic.) Suggestions for improvement (short of the |
1005 ;; ;; strong scheme shown above) are welcomed. | 1005 ;; ;; strong scheme shown above) are welcomed. |
1006 ;; | 1006 ;; |
1007 ;; (defconst c++-defun-header-weak "^{\\|^[_a-zA-Z].*{" | 1007 ;; (defconst c++-defun-header-weak "^{\\|^[_a-zA-Z].*{" |
1008 ;; "Weakly-defined regexp to match beginning of structure or function def.") | 1008 ;; "Weakly-defined regexp to match beginning of structure or function def.") |
1009 ;; | 1009 ;; |
1010 ;; (defun c++-beginning-of-defun (arg) | 1010 ;; (defun c++-beginning-of-defun (arg) |
1011 ;; (interactive "p") | 1011 ;; (interactive "p") |
1012 ;; (let ((c++-defun-header (if c++-match-header-strongly | 1012 ;; (let ((c++-defun-header (if c++-match-header-strongly |
1013 ;; c++-defun-header-strong | 1013 ;; c++-defun-header-strong |
1014 ;; c++-defun-header-weak))) | 1014 ;; c++-defun-header-weak))) |
1031 ;; (t | 1031 ;; (t |
1032 ;; (if (and (looking-at c++-defun-header) (not (bobp))) | 1032 ;; (if (and (looking-at c++-defun-header) (not (bobp))) |
1033 ;; (forward-char (if (< arg 0) 1 -1))) | 1033 ;; (forward-char (if (< arg 0) 1 -1))) |
1034 ;; (and (re-search-backward c++-defun-header nil 'move (or arg 1)) | 1034 ;; (and (re-search-backward c++-defun-header nil 'move (or arg 1)) |
1035 ;; (goto-char (match-beginning 0))))))) | 1035 ;; (goto-char (match-beginning 0))))))) |
1036 ;; | 1036 ;; |
1037 ;; | 1037 ;; |
1038 ;; (defun c++-end-of-defun (arg) | 1038 ;; (defun c++-end-of-defun (arg) |
1039 ;; (interactive "p") | 1039 ;; (interactive "p") |
1040 ;; (let ((c++-defun-header (if c++-match-header-strongly | 1040 ;; (let ((c++-defun-header (if c++-match-header-strongly |
1041 ;; c++-defun-header-strong | 1041 ;; c++-defun-header-strong |
1042 ;; c++-defun-header-weak))) | 1042 ;; c++-defun-header-weak))) |
1043 ;; (if (and (eobp) (> arg 0)) | 1043 ;; (if (and (eobp) (> arg 0)) |
1044 ;; nil | 1044 ;; nil |
1045 ;; (if (and (> arg 0) (looking-at c++-defun-header)) (forward-char 1)) | 1045 ;; (if (and (> arg 0) (looking-at c++-defun-header)) (forward-char 1)) |
1046 ;; (let ((pos (point))) | 1046 ;; (let ((pos (point))) |
1047 ;; (c++-beginning-of-defun | 1047 ;; (c++-beginning-of-defun |
1048 ;; (if (< arg 0) | 1048 ;; (if (< arg 0) |
1049 ;; (- (- arg (if (eobp) 0 1))) | 1049 ;; (- (- arg (if (eobp) 0 1))) |
1050 ;; arg)) | 1050 ;; arg)) |
1051 ;; (if (and (< arg 0) (bobp)) | 1051 ;; (if (and (< arg 0) (bobp)) |
1052 ;; t | 1052 ;; t |
1053 ;; (if (re-search-forward c++-defun-header nil 'move) | 1053 ;; (if (re-search-forward c++-defun-header nil 'move) |
1054 ;; (progn (forward-char -1) | 1054 ;; (progn (forward-char -1) |
1055 ;; (forward-sexp) | 1055 ;; (forward-sexp) |
1056 ;; (beginning-of-line 2))) | 1056 ;; (beginning-of-line 2))) |
1057 ;; (if (and (= pos (point)) | 1057 ;; (if (and (= pos (point)) |
1058 ;; (re-search-forward c++-defun-header nil 'move)) | 1058 ;; (re-search-forward c++-defun-header nil 'move)) |
1059 ;; (c++-end-of-defun 1)))) | 1059 ;; (c++-end-of-defun 1)))) |
1060 ;; t))) | 1060 ;; t))) |
1061 ;; | 1061 ;; |
1062 ;; (defun c++-indent-defun () | 1062 ;; (defun c++-indent-defun () |
1063 ;; "Indents the current function definition, struct or class declaration." | 1063 ;; "Indents the current function definition, struct or class declaration." |
1064 ;; (interactive) | 1064 ;; (interactive) |
1065 ;; (let ((restore (point))) | 1065 ;; (let ((restore (point))) |
1066 ;; (c++-end-of-defun 1) | 1066 ;; (c++-end-of-defun 1) |