From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Peter Dyballa Newsgroups: gmane.emacs.help Subject: Re: Saving/Recalling Shell Commands History? Date: Wed, 23 Aug 2006 01:13:04 +0200 Message-ID: <85A5A4F0-4577-4C65-B855-C776F96FA6E3@web.DE> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1156288425 9813 80.91.229.2 (22 Aug 2006 23:13:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 22 Aug 2006 23:13:45 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 23 01:13:34 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GFfQw-0000Cq-J0 for geh-help-gnu-emacs@m.gmane.org; Wed, 23 Aug 2006 01:13:22 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFfQv-0006du-UW for geh-help-gnu-emacs@m.gmane.org; Tue, 22 Aug 2006 19:13:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GFfQk-0006cz-N9 for help-gnu-emacs@gnu.org; Tue, 22 Aug 2006 19:13:10 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GFfQj-0006bg-2b for help-gnu-emacs@gnu.org; Tue, 22 Aug 2006 19:13:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GFfQj-0006bd-0W for help-gnu-emacs@gnu.org; Tue, 22 Aug 2006 19:13:09 -0400 Original-Received: from [217.72.192.227] (helo=fmmailgate02.web.de) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GFfYQ-0003Cq-Nz for help-gnu-emacs@gnu.org; Tue, 22 Aug 2006 19:21:07 -0400 Original-Received: from smtp07.web.de (fmsmtp07.dlan.cinetic.de [172.20.5.215]) by fmmailgate02.web.de (Postfix) with ESMTP id 3B3FB1618022; Wed, 23 Aug 2006 01:13:07 +0200 (CEST) Original-Received: from [84.245.176.189] (helo=[192.168.1.2]) by smtp07.web.de with asmtp (TLSv1:RC4-SHA:128) (WEB.DE 4.107 #114) id 1GFfQg-0003JT-00; Wed, 23 Aug 2006 01:13:07 +0200 In-Reply-To: X-Image-Url: http://homepage.mac.com/sparifankal/.cv/thumbs/me.thumbnail Original-To: Kevin Rodgers X-Mailer: Apple Mail (2.752.2) X-Sender: Peter_Dyballa@web.de X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:36853 Archived-At: Am 21.08.2006 um 23:32 schrieb Kevin Rodgers: > So leave it commented out, and put this in your ~/.emacs file: > > (add-hook 'shell-mode-hook > (lambda () > (setq comint-input-ring-file-name ; buffer-local > (expand-file-name "history" desktop-dirname)))) The code above works, but it only works for GNU Emacs. The shell =20 never gets knowledge of this! I think the meaning of comint-input-ring-file-name is to let GNU =20 Emacs know directly, for whatever reason or use, what the shell's =20 history file is. Maybe it's useful in dumb shells that cannot provide =20= their own history, maybe it's useful in TRAMP, i.e. working in a =20 remote shell. For my purpose I extended your hook to make the shell know where the =20 actual history file of the Emacs *shell* buffer is. Since I want to =20 separate the different Emacs versions I am using I have created an =20 intermediate and temporary file, ~/.emacs_tcsh-init, which contains a =20= line that tells the shell which file to use for a history. For tcsh =20 the file ~/.emacs_tcsh is executed in *shell* buffer. So =20 ~/.emacs_tcsh needs to be extended by one line that loads the =20 intermediate file =96 and removes it! Here is my extended hook: (add-hook 'shell-mode-hook (lambda () (setq comint-input-ring-file-name (expand-file-name "history" desktop-dirname)) (setq histfile_cmd (format "echo \"set histfile =3D %s\" > = .emacs_tcsh-init" comint-input-ring-file-name)) (shell-command histfile_cmd) )) ~/.emacs_tcsh-init will have a line like: set histfile =3D The extended version of ~/.emacs_tcsh has two more lines: sleep 1 if (-e ~/.emacs_tcsh-init) source ~/.emacs_tcsh-init && rm =20 ~/.emacs_tcsh-init The sleep is needed, otherwise the file's removal fails with an error =20= message in *shell*. One cannot feel this one more second in GNU =20 Emacs's start-up. For bash the history file is addressed by the environment variable =20 $HISTFILE. It's probably OK to use the syntax HISTFILE=3D without 'export.' The syntax for the ~/.emacs_bash file would be: if [ -e ~/.emacs_bash-init ]; then . ~/.emacs_bash-init && rm =20= ~/.emacs_bash-init; fi There is one more disadvantage: an empty buffer *Shell Command =20 Output* is created because of executing (shell-command =20 histfile_cmd) ... Could be a kill-buffer in the hook removes it! -- Greetings Pete The day Microsoft makes something that doesn't suck is the day they start selling vacuum cleaners. Ernest Jan Plugge