Re: [patch] Foldmethod for the quickfix window

2009-04-15 Fir de Conversatie Lech Lorens
On 14-Apr-2009 Tony Mechelynck antoine.mechely...@gmail.com wrote:
 Why do you think it's impossible to define quickfix folding in 
 vimscript? IMHO, a reasonable folding scheme would be to fold qf lines 
 together if they refer to errors/matches in the same source file. I 
 don't think that would be hard to implement in vimscript, with a 
 well-crafted expression folding method.

I bet it is possible to conceive a better way of folding for the
quickfix window. But before someone figures out what the perfect way is
I say: let's fix the current behaviour, which is wrong. While manual
folding method is not perfect, it has the advantage of not being wrong,
I believe.

 As for the command-line window, that's even simpler: I believe it 
 deserves no folding at all.

Agreed. My apologies for having neglected this case. The attached patch
fixes my omission.

 Also, moving everything to C code means harder to debug, harder to 
 change,

True - but this type of window is specially handled in the C code
anyway.

 and practically impossible to customize.

This is not the case, obviously.

 I'm in favour of having the maximum possible in vimscript, and only
 move to C code what cannot be done in vimscript, or only at an
 unacceptable performance loss.

In this case it would mean that Vim devoid of its configuration scripts
would default to behaviour that is incorrect. OK, this is a minor issue
which has probably never bothered anyone before, but still - why not fix
it?

-- 
Cheers,
Lech

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---

diff --git a/src/ex_getln.c b/src/ex_getln.c
index 3f1ea71..5386ee4 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -6072,6 +6072,7 @@ ex_window()
 (void)setfname(curbuf, (char_u *)[Command Line], NULL, TRUE);
 set_option_value((char_u *)bt, 0L, (char_u *)nofile, OPT_LOCAL);
 set_option_value((char_u *)swf, 0L, NULL, OPT_LOCAL);
+set_option_value((char_u *)fen, 0L, NULL, OPT_LOCAL);
 curbuf-b_p_ma = TRUE;
 # ifdef FEAT_RIGHTLEFT
 curwin-w_p_rl = cmdmsg_rl;
diff --git a/src/quickfix.c b/src/quickfix.c
index ee84160..ef0ae84 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2347,6 +2347,7 @@ ex_copen(eap)
   OPT_LOCAL);
set_option_value((char_u *)bh, 0L, (char_u *)wipe, OPT_LOCAL);
set_option_value((char_u *)diff, 0L, NULL, OPT_LOCAL);
+   set_option_value((char_u *)fdm, 0L, manual, OPT_LOCAL);
}
 
/* Only set the height when still in the same tab page and there is no


Re: [patch] Foldmethod for the quickfix window

2009-04-14 Fir de Conversatie Bram Moolenaar


lech Lorens wrote:

 The attached patch changes the default 'foldmethod' for the quickfix
 window to manual. The current behaviour is that the quickfix window
 inherits the values of 'foldmethod' and 'foldmarker' from the global
 options, which sometimes causes the contents of the quickfix window to
 be folded upon opening the window with :copen. Although it can be easily
 fixed in Vim script, I believe the 'foldmethod' should be explicitly set
 for quickfix window by Vim.
 
 Another way of fixing the problem of folded contents would be resetting
 the value of 'foldenable', but I sometimes find it valuable to be able
 to fold some lines of the quickfix window.

Looks like a good idea.

-- 
GUARD #2:  It could be carried by an African swallow!
GUARD #1:  Oh, yeah, an African swallow maybe, but not a European swallow,
   that's my point.
GUARD #2:  Oh, yeah, I agree with that...
  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



[patch] Foldmethod for the quickfix window

2009-04-13 Fir de Conversatie Lech Lorens
The attached patch changes the default 'foldmethod' for the quickfix
window to manual. The current behaviour is that the quickfix window
inherits the values of 'foldmethod' and 'foldmarker' from the global
options, which sometimes causes the contents of the quickfix window to
be folded upon opening the window with :copen. Although it can be easily
fixed in Vim script, I believe the 'foldmethod' should be explicitly set
for quickfix window by Vim.

Another way of fixing the problem of folded contents would be resetting
the value of 'foldenable', but I sometimes find it valuable to be able
to fold some lines of the quickfix window.

-- 
Cheers,
Lech

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---

diff --git a/src/quickfix.c b/src/quickfix.c
index ee84160..454ec03 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -2347,6 +2347,7 @@ ex_copen(eap)
    OPT_LOCAL);
 	set_option_value((char_u *)bh, 0L, (char_u *)wipe, OPT_LOCAL);
 	set_option_value((char_u *)diff, 0L, NULL, OPT_LOCAL);
+	set_option_value((char_u *)foldmethod, 0L, manual, OPT_LOCAL);
 	}
 
 	/* Only set the height when still in the same tab page and there is no


Re: [patch] Foldmethod for the quickfix window

2009-04-13 Fir de Conversatie Gary Johnson

On 2009-04-14, Lech Lorens wrote:
 The attached patch changes the default 'foldmethod' for the quickfix
 window to manual. The current behaviour is that the quickfix window
 inherits the values of 'foldmethod' and 'foldmarker' from the global
 options, which sometimes causes the contents of the quickfix window to
 be folded upon opening the window with :copen. Although it can be easily
 fixed in Vim script, I believe the 'foldmethod' should be explicitly set
 for quickfix window by Vim.
 
 Another way of fixing the problem of folded contents would be resetting
 the value of 'foldenable', but I sometimes find it valuable to be able
 to fold some lines of the quickfix window.

I'm a little concerned about applying such fine tuning of individual
window behavior to the source code.  If there is a general rule in
vim for the option values that windows inherit when they are
created, I think we should use that general rule unless there is a
compelling reason to do otherwise.  As you say, this could also be
fixed with a ftplugin/qf.vim script, which would be a more
consistent method of applying such filetype-specific adjustments.

Regards,
Gary



--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: [patch] Foldmethod for the quickfix window

2009-04-13 Fir de Conversatie Matt Wozniski

On 4/13/09, Gary Johnson wrote:

  On 2009-04-14, Lech Lorens wrote:
   The attached patch changes the default 'foldmethod' for the quickfix
   window to manual.


 I'm a little concerned about applying such fine tuning of individual
  window behavior to the source code.  If there is a general rule in
  vim for the option values that windows inherit when they are
  created, I think we should use that general rule unless there is a
  compelling reason to do otherwise.  As you say, this could also be
  fixed with a ftplugin/qf.vim script, which would be a more
  consistent method of applying such filetype-specific adjustments.

Well... I'm not sure I agree.  The quickfix, location list, and
command-line windows are already very distinct from any other windows
you can create.  They behave differently, they have special commands
that open and close them, they have key bindings that only apply in
that one type of window.  It seems reasonable that the code for these
types of windows should be as centralized as possible - doing it all
in vimscript would be a noble goal, but is certainly beyond the
abilities that are currently available in vimscript, and barring that,
I think that all of their special-case behavior should be held in the
source code.

~Matt

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: [patch] Foldmethod for the quickfix window

2009-04-13 Fir de Conversatie Tony Mechelynck

On 14/04/09 00:50, Matt Wozniski wrote:

 On 4/13/09, Gary Johnson wrote:

   On 2009-04-14, Lech Lorens wrote:
 The attached patch changes the default 'foldmethod' for the quickfix
 window to manual.


 I'm a little concerned about applying such fine tuning of individual
   window behavior to the source code.  If there is a general rule in
   vim for the option values that windows inherit when they are
   created, I think we should use that general rule unless there is a
   compelling reason to do otherwise.  As you say, this could also be
   fixed with a ftplugin/qf.vim script, which would be a more
   consistent method of applying such filetype-specific adjustments.

 Well... I'm not sure I agree.  The quickfix, location list, and
 command-line windows are already very distinct from any other windows
 you can create.  They behave differently, they have special commands
 that open and close them, they have key bindings that only apply in
 that one type of window.  It seems reasonable that the code for these
 types of windows should be as centralized as possible - doing it all
 in vimscript would be a noble goal, but is certainly beyond the
 abilities that are currently available in vimscript, and barring that,
 I think that all of their special-case behavior should be held in the
 source code.

 ~Matt

Why do you think it's impossible to define quickfix folding in 
vimscript? IMHO, a reasonable folding scheme would be to fold qf lines 
together if they refer to errors/matches in the same source file. I 
don't think that would be hard to implement in vimscript, with a 
well-crafted expression folding method.

As for the command-line window, that's even simpler: I believe it 
deserves no folding at all.

Also, moving everything to C code means harder to debug, harder to 
change, and practically impossible to customize. I'm in favour of having 
the maximum possible in vimscript, and only move to C code what cannot 
be done in vimscript, or only at an unacceptable performance loss.


Best regards,
Tony.
-- 
I'd love to go out with you, but I'm doing door-to-door collecting for
static cling.

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: [patch] Foldmethod for the quickfix window

2009-04-13 Fir de Conversatie Gary Johnson

On 2009-04-13, Matt Wozniski wrote:
 On 4/13/09, Gary Johnson wrote:
 
   On 2009-04-14, Lech Lorens wrote:
The attached patch changes the default 'foldmethod' for the quickfix
window to manual.
 
 
  I'm a little concerned about applying such fine tuning of individual
   window behavior to the source code.  If there is a general rule in
   vim for the option values that windows inherit when they are
   created, I think we should use that general rule unless there is a
   compelling reason to do otherwise.  As you say, this could also be
   fixed with a ftplugin/qf.vim script, which would be a more
   consistent method of applying such filetype-specific adjustments.
 
 Well... I'm not sure I agree.  The quickfix, location list, and
 command-line windows are already very distinct from any other windows
 you can create.  They behave differently, they have special commands
 that open and close them, they have key bindings that only apply in
 that one type of window.  It seems reasonable that the code for these
 types of windows should be as centralized as possible - doing it all
 in vimscript would be a noble goal, but is certainly beyond the
 abilities that are currently available in vimscript, and barring that,
 I think that all of their special-case behavior should be held in the
 source code.

Good argument, especially your point about centralization.  The
patch seems OK then.

Regards,
Gary



--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---



Re: [patch] Foldmethod for the quickfix window

2009-04-13 Fir de Conversatie Matt Wozniski

On 4/13/09, Tony Mechelynck wrote:

On 14/04/09 00:50, Matt Wozniski wrote:

 On 4/13/09, Gary Johnson wrote:

 On 2009-04-14, Lech Lorens wrote:
  The attached patch changes the default 'foldmethod' for the quickfix
  window to manual.


 I'm a little concerned about applying such fine tuning of individual
   window behavior to the source code.  If there is a general rule in
   vim for the option values that windows inherit when they are
   created, I think we should use that general rule unless there is a
   compelling reason to do otherwise.

 Well... I'm not sure I agree.  The quickfix, location list, and
 command-line windows are already very distinct from any other windows
 you can create.  They behave differently, they have special commands
 that open and close them, they have key bindings that only apply in
 that one type of window.  It seems reasonable that the code for these
 types of windows should be as centralized as possible - doing it all
 in vimscript would be a noble goal, but is certainly beyond the
 abilities that are currently available in vimscript, and barring that,
 I think that all of their special-case behavior should be held in the
 source code.

 Why do you think it's impossible to define quickfix folding in
 vimscript? IMHO, a reasonable folding scheme would be to fold qf lines
 together if they refer to errors/matches in the same source file. I
 don't think that would be hard to implement in vimscript, with a
 well-crafted expression folding method.

No, you misinterpreted what I said.  It's definitely possible to define
the *folding* behavior for quickfix windows in vimscript, but it's not
possible to create a window that behaves like a quickfix window in
vimscript without using the quickfix commands.  For instance, there's no
way to emulate what :make does in vimscript without duplicating all of
the 'errorformat' logic that's currently in C.

 As for the command-line window, that's even simpler: I believe it
 deserves no folding at all.

Again, I wasn't talking specifically about folding, I was talking about
all the behavior for a command-line window.  You can't use vimscript to
create a window that the cursor can't leave, other than by going through
the special-casing in C for a command-line window.

 Also, moving everything to C code means harder to debug,

Yep

 harder to change,

Yep

 and practically impossible to customize.

Well... no.  This would only change the default foldmethod, an autocmd
could still change the behavior from the default to match the user's
preferences.  And, a default of no folding with possible user-supplied
vimscript to make it possible to fold related lines together is probably
better than defaulting to folding related things.

 I'm in favour of having the maximum possible in vimscript, and only
 move to C code what cannot be done in vimscript, or only at an
 unacceptable performance loss.

I'm in favor of keeping all of the logic for the special window types in
one place.  I agree that it would be better if that place could be
vimscript, but it can't.

~Matt

--~--~-~--~~~---~--~~
You received this message from the vim_dev maillist.
For more information, visit http://www.vim.org/maillist.php
-~--~~~~--~~--~--~---