Re: [RFC/patch] Expose information about character searches (f, F, t, T) in VimL

2015-07-31 Thread Roland Eggner
On 2015-07-30 Thursday at 18:45 -0400 James McCoy wrote:
> On Thu, Jul 30, 2015 at 10:28:16PM +0200, Roland Eggner wrote:
> > On 2015-07-29 Wednesday at 21:51 -0400 James McCoy wrote:
> > > +getcharsearch()  
> > > *getcharsearch()*
> > > + Return the current character search information as a {dict}
> > > + with the following entries:
> > > +
> > > + charcharacter previously used for a character
> > > + search (|t|, |f|, |T|, or |F|); empty string
> > > + if no character search has been performed
> > > + forward direction of character search; 1 for forward,
> > > + 0 for backward
> > > + until   type of character search; 1 for a |t| or |T|
> > > + character search, 0 for an |f| or |F|
> > > + character search
> > 
> > Instead of “forward” and “until” entries having an entry “command” with the 
> > four 
> > legal values “f” “F” “t” “T” would be easier to memorize.
> > 
> > What do you think?
> 
> Interesting idea, but the current functionality allows one to easily control a
> single aspect of the search without needing to know the rest.
> 
> Currently, to set/reverse the direction I can just
> 
> :call setcharsearch({'forward': 1})
> or
> 
> :call setcharsearch({'forward': !getcharsearch().forward})
> 
> respecitvely without needing to know what type of character search is in
> effect.  Using your proposal turns the above into something like
> 
> :call setcharsearch({'command': tolower(getcharsearch().command)})
> 
> and
> 
> :call setcharsearch({'command': tr(getcharsearch().command, 'tfTF', 
> 'TFtf')})
> 
> That seems more unwieldy to me.

Yes in this usage examples I see the advantage of your variant.

“f” or “t“  → “getcharsearch().forward == 1” having the effect of “true“ in 
expressions matches intuition, but “until” seems to me rather difficult to 
memorize.

Could you imagine {dict} entry name “exlusive” instead of “until”, with the 
same 
values?  Or “inclusive” with the values swapped?

Thank you.



-- 
Best regards,
Roland Eggner

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pgpgpYWEJ9aLg.pgp
Description: PGP signature


Re: Issue 389 in vim: 'linebreak' breaks c% if the last visual selection was block

2015-07-31 Thread Axel Bender
Another sample would be the attached file with (failure on "s"):

fbds

Version here: 7.4.803 on Windows 7 (MinGW-64).

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
aa bb cc
aa bb cc


Re: Patch to add the :cdo and :ldo commands

2015-07-31 Thread Drew Neil
I can see myself finding uses for both :cdo and :cfdo.

On Thu, Jul 30, 2015 at 8:08 PM, Ingo Karkat  wrote:

> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> On 30-Jul-2015 08:21, Christian Brabandt wrote:
> > Am 2015-07-29 22:34, schrieb Yegappan Lakshmanan:
> >> I haven't see any replies so far. I am not sure whether we are
> >> agreeing to add both the commands or only the cfdo/lfdo commands?
> >> Do you guys think that only the cfdo/lfdo commands will be
> >> useful?
> >
> > I think, depending on the task, both options could be useful.
>
> I agree; my ArgsAndMore plugin
> (http://www.vim.org/scripts/script.php?script_id=4152) also provides
> both :CDoEntry and :CDoFile commands.
>
> - -- regards, ingo
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v2.0.17 (MingW32)
>
> iQEcBAEBAgAGBQJVunY+AAoJEA7ziXlAzQ/vL6kIAJRbiSHCSL4JDT07ia8DRPwS
> gaQGk7/tmngUs8vpwg8Qokx2KthS75eep69dS5KuzL2/f9c+Mdcs/sYbe7QJYE4Y
> r3uZvYhxnnvSWyle6+5OCSurUrc4YqG6qozT4EaBTXS9HvuUS4wVO1COTfirUwsG
> +IUYfg6X7esgBegTRyV1S2zliUv6y03de3r44L1zfUgU7/96/ODFFanGhb62Ehwc
> ZCaSD1X3ElVDOiFN4ZI3g/I7C/WUH1ndp8dB6EkFEM4+VyJVJdwT6W3/scbrDv3P
> eEnF5nJIQqgyN4JULRmFEaxYA8V2P0bzsaUvsxGP7g0nPlrtByxKEkxiWtCVa3E=
> =jwPs
> -END PGP SIGNATURE-
>
> --
> --
> You received this message from the "vim_dev" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "vim_dev" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/vim_dev/dfyt-G6SMec/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> vim_dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue 389 in vim: 'linebreak' breaks c% if the last visual selection was block

2015-07-31 Thread Arnaud Decara
On Friday, 31 July 2015 11:20:21 UTC+2, Axel Bender  wrote:
> Another sample would be the attached file with (failure on "s"):
> 
> fbds
> 
> Version here: 7.4.803 on Windows 7 (MinGW-64).

Hi all,

Please find attached a fix.
(Both issues with the change operator and 's' should 
be fixed; undiscovered similar issues that might have
occured should be fixed too.)

Best,
Arnaud

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -9586,7 +9586,7 @@
 {
 colnr_T	start, end;
 
-if (VIsual_mode != Ctrl_V)
+if (!VIsual_active || VIsual_mode != Ctrl_V)
 	return;
 
 oap->block_mode = TRUE;


Re: Patch 7.4.782

2015-07-31 Thread Christian Brabandt
On Mi, 29 Jul 2015, Christian Brabandt wrote:

Updated patch, that also fixes the redraw issue (mentioned in a 
different thread).

Best,
Christian
-- 
Die Freigebigkeit erwirbt einem jeden Gunst, vorzüglich wenn sie 
von Demut begleitet wird.
-- Goethe, Maximen und Reflektionen, Nr. 230

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -4256,11 +4256,7 @@ nv_addsub(cap)
 else
 	clearopbeep(cap->oap);
 if (visual)
-{
-	VIsual_active = FALSE;
-	redo_VIsual_busy = FALSE;
-	redraw_later(INVERTED);
-}
+	end_visual_mode();
 }
 
 /*
diff --git a/src/ops.c b/src/ops.c
--- a/src/ops.c
+++ b/src/ops.c
@@ -5492,6 +5492,7 @@ do_addsub(command, Prenum1, g_cmd)
 
 for (i = lnum; i <= lnume; i++)
 {
+	colnr_T stop = 0;
 	t = curwin->w_cursor;
 	curwin->w_cursor.lnum = i;
 	ptr = ml_get_curline();
@@ -5501,30 +5502,27 @@ do_addsub(command, Prenum1, g_cmd)
 	continue;
 	if (visual)
 	{
-	if (doalp) /* search for ascii chars */
+	if (VIsual_mode == 'v'
+		&& i == lnume)
+		stop = curwin->w_cursor.col;
+	else if (VIsual_mode == Ctrl_V
+		&& curbuf->b_visual.vi_curswant != MAXCOL)
+		stop = curwin->w_cursor.col;
+
+	while (ptr[col] != NUL
+		&& !vim_isdigit(ptr[col])
+		&& !(doalp && ASCII_ISALPHA(ptr[col])))
 	{
-		while (!ASCII_ISALPHA(ptr[col]) && ptr[col])
-		col++;
+		if (col > 0  && col == stop)
+		break;
+		++col;
 	}
-	/* skip to first digit, but allow for leading '-' */
-	else if (dohex)
+
+	if (col > startcol && ptr[col - 1] == '-')
 	{
-		while (!(vim_isxdigit(ptr[col]) || (ptr[col] == '-'
-&& vim_isxdigit(ptr[col+1]))) && ptr[col])
-		col++;
+		negative = TRUE;
+		was_positive = FALSE;
 	}
-	else /* decimal */
-	{
-		while (!(vim_isdigit(ptr[col]) || (ptr[col] == '-'
- && vim_isdigit(ptr[col+1]))) && ptr[col])
-		col++;
-	}
-	}
-	if (visual && ptr[col] == '-')
-	{
-	negative = TRUE;
-	was_positive = FALSE;
-	col++;
 	}
 	/*
 	 * If a number was found, and saving for undo works, replace the number.
diff --git a/src/testdir/test_increment.in b/src/testdir/test_increment.in
--- a/src/testdir/test_increment.in
+++ b/src/testdir/test_increment.in
@@ -260,6 +260,16 @@ Text:
   9
   12
   
+19) increment on number with nrformat including alpha
+Text:
+ 1
+ 1a
+
+ Expected:
+ 1) j$ 
+ 2
+ 1b
+   
 
 
 STARTTEST
@@ -369,6 +379,13 @@ 4kj$2j.
 :/^E18=/+put a
 V3kg..
 
+:" Test 19
+:set nrformats+=alpha
+:/^S19=/+,/^E19=/-y a
+:/^E19=/+put a
+k$
+:set nrformats&vim
+
 :" Save the report
 :/^# Test 1/,$w! test.out
 :qa!
@@ -547,6 +564,13 @@ E18
 
 
 
+# Test 19
+S19
+1
+1a
+E19
+
+
 
 
 ENDTEST
diff --git a/src/testdir/test_increment.ok b/src/testdir/test_increment.ok
--- a/src/testdir/test_increment.ok
+++ b/src/testdir/test_increment.ok
@@ -261,6 +261,15 @@ 9
 12
 
 
+# Test 19
+S19
+1
+1a
+E19
+
+2
+2a
+
 
 
 ENDTEST


Re: Issue 389 in vim: 'linebreak' breaks c% if the last visual selection was block

2015-07-31 Thread Christian Brabandt
Hi Arnaud!

On Fr, 31 Jul 2015, Arnaud Decara wrote:

> Please find attached a fix.
> (Both issues with the change operator and 's' should 
> be fixed; undiscovered similar issues that might have
> occured should be fixed too.)

I believe that breaks test_listlbr.out

Here is a slightly different approach, including a test. The idea is, to 
only recalculate the oap->start_vcol and oap->end_vcol columns, if the 
cursor is on a wrapped line, else that shouldn't be necessary. However, 
I am not completely sure, this is the best solution.

Best,
Christian
-- 
Der Mensch, der sich vielen Glückes und seiner Schwäche bewußt ist,
wird abergläubisch, flüchtet zum Gebet.
-- Georg Christoph Lichtenberg
(Vermischte Schriften - Beobachtung über den Menschen)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -9582,10 +9582,11 @@ get_op_vcol(oap, redo_VIsual_vcol, initi
 {
 colnr_T	start, end;
 
-if (VIsual_mode != Ctrl_V)
+if (VIsual_mode != Ctrl_V ||
+	(!initial && oap->end.col < W_WIDTH(curwin)))
 	return;
 
-oap->block_mode = TRUE;
+oap->block_mode = VIsual_active;
 
 #ifdef FEAT_MBYTE
 /* prevent from moving onto a trail byte */
diff --git a/src/testdir/test_listlbr.in b/src/testdir/test_listlbr.in
--- a/src/testdir/test_listlbr.in
+++ b/src/testdir/test_listlbr.in
@@ -80,6 +80,13 @@ Go
 aaa
 aaa
 a2k2j~e.
