StokeBloke.com

emacs refresh F5 key

Thursday, April 17th, 2008

I use this little addition to my .emacs file to support reloading the current file I’m editing.

(defun refresh-file ()
  (interactive)
  (revert-buffer t t t)
  )

(global-set-key [f5] 'refresh-file)

You can also use CTRL-x CTRL-v to do a “Find alternative file” and choose the same file that you are currently editing. F5 is a little quicker though.

emacs css-mode indent-buffer fix

Friday, March 21st, 2008

Ive been using emacs for some years now, but I always noticed the css mode seemed to format it a little strange.

I found this article, it fixes all the issues in the css mode.

(setq cssm-indent-level 4)
(setq cssm-newline-before-closing-bracket t)
(setq cssm-indent-function #'cssm-c-style-indenter)
(setq cssm-mirror-mode nil)

Now when I auto indent the buffer it looks correctly. I have no idea why this is not the default for the css-mode.

FYI my auto indent key is F2.

(defun indent-buffer ()
    (interactive)
    (save-excursion (indent-region (point-min) (point-max) nil))
)
(global-set-key [f2] 'indent-buffer)