Add internal eaf prefixes for buffer-url and buffer-app-name

master
Clemens Radermacher 6 years ago
parent 8ce1355d03
commit 2b14daa424
No known key found for this signature in database
GPG Key ID: ADEDCAC15E317EA0
  1. 24
      eaf.el

@ -97,6 +97,12 @@
(defvar-local eaf--buffer-id nil (defvar-local eaf--buffer-id nil
"Internal id used by eaf app.") "Internal id used by eaf app.")
(defvar-local eaf--buffer-url nil
"The buffer url.")
(defvar-local eaf--buffer-app-name nil
"The buffer app name.")
(define-derived-mode eaf-mode text-mode "EAF" (define-derived-mode eaf-mode text-mode "EAF"
"Major mode for Emacs Application Framework." "Major mode for Emacs Application Framework."
;; Kill all local variables first. ;; Kill all local variables first.
@ -543,16 +549,16 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
(key-desc (key-description key))) (key-desc (key-description key)))
;; Uncomment for debug. ;; Uncomment for debug.
;; (message (format "!!!!! %s %s %s %s %s" key key-command key-desc buffer-app-name)) ;; (message (format "!!!!! %s %s %s %s %s" key key-command key-desc eaf--buffer-app-name))
(cond (cond
;; Fix #51 , don't handle F11 to make emacs toggle frame fullscreen status successfully. ;; Fix #51 , don't handle F11 to make emacs toggle frame fullscreen status successfully.
((equal key-desc "<f11>") ((equal key-desc "<f11>")
t) t)
;; Call function on the Python side if matched key in the keybinding. ;; Call function on the Python side if matched key in the keybinding.
((eaf-identify-key-in-app key-command buffer-app-name) ((eaf-identify-key-in-app key-command eaf--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))))) (cdr (assoc key-desc (eaf-get-app-bindings eaf--buffer-app-name)))))
;; Send key to Python side if key-command is single character key. ;; Send key to Python side if key-command is single character key.
((or (equal key-command "self-insert-command") ((or (equal key-command "self-insert-command")
(equal key-command "completion-select-if-within-overlay") (equal key-command "completion-select-if-within-overlay")
@ -636,8 +642,8 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)"
(with-current-buffer eaf-buffer (with-current-buffer eaf-buffer
(eaf-mode) (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 'eaf--buffer-url) "")
(set (make-local-variable 'buffer-app-name) "browser")) (set (make-local-variable 'eaf--buffer-app-name) "browser"))
(switch-to-buffer eaf-buffer))) (switch-to-buffer eaf-buffer)))
(dbus-register-signal (dbus-register-signal
@ -744,8 +750,8 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)"
(progn (progn
;; Switch to new buffer if buffer create successful. ;; Switch to new buffer if buffer create successful.
(switch-to-buffer buffer) (switch-to-buffer buffer)
(set (make-local-variable 'buffer-url) url) (set (make-local-variable 'eaf--buffer-url) url)
(set (make-local-variable 'buffer-app-name) app-name) (set (make-local-variable 'eaf--buffer-app-name) app-name)
;; Focus to file window if is previewer application. ;; Focus to file window if is previewer application.
(when (or (string= app-name "markdown-previewer") (when (or (string= app-name "markdown-previewer")
(string= app-name "org-previewer")) (string= app-name "org-previewer"))
@ -841,8 +847,8 @@ When called interactively, URL accepts a file that can be opened by EAF."
(dolist (buffer (buffer-list)) (dolist (buffer (buffer-list))
(set-buffer buffer) (set-buffer buffer)
(when (equal major-mode 'eaf-mode) (when (equal major-mode 'eaf-mode)
(when (and (string= buffer-url url) (when (and (string= eaf--buffer-url url)
(string= buffer-app-name app-name)) (string= eaf--buffer-app-name app-name))
(setq exists-eaf-buffer buffer) (setq exists-eaf-buffer buffer)
(throw 'found-match-buffer t))))) (throw 'found-match-buffer t)))))
;; Switch to exists buffer, ;; Switch to exists buffer,

Loading…
Cancel
Save