does anyone know how to enable Ctrl-o to switch to normal-mode for one command in viper-mode or vimpulse? In viper-mode it's bound to open-line (which is what it does for vanilla Emacs and in vimpulse it is bound to (vimpulse-jump-backward ARG). I'm using Viper-mode + vimpulse at level 2.
If you're in insert-mode and want to execute one Vimpulse command :
(vimpulse-imap "\C-o" 'viper-escape-to-vi)
(it is bound by default to C-z in insert-mode)
Related
Invoking 'shell' by M-x shell,
and plan to start a tmux session
it report errors
$ tmux
open terminal failed: terminal does not support clear
What's the problem?
If invoking `ansi-term', the operations of yanking and pasting are invalid.
So, shell perform better than ansi-term in routines.
How could activate tmux within a shell
tmux needs a real terminal, and shell doesn't provide that (as implied by the error you get). So you need to use term with tmux.
Or you can use built in functionality of Emacs to have features of tmux. E.g. C-x 2 and C-x 3 will split the frame into windows so you can have multiple terminals in a frame (an Emacs frame is what most applications would call a window). Start an emacs server and emacsclient to have sessions that you can connect to and keep running after you close the frame.
Copy (M-w) and paste (S-<insert>) should work by default. If you want to play with bindings, the key map is called term-raw-map and the commands are kill-ring-save and term-paste.
Also learn the difference between term-line-mode (C-c C-j) and term-char-mode (C-c C-k). Briefly, line mode behaves more like shell, and char mode behaves more like a real terminal, with most Emacs keybindings unavailable. I personally keep term buffers in char mode almost always and add some keybindings to term-raw-map so I can run certain Emacs commands.
In the bottom of this this Github PR for clojure-emacs, bbatsov says :
#Bill You can also invoke cider-jack-in with a prefix argument and
you'll get prompted for a few things (like the command used to
jack-in).
How do I invoke cider-jack-in with a prefix ? For now I do M-x cider-jack-in. I would like to specify a profile interactively.
In emacs, C-u is used to specify a prefix argument before any command. Different commands treat prefixes differently, but you can generally expect a more customized response.
C-u M-x cider-jack-in
I'm trying to enable whitespace mode but it doesn't seem to be working for me.
I've added the whitespace.el file to my .emacs.d/ directory.
I added the following lines to me .emacs file:
(add-hook 'before-save-hook 'whitespace-cleanup)
(add-hook 'before-save-hook (lambda() (delete-trailing-whitespace)))
(require 'whitespace)
I did the following in the whitespace.el file:
M-x byte-compile-file <path to whitespace.el>
I tried executing the following command from any random text in emacs (e.g.: test.c):
M-x whitespace-toggle-options RET
But I just get a message saying [No match]
What am I missing?
Also, will I have to type in a command to enable the whitespace-mode every time I use emacs?
whitespace.el has been included in Emacs for quite a while. Unless you have a very old version, you shouldn't need to manually put it anywhere, or do anything particularly special to use it.
whitespace-toggle-options probably isn't the function you want to use. Instead, try whitespace-mode:
Toggle whitespace visualization (Whitespace mode).
With a prefix argument ARG, enable Whitespace mode if ARG is
positive, and disable it otherwise. If called from Lisp, enable
the mode if ARG is omitted or nil.
If you want to enable it by default, add
(global-whitespace-mode)
to your init file.
Is there a way to have Emacs to prompt by default for a binary of my choice when running M-x ansi-term. It always asks me for /bin/zsh but I have a new installation of zsh in a different path.
Alternatively, it would be great to have Emacs to just run the binary I want when I type M-x my-ansi-term
There are a number of ways to specify the default shell:
Set the variable explicit-shell-file-name. For example, in your .emacs: (setq explicit-shell-file-name "/bin/zsh")
Set the environment variable ESHELL
Set the environment variable SHELL
Alternatively, it would be great to have Emacs to just run the binary I want when I type M-x my-ansi-term
See Remote ssh connection from within Emacs.
Emacs M-x compile does not see any aliases set in .bashrc. If I use M-x shell then type the alias, it is fine. I tried sourcing .bashrc from /etc/profile, from ~/.profile, ~/bash_env, anything I can think of to no avail.
I am on Emacs 23 and Ubuntu 11. I start emacs using /usr/bin/emacs %F, from a desktop button.
Emacs inherits its environment from the parent process. How are you invoking Emacs - from the command line, or some other way?
What happens if you:
M-x compile RET C-a C-k bash -i -c your_alias RET
Invoking bash as an interactive shell (-i option) should read your .bashrc aliases.
Edit: I think both M-x shell-command and M-x compile execute commands in an inferior shell via call-process. Try the following in your .emacs (or just evaluate):
(setq shell-file-name "bash")
(setq shell-command-switch "-ic")
I notice that after evaluation of the above, .bashrc aliases are picked up for use by both M-x shell-command and M-x compile, i.e
M-x compile RET your_alias RET
should then work.
My environment: Emacs 24.1 (pretest rc1), OSX 10.7.3
Keith Flower's answer works but can result in some slowdowns due to .bashrc being unnecessarily loaded in other places (presumably many many times, my computer is not exactly under-powered but emacs was almost unusable when trying to use autocomplete.el).
An alternative way is to locally modify shell-command-switch only for the functions where it is needed. This can be done using emacs' "advice" feature to create a wrapper around those functions. Here's an example that modifies compile:
;; Define + active modification to compile that locally sets
;; shell-command-switch to "-ic".
(defadvice compile (around use-bashrc activate)
"Load .bashrc in any calls to bash (e.g. so we can use aliases)"
(let ((shell-command-switch "-ic"))
ad-do-it))
You need to write similar "advice" for each function that you want to use .bashrc (e.g. I also needed to define the same advice for recompile), just copy the above and replace compile in the above with another function name.
You may like emac's bash-completion :
https://github.com/szermatt/emacs-bash-completion
You'll be able to use tab completion of your aliases in the compilation minibuffer and in shell-mode.
Enjoy !
(they speak about it here Bash autocompletion in Emacs shell-mode )
I think compilation commands are not interpreted through a shell: they are juste exec'ed by emacs (which means aliases, shell functions and other shell-specific things are not taken into account).
Try to wrap you compilation command into a shell-script which would source the correct environment.
You can do this either with a full-fledged shell-script in the form
#!/bin/bash
source "~/.bashrc"
my_command
or directly in emacs with a compilation command of the form
bash -c "source ~/.bashrc; my_command"
See Is there a way to get my emacs to recognize my bash aliases and custom functions when I run a shell command? for a fix which doesn't run all your .bashrc and doesn't create these error messages:
bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell