EMACS: Toggle header and source

Wrote a function to toggle views between a header and source file in
c-mode and locally bound this to F11.
This commit is contained in:
Tom Willemsen 2011-04-23 00:29:34 +02:00
parent 79563a6264
commit 4344bbeeda
2 changed files with 11 additions and 0 deletions

View file

@ -26,3 +26,11 @@
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0)) '(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32 (x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))) '(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0)))
(defun c-toggle-header-source ()
(interactive)
(let ((ext (file-name-extension (buffer-file-name)))
(noext (file-name-sans-extension (buffer-file-name))))
(if (string= (substring ext 0 1) "c")
(find-file (concat noext ".h"))
(find-file (concat noext ".c")))))

3
emacs.d/20-c-mode.el Normal file
View file

@ -0,0 +1,3 @@
(add-hook 'c-mode-hook
(lambda ()
(local-set-key [f11] 'c-toggle-header-source)))