Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
New autocmds: OperationPending, OperationExecuted, OperationCleared
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mohammed Chelouti  
View profile  
 More options Oct 10 2012, 4:30 pm
From: Mohammed Chelouti <mh...@web.de>
Date: Wed, 10 Oct 2012 22:30:13 +0200
Local: Wed, Oct 10 2012 4:30 pm
Subject: [PATCH] New autocmds: OperationPending, OperationExecuted, OperationCleared

Hello

I have written a plugin[1] for Vim that enables relative line numbers for
pending operations. Unfortunately it's kinda messy to get to 'know' when an
operation is pending and when it is executed. You have to remap every
operator-command to call your specific plugin function (something like:
nnoremap d :call MyFunc()<CR>d). Of course this leads to the problem that you
cannot use more than one plugin that needs to know when you are in operation-
pending mode. Additionally you somehow need to remap operations that come from
other plugins.

A much more elegant solution would be to have an event to be called when an
operation is pending. I've looked at the Vim code and added the following
three autocommands:
- OperationPending: is executed when an operation is called which needs a
motion.
- OperationExecuted: is executed after the pending operation was executed
(i.e. a motion or a second keystroke like yy, dd etc. is passed).
- OperationCleared: is executed after every command that doesn't enter
operation-pending-mode. (executed after OperationExecuted)

I hope you see the reasoning behind my request and add my patch to Vim.

I haven't found any hint about your preferred patch format, so I just attached
the 'hg diff' output.

Best regards,
Mohammed

[1] http://www.vim.org/scripts/script.php?script_id=4212

  operation_autocmds.patch
7K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ben Fritz  
View profile  
 More options Oct 10 2012, 5:16 pm
From: Ben Fritz <fritzophre...@gmail.com>
Date: Wed, 10 Oct 2012 14:16:15 -0700 (PDT)
Local: Wed, Oct 10 2012 5:16 pm
Subject: Re: [PATCH] New autocmds: OperationPending, OperationExecuted, OperationCleared

On Wednesday, October 10, 2012 3:30:13 PM UTC-5, Mohammed Chelouti wrote:

> I've looked at the Vim code and added the following three autocommands:

> - OperationPending: is executed when an operation is called which needs a motion.
> - OperationExecuted: is executed after the pending operation was executed (i.e. a motion or a second keystroke like yy, dd etc. is passed).
> - OperationCleared: is executed after every command that doesn't enter operation-pending-mode. (executed after OperationExecuted)

I can see why the first two are needed for taking actions in operator pending mode. But why is the third needed?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mohammed Chelouti  
View profile  
 More options Oct 10 2012, 6:01 pm
From: Mohammed Chelouti <mh...@web.de>
Date: Thu, 11 Oct 2012 00:01:37 +0200
Local: Wed, Oct 10 2012 6:01 pm
Subject: Re: [PATCH] New autocmds: OperationPending, OperationExecuted, OperationCleared

On Wednesday 10 October 2012 14:16:15 Ben Fritz wrote:

> On Wednesday, October 10, 2012 3:30:13 PM UTC-5, Mohammed Chelouti wrote:
> > I've looked at the Vim code and added the following three autocommands:

> > - OperationPending: is executed when an operation is called which needs a
> > motion. - OperationExecuted: is executed after the pending operation was
> > executed (i.e. a motion or a second keystroke like yy, dd etc. is
> > passed). - OperationCleared: is executed after every command that doesn't
> > enter operation-pending-mode. (executed after OperationExecuted)
> I can see why the first two are needed for taking actions in operator
> pending mode. But why is the third needed?

Because a pending operation triggers OperationExecuted only when the operation
is really executed.
E.g. place your cursor on the first line and hit dk. This will leave operation
pending mode but won't execute the operation. Additionally actions like
hitting <Esc> or <C-c> or just leaving the buffer won't execute the operation,
either.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Fishburn  
View profile  
 More options Oct 11 2012, 8:47 am
