emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Occur stack


From: Andreas Röhler
Subject: Re: Occur stack
Date: Fri, 17 Jan 2014 09:24:43 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0

Am 16.01.2014 18:19, schrieb Tom:
Tom <adatgyujto <at> gmail.com> writes:

The code is generic, so in theory it can work for other
commands too, but I only tested it with occur.


I tried it with grep too, specifically grep-find. You need to
add  the saving function to compilation-finish-functions:


(defun buffer-history-grep-save (buf result)
   (if (and (eq major-mode 'grep-mode)
            (equal result "finished\n"))
       (buffer-history-save)))

(add-hook 'compilation-finish-functions 'buffer-history-grep-save)


If you do some grepping and then run M-x buffer-history-list
in the *grep* buffer then you can see your previous greps
and you can restore them.

The listing is not as useful as with occur, because this
simple implementation only takes the first line of the
output, assuming it describes the contents which is true
for occur, but not really true for grep-find. It only gives
you the directory, so a proper implementation should be more
clever about that, it should have a way to retrieve the relevant
inputs from the target command.

Another thing is that unlike occur it does not work seamlessly
if you do grep-find in different directories, because the
results are displayed as relative file names, so default-directory
should be restored too.

A proper implementation should restore the buffer local variables too
in addition to the buffer contents.




Hi Tom,

works for me, great, thanks!

BTW needed a (require 'cl) still.

In cases where a plenty of occur-calls is done, maybe the discussion WRT to 
memory pertains?

Andreas






reply via email to

[Prev in Thread] Current Thread [Next in Thread]