Open Xcode From Emacs At The Same Line

Álvaro Ramírez has a nice post on opening a file in the macOS Xcode editor from Emacs. There’s nothing unusual about that, of course, but Ramírez’s wrinkle is that he wants Xcode to open at the same line the Emacs point is on.

It’s reasonable to ask why a devoted Emacser like Ramírez would want to open Xcode at all. The answer is that he’s more pragmatic than I am. I consider leaving Emacs a fail; something that I should try to find a fix for. Ramírez, as I say, is more pragmatic. Although he much prefers working in Emacs, he’s willing to use other tools if they’re more appropriate. Although he mostly uses Emacs for his iOS development, there are certain situations—debugging, for instance—where he feels Xcode is a better solution.

He’s long used Bozhidar Batsov’s crux to open the file he’s working on in Emacs in the Xcode editor. The problem was that it opened at the top of the file rather than at the line he was looking at in Emacs. It turns out, though, that you can call Xcode from the command line and specify the line to open the file at.

Ramírez, of course, used his dwim-shell-command framework to implement this but it would be trivial to adopt to plain Elisp if you’re not a dwim-shell-command user. You should also check out the comments in the reddit post about the method. There are some other useful ways of integrating Emacs and Xcode workflows.

This entry was posted in General and tagged , . Bookmark the permalink.