* bug#6100: c-beginning-of-defun doesn't push mark @ 2010-05-04 16:01 Juri Linkov 2010-05-05 13:16 ` Stefan Monnier ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Juri Linkov @ 2010-05-04 16:01 UTC (permalink / raw) To: 6100 There is one annoying difference between `beginning-of-defun' and `c-beginning-of-defun': `beginning-of-defun' and `end-of-defun' pushes the mark for the old point location to the mark ring with this code: (or (not (eq this-command 'beginning-of-defun)) (eq last-command 'beginning-of-defun) (and transient-mark-mode mark-active) (push-mark)) but `c-beginning-of-defun' doesn't do that. This patch add the same code to `c-beginning-of-defun' and `c-end-of-defun': === modified file 'lisp/progmodes/cc-cmds.el' --- lisp/progmodes/cc-cmds.el 2010-04-19 15:07:52 +0000 +++ lisp/progmodes/cc-cmds.el 2010-05-04 16:01:05 +0000 @@ -1501,6 +1501,11 @@ (defun c-beginning-of-defun (&optional a (interactive "p") (or arg (setq arg 1)) + (or (not (eq this-command 'c-beginning-of-defun)) + (eq last-command 'c-beginning-of-defun) + (and transient-mark-mode mark-active) + (push-mark)) + (c-save-buffer-state (beginning-of-defun-function end-of-defun-function (start (point)) @@ -1604,6 +1609,11 @@ (defun c-end-of-defun (&optional arg) (interactive "p") (or arg (setq arg 1)) + (or (not (eq this-command 'c-end-of-defun)) + (eq last-command 'c-end-of-defun) + (and transient-mark-mode mark-active) + (push-mark)) + (c-save-buffer-state (beginning-of-defun-function end-of-defun-function (start (point)) -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#6100: c-beginning-of-defun doesn't push mark 2010-05-04 16:01 bug#6100: c-beginning-of-defun doesn't push mark Juri Linkov @ 2010-05-05 13:16 ` Stefan Monnier [not found] ` <jwvk4ripk1d.fsf-monnier+emacs@gnu.org> 2010-05-12 13:26 ` bug#6100: Fix Alan Mackenzie 2 siblings, 0 replies; 8+ messages in thread From: Stefan Monnier @ 2010-05-05 13:16 UTC (permalink / raw) To: Juri Linkov; +Cc: 6100 > There is one annoying difference between `beginning-of-defun' > and `c-beginning-of-defun': > `beginning-of-defun' and `end-of-defun' pushes the mark for the > old point location to the mark ring with this code: > (or (not (eq this-command 'beginning-of-defun)) > (eq last-command 'beginning-of-defun) > (and transient-mark-mode mark-active) > (push-mark)) > but `c-beginning-of-defun' doesn't do that. > This patch add the same code to `c-beginning-of-defun' and `c-end-of-defun': Of course, I'd argue that the right fix is to use `beginning-of-defun'. Stefan ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <jwvk4ripk1d.fsf-monnier+emacs@gnu.org>]
* bug#6100: c-beginning-of-defun doesn't push mark [not found] ` <jwvk4ripk1d.fsf-monnier+emacs@gnu.org> @ 2010-05-05 18:28 ` Juri Linkov 2010-05-05 20:29 ` Stefan Monnier ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Juri Linkov @ 2010-05-05 18:28 UTC (permalink / raw) To: Stefan Monnier; +Cc: 6100 >> There is one annoying difference between `beginning-of-defun' >> and `c-beginning-of-defun': > >> `beginning-of-defun' and `end-of-defun' pushes the mark for the >> old point location to the mark ring with this code: > >> (or (not (eq this-command 'beginning-of-defun)) >> (eq last-command 'beginning-of-defun) >> (and transient-mark-mode mark-active) >> (push-mark)) > >> but `c-beginning-of-defun' doesn't do that. > >> This patch add the same code to `c-beginning-of-defun' and `c-end-of-defun': > > Of course, I'd argue that the right fix is to use `beginning-of-defun'. Do you mean cc-mode should use `beginning-of-defun-function'? -- Juri Linkov http://www.jurta.org/emacs/ ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#6100: c-beginning-of-defun doesn't push mark 2010-05-05 18:28 ` Juri Linkov @ 2010-05-05 20:29 ` Stefan Monnier 2010-05-06 10:54 ` Alan Mackenzie [not found] ` <20100506105433.GA1366@muc.de> 2 siblings, 0 replies; 8+ messages in thread From: Stefan Monnier @ 2010-05-05 20:29 UTC (permalink / raw) To: Juri Linkov; +Cc: 6100 > Do you mean cc-mode should use `beginning-of-defun-function'? AFAIK it already does, so just using the beginning-of-defun command should DTRT. Stefan ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#6100: c-beginning-of-defun doesn't push mark 2010-05-05 18:28 ` Juri Linkov 2010-05-05 20:29 ` Stefan Monnier @ 2010-05-06 10:54 ` Alan Mackenzie [not found] ` <20100506105433.GA1366@muc.de> 2 siblings, 0 replies; 8+ messages in thread From: Alan Mackenzie @ 2010-05-06 10:54 UTC (permalink / raw) To: Juri Linkov; +Cc: 6100 Hi, Juri, On Wed, May 05, 2010 at 09:28:32PM +0300, Juri Linkov wrote: > >> There is one annoying difference between `beginning-of-defun' > >> and `c-beginning-of-defun': > >> `beginning-of-defun' and `end-of-defun' pushes the mark for the > >> old point location to the mark ring with this code: > >> (or (not (eq this-command 'beginning-of-defun)) > >> (eq last-command 'beginning-of-defun) > >> (and transient-mark-mode mark-active) > >> (push-mark)) > >> but `c-beginning-of-defun' doesn't do that. > >> This patch add the same code to `c-beginning-of-defun' and `c-end-of-defun': > > Of course, I'd argue that the right fix is to use `beginning-of-defun'. > Do you mean cc-mode should use `beginning-of-defun-function'? This would be OK. Unfortunately, end-of-defun-function isn't called cleanly. With a C-M-e, {beginning,end}-of-defun-function are often called 4 times. c-end-of-defun, however, already does the Right Thing on its own. c-{beginning,end}-of-defun have a heavy overhead in determining the type of starting position (inside the brace block, inside the function header, etc.) and in locating a top-level brace (at the start) and the start of the header (at the end). This overhead dominates the speed of the functions, which work essentially as fast regardless of how big ARG is. The speed of c-{beginning,end}-of-defun have presented problems from time to time. Quadrupling CC Mode's end-of-defun's runtime doesn't seem a good idea. I want to keep the handling of c-{beginning,end}-of-defun symmetrical for ease of maintenance. I would favour your patch to these defuns which pushes the marks. > Juri Linkov -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <20100506105433.GA1366@muc.de>]
* bug#6100: c-beginning-of-defun doesn't push mark [not found] ` <20100506105433.GA1366@muc.de> @ 2010-05-11 19:22 ` Stefan Monnier 2010-05-12 11:21 ` Alan Mackenzie 0 siblings, 1 reply; 8+ messages in thread From: Stefan Monnier @ 2010-05-11 19:22 UTC (permalink / raw) To: Alan Mackenzie; +Cc: 6100 > The speed of c-{beginning,end}-of-defun have presented problems from time > to time. Quadrupling CC Mode's end-of-defun's runtime doesn't seem a > good idea. I want to keep the handling of c-{beginning,end}-of-defun > symmetrical for ease of maintenance. IIUC the speed of those operations has been a problem when called many times within a single command (i.e. the cumulative time became a problem), so it shouldn't be a problem for interactive use where doing it 4 times rather than 1 shouldn't be noticeable. IOW, the problem was algorithmic, but running the same code 4 times makes no difference algorithmically. > I would favour your patch to these defuns which pushes the marks. It's your code, so it's your choice. Stefan ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#6100: c-beginning-of-defun doesn't push mark 2010-05-11 19:22 ` Stefan Monnier @ 2010-05-12 11:21 ` Alan Mackenzie 0 siblings, 0 replies; 8+ messages in thread From: Alan Mackenzie @ 2010-05-12 11:21 UTC (permalink / raw) To: Stefan Monnier; +Cc: 6100 Hi, Stefan and Juri, On Tue, May 11, 2010 at 03:22:10PM -0400, Stefan Monnier wrote: > > I would favour your patch to these defuns which pushes the marks. > It's your code, so it's your choice. I've commited Juri's patch. The mark will now be pushed when appropriate in c-{beginning,end}-of-function. > Stefan -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#6100: Fix 2010-05-04 16:01 bug#6100: c-beginning-of-defun doesn't push mark Juri Linkov 2010-05-05 13:16 ` Stefan Monnier [not found] ` <jwvk4ripk1d.fsf-monnier+emacs@gnu.org> @ 2010-05-12 13:26 ` Alan Mackenzie 2 siblings, 0 replies; 8+ messages in thread From: Alan Mackenzie @ 2010-05-12 13:26 UTC (permalink / raw) To: 6100-done c-{beginning,end}-of-function now push the mark like beginning-of-defun does. -- Alan Mackenzie (Nuremberg, Germany). ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-05-12 13:26 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-05-04 16:01 bug#6100: c-beginning-of-defun doesn't push mark Juri Linkov 2010-05-05 13:16 ` Stefan Monnier [not found] ` <jwvk4ripk1d.fsf-monnier+emacs@gnu.org> 2010-05-05 18:28 ` Juri Linkov 2010-05-05 20:29 ` Stefan Monnier 2010-05-06 10:54 ` Alan Mackenzie [not found] ` <20100506105433.GA1366@muc.de> 2010-05-11 19:22 ` Stefan Monnier 2010-05-12 11:21 ` Alan Mackenzie 2010-05-12 13:26 ` bug#6100: Fix Alan Mackenzie
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.