comparison lisp/progmodes/cc-mode.el @ 107086:1786f2e6a856

Change strategy for marking < and > as template delimiters: mark them strictly in matching pairs.
author Alan Mackenzie <acm@muc.de>
date Thu, 04 Feb 2010 21:15:37 +0000
parents 1d1d5d9bd884
children 17f07853dd4d
comparison
equal deleted inserted replaced
107085:d7831d04952b 107086:1786f2e6a856
639 639
640 ;; Starting a mode is a sort of "change". So call the change functions... 640 ;; Starting a mode is a sort of "change". So call the change functions...
641 (save-restriction 641 (save-restriction
642 (widen) 642 (widen)
643 (save-excursion 643 (save-excursion
644 (if c-get-state-before-change-function 644 (if c-get-state-before-change-functions
645 (funcall c-get-state-before-change-function (point-min) (point-max))) 645 (mapc (lambda (fn)
646 (funcall fn beg end))
647 c-get-state-before-change-functions))
646 (if c-before-font-lock-function 648 (if c-before-font-lock-function
647 (funcall c-before-font-lock-function (point-min) (point-max) 649 (funcall c-before-font-lock-function (point-min) (point-max)
648 (- (point-max) (point-min)))))) 650 (- (point-max) (point-min))))))
649 651
650 (make-local-variable 'outline-regexp) 652 (make-local-variable 'outline-regexp)
773 (add-hook 'before-hack-local-variables-hook 'c-before-hack-hook) 775 (add-hook 'before-hack-local-variables-hook 'c-before-hack-hook)
774 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)) 776 (add-hook 'hack-local-variables-hook 'c-postprocess-file-styles))
775 777
776 (defmacro c-run-mode-hooks (&rest hooks) 778 (defmacro c-run-mode-hooks (&rest hooks)
777 ;; Emacs 21.1 has introduced a system with delayed mode hooks that 779 ;; Emacs 21.1 has introduced a system with delayed mode hooks that
778 ;; require the use of the new function `run-mode-hooks'. 780 ;; requires the use of the new function `run-mode-hooks'.
779 (if (cc-bytecomp-fboundp 'run-mode-hooks) 781 (if (cc-bytecomp-fboundp 'run-mode-hooks)
780 `(run-mode-hooks ,@hooks) 782 `(run-mode-hooks ,@hooks)
781 `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks)))) 783 `(progn ,@(mapcar (lambda (hook) `(run-hooks ,hook)) hooks))))
782 784
783 785
806 ;; 808 ;;
807 ;; Point is undefined both before and after this function call; the buffer 809 ;; Point is undefined both before and after this function call; the buffer
808 ;; has already been widened, and match-data saved. The return value is 810 ;; has already been widened, and match-data saved. The return value is
809 ;; meaningless. 811 ;; meaningless.
810 ;; 812 ;;
811 ;; This function is the C/C++/ObjC value of 813 ;; This function is in the C/C++/ObjC values of
812 ;; `c-get-state-before-change-function' and is called exclusively as a 814 ;; `c-get-state-before-change-functions' and is called exclusively as a
813 ;; before change function. 815 ;; before change function.
814 (goto-char beg) 816 (goto-char beg)
815 (c-beginning-of-macro) 817 (c-beginning-of-macro)
816 (setq c-old-BOM (point)) 818 (setq c-old-BOM (point))
817 819
920 ) 922 )
921 (forward-line)) ; no infinite loop with, e.g., "#//" 923 (forward-line)) ; no infinite loop with, e.g., "#//"
922 ))))) 924 )))))
923 925
924 (defun c-before-change (beg end) 926 (defun c-before-change (beg end)
925 ;; Function to be put on `before-change-function'. Primarily, this calls 927 ;; Function to be put on `before-change-functions'. Primarily, this calls
926 ;; the language dependent `c-get-state-before-change-function'. It is 928 ;; the language dependent `c-get-state-before-change-functions'. It is
927 ;; otherwise used only to remove stale entries from the `c-found-types' 929 ;; otherwise used only to remove stale entries from the `c-found-types'
928 ;; cache, and to record entries which a `c-after-change' function might 930 ;; cache, and to record entries which a `c-after-change' function might
929 ;; confirm as stale. 931 ;; confirm as stale.
930 ;; 932 ;;
931 ;; Note that this function must be FAST rather than accurate. Note 933 ;; Note that this function must be FAST rather than accurate. Note
999 1001
1000 ;; (c-new-BEG c-new-END) will be the region to fontify. It may become 1002 ;; (c-new-BEG c-new-END) will be the region to fontify. It may become
1001 ;; larger than (beg end). 1003 ;; larger than (beg end).
1002 (setq c-new-BEG beg 1004 (setq c-new-BEG beg
1003 c-new-END end) 1005 c-new-END end)
1004 (if c-get-state-before-change-function 1006 (if c-get-state-before-change-functions
1005 (funcall c-get-state-before-change-function beg end)) 1007 (mapc (lambda (fn)
1008 (funcall fn beg end))
1009 c-get-state-before-change-functions))
1006 )))) 1010 ))))
1007 1011
1008 (defun c-after-change (beg end old-len) 1012 (defun c-after-change (beg end old-len)
1009 ;; Function put on `after-change-functions' to adjust various caches 1013 ;; Function put on `after-change-functions' to adjust various caches
1010 ;; etc. Prefer speed to finesse here, since there will be an order 1014 ;; etc. Prefer speed to finesse here, since there will be an order