unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Preloading Command/Parameter Recall in .emacs?
@ 2003-07-28 22:35 Siegfried Heintze
  2003-07-28 23:06 ` Thien-Thi Nguyen
  2003-07-28 23:19 ` Kin Cho
  0 siblings, 2 replies; 3+ messages in thread
From: Siegfried Heintze @ 2003-07-28 22:35 UTC (permalink / raw)


There are some might long commands, search strings and file names I use
frequently and I'm getting might tired of typing them in all the time.

How can I preload the command/parameter recal for the various command and
parameter prompts in my .emacs file? I'm particularly intersted in the find
file command (C-x C-f).

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Preloading Command/Parameter Recall in .emacs?
  2003-07-28 22:35 Preloading Command/Parameter Recall in .emacs? Siegfried Heintze
@ 2003-07-28 23:06 ` Thien-Thi Nguyen
  2003-07-28 23:19 ` Kin Cho
  1 sibling, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2003-07-28 23:06 UTC (permalink / raw)


"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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Preloading Command/Parameter Recall in .emacs?
  2003-07-28 22:35 Preloading Command/Parameter Recall in .emacs? Siegfried Heintze
  2003-07-28 23:06 ` Thien-Thi Nguyen
@ 2003-07-28 23:19 ` Kin Cho
  1 sibling, 0 replies; 3+ messages in thread
From: Kin Cho @ 2003-07-28 23:19 UTC (permalink / raw)


> I'm particularly intersted in the find file command (C-x C-f).

filecache is quite good for this purpose.  From filecache.el's
commentary:

;;   (eval-after-load
;;     "filecache"
;;      '(my-file-cache-initialize))
;;
;;   (defun my-file-cache-initialize ()
;;      (interactive)
;; 	(message "Loading file cache...")
;; 	(file-cache-add-directory-using-find "~/projects")
;;	(file-cache-add-directory-list load-path)
;;	(file-cache-add-directory "~/")
;;	(file-cache-add-file-list (list "~/foo/bar" "~/baz/bar"))
;;   ))

-kin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-07-28 23:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-28 22:35 Preloading Command/Parameter Recall in .emacs? Siegfried Heintze
2003-07-28 23:06 ` Thien-Thi Nguyen
2003-07-28 23:19 ` Kin Cho

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).