From: Thien-Thi Nguyen <ttn@glug.org>
Subject: Re: Preloading Command/Parameter Recall in .emacs?
Date: 28 Jul 2003 19:06:07 -0400 [thread overview]
Message-ID: <7gzniygskg.fsf@gnufans.net> (raw)
In-Reply-To: GyhVa.2631$YN5.3150@sccrnsc01
"Siegfried Heintze" <sieg_heintze@yahoo.com> 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
next prev parent reply other threads:[~2003-07-28 23:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-07-28 22:35 Preloading Command/Parameter Recall in .emacs? Siegfried Heintze
2003-07-28 23:06 ` Thien-Thi Nguyen [this message]
2003-07-28 23:19 ` Kin Cho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7gzniygskg.fsf@gnufans.net \
--to=ttn@glug.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).