After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 744286 - make indent operations repeatable with '.'
make indent operations repeatable with '.'
Status: RESOLVED OBSOLETE
Product: gnome-builder
Classification: Other
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-02-10 19:55 UTC by Ray Strode [halfline]
Modified: 2016-01-21 18:30 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
vim: make gb_source_vim_recording_end no-op when in replay (2.23 KB, patch)
2015-02-10 21:14 UTC, Ray Strode [halfline]
none Details | Review
vim: don't require non-zero captured events for replay (2.50 KB, patch)
2015-02-10 21:14 UTC, Ray Strode [halfline]
none Details | Review
vim: don't clear selection after indenting (2.65 KB, patch)
2015-02-10 21:14 UTC, Ray Strode [halfline]
none Details | Review
vim: support replaying '>' with '.' command (2.93 KB, patch)
2015-02-10 21:14 UTC, Ray Strode [halfline]
none Details | Review

Description Ray Strode [halfline] 2015-02-10 19:55:45 UTC
When I add a new public function to my code, I unsurpringly end up
with the function signature in two places (the declaration in the
header file, and the definition in the source file).  In order to
prevent retyping the whole thing I normally just type it in one place
and copy and paste it to the other. The problem, though, is they are
formatted differently.  In my source file the return type is put on
its own line, but in the header file, the return type is on the same
line as the symbol name. That means the arguments need to be at different
indention levels in each file.

In vim I deal with this by selecting the lines that need to be moved over
and then hitting '>' twice (to initiate an indent), followed by multiple
'.' operations (to repeat the indent).

This doesn't work in builder because '>' isn't recorded for replay.

I'm attaching a patchset that implements this feature, but it has
the somewhat undersirable side-effect of leaving the selection alive
after the user hits '>'.  A better patch would probably record the
selection at the same time the '>' is recorded. Consider this a first
draft, though I don't know if I'll pick it back up and do a second
draft right away.
Comment 1 Ray Strode [halfline] 2015-02-10 19:56:41 UTC
hmm, git-bz failed with 'Failed to attach patch to bug 744286, status=200'
Comment 2 Ray Strode [halfline] 2015-02-10 19:59:28 UTC
I'd rather not upload the patches manually, so until git-bz and new gnome bugzilla get fixed, i've just pushed them to a branch here:

https://git.gnome.org/browse/gnome-builder/log/?h=wip/halfline/repeatable-indent
Comment 3 Ray Strode [halfline] 2015-02-10 20:02:48 UTC
(In reply to Ray Strode [halfline] from comment #0)
> and then hitting '>' twice (to initiate an indent)

that should say hitting '>' once. I confused myself, when I wrote the above. I only hit '>' twice if I need to indent one single line, not multiple, already selected lines.
Comment 4 Alexandre Franke 2015-02-10 21:04:02 UTC
(In reply to Ray Strode [halfline] from comment #1)
> hmm, git-bz failed with 'Failed to attach patch to bug 744286, status=200'

http://cgit.collabora.com/git/user/pwith/git-bz.git/tree/git-bz?h=bugzilla-4.4 has an updated version that's compatible with the new bugzilla version.
Comment 5 Ray Strode [halfline] 2015-02-10 21:11:11 UTC
(In reply to Alexandre Franke from comment #4)
> (In reply to Ray Strode [halfline] from comment #1)
> > hmm, git-bz failed with 'Failed to attach patch to bug 744286, status=200'
> 
> http://cgit.collabora.com/git/user/pwith/git-bz.git/tree/git-bz?h=bugzilla-4.
> 4 has an updated version that's compatible with the new bugzilla version.

Thanks, I actually read about that earlier today and installed it. I had assumed the branch needed further updates to work, but come to think of it, I didn't install it on this laptop, just my workstation.
Comment 6 Ray Strode [halfline] 2015-02-10 21:14:14 UTC
Created attachment 296542 [details] [review]
vim: make gb_source_vim_recording_end no-op when in replay

When in the middle of a replace, gb_source_vim_recording_begin is
aa no-op, so gb_source_vim_recording_end should be, too.
Comment 7 Ray Strode [halfline] 2015-02-10 21:14:20 UTC
Created attachment 296543 [details] [review]
vim: don't require non-zero captured events for replay

Some commands that should be replayable don't have input
events associated with them, so requiring captured events
is wrong in those cases.
Comment 8 Ray Strode [halfline] 2015-02-10 21:14:26 UTC
Created attachment 296544 [details] [review]
vim: don't clear selection after indenting

Technically, clearing the selection is right, but
the selection isn't saved turn recording, and it's
needed to implement replay.

This commit keeps the selection around, to make way
for adding replay support to '<' and '>'
Comment 9 Ray Strode [halfline] 2015-02-10 21:14:30 UTC
Created attachment 296545 [details] [review]
vim: support replaying '>' with '.' command

One reasonable way to reindent code in vim is to select
the lines, hit '>' to indent one time and then hit '.'
several times until the desired indention level is reached.
This doesn't work in gnome-builder because the '>' command
isn't recorded.

This commit make sure '>' (and '<') get recorded, so they
can be replayed with '.'
Comment 10 Ray Strode [halfline] 2015-02-10 21:16:21 UTC
Review of attachment 296543 [details] [review]:

::: src/vim/gb-source-vim.c
@@ -4588,3 @@
   if (!GTK_SOURCE_IS_VIEW (vim->priv->text_view) ||
-      !vim->priv->recording_trigger ||
-      !vim->priv->captured_events->len)

So if we do end up saving the selection at record time, a better patch than this one would be (!vim->priv->captured_events->len && !vim->priv->captured_selection)  (or something like that)
Comment 11 Ray Strode [halfline] 2015-02-10 21:20:14 UTC
Review of attachment 296544 [details] [review]:

One issue with this patch is the old selection isn't exactly correct. Ideally, if keeping the selection around is right, and the selection was initiated with shift-V, then the selection should get expanded to include the newly added whitespace.

::: src/vim/gb-source-vim.c
@@ -4745,3 @@
     gb_source_vim_indent (vim);
-
-  gb_source_vim_clear_selection (vim);

One issue with this is the old selection isn't exactly correct. Ideally, if keeping the selection around is right, and the selection was initiated with shift-V, then the selection should get expanded to include the newly added whitespace.

Of course, I think a better solution is to clear the selection here but tuck it away from replay.
Comment 12 sébastien lafargue 2016-01-21 18:30:35 UTC
hi,

Most things have been fixed in master and those patches are obsolete now
( code has changed )

thanks anyway for your work. I close this bug report but
open a new one about non-working of repeat after indenting a selection