Wednesday, 22 July 2009

emacs macro open-this-file and minimum .emacs settings for c-mode


; open file (path and file at cursor) and bounce back to original buffer next line
; handy for restoring sessions or opening list of interesting files
; it's obvious here I'm repeating myself somewhat
; easier creating a quick macro each time sometimes than reading docs and trying to find the one-and-only proper way of the probably few ways of doing something
(fset 'open-this-file2
[?\C- ?\C-e escape ?w ?\C-x ?\C-f ?\C- left left left left left left left left left left left left left left left left left left left left left left left left left left ?\C-a ?\C-y ?\C-k return ?\C-x ?b return ?\C-a down])

(fset 'load-file-at-cursor
[?\C- ?\C-e escape ?w ?\C-a ?\C-x ?\C-f ?\C-a ?\C-y ?\C-k return ?\C-x ?b return down])

(fset 'open-this-file
[?\C- ?\C-e escape ?w ?\C-a down ?\C-x ?\C-f ?\C-a ?\C-y ?\C-k return ?\C-x ?b return])


I used to carry a massive .emacs file around everywhere, now-a-days I just put in the minimum:

(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(c-basic-offset 4)
'(c-default-style (quote ((java-mode . "java") (awk-mode . "awk") (other . "gnu"))))
'(indent-tabs-mode nil))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

No comments: