├── README.md ├── TODO.markdown └── emacs-xcode.el /README.md: -------------------------------------------------------------------------------- 1 | ## Overview 2 | 3 | Emacs-xcode allows you to use xcode specific features inside your favourite text editor Emacs. 4 | 5 | ## Installation 6 | 7 | * install xcode 8 | * download emacs-xcode 9 | * add the following code to your emacs startup script 10 | 11 | (add-to-list 'load-path (expand-file-name "/path/to/emacs-xcode/")) 12 | (require 'xcode) 13 | 14 | ## Contributing 15 | 16 | The project is very new and is always looking for assistance. 17 | 18 | 1. Fork emacs-xcode 19 | 2. Create a topic branch - `git checkout -b my_branch` 20 | 3. Make your changes and update the History.txt file 21 | 4. Push to your branch - `git push origin my_branch` 22 | 5. Send me a pull-request for your topic branch 23 | 6. That's it! 24 | 25 | [![githalytics.com alpha](https://cruel-carlota.pagodabox.com/49ef112f831c38731706c754aeb6241a "githalytics.com")](http://githalytics.com/senny/emacs-xcode) 26 | -------------------------------------------------------------------------------- /TODO.markdown: -------------------------------------------------------------------------------- 1 | # TODO # 2 | ## Build ## 3 | * use xcodebuild to build projects 4 | ## Run ## 5 | * run the applications from within emacs (iphone simulator) 6 | ## Completion ## 7 | * integrate objective-c completion functionality, similar to xcode 8 | * write handy snippets to speed up obj-c development (properties, methods, templates, ...) 9 | -------------------------------------------------------------------------------- /emacs-xcode.el: -------------------------------------------------------------------------------- 1 | ;; emacs-xcode.el --- an interface to the XCode IDE. 2 | ;; 3 | ;; Copyright (C) 2009 Yves Senn 4 | ;; 5 | ;; This program is free software: you can redistribute it and/or modify 6 | ;; it under the terms of the GNU General Public License as published by 7 | ;; the Free Software Foundation, either version 3 of the License, or 8 | ;; (at your option) any later version. 9 | ;; 10 | ;; This program is distributed in the hope that it will be useful, 11 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | ;; GNU General Public License for more details. 14 | ;; 15 | ;; You should have received a copy of the GNU General Public License 16 | ;; along with this program. If not, see . 17 | ;; 18 | ;;; Contributors 19 | ;; 20 | ;; - Yves Senn 21 | ;; - Peter Jones 22 | ;; 23 | ;;; Conventions 24 | ;; 25 | ;; Conventions used in this file: Name internal variables and functions 26 | ;; "xcode--", and name xcode command invocations 27 | ;; "xcode/command-name", like xcode/build. 28 | 29 | ;;* emacs-xcode 30 | 31 | (defvar *xcode-project-root* nil) 32 | 33 | (defun xcode--project-root () 34 | (or *xcode-project-root* 35 | (setq *xcode-project-root* (xcode--project-lookup)))) 36 | 37 | (defun xcode--project-lookup (&optional current-directory) 38 | (when (null current-directory) (setq current-directory default-directory)) 39 | (cond ((xcode--project-for-directory (directory-files current-directory)) (expand-file-name current-directory)) 40 | ((equal (expand-file-name current-directory) "/") nil) 41 | (t (xcode--project-lookup (concat (file-name-as-directory current-directory) ".."))))) 42 | 43 | (defun xcode--project-for-directory (files) 44 | (let ((project-file nil)) 45 | (dolist (file files project-file) 46 | (if (> (length file) 10) 47 | (when (string-equal (substring file -10) ".xcodeproj") (setq project-file file)))))) 48 | 49 | (defun xcode--project-command (options) 50 | (concat "cd " (xcode--project-root) "; " options)) 51 | 52 | (defun xcode/build-compile () 53 | (interactive) 54 | (compile (xcode--project-command (xcode--build-command)))) 55 | 56 | (defun xcode/build-list-sdks () 57 | (interactive) 58 | (message (shell-command-to-string (xcode--project-command "xcodebuild -showsdks")))) 59 | 60 | (defun xcode--build-command (&optional target configuration sdk) 61 | (let ((build-command "xcodebuild")) 62 | (if (not target) 63 | (setq build-command (concat build-command " -activetarget")) 64 | (setq build-command (concat build-command " -target " target))) 65 | (if (not configuration) 66 | (setq build-command (concat build-command " -activeconfiguration")) 67 | (setq build-command (concat build-command " -configuration " configuration))) 68 | (when sdk (setq build-command (concat build-command " -sdk " sdk))) 69 | build-command)) 70 | 71 | (defun xcode/toggle-header-and-source nil 72 | "Toggle between source and header files" 73 | (interactive) 74 | (let ((fname buffer-file-name) oname) 75 | (setq oname 76 | (cond 77 | ((string-match "\\.h$" fname) (replace-match ".m" nil nil fname)) 78 | ((string-match "\\.m$" fname) (replace-match ".h" nil nil fname)) 79 | (t fname))) 80 | (find-file oname))) 81 | 82 | (defun bh-compile () 83 | (interactive) 84 | (let ((df (directory-files ".")) 85 | (has-proj-file nil) 86 | ) 87 | (while (and df (not has-proj-file)) 88 | (let ((fn (car df))) 89 | (if (> (length fn) 10) 90 | (if (string-equal (substring fn -10) ".xcodeproj") 91 | (setq has-proj-file t) 92 | ) 93 | ) 94 | ) 95 | (setq df (cdr df)) 96 | ) 97 | (if has-proj-file 98 | (compile "xcodebuild -configuration Debug") 99 | (compile "make") 100 | ) 101 | ) 102 | ) 103 | 104 | (defun bh-choose-header-mode () 105 | (interactive) 106 | (if (string-equal (substring (buffer-file-name) -2) ".h") 107 | (progn 108 | ;; OK, we got a .h file, if a .m file exists we'll assume it's 109 | ;; an objective c file. Otherwise, we'll look for a .cpp file. 110 | (let ((dot-m-file (concat (substring (buffer-file-name) 0 -1) "m")) 111 | (dot-cpp-file (concat (substring (buffer-file-name) 0 -1) "cpp"))) 112 | (if (file-exists-p dot-m-file) 113 | (progn 114 | (objc-mode) 115 | ) 116 | (if (file-exists-p dot-cpp-file) 117 | (c++-mode))))))) 118 | (add-hook 'find-file-hook 'bh-choose-header-mode) 119 | 120 | (provide 'xcode) 121 | --------------------------------------------------------------------------------