Mercurial > emacs
comparison lisp/simple.el @ 57653:b324ca4df07c
* simple.el (process-file): New function, similar to call-process
but supports file handlers.
* vc.el (vc-do-command): Use it, instead of call-process.
* net/tramp-vc.el (vc-do-command): Do not advise it if
process-file is fboundp.
* net/tramp.el (tramp-file-name-handler-alist): Add entry for
process-file.
(tramp-handle-process-file): New function.
(tramp-file-name-for-operation): Support process-file.
author | Kai Großjohann <kgrossjo@eu.uu.net> |
---|---|
date | Sat, 23 Oct 2004 19:52:18 +0000 |
parents | 942b8e28d21a |
children | d9dc84198059 |
comparison
equal
deleted
inserted
replaced
57652:1d0ad14ff912 | 57653:b324ca4df07c |
---|---|
1877 "Execute shell command COMMAND and return its output as a string." | 1877 "Execute shell command COMMAND and return its output as a string." |
1878 (with-output-to-string | 1878 (with-output-to-string |
1879 (with-current-buffer | 1879 (with-current-buffer |
1880 standard-output | 1880 standard-output |
1881 (call-process shell-file-name nil t nil shell-command-switch command)))) | 1881 (call-process shell-file-name nil t nil shell-command-switch command)))) |
1882 | |
1883 (defun process-file (program &optional infile buffer display &rest args) | |
1884 "Process files synchronously in a separate process. | |
1885 Similar to `call-process', but may invoke a file handler based on | |
1886 `default-directory'. The current working directory of the | |
1887 subprocess is `default-directory'. | |
1888 | |
1889 File names in INFILE and BUFFER are handled normally, but file | |
1890 names in ARGS should be relative to `default-directory', as they | |
1891 are passed to the process verbatim. \(This is a difference to | |
1892 `call-process' which does not support file handlers for INFILE | |
1893 and BUFFER.\) | |
1894 | |
1895 Some file handlers might not support all variants, for example | |
1896 they might behave as if DISPLAY was nil, regardless of the actual | |
1897 value passed." | |
1898 (let ((fh (find-file-name-handler default-directory 'process-file)) | |
1899 lc stderr-file) | |
1900 (unwind-protect | |
1901 (if fh (apply fh 'process-file program infile buffer display args) | |
1902 (setq lc (file-local-copy infile)) | |
1903 (setq stderr-file (when (and (consp buffer) (stringp (cadr buffer))) | |
1904 (make-temp-file "emacs")))) | |
1905 (prog1 | |
1906 (apply 'call-process program | |
1907 (or lc infile) | |
1908 (if stderr-file (list (car buffer) stderr-file) buffer) | |
1909 display args) | |
1910 (when stderr-file (copy-file stderr-file (cadr buffer)))) | |
1911 (when stderr-file (delete-file stderr-file)) | |
1912 (when lc (delete-file lc))))) | |
1913 | |
1914 | |
1882 | 1915 |
1883 (defvar universal-argument-map | 1916 (defvar universal-argument-map |
1884 (let ((map (make-sparse-keymap))) | 1917 (let ((map (make-sparse-keymap))) |
1885 (define-key map [t] 'universal-argument-other-key) | 1918 (define-key map [t] 'universal-argument-other-key) |
1886 (define-key map (vector meta-prefix-char t) 'universal-argument-other-key) | 1919 (define-key map (vector meta-prefix-char t) 'universal-argument-other-key) |