Loading eaf.el +16 −16 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ map) "Keymap used by `eaf-mode'.") (defvar-local eaf-buffer-id nil (defvar-local eaf--buffer-id nil "Internal id used by eaf app.") (define-derived-mode eaf-mode text-mode "EAF" Loading @@ -106,7 +106,7 @@ (setq mode-name "EAF") ;; Split window combinations proportionally. (setq window-combination-resize t) (set (make-local-variable 'eaf-buffer-id) (eaf-generate-id)) (set (make-local-variable 'eaf--buffer-id) (eaf-generate-id)) ;; Load local map. (use-local-map eaf-mode-map) ;; Fix #110 , make `eaf-monitor-key-event' buffer locally to pre-command-hook of the eaf-mode buffer. Loading Loading @@ -418,13 +418,13 @@ Use `eaf-execute-app-cmd' if you want to execute this command programmatically. Please ONLY use `eaf-bind-key' to edit EAF keybindings!" (interactive) ;; ensure this is only called from eaf buffer (unless (boundp 'eaf-buffer-id) (unless (boundp 'eaf--buffer-id) (error "%s command can only be called in eaf buffer" sym)) ;; Enable the command to be called by M-x or from lisp code in ;; the case that this command isn't invoked by key-sequence. (when (and (eq this-command sym) (not (equal (this-command-keys-vector) key))) (eaf-call "execute_function" eaf-buffer-id fun))))) (eaf-call "execute_function" eaf--buffer-id fun))))) (defun eaf-gen-keybinding-map (keybinding) "Configure the eaf-mode-map from KEYBINDING, one of the eaf-*-keybinding variables." Loading Loading @@ -485,7 +485,7 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!" (w (nth 2 window-allocation)) (h (nth 3 window-allocation)) ) (add-to-list 'view-infos (format "%s:%s:%s:%s:%s:%s" eaf-buffer-id (eaf-get-emacs-xid frame) x y w h)) (add-to-list 'view-infos (format "%s:%s:%s:%s:%s:%s" eaf--buffer-id (eaf-get-emacs-xid frame) x y w h)) )))))) ;; I don't know how to make emacs send dbus-message with two-dimensional list. ;; So i package two-dimensional list in string, then unpack on server side. ;) Loading Loading @@ -521,8 +521,8 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!" (run-with-timer 1 nil (lambda () (eaf-org-killed-buffer-clean))) )) ((derived-mode-p 'eaf-mode) (eaf-call "kill_buffer" eaf-buffer-id) (message (format "Kill %s" eaf-buffer-id))) (eaf-call "kill_buffer" eaf--buffer-id) (message (format "Kill %s" eaf--buffer-id))) )))) (defun eaf-monitor-buffer-save () Loading Loading @@ -551,14 +551,14 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!" t) ;; Call function on the Python side if matched key in the keybinding. ((eaf-identify-key-in-app key-command buffer-app-name) (eaf-call "execute_function" eaf-buffer-id (eaf-call "execute_function" eaf--buffer-id (cdr (assoc key-desc (eaf-get-app-bindings buffer-app-name))))) ;; Send key to Python side if key-command is single character key. ((or (equal key-command "self-insert-command") (equal key-command "completion-select-if-within-overlay") (equal key-command "nil") (member key-desc eaf-single-key-list)) (eaf-call "send_key" eaf-buffer-id key-desc)) (eaf-call "send_key" eaf--buffer-id key-desc)) (t nil))))) Loading Loading @@ -635,7 +635,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (let ((eaf-buffer (generate-new-buffer (concat "Browser Popup Window " new-window-buffer-id)))) (with-current-buffer eaf-buffer (eaf-mode) (set (make-local-variable 'eaf-buffer-id) new-window-buffer-id) (set (make-local-variable 'eaf--buffer-id) new-window-buffer-id) (set (make-local-variable 'buffer-url) "") (set (make-local-variable 'buffer-app-name) "browser")) (switch-to-buffer eaf-buffer))) Loading @@ -650,7 +650,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (dolist (buffer (buffer-list)) (set-buffer buffer) (when (equal major-mode 'eaf-mode) (when (string= eaf-buffer-id kill-buffer-id) (when (string= eaf--buffer-id kill-buffer-id) (kill-buffer buffer) (message (format "Request kill buffer %s" kill-buffer-id)) (throw 'found-match-buffer t)))))) Loading @@ -677,7 +677,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (with-current-buffer buffer (when (and (derived-mode-p 'eaf-mode) (equal eaf-buffer-id bid)) (equal eaf--buffer-id bid)) (rename-buffer (truncate-string-to-width title eaf-title-length)) (throw 'find-buffer t) ))))))) Loading Loading @@ -708,10 +708,10 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" "Like `read-string', but return nil if user execute `keyboard-quit' when input." (condition-case nil (read-string interactive-string) (quit nil))) (defun eaf-input-message (eaf-buffer-id interactive-string callback-type) (defun eaf-input-message (eaf--buffer-id interactive-string callback-type) (let* ((input-message (eaf-read-string interactive-string))) (when input-message (eaf-call "handle_input_message" eaf-buffer-id callback-type input-message) (eaf-call "handle_input_message" eaf--buffer-id callback-type input-message) ))) (dbus-register-signal Loading Loading @@ -739,7 +739,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (let* ((buffer (eaf-create-buffer url app-name)) buffer-result) (with-current-buffer buffer (setq buffer-result (eaf-call "new_buffer" eaf-buffer-id url app-name arguments))) (setq buffer-result (eaf-call "new_buffer" eaf--buffer-id url app-name arguments))) (if (equal buffer-result "") (progn ;; Switch to new buffer if buffer create successful. Loading Loading @@ -930,7 +930,7 @@ Other files will open normally with `dired-find-file' or `dired-find-alternate-f (y (nth 1 window-allocation)) (w (nth 2 window-allocation)) (h (nth 3 window-allocation))) (format "%s:%s:%s:%s:%s" eaf-buffer-id x y w h))) (format "%s:%s:%s:%s:%s" eaf--buffer-id x y w h))) ;;;;;;;;;;;;;;;;;;;; Advice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defadvice scroll-other-window (around eaf-scroll-up-or-next-page activate) Loading Loading
eaf.el +16 −16 Original line number Diff line number Diff line Loading @@ -94,7 +94,7 @@ map) "Keymap used by `eaf-mode'.") (defvar-local eaf-buffer-id nil (defvar-local eaf--buffer-id nil "Internal id used by eaf app.") (define-derived-mode eaf-mode text-mode "EAF" Loading @@ -106,7 +106,7 @@ (setq mode-name "EAF") ;; Split window combinations proportionally. (setq window-combination-resize t) (set (make-local-variable 'eaf-buffer-id) (eaf-generate-id)) (set (make-local-variable 'eaf--buffer-id) (eaf-generate-id)) ;; Load local map. (use-local-map eaf-mode-map) ;; Fix #110 , make `eaf-monitor-key-event' buffer locally to pre-command-hook of the eaf-mode buffer. Loading Loading @@ -418,13 +418,13 @@ Use `eaf-execute-app-cmd' if you want to execute this command programmatically. Please ONLY use `eaf-bind-key' to edit EAF keybindings!" (interactive) ;; ensure this is only called from eaf buffer (unless (boundp 'eaf-buffer-id) (unless (boundp 'eaf--buffer-id) (error "%s command can only be called in eaf buffer" sym)) ;; Enable the command to be called by M-x or from lisp code in ;; the case that this command isn't invoked by key-sequence. (when (and (eq this-command sym) (not (equal (this-command-keys-vector) key))) (eaf-call "execute_function" eaf-buffer-id fun))))) (eaf-call "execute_function" eaf--buffer-id fun))))) (defun eaf-gen-keybinding-map (keybinding) "Configure the eaf-mode-map from KEYBINDING, one of the eaf-*-keybinding variables." Loading Loading @@ -485,7 +485,7 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!" (w (nth 2 window-allocation)) (h (nth 3 window-allocation)) ) (add-to-list 'view-infos (format "%s:%s:%s:%s:%s:%s" eaf-buffer-id (eaf-get-emacs-xid frame) x y w h)) (add-to-list 'view-infos (format "%s:%s:%s:%s:%s:%s" eaf--buffer-id (eaf-get-emacs-xid frame) x y w h)) )))))) ;; I don't know how to make emacs send dbus-message with two-dimensional list. ;; So i package two-dimensional list in string, then unpack on server side. ;) Loading Loading @@ -521,8 +521,8 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!" (run-with-timer 1 nil (lambda () (eaf-org-killed-buffer-clean))) )) ((derived-mode-p 'eaf-mode) (eaf-call "kill_buffer" eaf-buffer-id) (message (format "Kill %s" eaf-buffer-id))) (eaf-call "kill_buffer" eaf--buffer-id) (message (format "Kill %s" eaf--buffer-id))) )))) (defun eaf-monitor-buffer-save () Loading Loading @@ -551,14 +551,14 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!" t) ;; Call function on the Python side if matched key in the keybinding. ((eaf-identify-key-in-app key-command buffer-app-name) (eaf-call "execute_function" eaf-buffer-id (eaf-call "execute_function" eaf--buffer-id (cdr (assoc key-desc (eaf-get-app-bindings buffer-app-name))))) ;; Send key to Python side if key-command is single character key. ((or (equal key-command "self-insert-command") (equal key-command "completion-select-if-within-overlay") (equal key-command "nil") (member key-desc eaf-single-key-list)) (eaf-call "send_key" eaf-buffer-id key-desc)) (eaf-call "send_key" eaf--buffer-id key-desc)) (t nil))))) Loading Loading @@ -635,7 +635,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (let ((eaf-buffer (generate-new-buffer (concat "Browser Popup Window " new-window-buffer-id)))) (with-current-buffer eaf-buffer (eaf-mode) (set (make-local-variable 'eaf-buffer-id) new-window-buffer-id) (set (make-local-variable 'eaf--buffer-id) new-window-buffer-id) (set (make-local-variable 'buffer-url) "") (set (make-local-variable 'buffer-app-name) "browser")) (switch-to-buffer eaf-buffer))) Loading @@ -650,7 +650,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (dolist (buffer (buffer-list)) (set-buffer buffer) (when (equal major-mode 'eaf-mode) (when (string= eaf-buffer-id kill-buffer-id) (when (string= eaf--buffer-id kill-buffer-id) (kill-buffer buffer) (message (format "Request kill buffer %s" kill-buffer-id)) (throw 'found-match-buffer t)))))) Loading @@ -677,7 +677,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (with-current-buffer buffer (when (and (derived-mode-p 'eaf-mode) (equal eaf-buffer-id bid)) (equal eaf--buffer-id bid)) (rename-buffer (truncate-string-to-width title eaf-title-length)) (throw 'find-buffer t) ))))))) Loading Loading @@ -708,10 +708,10 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" "Like `read-string', but return nil if user execute `keyboard-quit' when input." (condition-case nil (read-string interactive-string) (quit nil))) (defun eaf-input-message (eaf-buffer-id interactive-string callback-type) (defun eaf-input-message (eaf--buffer-id interactive-string callback-type) (let* ((input-message (eaf-read-string interactive-string))) (when input-message (eaf-call "handle_input_message" eaf-buffer-id callback-type input-message) (eaf-call "handle_input_message" eaf--buffer-id callback-type input-message) ))) (dbus-register-signal Loading Loading @@ -739,7 +739,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)" (let* ((buffer (eaf-create-buffer url app-name)) buffer-result) (with-current-buffer buffer (setq buffer-result (eaf-call "new_buffer" eaf-buffer-id url app-name arguments))) (setq buffer-result (eaf-call "new_buffer" eaf--buffer-id url app-name arguments))) (if (equal buffer-result "") (progn ;; Switch to new buffer if buffer create successful. Loading Loading @@ -930,7 +930,7 @@ Other files will open normally with `dired-find-file' or `dired-find-alternate-f (y (nth 1 window-allocation)) (w (nth 2 window-allocation)) (h (nth 3 window-allocation))) (format "%s:%s:%s:%s:%s" eaf-buffer-id x y w h))) (format "%s:%s:%s:%s:%s" eaf--buffer-id x y w h))) ;;;;;;;;;;;;;;;;;;;; Advice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (defadvice scroll-other-window (around eaf-scroll-up-or-next-page activate) Loading