annotate lisp/dired/dired-cwd.el @ 16:0293115a14e9 r19-15b91

Import from CVS: tag r19-15b91
author cvs
date Mon, 13 Aug 2007 08:49:20 +0200
parents 376386a54a3c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;;; dired-cwd.el - Fix a command's current working directory in Tree Dired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 (defconst dired-cwd-version (substring "!Revision: 1.2 !" 11 -2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 "!Id: dired-cwd.el,v 1.2 1991/10/08 15:31:28 sk RelBeta !")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Copyright (C) 1991 by Sebastian Kremer <sk@thp.uni-koeln.de>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; the Free Software Foundation; either version 1, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; along with this program; if not, write to the Free Software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; LISPDIR ENTRY for the Elisp Archive ===============================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; dired-cwd|Sebastian Kremer|sk@thp.uni-koeln.de
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; |Fix a command's current working directory in Tree Dired.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; |Date: 1991/10/08 15:31:28 |Revision: 1.2 |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; INSTALLATION ======================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; Put this file into your load-path and the following in your ~/.emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; (autoload 'dired-cwd-make-magic "dired-cwd")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; You have to load dired-x.el in your dired-load-hook to define
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; function default-directory, or you will not benefit from this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; package: as long as function default-directory is not defined, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; functions wrapped by dired-cwd-make-magic will behave as before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; EXAMPLE USAGE ======================================================
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; How to fix M-x compile (and grep) to know about Tree Dired's multiple
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; working directories by putting the following lines into your ~/.emacs:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; (require 'compile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; (dired-cwd-make-magic 'compile1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; After that, a compilation or grep started in a subdirectory in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; Dired buffer will have that subdirectory as working directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; Note you must require 'compile as function compile1 is redefined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; You could use a load hook instead by adding the line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; (run-hooks 'compile-load-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; at the end of compile.el and setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; (setq compile-load-hook '(lambda () (dired-cwd-make-magic 'compile1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; in your ~/.emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (defun dired-cwd-make-magic (function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 "Modify COMMAND so that it's working directory is the current dired directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 This works by binding `default-directory' to `(default-directory)'s value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 See also function `default-directory'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (interactive "aMake work with tree dired (function): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (if (commandp function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (error "Cannot make interactive functions work for tree dired"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (let ((save-name (intern (concat "dired-cwd-wrap-real-" (symbol-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 new-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (setq new-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (` (lambda (&rest dired-cwd-args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; Name our formal args unique to avoid shadowing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; through dynamic scope.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (let ((default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (if (fboundp 'default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; This is defined in dired-x.el, but dired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; may not yet be loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (apply 'funcall (quote (, save-name)) dired-cwd-args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (or (fboundp save-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (fset save-name (symbol-function function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (fset function new-function)))