2012/12/19 ridiculous_fish <corydo...@ridiculousfish.com>:
> After running a command, some processing occurs on a background thread. When 
> that's done, it notifies the main thread, which adds the item to the history. 
> The earliest that the main thread can respond to the notification is in its 
> main "event loop", which is a call to select().  So the history item only 
> gets added after the next prompt is displayed.
>

What's the motivation for using another thread for adding history? I
guess this is due to performance consideration (writing to disk may
take some time), but perhaps we can add the history to $history in the
main thread, and write to disk in a thread. That way a preexec-like
event can be added, and a preexec-catching function can get the latest
history in $history[1] reliably.

The the availability of latest history item before it is executed is
crucial to the filename saving part of a fasd-like tool. Assuming a
preexec event implemented, it will look like:

function parse_and_save -e preexec
    eval set args (echo $history[1] | tr \;\n '  ')
    for a in $args
        if test -f $a
            save (readlink -f $a)
        end
    end
end

parse_and_save tries to re-expanded the last command (it uses an adhoc
method now, could be better), test for existing files (or
directories), and save their canonicalized file names (readlink -f is
only available in GNU coreutils, and there seems to be no easy
alternative for non-GNU users; but you get the point). These need to
be done as early as possible - preferably *before* the command is
actually executed. Otherwise, the major problem is that the current
directory may have changed, and there the re-expansions, file testing
will break.

> Incidentally, I believe this is why if you run 'exit', it doesn't show up in 
> history.


--
Regards,
Cheer Xiao

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to