+:let g:test ="Test 10: using normal commands after block-visual"
+:$put =g:test
+:set linebreak
+Go
+abcd{ef
+ghijklm
+no}pqrs2k0f{c%
 :%w! test.out
 :qa!
 ENDTEST
diff --git a/src/testdir/test_listlbr.ok b/src/testdir/test_listlbr.ok
--- a/src/testdir/test_listlbr.ok
+++ b/src/testdir/test_listlbr.ok
@@ -46,3 +46,6 @@ Test 9: using redo after block visual mo
 AaA
 AaA
 A
+Test 10: using normal commands after block-visual
+
+abcdpqrs


Re: E749 on switching to buffer

2015-07-31 Thread h_east
Hi itchyny,

2015-7-26(Sun) 20:46:05 UTC+9 itchyny:
> Vim warns E749 on switching to a buffer which used to be checked diff.
> 
> How to reproduce.
> 1. vim -u NONE -N
> 2. :e test | diffthis
> 3. :vnew test2 | diffthis
> 4. :e test3
> 5. :buffer #
> 
> Error message
> E749: empty buffer
> 
> What I expect
> Vim opens the test2 with no error message.
...snip...
> Hope it fixed. Thanks.


I can reproduced.

Places that are output E749 is four. In this case it is output in the following 
locations.

fileio.c (in function buf_write())
 3167 if (buf->b_ml.ml_mfp == NULL)
 3168 {
 3169 /* This can happen during startup when there is a stray "w" in the
 3170  * vimrc file. */
 3171 EMSG(_(e_emptybuf));
 3172 return FAIL;
 3173 }

And It's backtrace at this time. 
(gdb) bt
#0  buf_write (buf=0x1a961b0, fname=0x1a9d3c0 "/tmp/vCVByI3/4", sfname=0x0,
start=1, end=1, eap=0x0, append=0, forceit=0, reset_changed=0, filtering=1)
at fileio.c:3171
#1  0x00414743 in diff_write (buf=0x1a961b0,
fname=0x1a9d3c0 "/tmp/vCVByI3/4") at diff.c:645
#2  0x00414b21 in ex_diffupdate (eap=0x0) at diff.c:809
#3  0x004160e3 in diff_check (wp=0x1a921b0, lnum=1) at diff.c:1520
#4  0x0041463b in diff_redraw (dofold=1) at diff.c:618
#5  0x00413868 in diff_buf_add (buf=0x1a961b0) at diff.c:137
#6  0x00405d42 in enter_buffer (buf=0x1a961b0) at buffer.c:1542
#7  0x00405c7d in set_curbuf (buf=0x1a961b0, action=0) at buffer.c:1507
#8  0x00405a16 in do_buffer (action=0, start=1, dir=1, count=2,
forceit=0) at buffer.c:1403
#9  0x00404bdb in goto_buffer (eap=0x7ffed7d77d30, start=1, dir=1,
count=2) at buffer.c:775
#10 0x0046c2fa in ex_buffer (eap=0x7ffed7d77d30) at ex_docmd.c:5494
#11 0x0046795c in do_one_cmd (cmdlinep=0x7ffed7d783c8, sourcing=0,
cstack=0x7ffed7d77f20, fgetline=0x47ce87 , cookie=0x0)
at ex_docmd.c:2941
#12 0x004647b7 in do_cmdline (cmdline=0x0,
fgetline=0x47ce87 , cookie=0x0, flags=0) at ex_docmd.c:1133
#13 0x004ec941 in nv_colon (cap=0x7ffed7d784f0) at normal.c:5405
#14 0x004e5d8c in normal_cmd (oap=0x7ffed7d785d0, toplevel=1)


The fileio.c:3169 comments do not know well to me.. ( ゚д゚)
However, I have taken measures so as not to come here when the 'diff'.

Please check attached patch.

--
Best regards,
Hirohito Higashi (a.k.a h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff --git a/src/diff.c b/src/diff.c
--- a/src/diff.c
+++ b/src/diff.c
@@ -804,7 +804,7 @@
 for (idx_new = idx_orig + 1; idx_new < DB_COUNT; ++idx_new)
 {
 	buf = curtab->tp_diffbuf[idx_new];
-	if (buf == NULL)
+	if (buf == NULL || buf->b_ml.ml_mfp == NULL)
 	continue;
 	if (diff_write(buf, tmp_new) == FAIL)
 	continue;


Re: Patch 7.4.782

2015-07-31 Thread h_east
Hi,

2015-7-31(Fri) 22:57:44 UTC+9 Christian Brabandt:
> On Mi, 29 Jul 2015, Christian Brabandt wrote:
> 
> Updated patch, that also fixes the redraw issue (mentioned in a 
> different thread).

It maybe this thread.
https://groups.google.com/d/msg/vim_dev/C4pX7ouCqAk/0qB-UbBnAAAJ

Your patch is seems good for me.

--
Best regards,
Hirohito Higashi (a.k.a h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue 389 in vim: 'linebreak' breaks c% if the last visual selection was block

2015-07-31 Thread Arnaud Decara
Hello Christian!

On Friday, 31 July 2015 16:03:21 UTC+2, Christian Brabandt  wrote:
> Hi Arnaud!
> 
> On Fr, 31 Jul 2015, Arnaud Decara wrote:
> 
> > Please find attached a fix.
> > (Both issues with the change operator and 's' should 
> > be fixed; undiscovered similar issues that might have
> > occured should be fixed too.)
> 
> I believe that breaks test_listlbr.out
> 
> Here is a slightly different approach, including a test. The idea is, to 
> only recalculate the oap->start_vcol and oap->end_vcol columns, if the 
> cursor is on a wrapped line, else that shouldn't be necessary. However, 
> I am not completely sure, this is the best solution.
> 
> Best,
> Christian
> -- 
> Der Mensch, der sich vielen Glückes und seiner Schwäche bewußt ist,
> wird abergläubisch, flüchtet zum Gebet.
>   -- Georg Christoph Lichtenberg
> (Vermischte Schriften - Beobachtung über den Menschen)

Maybe I'm not using correctly the tests but test_librl does not seem to be
broken here. 
(When I run all the tests via the Makefile, i get "Test results : ALL DONE",
and when I remove test_listlbr.out and rerun the test separately I don't get 
any error)
Am I doing something wrong?

(But your idea might be better, I'll look at it)

Arnaud

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue 389 in vim: 'linebreak' breaks c% if the last visual selection was block

2015-07-31 Thread Christian Brabandt
Hi Arnaud!

On Fr, 31 Jul 2015, Arnaud Decara wrote:

> Hello Christian!
> 
> On Friday, 31 July 2015 16:03:21 UTC+2, Christian Brabandt  wrote:
> > Hi Arnaud!
> > 
> > On Fr, 31 Jul 2015, Arnaud Decara wrote:
> > 
> > > Please find attached a fix.
> > > (Both issues with the change operator and 's' should 
> > > be fixed; undiscovered similar issues that might have
> > > occured should be fixed too.)
> > 
> > I believe that breaks test_listlbr.out
> > 
> > Here is a slightly different approach, including a test. The idea is, to 
> > only recalculate the oap->start_vcol and oap->end_vcol columns, if the 
> > cursor is on a wrapped line, else that shouldn't be necessary. However, 
> > I am not completely sure, this is the best solution.
> > 
> Maybe I'm not using correctly the tests but test_librl does not seem
> to be broken here. (When I run all the tests via the Makefile, i get
> "Test results : ALL DONE", and when I remove test_listlbr.out and
> rerun the test separately I don't get any error)
> Am I doing something wrong?

That should be okay. I am just wondering, because for me that test 
failed (which was my first idea when I saw that problem).

Perhaps this was a problem just for me, so in that case your patch would 
be preferable for its simplicity. The test should be included 
nevertheless ;)

Best,
Christian 
-- 
Mathematiker-Glücksrad: "Ich kaufe ein Epsilon."

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Patch] Visual mode movements for python.vim

2015-07-31 Thread Carlos Pita
Hi all,

I've patched the python.vim ftplugin in order it to support [[,]],]m,[m 
movements in visual mode also. The patch simplifies the logic of the previous 
implementation by using the search() function instead of user-oriented commands.

There are a couple of minor improvements also:

* Explicitly check executable('pydoc') == 1 (to avoid the -1 trap).
* Expand a couple of tabs to spaces to normalize indentation a bit.

Hope you find it useful. I tried to contact the maintainer before but to no 
avail so I'm submitting this directly to this list. 

Cheers
--
Carlos

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
>From 66783b5ca11f2c4ec6a76cf666dadd48d475b58b Mon Sep 17 00:00:00 2001
From: memeplex 
Date: Fri, 31 Jul 2015 12:31:37 -0300
Subject: [PATCH] python plugin: movements in visual mode.

---
 runtime/ftplugin/python.vim | 46 +++--
 1 file changed, 24 insertions(+), 22 deletions(-)

diff --git a/runtime/ftplugin/python.vim b/runtime/ftplugin/python.vim
index 75c7e87..3c0eb2e 100644
--- a/runtime/ftplugin/python.vim
+++ b/runtime/ftplugin/python.vim
@@ -1,8 +1,8 @@
 " Vim filetype plugin file
 " Language:	python
 " Maintainer:	Johannes Zellner 
-" Last Change:	2014 Feb 09
 " Last Change By Johannes: Wed, 21 Apr 2004 13:13:08 CEST
+" Last Change:	Fri Jul 31 12:29:55 ART 2015 (carlosjosep...@gmail.com)
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
@@ -21,28 +21,34 @@ setlocal omnifunc=pythoncomplete#Complete
 
 set wildignore+=*.pyc
 
-nnoremap   ]] :call Python_jump('/^\(class\\|def\)')
-nnoremap   [[ :call Python_jump('?^\(class\\|def\)')
-nnoremap   ]m :call Python_jump('/^\s*\(class\\|def\)')
-nnoremap   [m :call Python_jump('?^\s*\(class\\|def\)')
+nnoremap   ]] :call Python_jump(0, 0, '')
+nnoremap   [[ :call Python_jump(1, 0, '')
+nnoremap   ]m :call Python_jump(0, 0, '\s*')
+nnoremap   [m :call Python_jump(1, 0, '\s*')
+
+vnoremap   ]] :call Python_jump(0, 1, '')
+vnoremap   [[ :call Python_jump(1, 1, '')
+vnoremap   ]m :call Python_jump(0, 1, '\s*')
+vnoremap   [m :call Python_jump(1, 1, '\s*')
 
 if !exists('*Python_jump')
-  fun! Python_jump(motion) range
-  let cnt = v:count1
-  let save = @/" save last search pattern
-  mark '
-  while cnt > 0
-	  silent! exe a:motion
-	  let cnt = cnt - 1
-  endwhile
-  call histdel('/', -1)
-  let @/ = save" restore last search pattern
-  endfun
+fun! Python_jump(back, visual, ws)
+let n = v:count1
+let pattern = '^' . a:ws . '\(class\|def\)'
+if a:visual
+normal gv
+let pattern = (a:back ? '' : '\n') . pattern
+endif
+mark '
+for _ in range(1, n)
+call search(pattern, 'W' . (a:back ? 'b' : ''))
+endfor
+endfun
 endif
 
 if has("browsefilter") && !exists("b:browsefilter")
 let b:browsefilter = "Python Files (*.py)\t*.py\n" .
-		   \ "All Files (*.*)\t*.*\n"
+   \ "All Files (*.*)\t*.*\n"
 endif
 
 " As suggested by PEP8.
@@ -50,11 +56,7 @@ setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
 
 " First time: try finding "pydoc".
 if !exists('g:pydoc_executable')
-if executable('pydoc')
-let g:pydoc_executable = 1
-else
-let g:pydoc_executable = 0
-endif
+let g:pydoc_executable = executable('pydoc') == 1
 endif
 " If "pydoc" was found use it for keywordprg.
 if g:pydoc_executable
-- 
2.4.5



[Patch] Python syntax: avoid highlighting attributes as builtins

2015-07-31 Thread Carlos Pita
Hi all,

the syntax rules for python incorrectly consider, say, both `filter` and 
`obj.filter` as instances of the builtin `filter`. I've added a rule to 
explicitly set the group of attributes (defined as an identifier following a 
dot) to none. Maybe it's better to create a new group for attributes, I'm not 
sure. I will update the patch with any improving suggestion.

Cheers
--
Carlos

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
>From cc25cc6ee83f1c0e1ca9349bb2cf1f9858bd28bb Mon Sep 17 00:00:00 2001
From: memeplex 
Date: Fri, 31 Jul 2015 13:40:51 -0300
Subject: [PATCH] Python syntax: don't highlight attrs as builtins.

---
 runtime/syntax/python.vim | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/runtime/syntax/python.vim b/runtime/syntax/python.vim
index f99153f..d944e76 100644
--- a/runtime/syntax/python.vim
+++ b/runtime/syntax/python.vim
@@ -197,6 +197,8 @@ if !exists("python_no_builtin_highlight")
   syn keyword pythonBuiltin	ascii bytes exec
   " non-essential built-in functions; Python 2 only
   syn keyword pythonBuiltin	apply buffer coerce intern
+  " Avoid highlighting attributes as builtins
+  syn match none /\.\i\+/hs=s+1
 endif
 
 " From the 'Python Library Reference' class hierarchy at the bottom.
-- 
2.4.5



Re: [Patch] Visual mode movements for python.vim

2015-07-31 Thread Carlos Pita
PS: maybe worth noticing, the new implementation also fixes a
potential bug related to the approach to get the v:count argument the
previous implementation adopts: it defines a range function, but then
the argument must be valid as a range not just as a count. In practice
this shouldn't be a problem, but it's not entirely correct. Moreover,
it is a problem for implementing the visual mode map. All in all I
feel the new approach is cleaner.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [PATCH] improve Objective-C filetype detection

2015-07-31 Thread Bram Moolenaar

Kazuki Sakamoto wrote:

> I've created a patch to improve Objective-C filetype detection in ".m"
> and ".mm" file. Could you check the patch?
> 
> Modern Objective-C code uses "@import" instead of "#include" or "#import".
> http://clang.llvm.org/docs/Modules.html#objective-c-import-declaration

Thanks!


-- 
GALAHAD: No. Look, I can tackle this lot single-handed!
GIRLS:   Yes, yes, let him Tackle us single-handed!
 "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 received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Patch] Visual mode movements for python.vim

2015-07-31 Thread Carlos Pita
Here is an updated patch with a couple of improvements:

1. Reach BOF/EOF when there are no more class/method text objects remaining.

2. In visual mode select the object up to its beginning/end without matching 
the first line/char of the next object (I think it's not difficult to implement 
the omap version from here, but I don't have the time to do it right now).

Cheers
--
Carlos

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
>From 48aa0fa45b64e87b56d4442c2e1e3257d068ec02 Mon Sep 17 00:00:00 2001
From: memeplex 
Date: Fri, 31 Jul 2015 12:31:37 -0300
Subject: [PATCH] Python plugin: movements in visual mode.

---
 runtime/ftplugin/python.vim | 47 -
 1 file changed, 25 insertions(+), 22 deletions(-)

diff --git a/runtime/ftplugin/python.vim b/runtime/ftplugin/python.vim
index 75c7e87..8563749 100644
--- a/runtime/ftplugin/python.vim
+++ b/runtime/ftplugin/python.vim
@@ -1,8 +1,8 @@
 " Vim filetype plugin file
 " Language:	python
 " Maintainer:	Johannes Zellner 
-" Last Change:	2014 Feb 09
 " Last Change By Johannes: Wed, 21 Apr 2004 13:13:08 CEST
+" Last Change:	Fri Jul 31 12:29:55 ART 2015 (carlosjosep...@gmail.com)
 
 if exists("b:did_ftplugin") | finish | endif
 let b:did_ftplugin = 1
@@ -21,28 +21,35 @@ setlocal omnifunc=pythoncomplete#Complete
 
 set wildignore+=*.pyc
 
-nnoremap   ]] :call Python_jump('/^\(class\\|def\)')
-nnoremap   [[ :call Python_jump('?^\(class\\|def\)')
-nnoremap   ]m :call Python_jump('/^\s*\(class\\|def\)')
-nnoremap   [m :call Python_jump('?^\s*\(class\\|def\)')
+nnoremap   ]] :call Python_jump(0, 0, '')
+nnoremap   [[ :call Python_jump(1, 0, '')
+nnoremap   ]m :call Python_jump(0, 0, '\s*')
+nnoremap   [m :call Python_jump(1, 0, '\s*')
+
+vnoremap   ]] :call Python_jump(0, 1, '')
+vnoremap   [[ :call Python_jump(1, 1, '')
+vnoremap   ]m :call Python_jump(0, 1, '\s*')
+vnoremap   [m :call Python_jump(1, 1, '\s*')
 
 if !exists('*Python_jump')
-  fun! Python_jump(motion) range
-  let cnt = v:count1
-  let save = @/" save last search pattern
-  mark '
-  while cnt > 0
-	  silent! exe a:motion
-	  let cnt = cnt - 1
-  endwhile
-  call histdel('/', -1)
-  let @/ = save" restore last search pattern
-  endfun
+fun! Python_jump(back, visual, ws)
+let n = v:count1
+let pattern = '^' . a:ws . '\(class\|def\)'
+if a:visual
+normal gv
+let pattern = '\n' . pattern
+endif
+let pattern = '\(\%^\|\%$\|' . pattern . '\)'
+mark '
+for _ in range(1, n)
+call search(pattern, 'W' . (a:back ? 'b' : ''))
+endfor
+endfun
 endif
 
 if has("browsefilter") && !exists("b:browsefilter")
 let b:browsefilter = "Python Files (*.py)\t*.py\n" .
-		   \ "All Files (*.*)\t*.*\n"
+   \ "All Files (*.*)\t*.*\n"
 endif
 
 " As suggested by PEP8.
@@ -50,11 +57,7 @@ setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
 
 " First time: try finding "pydoc".
 if !exists('g:pydoc_executable')
-if executable('pydoc')
-let g:pydoc_executable = 1
-else
-let g:pydoc_executable = 0
-endif
+let g:pydoc_executable = executable('pydoc') == 1
 endif
 " If "pydoc" was found use it for keywordprg.
 if g:pydoc_executable
-- 
2.4.5



[patch] fixed access to invalid memory when doing :exe "sc"

2015-07-31 Thread Dominique Pellé
Hi

Vim-7.4.803 (and older) accesses invalid memory beyond end of
string when doing:

  $ vim -u NONE -c 'exe "sc"'

Bug is fixed in attached patch.

Apparently, ":sc" is doing a  :substitute  command with the
'c' flag.  I could not find where it is documented, but perhaps
I missed it in the doc.

Bug was found using afl-fuzz + asan.  Here is asan's report:

=
==5082==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x60216d33 at pc 0x52c4de bp 0x7ffc38814d00 sp 0x7ffc38814cf8
READ of size 1 at 0x60216d33 thread T0
#0 0x52c4dd in find_command /home/pel/sb/vim/src/ex_docmd.c:3133
#1 0x527ba7 in do_one_cmd /home/pel/sb/vim/src/ex_docmd.c:2114
#2 0x523388 in do_cmdline /home/pel/sb/vim/src/ex_docmd.c:1133
#3 0x4d7ef8 in ex_execute /home/pel/sb/vim/src/eval.c:22155
#4 0x52afb6 in do_one_cmd /home/pel/sb/vim/src/ex_docmd.c:2941
#5 0x523388 in do_cmdline /home/pel/sb/vim/src/ex_docmd.c:1133
#6 0x521f6c in do_cmdline_cmd /home/pel/sb/vim/src/ex_docmd.c:738
#7 0x9450df in exe_commands /home/pel/sb/vim/src/main.c:2926
#8 0x93e9b5 in main /home/pel/sb/vim/src/main.c:961
#9 0x7f1fdb67eec4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
#10 0x40ea18 (/home/pel/sb/vim/src/vim+0x40ea18)

0x60216d33 is located 0 bytes to the right of 3-byte region
[0x60216d30,0x60216d33)
allocated by thread T0 here:
#0 0x7f1fde44f7df in __interceptor_malloc
(/usr/lib/x86_64-linux-gnu/libasan.so.1+0x547df)
#1 0x664ca7 in lalloc /home/pel/sb/vim/src/misc2.c:921
#2 0x664a8b in alloc /home/pel/sb/vim/src/misc2.c:820
#3 0x665533 in vim_strsave /home/pel/sb/vim/src/misc2.c:1246
#4 0x522f35 in do_cmdline /home/pel/sb/vim/src/ex_docmd.c:1063
#5 0x4d7ef8 in ex_execute /home/pel/sb/vim/src/eval.c:22155
#6 0x52afb6 in do_one_cmd /home/pel/sb/vim/src/ex_docmd.c:2941
#7 0x523388 in do_cmdline /home/pel/sb/vim/src/ex_docmd.c:1133
#8 0x521f6c in do_cmdline_cmd /home/pel/sb/vim/src/ex_docmd.c:738
#9 0x9450df in exe_commands /home/pel/sb/vim/src/main.c:2926
#10 0x93e9b5 in main /home/pel/sb/vim/src/main.c:961
#11 0x7f1fdb67eec4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)

SUMMARY: AddressSanitizer: heap-buffer-overflow
/home/pel/sb/vim/src/ex_docmd.c:3133 find_command
Shadow bytes around the buggy address:
  0x0c047fffad50: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffad60: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffad70: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffad80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffad90: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0c047fffada0: fa fa fa fa fa fa[03]fa fa fa fd fa fa fa 00 01
  0x0c047fffadb0: fa fa 04 fa fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fffadc0: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fffadd0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fffade0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fffadf0: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:   00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:   fa
  Heap right redzone:  fb
  Freed heap region:   fd
  Stack left redzone:  f1
  Stack mid redzone:   f2
  Stack right redzone: f3
  Stack partial redzone:   f4
  Stack after return:  f5
  Stack use after scope:   f8
  Global redzone:  f9
  Global init order:   f6
  Poisoned by user:f7
  Contiguous container OOB:fc
  ASan internal:   fe
==5082==ABORTING

Regards
Dominique

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff -r 893d1ea575c9 src/ex_docmd.c
--- a/src/ex_docmd.c	Tue Jul 28 21:17:37 2015 +0200
+++ b/src/ex_docmd.c	Sat Aug 01 04:04:53 2015 +0200
@@ -3129,8 +3129,8 @@
 	++p;
 }
 else if (p[0] == 's'
-	&& ((p[1] == 'c' && p[2] != 's' && p[2] != 'r'
-		&& p[3] != 'i' && p[4] != 'p')
+	&& ((p[1] == 'c' && (p[2] == NUL || (p[2] != 's' && p[2] != 'r'
+			&& (p[3] == NUL || (p[3] != 'i' && p[4] != 'p')
 		|| p[1] == 'g'
 		|| (p[1] == 'i' && p[2] != 'm' && p[2] != 'l' && p[2] != 'g')
 		|| p[1] == 'I'


Re: [patch] fixed access to invalid memory when doing :exe "sc"

2015-07-31 Thread James McCoy
On Sat, Aug 01, 2015 at 04:27:53AM +0200, Dominique Pellé wrote:
> Hi
> 
> Vim-7.4.803 (and older) accesses invalid memory beyond end of
> string when doing:
> 
>   $ vim -u NONE -c 'exe "sc"'
> 
> Bug is fixed in attached patch.
> 
> Apparently, ":sc" is doing a  :substitute  command with the
> 'c' flag.  I could not find where it is documented, but perhaps
> I missed it in the doc.

:[range]s[ubstitute] [flags] [count]
:[range]&[&][flags] [count] *:&*
…
The space between `:substitute` and the 'c', 'g' and
'r' flags isn't required, but in scripts it's a good
idea to keep it to avoid confusion.

Cheers,
-- 
James
GPG Key: 4096R/331BA3DB 2011-12-05 James McCoy 

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Patch] Python syntax: avoid highlighting attributes as builtins

2015-07-31 Thread Zvezdan Petkovic

> On Jul 31, 2015, at 9:43 AM, Carlos Pita  wrote:
> 
> Hi all,
> 
> the syntax rules for python incorrectly consider, say, both `filter` and 
> `obj.filter` as instances of the builtin `filter`.

Yes, I’m aware of this. I don’t think it’s incorrect though.

>  I've added a rule to explicitly set the group of attributes (defined as an 
> identifier following a dot) to none. Maybe it's better to create a new group 
> for attributes, I'm not sure. I will update the patch with any improving 
> suggestion.

Maybe, this should be a warning sign that you are using the name that’s also a 
builtin which is at least a bad practice? :-)

For example, take this program:

class A:
filter = None

def bogus_filter():
pass

filter = bogus_filter
# lots of code in between
filter(...)  # oops, just called bogus_filter instead of the real one

a = A()
a.filter = 2

- your change will strip the highlighting only from the last line in “a.filter”.
- your change will not strip highlighting from the line in class A: “filter = 
None”

Questions for you:

- Is there any value in making an exception for only a.filter line?
- How about filter = None line?
- Do you consider useful a highlighting hint that you are using a builtin name 
as the name of the binding that’s assigned bogus_filter? Wouldn’t this prevent 
a mistake later?

I’m not convinced that such change adds enough value for a small number of 
cases, while it does take away the value of a warning that one is making a 
potential mistake. Isn’t that the main reason we use syntax highlighting?

What does the rest of Vim community think?

Regards,

Zvezdan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [patch] fixed access to invalid memory when doing :exe "sc"

2015-07-31 Thread Dominique Pellé
James McCoy wrote:

> On Sat, Aug 01, 2015 at 04:27:53AM +0200, Dominique Pellé wrote:
>> Hi
>>
>> Vim-7.4.803 (and older) accesses invalid memory beyond end of
>> string when doing:
>>
>>   $ vim -u NONE -c 'exe "sc"'
>>
>> Bug is fixed in attached patch.
>>
>> Apparently, ":sc" is doing a  :substitute  command with the
>> 'c' flag.  I could not find where it is documented, but perhaps
>> I missed it in the doc.
>
> :[range]s[ubstitute] [flags] [count]
> :[range]&[&][flags] [count] *:&*
> …
> The space between `:substitute` and the 'c', 'g' and
> 'r' flags isn't required, but in scripts it's a good
> idea to keep it to avoid confusion.


Thanks James,

OK, so   :sc   is documented after all.  But the documentation
is incomplete. It's missing flags 'i' and 'I'. See attached doc patch.

Regards
Dominique

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff -r 893d1ea575c9 runtime/doc/change.txt
--- a/runtime/doc/change.txtTue Jul 28 21:17:37 2015 +0200
+++ b/runtime/doc/change.txtSat Aug 01 04:55:23 2015 +0200
@@ -634,9 +634,9 @@
may add [flags], see |:s_flags|.
Note that after `:substitute` the '&' flag can't be
used, it's recognized as a pattern separator.
-   The space between `:substitute` and the 'c', 'g' and
-   'r' flags isn't required, but in scripts it's a good
-   idea to keep it to avoid confusion.
+   The space between `:substitute` and the 'c', 'g',
+   'i', 'I' and 'r' flags isn't required, but in scripts
+   it's a good idea to keep it to avoid confusion.
 
 :[range]~[&][flags] [count]*:~*
Repeat last substitute with same substitute string


Re: [Patch] Python syntax: avoid highlighting attributes as builtins

2015-07-31 Thread Carlos Pita
> - Is there any value in making an exception for only a.filter line?

Yes, you can say for (99%) sure that a.filter is not a builtin, at least no
more than a.x. Instead it's dubious practice to name a global or local
variable as a builtin, that's looking for trouble. But attributes and
variables are different beasts, differently scoped.

There's little to say against value.set(3) or point.set(x=3, y=2) but a lot
against def set(obj, attr, val):  or set = [1, 2, 3].

Cheers
--
Carlos

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[patch] fixed invalid memory in vim-7.4.803 when doing :fun X(

2015-07-31 Thread Dominique Pellé
Hi

Vim-7.4.803 (and older) accesses invalid memory when doing:

  $ vim -u NONE -c 'fun X('

Attached patch fixes it.
Bug was found with afl-fuzz + asan.  Here's asan's report:

=
==8351==ERROR: AddressSanitizer: heap-buffer-overflow on address
0x60214fb7 at pc 0x437a42 bp 0x7fff2eedb810 sp 0x7fff2eedb808
READ of size 1 at 0x60214fb7 thread T0
#0 0x437a41 in skipwhite /home/pel/sb/vim/src/charset.c:1552
#1 0x4da110 in ex_function /home/pel/sb/vim/src/eval.c:22498
#2 0x52afb6 in do_one_cmd /home/pel/sb/vim/src/ex_docmd.c:2941
#3 0x523388 in do_cmdline /home/pel/sb/vim/src/ex_docmd.c:1133
#4 0x521f6c in do_cmdline_cmd /home/pel/sb/vim/src/ex_docmd.c:738
#5 0x9450df in exe_commands /home/pel/sb/vim/src/main.c:2926
#6 0x93e9b5 in main /home/pel/sb/vim/src/main.c:961
#7 0x7ff967b2cec4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
#8 0x40ea18 (/home/pel/sb/vim/src/vim+0x40ea18)

0x60214fb7 is located 0 bytes to the right of 7-byte region
[0x60214fb0,0x60214fb7)
allocated by thread T0 here:
#0 0x7ff96a8fd7df in __interceptor_malloc
(/usr/lib/x86_64-linux-gnu/libasan.so.1+0x547df)
#1 0x664ca7 in lalloc /home/pel/sb/vim/src/misc2.c:921
#2 0x664a8b in alloc /home/pel/sb/vim/src/misc2.c:820
#3 0x665533 in vim_strsave /home/pel/sb/vim/src/misc2.c:1246
#4 0x522f35 in do_cmdline /home/pel/sb/vim/src/ex_docmd.c:1063
#5 0x521f6c in do_cmdline_cmd /home/pel/sb/vim/src/ex_docmd.c:738
#6 0x9450df in exe_commands /home/pel/sb/vim/src/main.c:2926
#7 0x93e9b5 in main /home/pel/sb/vim/src/main.c:961
#8 0x7ff967b2cec4 in __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)

SUMMARY: AddressSanitizer: heap-buffer-overflow
/home/pel/sb/vim/src/charset.c:1552 skipwhite
Shadow bytes around the buggy address:
  0x0c047fffa9a0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffa9b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffa9c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffa9d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c047fffa9e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa 00 05
=>0x0c047fffa9f0: fa fa 02 fa fa fa[07]fa fa fa 04 fa fa fa 00 00
  0x0c047fffaa00: fa fa 00 00 fa fa 00 00 fa fa 00 00 fa fa 00 00
  0x0c047fffaa10: fa fa 00 00 fa fa 00 00 fa fa fd fd fa fa fd fd
  0x0c047fffaa20: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fffaa30: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
  0x0c047fffaa40: fa fa fd fd fa fa fd fd fa fa fd fd fa fa fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:   00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:   fa
  Heap right redzone:  fb
  Freed heap region:   fd
  Stack left redzone:  f1
  Stack mid redzone:   f2
  Stack right redzone: f3
  Stack partial redzone:   f4
  Stack after return:  f5
  Stack use after scope:   f8
  Global redzone:  f9
  Global init order:   f6
  Poisoned by user:f7
  Contiguous container OOB:fc
  ASan internal:   fe
==8351==ABORTING

Regards
Dominique

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff -r 893d1ea575c9 src/eval.c
--- a/src/eval.c	Tue Jul 28 21:17:37 2015 +0200
+++ b/src/eval.c	Sat Aug 01 05:24:32 2015 +0200
@@ -22490,6 +22490,11 @@
 	break;
 	}
 }
+if (*p != ')')
+{
+	EMSG2(_("E107: Missing parentheses: %s"), eap->arg);
+	goto erret;
+}
 ++p;	/* skip the ')' */
 
 /* find extra arguments "range", "dict" and "abort" */


Re: [Patch] Python syntax: avoid highlighting attributes as builtins

2015-07-31 Thread Zvezdan Petkovic
Hi Carlos,

> On Jul 31, 2015, at 8:14 PM, Carlos Pita  wrote:
> > - Is there any value in making an exception for only a.filter line?
> 
> Yes, you can say for (99%) sure that a.filter is not a builtin, at least no 
> more than a.x. Instead it's dubious practice to name a global or local 
> variable as a builtin, that's looking for trouble. But attributes and 
> variables are different beasts, differently scoped.
> 
> There's little to say against value.set(3) or point.set(x=3, y=2) but a lot 
> against def set(obj, attr, val):  or set = [1, 2, 3].
> 
OK. But there still remains the question of discrepancy between:

class A:
filter = None

and:

a = A()
a.filter = 2

On one line it would still be highlighted, while on another it wouldn’t, for 
the same attribute.
That’s inconsistent.

Zvezdan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[patch] updated syntax file for DataScript (*.ds)

2015-07-31 Thread Dominique Pellé
Hi

Attached patch improves syntax highlighting for DataScript files:
- better synchronization to fix highlighting when scrolling back
- use doxygen syntax for DataScript files (as for C, C++, C#, IDL, java, php)
- added a few keywords
- fixed obsolete URL

Regards
Dominique

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
diff -r 893d1ea575c9 runtime/makemenu.vim
--- a/runtime/makemenu.vim	Tue Jul 28 21:17:37 2015 +0200
+++ b/runtime/makemenu.vim	Sat Aug 01 06:14:59 2015 +0200
@@ -177,6 +177,7 @@
 SynMenu DE.Doxygen.C++\ with\ doxygen:cpp.doxygen
 SynMenu DE.Doxygen.IDL\ with\ doxygen:idl.doxygen
 SynMenu DE.Doxygen.Java\ with\ doxygen:java.doxygen
+SynMenu DE.Doxygen.DataScript\ with\ doxygen:datascript.doxygen
 SynMenu DE.Dracula:dracula
 SynMenu DE.DSSSL:dsl
 SynMenu DE.DTD:dtd
diff -r 893d1ea575c9 runtime/synmenu.vim
--- a/runtime/synmenu.vim	Tue Jul 28 21:17:37 2015 +0200
+++ b/runtime/synmenu.vim	Sat Aug 01 06:14:59 2015 +0200
@@ -161,6 +161,7 @@
 an 50.30.300 &Syntax.DE.Doxygen.C++\ with\ doxygen :cal SetSyn("cpp.doxygen")
 an 50.30.310 &Syntax.DE.Doxygen.IDL\ with\ doxygen :cal SetSyn("idl.doxygen")
 an 50.30.320 &Syntax.DE.Doxygen.Java\ with\ doxygen :cal SetSyn("java.doxygen")
+an 50.30.320 &Syntax.DE.Doxygen.DataScript\ with\ doxygen :cal SetSyn("datascript.doxygen")
 an 50.30.330 &Syntax.DE.Dracula :cal SetSyn("dracula")
 an 50.30.340 &Syntax.DE.DSSSL :cal SetSyn("dsl")
 an 50.30.350 &Syntax.DE.DTD :cal SetSyn("dtd")
diff -r 893d1ea575c9 runtime/syntax/datascript.vim
--- a/runtime/syntax/datascript.vim	Tue Jul 28 21:17:37 2015 +0200
+++ b/runtime/syntax/datascript.vim	Sat Aug 01 06:14:59 2015 +0200
@@ -1,11 +1,12 @@
 " Vim syntax file
-" Language:	Datascript
+" Language:	DataScript
 " Maintainer:	Dominique Pelle 
-" Last Change:	2014 Feb 26
+" Last Change:	2015 Jul 30
 "
 " DataScript is a formal language for modelling binary datatypes,
 " bitstreams or file formats. For more information, see:
-" http://datascript.berlios.de/DataScriptLanguageOverview.html
+"
+" http://dstools.sourceforge.net/DataScriptLanguageOverview.html
 
 if version < 600
   syntax clear
@@ -19,6 +20,8 @@
 syn keyword dsType bit bool string
 syn keyword dsType int int8 int16 int32 int64
 syn keyword dsType uint8 uint16 uint32 uint64
+syn keyword dsType varint16 varint32 varint64
+syn keyword dsType varuint16 varuint32 varuint64
 syn keyword dsType leint16 leint32 leint64
 syn keyword dsType leuint16 leuint32 leuint64
 syn keyword dsEndian   little big
@@ -32,7 +35,8 @@
 syn keyword dsStorageClass const
 syn keyword dsTodo contained TODO FIXME XXX
 syn keyword dsSql  sql sql_table sql_database sql_pragma sql_index
-syn keyword dsSql  sql_integer sql_metadata sql_key foreign_key
+syn keyword dsSql  sql_integer sql_metadata sql_key sql_virtual
+syn keyword dsSql  using reference_key foreign_key to
 
 " dsCommentGroup allows adding matches for special things in comments.
 syn cluster dsCommentGroup  contains=dsTodo
@@ -61,6 +65,8 @@
 syn region  dsString
   \ start=+L\="+ skip=+\|\\"+ end=+"+ contains=@Spell
 
+syn sync ccomment dsComment
+
 " Define the default highlighting.
 hi def link dsType  Type
 hi def link dsEndianStorageClass
diff -r 893d1ea575c9 runtime/syntax/synload.vim
--- a/runtime/syntax/synload.vim	Tue Jul 28 21:17:37 2015 +0200
+++ b/runtime/syntax/synload.vim	Sat Aug 01 06:14:59 2015 +0200
@@ -60,8 +60,8 @@
 endfun
 
 
-" Handle adding doxygen to other languages (C, C++, C#, IDL)
-au Syntax c,cpp,cs,idl,php
+" Handle adding doxygen to other languages (C, C++, C#, IDL, java, php, DataScript)
+au Syntax c,cpp,cs,idl,java,php,datascript
 	\ if (exists('b:load_doxygen_syntax') && b:load_doxygen_syntax)
 	\	|| (exists('g:load_doxygen_syntax') && g:load_doxygen_syntax)
 	\   | runtime! syntax/doxygen.vim