From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: Preloading Command/Parameter Recall in .emacs? Date: 28 Jul 2003 19:06:07 -0400 Organization: sometimes Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: <7gzniygskg.fsf@gnufans.net> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: main.gmane.org 1059434233 13005 80.91.224.249 (28 Jul 2003 23:17:13 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Mon, 28 Jul 2003 23:17:13 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jul 29 01:17:10 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 19hHEs-0003NW-00 for ; Tue, 29 Jul 2003 01:17:10 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.20) id 19hHDa-00046m-4A for geh-help-gnu-emacs@m.gmane.org; Mon, 28 Jul 2003 19:15:50 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn-post-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Original-X-Complaints-To: abuse@supernews.com Original-Lines: 82 Original-Xref: shelby.stanford.edu gnu.emacs.help:115513 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:11431 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:11431 "Siegfried Heintze" writes: > I'm particularly intersted in the find > file command (C-x C-f). i like to use (setenv "e" "/home/ttn/build/GNU/emacs") then the sequence is `C-x C-f $ e RET' to start dired there. below is some reverse-substitution elisp you can use (for example) in the hook of your favorite buffer listing facility, to both reduce clutter and remind yourself of the association. in any case, try `M-p' to recall previously-entered input. thi ______________________________________________ ;;; ID: buffer-substitute-file-env-vars.el,v 1.9 2000/06/01 23:39:49 ttn Rel ;;; ;;; Copyright (C) 1998-2000 Thien-Thi Nguyen ;;; This file is part of ttn's personal elisp library, released under GNU ;;; GPL with ABSOLUTELY NO WARRANTY. See the file COPYING for details. ;;; Description: In current buffer, substitute env vars that look like files. ;;; Commentary: ;; Rewritten for inclusion in Emacs (remove external dependency). ;;; Code: ;;;###autoload (defun buffer-substitute-file-env-vars () (let (buffer-read-only (ms-lose (memq system-type '(ms-dos windows-nt)))) (save-excursion (mapcar (lambda (ev-pair) ;; In buffer, replace EV w/ backward mapping. (goto-char (point-max)) (let ((var (car ev-pair)) (val (cdr ev-pair))) (while (search-backward val (point-min) t) (replace-match (concat "$" var))))) ;; FEV-PAIRS is a sorted canonicallized list, longest first. (sort (let (fev-pairs) (mapcar (lambda (ev) (let* ((x (string-match "=" ev)) (v (and x (substring ev (1+ x)))) (val (and v (not (string= v "")) (if (eq ?~ (aref v 0)) (concat (getenv "HOME") (substring v 1)) v)))) (when (and val (or (eq ?/ (aref val 0)) (and ms-lose (string-match "^[a-zA-Z]:/" val)))) (setq fev-pairs (cons (cons (substring ev 0 x) val) fev-pairs))))) process-environment) fev-pairs) (lambda (a b) (> (length (cdr a)) (length (cdr b)))))) ;; Do HOME, then HOOD replacements. ;; HOOD is short for neighborhood, the parent dir of HOME. (goto-char 1) (while (re-search-forward "$HOME\\>" (point-max) t) (replace-match "~")) (let* ((hood (file-name-directory (getenv "HOME")))) (unless (string= hood "/") (goto-char (point-max)) (while (search-backward hood (point-min) t) (replace-match "~"))))))) ;;; buffer-substitute-file-env-vars.el,v1.9 ends here