From: David Fishburn <dfishburn....@gmail.com>
Date: Thu, 11 Oct 2012 08:47:49 -0400
Local: Thurs, Oct 11 2012 8:47 am
Subject: Re: [PATCH] New autocmds: OperationPending, OperationExecuted, OperationCleared
On Wed, Oct 10, 2012 at 4:30 PM, Mohammed Chelouti <mh...@web.de> wrote:

...

> A much more elegant solution would be to have an event to be called when an
> operation is pending. I've looked at the Vim code and added the following
> three autocommands:

> - OperationPending: is executed when an operation is called which needs a
> motion.

> - OperationExecuted: is executed after the pending operation was executed
> (i.e. a motion or a second keystroke like yy, dd etc. is passed).

> - OperationCleared: is executed after every command that doesn't enter
> operation-pending-mode. (executed after OperationExecuted)

Mohammed,

What information is available within these events?
Usually this is through some v: scoped variable or something like
<a:file> and so on.

I would expect the usual stuff like:

v:register  - Register currently being operated on
v:operator - Current operator (i.e. "f" for cf)
v:count - Count given for the command

Right now, the YankRing plugin had to create expression maps for these
and prompt the user for the remaining part of the command.  It sounds
like I could use this feature instead of some of those maps, if the
required information is available.

Thanks,
Dave


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mohammed Chelouti  
View profile  
 More options Oct 11 2012, 9:37 am
From: Mohammed Chelouti <mh...@web.de>
Date: Thu, 11 Oct 2012 15:36:48 +0200
Local: Thurs, Oct 11 2012 9:36 am
Subject: Re: [PATCH] New autocmds: OperationPending, OperationExecuted, OperationCleared
On Thursday 11 October 2012 08:47:49 David Fishburn wrote:

> What information is available within these events?
> Usually this is through some v: scoped variable or something like
> <a:file> and so on.

> I would expect the usual stuff like:

> v:register  - Register currently being operated on
> v:operator - Current operator (i.e. "f" for cf)
> v:count - Count given for the command

> Thanks,
> Dave

Hello Dave

The v:variables you mentioned work as expected.
So the command 4"adk would give

v:count = 4
v:register = a
v:operator = d

Best,
Mohammed


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bram Moolenaar  
View profile  
 More options Oct 11 2012, 10:03 pm
From: Bram Moolenaar <B...@Moolenaar.net>
Date: Fri, 12 Oct 2012 04:03:29 +0200
Local: Thurs, Oct 11 2012 10:03 pm
Subject: Re: [PATCH] New autocmds: OperationPending, OperationExecuted, OperationCleared

The problem with autocommands is that they can do lots of things that
the code where they are triggered from does not expect.  It's not
unusual for Vim to crash.  Try changing to another buffer, moving the
cursor, closing the window, renaming the buffer, etc.  It is very
difficult to handle every single one of these.  We still find problems
with existing autocommands.

Perhaps there is another way to do what you want?

--
The Characters and incidents portrayed and the names used are fictitious and
any similarity to the names, characters, or history of any person is entirely
accidental and unintentional.
                                  Signed RICHARD M. NIXON
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- B...@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mohammed Chelouti  
View profile  
 More options Oct 15 2012, 6:26 pm
From: Mohammed Chelouti <mh...@web.de>
Date: Tue, 16 Oct 2012 00:26:18 +0200
Local: Mon, Oct 15 2012 6:26 pm
Subject: Re: [PATCH] New autocmds: OperationPending, OperationExecuted, OperationCleared
On Friday 12 October 2012 04:03:29 Bram Moolenaar wrote:

> The problem with autocommands is that they can do lots of things that
> the code where they are triggered from does not expect.  It's not
> unusual for Vim to crash.  Try changing to another buffer, moving the
> cursor, closing the window, renaming the buffer, etc.  It is very
> difficult to handle every single one of these.  We still find problems
> with existing autocommands.

> Perhaps there is another way to do what you want?

My plugin unfortunately breaks default Vim functionality (<count>{dd,yy,cc
etc}) and as mentioned in my first mail, other plugins using the default Vim
operations may not work with mine (or vice versa).
I tried to fix that with VimL but without success. This patch was my last
resort to fix my problems rather than to add a nice to have feature. But I
fully understand your concerns.

Thank you anyways.

Best,
Mohammed


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »