Re: folding patch
Hi Bram Dear Mr. Campbell On 2014-12-16 Tue at 04:09 +0100 Roland Eggner wrote: > Subject: Re: "Make closed folds line up" by Charles Campbell: patch > On Fri, Dec 12, 2014 at 12:57:39AM +0100, Roland Eggner wrote: > > Patch "Make closed folds line up" by Charles Campbell is already on Brams > > todo list. > > http://www.drchip.org/astronaut/vim/patch/folding.ptch > > > > It works nicely apart from case "relativenumber nonumber" with numberwidth > > smaller than for absolute linenumbers would be appropriate. And in this > > particular case, I am encountering rare crashes -- both with and without > > the > > named patch applied, “foldmethod=expr” and „syntax on” always in effect. > > So far > > I cannot reproduce the crashes, they are too rare. > > > > E.g. with terminal LINES=90 relativenumbers are never longer than 2 digits, > > thus > > I set numberwidth=3. If the buffer holds a file with >1 lines of text, > > numberwidth<6 seems to be not considered in all related code parts, the > > relativenumbers are consuming part of the padding introduced by the patch, > > which > > does not look as nice as with “norelativenumber number” set. > > > Patch improved: > • Cover the case “:set relativenumber nonumber numberwidth=3”. > • Adjust padding to minimum required for line numbers aligned in a column. > • “make test” runs cleanly. > • Has been working flawlessly during 2 days intensive usage. > > > Example “:help netrw” exhibits the effect nicely: > (1) Plain vim-7.4.529. > (2) With “Charles Campbell 2014 Make closed folds line up.patch” > (3) With “Charles Campbell 2014 Make closed folds line up.patch”, improved > version provided below. > > :set nonumber norelativenumber > (1) > ==|~ > +-- 88 lines: 1. Contents *netrw-contents* > --|~ > +-- 73 lines: 2. Starting With Netrw *netrw-start* > ---|~ > +--273 lines: 3. Netrw Reference *netrw-ref* > -|~ > +--209 lines: 4. Network-Oriented File Transfer *netrw-xfer* > ---|~ > +-- 17 lines: 5. Activation *netrw-activate* > |~ > +-- 16 lines: 6. Transparent Remote File Editing *netrw-transparent* > |~ > +-- 58 lines: 7. Ex Commands *netrw-ex* > -|~ > +--182 lines: 8. Variables and Options *netrw-var* *netrw-settings* > -|~ > +--1923 lines: 9. Browsing *netrw-browsing* *netrw-browse* *netrw-help* > -|~ > +--294 lines: 10. Problems and Fixes *netrw-problems* > |~ > +-- 56 lines: 11. Debugging Netrw Itself*netrw-debug* > |~ > +--273 lines: 12. History *netrw-history* > ---|~ > +-- 9 lines: 13. Todo *netrw-todo* > -|~ > +-- 24 lines: 14. Credits *netrw-credits* > ---|~ > +-- 2 lines: Modelines: > -|~ > > (2) > ==|~ > +-- 88 lines: 1. Contents *netrw-contents* > --|~ > +-- 73 lines: 2. Starting With Netrw *netrw-start* > ---|~ > +--273 lines: 3. Netrw Reference *netrw-ref* > -|~ > +--209 lines: 4. Network-Oriented File Transfer *netrw-xfer* > ---|~ > +-- 17 lines: 5. Activation *netrw-activate* > |~ > +-- 16 lines: 6. Transparent Remote File Editing *netrw-transparent* > |~ > +-- 58 lines: 7. Ex Commands *netrw-ex* > -|~ > +--182 lines: 8. Variables and Options *netrw-var* *netrw-settings* > -|~ > +-- 1923 lines: 9. Browsing *netrw-browsing* *netrw-browse* *netrw-help* > --|~ > +--294 lines: 10. Problems and Fixes *netrw-problems* > |~ > +-- 56 lines: 11. Debugging Netrw Itself*netrw-debug* > |~ > +--273 lines: 12. History *netrw-history* > ---|~ > +-- 9 lines: 13. Todo *netrw-todo* > -|~ > +-- 24 lines: 14. Credits *netrw-credits* > ---|~ > +-- 2 lines: Modelines: > -|~ > > (3) > ==|~ > +-- 88 lines: 1. Contents *netrw-contents* > |~ > +-- 73 lines: 2. Starting With Netrw *netrw-start* > -|~ > +-- 273 lines: 3. Netrw Reference *netrw-ref* > ---|~ > +-- 209 lines: 4. Network-Oriented File Transfer *netrw-xfer* > -|~ > +-- 17 lines: 5. Activation *netrw-activate* >
folding patch
Hello: Here's my patch for neater folding displays, updated to apply cleanly for vim 7.4.1979. Regards, Chip Campbell -- -- 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. *** eval.c.orig 2016-07-01 17:46:29.997747660 -0400 --- eval.c 2016-07-01 17:47:11.949546588 -0400 *** *** 1,12227 --- 1,12231 char_u*r; int len; char *txt; + charfmt[40]; + int nuw; + int padding; + unsignedrlen; #endif rettv->v_type = VAR_STRING; *** *** 12255,12270 s = skipwhite(s + 1); } } ! txt = _("+-%s%3ld lines: "); ! r = alloc((unsigned)(STRLEN(txt) ! + STRLEN(vimvars[VV_FOLDDASHES].vv_str)/* for %s */ ! + 20/* for %3ld */ ! + STRLEN(s))); /* concatenated */ if (r != NULL) { sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str, (long)((linenr_T)vimvars[VV_FOLDEND].vv_nr ! - (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1)); len = (int)STRLEN(r); STRCAT(r, s); /* remove 'foldmarker' and 'commentstring' */ --- 12259,12280 s = skipwhite(s + 1); } } ! /* next two lines construct a format to be used for the folded region. !* Example: assume nuw=5, then fmt becomes "+-%-5s%5ld lines: %*s" !*/ ! nuw= number_width(curwin); /* obtain log10(lastline) */ ! padding= STRLEN(vimvars[VV_FOLDDASHES].vv_str); ! sprintf(fmt,"+-%%-%ds%%%dld lines:%%*s",(padding > nuw)? padding : nuw,nuw); ! txt = _(fmt); /* internationalize */ ! rlen= (STRLEN(txt) - 11) + 2*nuw + ((padding > nuw)? padding : nuw) + STRLEN(s) + 10; ! r = alloc(rlen); if (r != NULL) { + if(padding > nuw) padding= nuw; sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str, (long)((linenr_T)vimvars[VV_FOLDEND].vv_nr ! - (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1), ! padding," "); len = (int)STRLEN(r); STRCAT(r, s); /* remove 'foldmarker' and 'commentstring' */
Folding patch updated for 7.4.1049
I've attached the patch. As a reminder: it makes folded lines more readable by doing some aligning. Regards, Chip Campbell -- -- 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. *** eval.c.orig 2016-01-04 12:14:14.880933518 -0500 --- eval.c 2016-01-04 12:15:38.104291332 -0500 *** *** 11371,11376 --- 11371,11380 char_u*r; int len; char *txt; + charfmt[40]; + int nuw; + int padding; + unsignedrlen; #endif rettv->v_type = VAR_STRING; *** *** 11404,11419 s = skipwhite(s + 1); } } ! txt = _("+-%s%3ld lines: "); ! r = alloc((unsigned)(STRLEN(txt) ! + STRLEN(vimvars[VV_FOLDDASHES].vv_str)/* for %s */ ! + 20/* for %3ld */ ! + STRLEN(s))); /* concatenated */ if (r != NULL) { sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str, (long)((linenr_T)vimvars[VV_FOLDEND].vv_nr ! - (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1)); len = (int)STRLEN(r); STRCAT(r, s); /* remove 'foldmarker' and 'commentstring' */ --- 11408,11429 s = skipwhite(s + 1); } } ! /* next two lines construct a format to be used for the folded region. !* Example: assume nuw=5, then fmt becomes "+-%-5s%5ld lines: %*s" !*/ ! nuw= number_width(curwin); /* obtain log10(lastline) */ ! padding= STRLEN(vimvars[VV_FOLDDASHES].vv_str); ! sprintf(fmt,"+-%%-%ds%%%dld lines:%%*s",(padding > nuw)? padding : nuw,nuw); ! txt = _(fmt); /* internationalize */ ! rlen= (STRLEN(txt) - 11) + 2*nuw + ((padding > nuw)? padding : nuw) + STRLEN(s) + 10; ! r = alloc(rlen); if (r != NULL) { + if(padding > nuw) padding= nuw; sprintf((char *)r, txt, vimvars[VV_FOLDDASHES].vv_str, (long)((linenr_T)vimvars[VV_FOLDEND].vv_nr ! - (linenr_T)vimvars[VV_FOLDSTART].vv_nr + 1), ! padding," "); len = (int)STRLEN(r); STRCAT(r, s); /* remove 'foldmarker' and 'commentstring' */