diff options
| author | Alan Mackenzie | 2012-03-08 11:32:57 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2012-03-08 11:32:57 +0000 |
| commit | 9cec78342c003b09a961c1b501eba55e14ef32cc (patch) | |
| tree | 81d719e55a545f96ca05698be23df19e8c1861ec | |
| parent | 5aca4f7140664beda9a789e689e5101224b61442 (diff) | |
| download | emacs-9cec78342c003b09a961c1b501eba55e14ef32cc.tar.gz emacs-9cec78342c003b09a961c1b501eba55e14ef32cc.zip | |
Make c-mark-defun extend region when repeated, and leave a mark.
Fixes bugs #5525, #10906.
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/cc-cmds.el | 27 |
2 files changed, 31 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bc097448aeb..7673b1fc429 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2012-03-08 Alan Mackenzie <acm@muc.de> | ||
| 2 | |||
| 3 | * progmodes/cc-cmds.el (c-mark-function): Make it leave a mark at | ||
| 4 | the starting position; make it extend the marked region when | ||
| 5 | invoked repeatedly - all under appropriate circumstances. | ||
| 6 | Fixes bugs #5525, #10906. | ||
| 7 | |||
| 1 | 2012-03-08 Glenn Morris <rgm@gnu.org> | 8 | 2012-03-08 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * files.el (locate-dominating-file, dir-locals-find-file): | 10 | * files.el (locate-dominating-file, dir-locals-find-file): |
diff --git a/lisp/progmodes/cc-cmds.el b/lisp/progmodes/cc-cmds.el index 509bb203f78..55ab6c9981c 100644 --- a/lisp/progmodes/cc-cmds.el +++ b/lisp/progmodes/cc-cmds.el | |||
| @@ -1958,7 +1958,12 @@ with a brace block." | |||
| 1958 | 1958 | ||
| 1959 | (defun c-mark-function () | 1959 | (defun c-mark-function () |
| 1960 | "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. |
| 1961 | If point is not inside any then the closest following one is chosen. | 1961 | If point is not inside any then the closest following one is |
| 1962 | chosen. Each successive call of this command extends the marked | ||
| 1963 | region by one function. | ||
| 1964 | |||
| 1965 | A mark is left where the command started, unless the region is already active | ||
| 1966 | \(in Transient Mark mode). | ||
| 1962 | 1967 | ||
| 1963 | As opposed to \\[c-beginning-of-defun] and \\[c-end-of-defun], this | 1968 | As opposed to \\[c-beginning-of-defun] and \\[c-end-of-defun], this |
| 1964 | function does not require the declaration to contain a brace block." | 1969 | function does not require the declaration to contain a brace block." |
| @@ -1974,8 +1979,24 @@ function does not require the declaration to contain a brace block." | |||
| 1974 | 1979 | ||
| 1975 | (if (not decl-limits) | 1980 | (if (not decl-limits) |
| 1976 | (error "Cannot find any declaration") | 1981 | (error "Cannot find any declaration") |
| 1977 | (goto-char (car decl-limits)) | 1982 | (let* ((extend-region-p |
| 1978 | (push-mark (cdr decl-limits) nil t)))) | 1983 | (and (eq this-command 'c-mark-function) |
| 1984 | (eq last-command 'c-mark-function))) | ||
| 1985 | (push-mark-p (and (eq this-command 'c-mark-function) | ||
| 1986 | (not extend-region-p) | ||
| 1987 | (not (and transient-mark-mode mark-active))))) | ||
| 1988 | (if push-mark-p (push-mark (point))) | ||
| 1989 | (if extend-region-p | ||
| 1990 | (progn | ||
| 1991 | (exchange-point-and-mark) | ||
| 1992 | (setq decl-limits (c-declaration-limits t)) | ||
| 1993 | (when (not decl-limits) | ||
| 1994 | (exchange-point-and-mark) | ||
| 1995 | (error "Cannot find any declaration")) | ||
| 1996 | (goto-char (cdr decl-limits)) | ||
| 1997 | (exchange-point-and-mark)) | ||
| 1998 | (goto-char (car decl-limits)) | ||
| 1999 | (push-mark (cdr decl-limits) nil t)))))) | ||
| 1979 | 2000 | ||
| 1980 | (defun c-cpp-define-name () | 2001 | (defun c-cpp-define-name () |
| 1981 | "Return the name of the current CPP macro, or NIL if we're not in one." | 2002 | "Return the name of the current CPP macro, or NIL if we're not in one." |