eval command onto other buffer in Emacs
I have a broken meta key and am trying to do M-x viper-mode onto an org file.
I want elisp to run (vi开发者_如何学Cper-mode) onto the example.org file from the scratch buffer.
In Lisp, call set-buffer
to switch to a different buffer for editing operations (this doesn't affect what buffer the user interacts with).
(save-excursion
(set-buffer "example.org")
(viper-mode))
The save-excursion
form executes its arguments, then returns to the originally current buffer. Here, you could actually use progn
instead, because returning to the toplevel restores the current buffer. But you need to group the two function calls anyway, and save-excursion
is a good habit to get into.
But note that your problem is that your Meta key doesn't work, you can type Esc x instead of Meta+x (and likewise for any other M-key
combination).
精彩评论