What is Emacs Application Framework?
Emacs Application Framework (EAF) is an application framework that extend GNU Emacs to an entire new universe of powerful GUI PyQt applications.
EAF is also super extensible, developers can develop any PyQt program, and integrate it into Emacs through EAF.
This framework mainly implements three functions:
- Integrate PyQt program window into Emacs Frame using Xlib Reparent technology
- Listening to EAF buffer's keyboard event flow and controlling the keyboard input of PyQt program via DBus IPC
- Created a window compositer to make the PyQt program window adapt Emacs's Window/Buffer design
|Image Viewer||Video Player|
|File Sender||File Receiver|
|Air Share||Org Previewer|
- Install python dependences:
sudo pip3 install dbus-python pymupdf grip qrcode python-xlib pyqt5 pyqtwebengine
- Install QTermWidget's Python binding:
git clone https://github.com/lxqt/qtermwidget.git --depth=1 mkdir bulid && cd build cmake .. -DQTERMWIDGET_BUILD_PYTHON_BINDING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr make sudo make install
- Clone this repository and add below code in
use-package sample configuration
(use-package eaf :load-path "~/.emacs.d/site-lisp/emacs-application-framework" :custom (eaf-find-alternate-file-in-dired t) :config (eaf-bind-key scroll_up "RET" eaf-pdf-viewer-keybinding) (eaf-bind-key scroll_down_page "DEL" eaf-pdf-viewer-keybinding) (eaf-bind-key scroll_up "C-n" eaf-pdf-viewer-keybinding) (eaf-bind-key scroll_down "C-p" eaf-pdf-viewer-keybinding) (eaf-bind-key take_photo "p" eaf-camera-keybinding) (defun eaf-open-google () "Open Google using EAF." (interactive) (eaf-open-browser "https://www.google.com")))
|Debian Package||Package Repo||Use for|
|dbus-python||pip3||DBus IPC for python and elisp|
|pymupdf||pip3||Render engine required for PDF Viewer|
|grip||pip3||Markdown render server for Markdown Previewer|
|qrcode||pip3||Render local file QR code|
|python-xlib||pip3||Stick app window into emacs frame|
|pyqt5||pip3||GUI library required for application development|
|pyqtwebengine||pip3||QtWebEngine for browser application|
|qtermwidget-git||source code compile||QTermWidget is terminal emulator for PyQt5|
You can choose to run EAF with docker@
If you prefer to run linux in a docker, you can read Run EAF with docker
Why this awesome framework doesn't works with MacOS or Windows?
There are mainly three obstacles:
- I can't make dbus/python-dbus works on MacOS High Sierra
- This framework need use X11 reparent to stick Qt5 window to emacs frame, but I don't know how to make X11 works on MacOS.
- Qt5 QGraphicsView/QGraphicsScene can't work MacOS, specify QGraphicsVideoItem can't work.
- If you figure them out, PR always welcome
|Browser||Type 'eaf-browser' RET https://www.google.com|
|PDF Viewer||Type 'eaf-open' RET pdf filepath|
|Video Player||Type 'eaf-open' RET video filepath|
|Image Viewer||Type 'eaf-open' RET image filepath|
|Markdown previewer||Type 'eaf-open' RET markdown filepath|
|Org file previewer||Type 'eaf-open' RET org filepath|
|File Sender||Type 'eaf-file-sender-qrcode'|
|Or use 'eaf-file-sender-qrcode-in-dired'|
|File Receiver||Type 'eaf-file-receiver-qrcode'|
Please check Key binding to check keybinding of application.
NOTE: EAF use DBus' session bus, it must running in general user. Please don't run EAF with root user, root user just can access DBus's system bus.
There are default keybindings for each EAF application provided by us. If you want to see them all, execute
C-h m within an EAF buffer.
You can easily customize EAF keybindings, find the corresponding keybinding variable, and add the something like the following to
(eaf-bind-key scroll_up "C-n" eaf-pdf-viewer-keybinding) (eaf-bind-key scroll_down "C-p" eaf-pdf-viewer-keybinding) (eaf-bind-key take_photo "p" eaf-camera-keybinding)
Currently available keybinding variables are
There are certain variables will be shared across Emacs Lisp and Python. You can easily configure then with
Check the full list of configurable variables with
C-h v eaf-var-list.
To set EAF Browser as your default browser, put the following in your
(setq browse-url-browser-function 'eaf-open-browser) (defalias 'browse-web 'eaf-open-browser)
The default directory to store images taken by EAF Camera is
~/Downloads. To modify it, add the something like the following to
(eaf-setq eaf-camera-save-path "new/path/")
If you can't access most awesome internet services like me, you perhaps need proxy settings like below:
(setq eaf-http-proxy-host "127.0.0.1") (setq eaf-http-proxy-port "1080")
Then EAF browser is working! ;)
If you use markdown previewer, you need the access to a Personal access token, fill something in "Token description" and click button "Generate token" to get your personal token, then set token with code:
(setq eaf-grip-token "yourtokencode")
Otherwise, github will popup "times limit" error because so many people use grip. ;)
How about EXWM? What makes EAF special?
- EAF gives you control over your program, while satisfying Emacs window design model. EXWM is only a tiling WM, that combines different applications together in an Emacs-like fashion. However, EXWM is unable to split the same application into two different windows while displaying different parts of the same application at the same time. For example, EAF is able to display different pages of the same PDF on two different windows.
- EAF essentially provides Emacs a secondary scripting language (This topic has been brought up in EmacsConf2019 and reddit). Emacs Lisp doesn't render graphics very well, especially it doesn't play nicely with the browser. This is (an example of) where PyQt5 can come in handy.
- With DBus IPC, EAF can use Python to control Emacs Lisp, conversely also true that Emacs Lisp can control Qt rendering and Python code.
- EXWM, as a Windows Manager, does its job very well. Therefore, it doesn't have control and doesn't care at all how other program functions. For example, EXWM cannot control keyboard events of other programs. On the other hand, you can configure them in EAF either using existing features (see above) or write code to contribute to this repository.
- From a higher point of view, EAF is using Emacs' design principles to extend GUI programs. You have the ability to control good GUI programs using Emacs keybindings. To achieve the ultimate goal: live in Emacs ;)
Why not support Wayland?
EAF use X11 XReparent technology to stick Qt5 window on Emacs buffer area, Wayland not support XReparent.
I recommend you use KDE, it's stable enough and support X11 XReparent technology.
"undefined symbol" error
If you got "undefined symbol" error after start EAF, and you use Arch Linux, yes, it's a bug of Arch.
You need use pip install all dependences after you upgrade your Arch system, then undefine symbol error will fix.
If you got
*eaf* aborted error, please check buffer
*eaf* first, mostly because Python library dependencies is not installed successfully.
If you have any problem with EAF, please use command "emacs -Q" to start Emacs without any customizations.
Then re-test your workflow. If "emacs -Q" works fine, it's must be something wrong with your emacs config file.
If the problem persists, please report bug here.
Do you want to make Emacs a real operating system?
Do you want to live in emacs more comfortably?
Want to create unparalleled plugins to extend emacs?
如果我的作品让你的生活充满快乐, 欢迎请我喝瓶啤酒, 哈哈哈哈