The Artima Developer Community
Sponsored Link

Java Buzz Forum
Emacs Client on Mac OS X

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Brian McCallister

Posts: 1282
Nickname: frums
Registered: Sep, 2003

Brian McCallister is JustaProgrammer who thinks too much.
Emacs Client on Mac OS X Posted: Mar 16, 2011 3:56 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Brian McCallister.
Original Post: Emacs Client on Mac OS X
Feed Title: Waste of Time
Feed URL: http://kasparov.skife.org/blog/index.rss
Feed Description: A simple waste of time and weblog experiment
Latest Java Buzz Posts
Latest Java Buzz Posts by Brian McCallister
Latest Posts From Waste of Time

Advertisement

I have been using J Aaron Farr’s approach to an emacsclient app on the Mac for a while, but it has always bugged me that it behaved differently than other apps. It would open a frame any time the app was launched (say via quicksilver or its ilk).

I finally took some time to munge the applescript to get the normal behavior, that is open a frame if there is no open frame, otherwise bring emacs to the front. Along the way I added “and start the emacs server if it is not already running.”

tell application "Terminal"
	try
		-- we look for <= 2 because Emacs --daemon seems to always have an entry in visibile-frame-list even if there isn't
		set frameVisible to do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -e '(<= 2 (length (visible-frame-list)))'"
		if frameVisible is not "t" then
			-- there is a not a visible frame, launch one
			do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n"
		end if
	on error
		-- daemon is not running, start the daemon and open a frame		
		do shell script "/Applications/Emacs.app/Contents/MacOS/Emacs --daemon"
		do shell script "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient -c -n"
	end try
end tell

-- bring the visible frame to the front
tell application "Emacs" to activate

The script assumes that Emacs.app is version 23 or higher and is installed under /Applications – if it isn’t you will need to modify it accordingly. Assuming it is, you can use this built version, otherwise grab the source from github and adjust strings accordingly.

Read: Emacs Client on Mac OS X

Topic: Da Guttenberg Button! Previous Topic   Next Topic Topic: JDK 7 Developer Preview Available

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use