From 22f2232c94ceabccdf8ecc60bb4a768a55da91cc Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 14 Dec 2019 14:10:17 -0500 Subject: [PATCH] Use eaf-- prefixes for all internal functions --- eaf.el | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/eaf.el b/eaf.el index c650053..0b56fe1 100644 --- a/eaf.el +++ b/eaf.el @@ -7,7 +7,7 @@ ;; Copyright (C) 2018, Andy Stewart, all rights reserved. ;; Created: 2018-06-15 14:10:12 ;; Version: 0.5 -;; Last-Updated: Fri Dec 13 22:57:38 2019 (-0500) +;; Last-Updated: Sat Dec 14 14:07:57 2019 (-0500) ;; By: Mingde (Matthew) Zeng ;; URL: http://www.emacswiki.org/emacs/download/eaf.el ;; Keywords: @@ -137,7 +137,7 @@ the app buffer has initialized." ;; FIXME: this changes this setting globally for the user ;; which may not want this, introduce EAF user option? (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)) (setq-local bookmark-make-record-function #'eaf--bookmark-make-record) ;; copy default value in case user already has bindings there (setq-local emulation-mode-map-alists @@ -480,7 +480,7 @@ We need calcuate render allocation to make sure no black border around render co (h (- (nth 3 window-edges) y))) (list x y w h))) -(defun eaf-generate-id () +(defun eaf--generate-id () (format "%04x-%04x-%04x-%04x-%04x-%04x-%04x" (random (expt 16 4)) (random (expt 16 4)) @@ -501,9 +501,9 @@ buffer." (call-interactively cmd)))) -(defun eaf-proxy-function (fun) - "Define elisp command which can call python function FUN." - (let ((sym (intern (format "eaf--proxy-%s" fun)))) +(defun eaf--make-proxy-function (fun) + "Define elisp command which can call python function string FUN." + (let ((sym (intern (format "eaf-proxy-%s" fun)))) (unless (fboundp sym) (defalias sym (lambda nil @@ -520,23 +520,23 @@ Please ONLY use `eaf-bind-key' and use the unprefixed command name (\"%s\") to edit EAF keybindings!" fun fun))) sym)) -(defun eaf-gen-keybinding-map (keybinding) +(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))) (set-keymap-parent map eaf-mode-map*) (cl-loop for (key . fun) in keybinding do (define-key map (kbd key) - (if (symbolp fun) fun (eaf-proxy-function fun))) + (if (symbolp fun) fun (eaf--make-proxy-function fun))) finally return map)))) -(defun eaf-get-app-bindings (app-name) +(defun eaf--get-app-bindings (app-name) (symbol-value (cdr (assoc app-name eaf-app-binding-alist)))) -(defun eaf-create-buffer (input-content app-name) +(defun eaf--create-buffer (input-content app-name) "Create an EAF buffer given INPUT-CONTENT and APP-NAME." - (eaf-gen-keybinding-map (eaf-get-app-bindings app-name)) + (eaf--gen-keybinding-map (eaf--get-app-bindings app-name)) (let* ((file-or-command-name (substring input-content (string-match "[^/]*/?$" input-content))) (eaf-buffer (generate-new-buffer (truncate-string-to-width file-or-command-name eaf-title-length)))) (with-current-buffer eaf-buffer @@ -629,6 +629,7 @@ to edit EAF keybindings!" fun fun))) (message (format "export %s to html" (buffer-file-name)))))) (defun eaf-send-key () + "Directly send key to EAF Python side." (interactive) (with-current-buffer (current-buffer) (eaf-call "send_key" eaf--buffer-id (key-description (this-command-keys-vector))))) @@ -648,7 +649,7 @@ Use it as (eaf-setq var val)" (defmacro eaf-bind-key (command key eaf-app-keybinding) "This function binds COMMAND to KEY in EAF-APP-KEYBINDING list. -COMMAND is a command with `eaf--proxy-' prefix found by calling +COMMAND is a command with `eaf-proxy-' prefix found by calling `eaf-describe-bindings' in an EAF buffer, but dropping the prefix. KEY is a string representing a sequence of keystrokes and events. @@ -735,8 +736,8 @@ This is used to bind key to EAF Python applications." #'eaf-focus-buffer) (defun eaf-start-finish () - "Call `eaf-open-internal' after receive `start_finish' signal from server process." - (eaf-open-internal eaf-first-start-url eaf-first-start-app-name eaf-first-start-arguments)) + "Call `eaf--open-internal' after receive `start_finish' signal from server process." + (eaf--open-internal eaf-first-start-url eaf-first-start-app-name eaf-first-start-arguments)) (dbus-register-signal :session "com.lazycat.eaf" "/com/lazycat/eaf" @@ -793,7 +794,7 @@ This is used to bind key to EAF Python applications." "com.lazycat.eaf" "input_message" #'eaf-input-message) -(defun eaf-send-var-to-python () +(defun eaf--send-var-to-python () "Send variables defined in `eaf-var-list' to the Python side." (eaf-call "store_emacs_var" (string-join (cl-loop for (key . value) in eaf-var-list @@ -802,10 +803,10 @@ This is used to bind key to EAF Python applications." (dbus-register-signal :session "com.lazycat.eaf" "/com/lazycat/eaf" "com.lazycat.eaf" "get_emacs_var" - #'eaf-send-var-to-python) + #'eaf--send-var-to-python) -(defun eaf-open-internal (url app-name arguments) - (let* ((buffer (eaf-create-buffer url app-name)) +(defun eaf--open-internal (url app-name arguments) + (let* ((buffer (eaf--create-buffer url app-name)) (buffer-result (with-current-buffer buffer (eaf-call "new_buffer" @@ -932,11 +933,11 @@ When called interactively, URL accepts a file that can be opened by EAF." (setq exists-eaf-buffer buffer) (throw 'found-match-buffer t))))) ;; Switch to exists buffer, - ;; if no match buffer found, call `eaf-open-internal'. + ;; if no match buffer found, call `eaf--open-internal'. (if exists-eaf-buffer (eaf--display-app-buffer app-name exists-eaf-buffer) - (eaf-open-internal url app-name arguments))) - ;; Record user input, and call `eaf-open-internal' after receive `start_finish' signal from server process. + (eaf--open-internal url app-name arguments))) + ;; Record user input, and call `eaf--open-internal' after receive `start_finish' signal from server process. (setq eaf-first-start-url url) (setq eaf-first-start-app-name app-name) (setq eaf-first-start-arguments arguments)