Use internal double dash prefix

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

@ -94,7 +94,7 @@
map) map)
"Keymap used by `eaf-mode'.") "Keymap used by `eaf-mode'.")
(defvar-local eaf-buffer-id nil (defvar-local eaf--buffer-id nil
"Internal id used by eaf app.") "Internal id used by eaf app.")
(define-derived-mode eaf-mode text-mode "EAF" (define-derived-mode eaf-mode text-mode "EAF"
@ -106,7 +106,7 @@
(setq mode-name "EAF") (setq mode-name "EAF")
;; Split window combinations proportionally. ;; Split window combinations proportionally.
(setq window-combination-resize t) (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. ;; Load local map.
(use-local-map eaf-mode-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. ;; Fix #110 , make `eaf-monitor-key-event' buffer locally to pre-command-hook of the eaf-mode buffer.
@ -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!" Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
(interactive) (interactive)
;; ensure this is only called from eaf buffer ;; 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)) (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 ;; 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. ;; the case that this command isn't invoked by key-sequence.
(when (and (eq this-command sym) (when (and (eq this-command sym)
(not (equal (this-command-keys-vector) key))) (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) (defun eaf-gen-keybinding-map (keybinding)
"Configure the eaf-mode-map from KEYBINDING, one of the eaf-*-keybinding variables." "Configure the eaf-mode-map from KEYBINDING, one of the eaf-*-keybinding variables."
@ -485,7 +485,7 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
(w (nth 2 window-allocation)) (w (nth 2 window-allocation))
(h (nth 3 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. ;; 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. ;) ;; So i package two-dimensional list in string, then unpack on server side. ;)
@ -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))) (run-with-timer 1 nil (lambda () (eaf-org-killed-buffer-clean)))
)) ))
((derived-mode-p 'eaf-mode) ((derived-mode-p 'eaf-mode)
(eaf-call "kill_buffer" eaf-buffer-id) (eaf-call "kill_buffer" eaf--buffer-id)
(message (format "Kill %s" eaf-buffer-id))) (message (format "Kill %s" eaf--buffer-id)))
)))) ))))
(defun eaf-monitor-buffer-save () (defun eaf-monitor-buffer-save ()
@ -551,14 +551,14 @@ Please ONLY use `eaf-bind-key' to edit EAF keybindings!"
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 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 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")
(equal key-command "nil") (equal key-command "nil")
(member key-desc eaf-single-key-list)) (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 (t
nil))))) nil)))))
@ -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)))) (let ((eaf-buffer (generate-new-buffer (concat "Browser Popup Window " new-window-buffer-id))))
(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 'buffer-url) "")
(set (make-local-variable 'buffer-app-name) "browser")) (set (make-local-variable 'buffer-app-name) "browser"))
(switch-to-buffer eaf-buffer))) (switch-to-buffer eaf-buffer)))
@ -650,7 +650,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)"
(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 (string= eaf-buffer-id kill-buffer-id) (when (string= eaf--buffer-id kill-buffer-id)
(kill-buffer buffer) (kill-buffer buffer)
(message (format "Request kill buffer %s" kill-buffer-id)) (message (format "Request kill buffer %s" kill-buffer-id))
(throw 'found-match-buffer t)))))) (throw 'found-match-buffer t))))))
@ -677,7 +677,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)"
(with-current-buffer buffer (with-current-buffer buffer
(when (and (when (and
(derived-mode-p 'eaf-mode) (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)) (rename-buffer (truncate-string-to-width title eaf-title-length))
(throw 'find-buffer t) (throw 'find-buffer t)
))))))) )))))))
@ -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." "Like `read-string', but return nil if user execute `keyboard-quit' when input."
(condition-case nil (read-string interactive-string) (quit nil))) (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))) (let* ((input-message (eaf-read-string interactive-string)))
(when input-message (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 (dbus-register-signal
@ -739,7 +739,7 @@ Use it as (eaf-bind-key var key eaf-app-keybinding)"
(let* ((buffer (eaf-create-buffer url app-name)) (let* ((buffer (eaf-create-buffer url app-name))
buffer-result) buffer-result)
(with-current-buffer buffer (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 "") (if (equal buffer-result "")
(progn (progn
;; Switch to new buffer if buffer create successful. ;; Switch to new buffer if buffer create successful.
@ -930,7 +930,7 @@ Other files will open normally with `dired-find-file' or `dired-find-alternate-f
(y (nth 1 window-allocation)) (y (nth 1 window-allocation))
(w (nth 2 window-allocation)) (w (nth 2 window-allocation))
(h (nth 3 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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;; Advice ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defadvice scroll-other-window (around eaf-scroll-up-or-next-page activate) (defadvice scroll-other-window (around eaf-scroll-up-or-next-page activate)

Loading…
Cancel
Save