diff options
| author | Alan Mackenzie | 2007-04-09 10:51:29 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2007-04-09 10:51:29 +0000 |
| commit | 28abe5e279255c2b19564bd662f87e978c79702d (patch) | |
| tree | 7715e1f5d99b99f04cfe2664a08c580420d909f9 | |
| parent | 1eca8ae69b8c081af9c0ca12d292ea91929f5ed6 (diff) | |
| download | emacs-28abe5e279255c2b19564bd662f87e978c79702d.tar.gz emacs-28abe5e279255c2b19564bd662f87e978c79702d.zip | |
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.
| -rw-r--r-- | lisp/progmodes/cc-awk.el | 1 | ||||
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 6 | ||||
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 18 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 25 |
4 files changed, 35 insertions, 15 deletions
diff --git a/lisp/progmodes/cc-awk.el b/lisp/progmodes/cc-awk.el index b0c15bff903..b3e0e381135 100644 --- a/lisp/progmodes/cc-awk.el +++ b/lisp/progmodes/cc-awk.el | |||
| @@ -988,6 +988,7 @@ nor helpful. | |||
| 988 | Note that this function might do hidden buffer changes. See the | 988 | Note that this function might do hidden buffer changes. See the |
| 989 | comment at the start of cc-engine.el for more info." | 989 | comment at the start of cc-engine.el for more info." |
| 990 | (interactive "p") | 990 | (interactive "p") |
| 991 | (or arg (setq arg 1)) | ||
| 991 | (save-match-data | 992 | (save-match-data |
| 992 | (c-save-buffer-state ; ensures the buffer is writable. | 993 | (c-save-buffer-state ; ensures the buffer is writable. |
| 993 | nil | 994 | nil |
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 7b28851b3bb..79043c87b63 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -1511,7 +1511,8 @@ defun." | |||
| 1511 | (or arg (setq arg 1)) | 1511 | (or arg (setq arg 1)) |
| 1512 | 1512 | ||
| 1513 | (c-save-buffer-state | 1513 | (c-save-buffer-state |
| 1514 | ((start (point)) | 1514 | (beginning-of-defun-function end-of-defun-function |
| 1515 | (start (point)) | ||
| 1515 | where paren-state pos) | 1516 | where paren-state pos) |
| 1516 | 1517 | ||
| 1517 | ;; Move back out of any macro/comment/string we happen to be in. | 1518 | ;; Move back out of any macro/comment/string we happen to be in. |
| @@ -1613,7 +1614,8 @@ the open-parenthesis that starts a defun; see `beginning-of-defun'." | |||
| 1613 | (or arg (setq arg 1)) | 1614 | (or arg (setq arg 1)) |
| 1614 | 1615 | ||
| 1615 | (c-save-buffer-state | 1616 | (c-save-buffer-state |
| 1616 | ((start (point)) | 1617 | (beginning-of-defun-function end-of-defun-function |
| 1618 | (start (point)) | ||
| 1617 | where paren-state pos) | 1619 | where paren-state pos) |
| 1618 | 1620 | ||
| 1619 | ;; Move back out of any macro/comment/string we happen to be in. | 1621 | ;; Move back out of any macro/comment/string we happen to be in. |
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 43fa0ab5937..8c10df649de 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -74,12 +74,12 @@ | |||
| 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. |
| @@ -708,7 +708,8 @@ be after it." | |||
| 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) |
| @@ -731,7 +732,8 @@ be after it." | |||
| 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 |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index fe01ab02ae3..906cbfb19a7 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -221,11 +221,6 @@ the evaluated constant value at compile time." | |||
| 221 | ;; with the group symbol for each group and should return non-nil | 221 | ;; with the group symbol for each group and should return non-nil |
| 222 | ;; if that group is to be included. | 222 | ;; if that group is to be included. |
| 223 | ;; | 223 | ;; |
| 224 | ;; OP-FILTER filters the individual operators in each group. It | ||
| 225 | ;; can be t to choose all operators, a regexp to test against each | ||
| 226 | ;; operator, or a function which will be called for each operator | ||
| 227 | ;; and should return non-nil for those to include. | ||
| 228 | ;; | ||
| 229 | ;; If XLATE is given, it's a function which is called for each | 224 | ;; If XLATE is given, it's a function which is called for each |
| 230 | ;; matching operator and its return value is collected instead. | 225 | ;; matching operator and its return value is collected instead. |
| 231 | ;; If it returns a list, the elements are spliced directly into | 226 | ;; If it returns a list, the elements are spliced directly into |
| @@ -1376,6 +1371,26 @@ EOL terminated statements." | |||
| 1376 | (c-lang-const c-vsemi-status-unknown-p-fn)) | 1371 | (c-lang-const c-vsemi-status-unknown-p-fn)) |
| 1377 | 1372 | ||
| 1378 | 1373 | ||
| 1374 | ;;; Defun functions | ||
| 1375 | |||
| 1376 | ;; The Emacs variables beginning-of-defun-function and | ||
| 1377 | ;; end-of-defun-function will be set so that commands like | ||
| 1378 | ;; `mark-defun' and `narrow-to-defun' work right. The key sequences | ||
| 1379 | ;; C-M-a and C-M-e are, however, bound directly to the CC Mode | ||
| 1380 | ;; functions, allowing optimisation for large n. | ||
| 1381 | (c-lang-defconst beginning-of-defun-function | ||
| 1382 | "Function to which beginning-of-defun-function will be set." | ||
| 1383 | t 'c-beginning-of-defun | ||
| 1384 | awk 'c-awk-beginning-of-defun) | ||
| 1385 | (c-lang-setvar beginning-of-defun-function | ||
| 1386 | (c-lang-const beginning-of-defun-function)) | ||
| 1387 | |||
| 1388 | (c-lang-defconst end-of-defun-function | ||
| 1389 | "Function to which end-of-defun-function will be set." | ||
| 1390 | t 'c-end-of-defun | ||
| 1391 | awk 'c-awk-end-of-defun) | ||
| 1392 | (c-lang-setvar end-of-defun-function (c-lang-const end-of-defun-function)) | ||
| 1393 | |||
| 1379 | ;;; In-comment text handling. | 1394 | ;;; In-comment text handling. |
| 1380 | 1395 | ||
| 1381 | (c-lang-defconst c-paragraph-start | 1396 | (c-lang-defconst c-paragraph-start |