Created
October 12, 2012 22:29
-
-
Save kirankulkarni/3881996 to your computer and use it in GitHub Desktop.
Switching between header and source file in objective-C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun objc-in-header-file () | |
(let* ((filename (buffer-file-name)) | |
(extension (car (last (split-string filename "\\."))))) | |
(string= "h" extension))) | |
(defun objc-jump-to-extension (extension) | |
(let* ((filename (buffer-file-name)) | |
(file-components (append (butlast (split-string filename | |
"\\.")) | |
(list extension)))) | |
(find-file (mapconcat 'identity file-components ".")))) | |
;;; Assumes that Header and Source file are in same directory | |
(defun objc-jump-between-header-source () | |
(interactive) | |
(if (objc-in-header-file) | |
(objc-jump-to-extension "m") | |
(objc-jump-to-extension "h"))) | |
(defun objc-mode-customizations () | |
(define-key objc-mode-map (kbd "C-c t") 'objc-jump-between-header-source)) | |
(add-hook 'objc-mode-hook 'objc-mode-customizations) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment