diff options
| author | Juri Linkov | 2008-04-22 19:50:11 +0000 |
|---|---|---|
| committer | Juri Linkov | 2008-04-22 19:50:11 +0000 |
| commit | a98a2fe87a5d0e16a3b518b5278c4818eb43caec (patch) | |
| tree | 49c7ebf6f4949b03ec96418d1c72555d8cb6dbb0 | |
| parent | 88970542acc49553255b38913eae8dcd30f42af5 (diff) | |
| download | emacs-a98a2fe87a5d0e16a3b518b5278c4818eb43caec.tar.gz emacs-a98a2fe87a5d0e16a3b518b5278c4818eb43caec.zip | |
(minibuffer-default-add-shell-commands): New function.
Use declare-function for mailcap-file-default-commands from "mailcap".
(shell-command): Set local minibuffer-default-add-function to
minibuffer-default-add-shell-commands in minibuffer-with-setup-hook
before calling read-shell-command. Set 4th arg default-value of
read-shell-command to relative buffer-file-name in file buffers.
| -rw-r--r-- | lisp/simple.el | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/lisp/simple.el b/lisp/simple.el index 44dcbf45be1..4ef352e1cd5 100644 --- a/lisp/simple.el +++ b/lisp/simple.el | |||
| @@ -1957,6 +1957,25 @@ This buffer is used when `shell-command' or `shell-command-on-region' | |||
| 1957 | is run interactively. A value of nil means that output to stderr and | 1957 | is run interactively. A value of nil means that output to stderr and |
| 1958 | stdout will be intermixed in the output stream.") | 1958 | stdout will be intermixed in the output stream.") |
| 1959 | 1959 | ||
| 1960 | (declare-function mailcap-file-default-commands "mailcap" (files)) | ||
| 1961 | |||
| 1962 | (defun minibuffer-default-add-shell-commands () | ||
| 1963 | "Return a list of all commands associted with the current file. | ||
| 1964 | This function is used to add all related commands retieved by `mailcap' | ||
| 1965 | to the end of the list of defaults just after the default value." | ||
| 1966 | (interactive) | ||
| 1967 | (let* ((filename (if (listp minibuffer-default) | ||
| 1968 | (car minibuffer-default) | ||
| 1969 | minibuffer-default)) | ||
| 1970 | (commands (and filename (require 'mailcap nil t) | ||
| 1971 | (mailcap-file-default-commands (list filename))))) | ||
| 1972 | (setq commands (mapcar (lambda (command) | ||
| 1973 | (concat command " " filename)) | ||
| 1974 | commands)) | ||
| 1975 | (if (listp minibuffer-default) | ||
| 1976 | (append minibuffer-default commands) | ||
| 1977 | (cons minibuffer-default commands)))) | ||
| 1978 | |||
| 1960 | (defun minibuffer-complete-shell-command () | 1979 | (defun minibuffer-complete-shell-command () |
| 1961 | "Dynamically complete shell command at point." | 1980 | "Dynamically complete shell command at point." |
| 1962 | (interactive) | 1981 | (interactive) |
| @@ -2031,9 +2050,17 @@ If it is nil, error output is mingled with regular output. | |||
| 2031 | In an interactive call, the variable `shell-command-default-error-buffer' | 2050 | In an interactive call, the variable `shell-command-default-error-buffer' |
| 2032 | specifies the value of ERROR-BUFFER." | 2051 | specifies the value of ERROR-BUFFER." |
| 2033 | 2052 | ||
| 2034 | (interactive (list (read-shell-command "Shell command: ") | 2053 | (interactive |
| 2035 | current-prefix-arg | 2054 | (list |
| 2036 | shell-command-default-error-buffer)) | 2055 | (minibuffer-with-setup-hook |
| 2056 | (lambda () | ||
| 2057 | (set (make-local-variable 'minibuffer-default-add-function) | ||
| 2058 | 'minibuffer-default-add-shell-commands)) | ||
| 2059 | (read-shell-command "Shell command: " nil nil | ||
| 2060 | (and buffer-file-name | ||
| 2061 | (file-relative-name buffer-file-name)))) | ||
| 2062 | current-prefix-arg | ||
| 2063 | shell-command-default-error-buffer)) | ||
| 2037 | ;; Look for a handler in case default-directory is a remote file name. | 2064 | ;; Look for a handler in case default-directory is a remote file name. |
| 2038 | (let ((handler | 2065 | (let ((handler |
| 2039 | (find-file-name-handler (directory-file-name default-directory) | 2066 | (find-file-name-handler (directory-file-name default-directory) |