Unverified Commit 95f03e7f authored by Clemens Radermacher's avatar Clemens Radermacher
Browse files

Use eaf prefix for dummy commands to avoid name conflicts

parent f10db6a1
Loading
Loading
Loading
Loading
+20 −14
Original line number Diff line number Diff line
@@ -402,8 +402,12 @@ buffer."
      (call-interactively cmd))))


(defun eaf-dummy-function (sym key)
  "Define an alias from SYM to a dummy function that acts as a placeholder."
(defun eaf-dummy-function (sym fun key)
  "Define elisp command SYM which can call python function FUN.

FUN is only called when command SYM is not invoked by KEY, thus
this command does nothing when `eaf-monitor-key-event' has
already handled it."
  (defalias sym (lambda nil
                   "This Lisp function is a placeholder, the actual function will be handled on the Python side.

@@ -417,15 +421,17 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
                   ;; 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" buffer-id (symbol-name sym))))))
                     (eaf-call "execute_function" buffer-id fun)))))

(defun eaf-gen-keybinding-map (keybinding)
  "Configure the eaf-mode-map from KEYBINDING, one of the eaf-*-keybinding variables."
  (setq eaf-mode-map
        (let ((map (make-sparse-keymap)))
          (cl-loop for (key . fun) in keybinding
                   do (eaf-dummy-function (intern fun) key)
                      (define-key map (kbd key) (intern fun))) map)))
                   do (let ((dummy (intern (format "eaf-%s" fun))))
                        (eaf-dummy-function dummy fun key)
                        (define-key map (kbd key) dummy))
                   finally return map))))

(defun eaf-get-app-bindings (app-name)
  (symbol-value