Running Shells in Emacs: An Overview
masteringemacs.org
masteringemacs.org
a) $ ifconfig > #<buffer interfaces>
b) find-file README.txt # same as doing C-x C-f
http://www.shellarchive.co.uk/content/emacs_tips.html#have-e...
I alias that script to 'e' so I can do this:
$ ifconfig | e
$ e README.txt (defvar explicit-su-file-name "/bin/su")
(defvar explicit-su-args '("-"))
(defun su (&optional buffer)
(interactive
(list
(and current-prefix-arg
(prog1
(read-buffer "SU buffer: "
(generate-new-buffer-name "*su*"))
(if (file-remote-p default-directory)
;; It must be possible to declare a local default-directory.
(setq default-directory
(expand-file-name
(read-file-name
"Default directory: " default-directory default-directory
t nil 'file-directory-p))))))))
(setq buffer (get-buffer-create (or buffer "*su*")))
;; Pop to buffer, so that the buffer's window will be correctly set
;; when we call comint (so that comint sets the COLUMNS env var properly).
(pop-to-buffer buffer)
(unless (comint-check-proc buffer)
(let* ((prog explicit-su-file-name)
(name (file-name-nondirectory prog))
(startfile (concat "~/.emacs_" name))
(xargs-name (intern-soft (concat "explicit-" name "-args"))))
(apply 'make-comint-in-buffer "su" buffer prog
(if (file-exists-p startfile) startfile)
(if (and xargs-name (boundp xargs-name))
(symbol-value xargs-name)
'("-i")))
(shell-mode)))
buffer) ;; It must be possible to declare a local default-directory.
make-local-variable is an interactive built-in function in `C source
code'. (make-local-variable VARIABLE)
Make VARIABLE have a separate value in the current buffer.
Other buffers will continue to share a common default value.
(The buffer-local value of VARIABLE starts out as the same value
VARIABLE previously had. If VARIABLE was void, it remains void.)
Return VARIABLE.http://blogs.msdn.com/b/dotnetinterop/archive/2008/04/10/run...
(Thanks for the link)
urxvt:
$ time ls /usr/bin
0.036 real 0.013 user 0.020 sys 93.76 cpu
emacs ansi-term: 4.265 real 0.023 user 0.023 sys 1.09 cpuurxvt: real 0m0.314s user 0m0.080s sys 0m0.040s
gnome-terminal: real 0m1.228s user 0m0.090s sys 0m0.040s
ansi-term: real 0m6.493s user 0m0.150s sys 0m0.030s
Also, ls --color=auto really messes up ansi-term. It glitches all over the place and I think treats some color codes as carriage returns or other motion commands for some reason.
I've been put off by M-x shell because it only offers "line" interaction, so bash tab completion doesn't work. M-x term looks much better, but "ls /usr/bin" stalls the output part way through with my cursor off in the middle of the screen until I type a character in char mode, and I see stuff like
error in process filter: cd-absolute: /hom/: no such directory
error in process filter: /hom/: no such directory
in messages. Is this sort of thing endemic?Term works fine as well.
git <TAB>
Is it completing subcommands, or is it trying to complete file names (I always observe the latter)? Now type alias foo='cd /'
foo
ls <TAB>
See how it tries to complete paths in ~ (or wherever your last path was instead of in the new directory).GNU Emacs 24.0.50.1 (Linux), and every version of Emacs I've used in the last 10 years.
The alias completion does appear broken, as you demonstrated.
git <TAB>
completes subcommands ls <TAB>
with the alias shows files from the root /GNU Emacs 23.1.1 (Linux)