jed-users mailing list

[2016 Date Index] [2016 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [jed-users] using _for [was: Dired fails on directory or file names with spaces?]


@Manfred - Ah! I see what i was doing wrong with the _for now. Using loop
is definitely the way to go here. Much more concise and no extraneous index
variable getting pushed on the stack.that needs to be consumed. Some of the
stack based code tricks that slang is capable of (like the code in
dired_xop_tagged_files) always make me go a bit cross eyed until I make the
mental shift.

@John - I also grabbed and tried the experimental version from snapshots,
but found the name encoding a bit too wonky. Getting rid of the external
commands and a lot of the platform dependencies rather than screen scraping
their output seems like a much more robust approach, but the escaping isn't
very readable. I'm wondering if there might be a way to leave yourself a
breadcrumb in the buffer (since you now control the format) and do
something a little more minimal for encoding like shell single quote style
or \ style.


On Mon, Aug 15, 2016 at 2:44 AM, Manfred Hanke <
Manfred.Hanke@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Tom,
>
> just briefly about using _for:
>
> >    variable i;
> >    for (i = 0; i < 8; i++) {
> >        skip_chars ("^ \t");
> >        skip_white ();
> >    }
>
> should translate to:
>
> >    variable i;
> >    _for i (0, 7, 1) {
> >        skip_chars ("^ \t");
> >        skip_white ();
> >    }
>
> or since S-Lang version pre2.3.0-75:
>
> >    variable i;
> >    _for i (0, 7) {
> >        skip_chars ("^ \t");
> >        skip_white ();
> >    }
>
> or even more concise using loop:
>
> >    loop(8) {
> >        skip_chars ("^ \t");
> >        skip_white ();
> >    }
>
> Cheers,
>
> Manfred
>
>
> On 15.08.2016 03:34, Tom Culliton wrote:
> > Darn, not sure how I missed your reply John, but I was just messing
> > around with this again after quite a while and came up with this for the
> > Unix verison of dired_point:
> >
> >    bol ();
> >    if (looking_at_char ('D') or looking_at_char ('%')) go_right_1 ();
> >    skip_white ();
> >    variable i;
> >    for (i = 0; i < 8; i++) {
> >        skip_chars ("^ \t");
> >        skip_white ();
> >    }
> >
> > Along with adding quoting of the directory name in the ls command (media
> > files that use apostrophe in the name, sweet merciless Cthulhu!):
> >
> > shell_cmd (sprintf ("ls -al '%s' 2>/dev/null", str_replace_all(dir, "'",
> > "'\\''")));
> >
> > It's not the most elegant solution but it seems to be working. I tried
> > using a _for but it seemed to leave trash on the stack in some cases.
> >
> >
> > On Sun, Apr 26, 2015 at 10:29 PM, John E. Davis <jed@xxxxxxxxxxx
> > <mailto:jed@xxxxxxxxxxx>> wrote:
> >
> >     Tom Culliton <tom.culliton@xxxxxxxxx
> >     <mailto:tom.culliton@xxxxxxxxx>> wrote:
> >     > The problem with the code in dired.sl <http://dired.sl> comes
> down to the following two lines
> >     > at the end of dired_point:
> >     >
> >     >    eol ();
> >     >    bskip_chars ("^ \n");
> >
> >     Yes, that is correct.  I just pushed an update to the git repository
> >     that avoids the use of ls and dir.  It also encodes any filenames
> that
> >     contain spaces, newlines, etc.
> >
> >     I have not tested it thoroughly, but it does seem to work on the
> tests
> >     that I have performed.  I have not tested it at all on VMS/Windows,
> >     and it may require some tweaks on those systems.
> >
> >     Please consider it to be experimental.
> >
> >     Thanks,
> >     --John
> >
> >
>
>

[2016 date index] [2016 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]