开发者

eval command onto other buffer in Emacs

开发者 https://www.devze.com 2023-02-12 03:56 出处:网络
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-buffe

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).

0

精彩评论

暂无评论...
验证码 换一张
取 消