comparison lisp/progmodes/cc-defs.el @ 77081:e8bd3e011b64

Changes to make `narrow-to-defun' and `mark-defun' work properly in CC Mode: cc-defs.el (c-beginning-of-defun-1): cc-cmds.el (c-beginning-of-defun, c-end-of-defun): bind beginning/end-of-defun-function to nil around calls to beginning/end-of-defun. cc-langs.el (beginning-of-defun-function, end-of-defun-function): new c-lang-setvar's. cc-awk.el (c-awk-beginning-of-defun): Add "(or arg (setq arg 1))" to enable non-interactive call.
author Alan Mackenzie <acm@muc.de>
date Mon, 09 Apr 2007 10:51:29 +0000
parents b48c6cc5f648
children c1ec1c8a8d2e 4ef881a120fe
comparison
equal deleted inserted replaced
77080:32c1980a1285 77081:e8bd3e011b64
72 (cc-load "cc-fix"))) 72 (cc-load "cc-fix")))
73 73
74 ; (eval-after-load "font-lock" ; 2006-07-09. font-lock is now preloaded 74 ; (eval-after-load "font-lock" ; 2006-07-09. font-lock is now preloaded
75 ; ' 75 ; '
76 (if (and (not (featurep 'cc-fix)) ; only load the file once. 76 (if (and (not (featurep 'cc-fix)) ; only load the file once.
77 (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS 77 (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
78 ; to make the call to f-l-c-k throw an error. 78 ; to make the call to f-l-c-k throw an error.
79 (let (font-lock-keywords) 79 (let (font-lock-keywords)
80 (font-lock-compile-keywords '("\\<\\>")) 80 (font-lock-compile-keywords '("\\<\\>"))
81 font-lock-keywords)) ; did the previous call foul this up? 81 font-lock-keywords)) ; did the previous call foul this up?
82 (load "cc-fix")) ;) 82 (load "cc-fix")) ;)
83 83
84 ;; The above takes care of the delayed loading, but this is necessary 84 ;; The above takes care of the delayed loading, but this is necessary
85 ;; to ensure correct byte compilation. 85 ;; to ensure correct byte compilation.
86 (eval-when-compile 86 (eval-when-compile
87 (if (and (not (featurep 'cc-fix)) 87 (if (and (not (featurep 'cc-fix))
706 ,(when (cc-bytecomp-fboundp 'buffer-syntactic-context-depth) 706 ,(when (cc-bytecomp-fboundp 'buffer-syntactic-context-depth)
707 ;; XEmacs only. This can improve the performance of 707 ;; XEmacs only. This can improve the performance of
708 ;; c-parse-state to between 3 and 60 times faster when 708 ;; c-parse-state to between 3 and 60 times faster when
709 ;; braces are hung. It can also degrade performance by 709 ;; braces are hung. It can also degrade performance by
710 ;; about as much when braces are not hung. 710 ;; about as much when braces are not hung.
711 '(let (pos) 711 '(let (beginning-of-defun-function end-of-defun-function
712 pos)
712 (while (not pos) 713 (while (not pos)
713 (save-restriction 714 (save-restriction
714 (widen) 715 (widen)
715 (setq pos (c-safe-scan-lists 716 (setq pos (c-safe-scan-lists
716 (point) -1 (buffer-syntactic-context-depth)))) 717 (point) -1 (buffer-syntactic-context-depth))))
729 (goto-char pos) 730 (goto-char pos)
730 (setq pos nil)) 731 (setq pos nil))
731 )) 732 ))
732 (goto-char pos))) 733 (goto-char pos)))
733 ;; Emacs, which doesn't have buffer-syntactic-context-depth 734 ;; Emacs, which doesn't have buffer-syntactic-context-depth
734 (beginning-of-defun)) 735 (let (beginning-of-defun-function end-of-defun-function)
736 (beginning-of-defun)))
735 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at the 737 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at the
736 ;; open brace. 738 ;; open brace.
737 (and defun-prompt-regexp 739 (and defun-prompt-regexp
738 (looking-at defun-prompt-regexp) 740 (looking-at defun-prompt-regexp)
739 (goto-char (match-end 0))))) 741 (goto-char (match-end 0)))))