aquamacs open and jump to line number

How can I open Aquamacs and jump to a specific line number from the command line (I've already installed the Aquamacs command line tools).

In regular emacs I can do emacs +5 test.txt to open and jump to line 5, but it doesn't work when I replace emacs with aquamacs.


Looks like the answer is no:

unlike the “emacs” command, “aquamacs” currently does not process other arguments than filenames.

But M-g-g (GoTo line) still works once you have the file open.


This small AppleScript / bash function opens a file and jumps to a specific line.

First, add this function to your ~/.bash_profile:

function aquamacs-line {
  aquamacs "$2"
  osascript -e "
  tell application \"AquaMacs\"
    activate
    tell application \"System Events\"
      keystroke \"l\" using command down
      keystroke \"$1\"
      key code 36
    end tell
  end tell" > /dev/null 2>&1
}

Reload the shell by opening a new terminal or calling source ~/.bash_profile. Then call it, for example with:

aquamacs-line 5 /some/file

There is of room for improvement, but it works so far. Others feel free to add/fix stuff.