From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tom Newsgroups: gmane.emacs.devel Subject: Re: Occur stack Date: Thu, 16 Jan 2014 17:19:11 +0000 (UTC) Message-ID: References: <52D6D907.4030702@online.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1389892820 32722 80.91.229.3 (16 Jan 2014 17:20:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 16 Jan 2014 17:20:20 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jan 16 18:20:27 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W3qcD-0000b2-Bt for ged-emacs-devel@m.gmane.org; Thu, 16 Jan 2014 18:20:25 +0100 Original-Received: from localhost ([::1]:34061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3qcC-0000pr-Tq for ged-emacs-devel@m.gmane.org; Thu, 16 Jan 2014 12:20:24 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3qbX-0008Q1-9Z for emacs-devel@gnu.org; Thu, 16 Jan 2014 12:19:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W3qbQ-0000zh-0C for emacs-devel@gnu.org; Thu, 16 Jan 2014 12:19:43 -0500 Original-Received: from plane.gmane.org ([80.91.229.3]:51020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W3qbP-0000zP-QP for emacs-devel@gnu.org; Thu, 16 Jan 2014 12:19:35 -0500 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W3qbO-0007m5-7m for emacs-devel@gnu.org; Thu, 16 Jan 2014 18:19:34 +0100 Original-Received: from 94-21-76-52.pool.digikabel.hu ([94.21.76.52]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Jan 2014 18:19:34 +0100 Original-Received: from adatgyujto by 94-21-76-52.pool.digikabel.hu with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 16 Jan 2014 18:19:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 37 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 94.21.76.52 (Opera/9.80 (Windows NT 6.1) Presto/2.12.388 Version/12.16) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:168543 Archived-At: Tom 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.