32
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Emacsで現在開いてるバッファを再読込する

Posted at

Compassを使いはじめたけど、まだ慣れてないので実際にどんなcssが出力されるかを確認しながら使っているとEmacsで開いてるバッファの再読み込みをブラウザの「更新」みたいにやりたくなったので設定方法を調べてみました。

設定方法

まず revert-buffer だと確認をしないといけないので、確認の必要のない関数を定義。
ファイルの変更が保存されてない場合はエラー。それでも必ず再読込したい場合は「参考」を見てください。

~/.emacs.d/inits/00-common-func.el
(defun revert-buffer-no-confirm (&optional force-reverting)
  "Interactive call to revert-buffer. Ignoring the auto-save
 file and not requesting for confirmation. When the current buffer
 is modified, the command refuses to revert it, unless you specify
 the optional argument: force-reverting to true."
  (interactive "P")
  ;;(message "force-reverting value is %s" force-reverting)
  (if (or force-reverting (not (buffer-modified-p)))
      (revert-buffer :ignore-auto :noconfirm)
    (error "The buffer has been modified")))

MacではCommand+Rで、UbuntuではF5で更新

~/.emacs.d/inits/cocoa-emacs-keybinds.el
;; reload buffer
(global-set-key "\M-r" 'revert-buffer-no-confirm)
~/.emacs.d/inits/linux-keybinds.el
;; reload buffer
(global-set-key (kbd "<f5>") 'revert-buffer-no-confirm)

いつものこのファンクションキーを割り当てる方法を忘れるのどうにかしたい。

参考

EmacsWiki: Revert Buffer
http://www.emacswiki.org/emacs/RevertBuffer

32
29
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
29

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?