Anonymous avatar Anonymous committed 6f94597

added a switch for emacs 23.1/24 (emacs or emacsclient) and python <2.7/≥2.7

Comments (0)

Files changed (1)

 from PyQt4.QtGui import QApplication
 from PyQt4.QtCore import QProcess, SIGNAL, SLOT
 
-from sys import argv
+from sys import argv, version_info
+
+if version_info > (2,7,0, 'final', 0): 
+    from subprocess import check_output
+    out = check_output(["emacs", "--version"])
+    n = len("GNU Emacs ")
+    vers = float(out[n:n+4])
+else:
+    vers = None
 
 app = QApplication(argv)
 
 container = QX11EmbedContainer()
+container.resize(670, 630)
 container.show()
 
-def resize():
-    container.resize(670, 630)
-container.resize_ = resize
-
 process = QProcess(container)
-print container.winId()
 args = ["--parent-id", str(container.winId())]
-#process.start("emacs", args)
-process.start("emacsclient-emacs-24", args)
+if vers >= 24: 
+    process.start("emacsclient", args)
+elif vers is None or vers >= 23.1: 
+    process.start("emacs", args)
+else:
+    print "You need at least emacs 23.1 for embedding emacs via XEmbed."
+    exit()
 container.connect(container, SIGNAL("clientClosed()"), app.quit)
-container.connect(container, SIGNAL("clientIsEmbedded()"), container.resize_)
+#container.connect(container, SIGNAL("clientIsEmbedded()"), container.resize_)
 container.connect(container, SIGNAL("error(QX11EmbedContainer::Error)"), app.quit)
 status = app.exec_()
 process.close()
-
-
-### Self Test == Run the Program ###
-
-if __name__ == "__main__":
-    pass
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.