tecosaur / emacs-everywhere

Mirror of https://git.tecosaur.net/tec/emacs-everywhere
GNU General Public License v3.0
554 stars 58 forks source link

Error when trying to write in apps #3

Open innerout opened 3 years ago

innerout commented 3 years ago

When invoking emacs-everywhere in any app and trying to paste the written text from Emacs in the apps the following error is thrown.

call-process: Wrong type argument: numberp, nil

I have all the tools in the README installed. I am using doom-emacs with Emacs 27.1 in Archlinux with the latest doom commit.

tecosaur commented 3 years ago

Hello :)

Thanks for the info on your system, that's quite helpful. call-process is used in a few places though so if you could get your hands on a backtrace (setq debug-on-error t) that would be most helpful.

innerout commented 3 years ago

Hi, the error thrown when setting debug-on-error:

Debugger entered--Lisp error: (wrong-type-argument numberp nil)
  number-to-string(nil)
  (call-process "xdotool" nil nil nil "windowactivate" "--sync" (number-to-string emacs-everywhere-window-id))
  (if (eq system-type 'darwin) (call-process "osascript" nil nil nil "-e" (format "tell application \"%s\" to activate" emacs-everywhere-app-name)) (call-process "xdotool" nil nil nil "windowactivate" "--sync" (number-to-string emacs-everywhere-window-id)))
  emacs-everywhere-finish()
  (if (and (eq major-mode 'org-mode) (org-in-src-block-p)) (org-ctrl-c-ctrl-c) (emacs-everywhere-finish))
  (closure (t) nil (interactive) (if (and (eq major-mode 'org-mode) (org-in-src-block-p)) (org-ctrl-c-ctrl-c) (emacs-everywhere-finish)))()
  funcall-interactively((closure (t) nil (interactive) (if (and (eq major-mode 'org-mode) (org-in-src-block-p)) (org-ctrl-c-ctrl-c) (emacs-everywhere-finish))))
  call-interactively((closure (t) nil (interactive) (if (and (eq major-mode 'org-mode) (org-in-src-block-p)) (org-ctrl-c-ctrl-c) (emacs-everywhere-finish))) nil nil)
  command-execute((closure (t) nil (interactive) (if (and (eq major-mode 'org-mode) (org-in-src-block-p)) (org-ctrl-c-ctrl-c) (emacs-everywhere-finish))))
tecosaur commented 3 years ago

Ah! Interesting. Could you check the value of emacs-everywhere-window-id for me? (while in an Emacs Everywhere generated buffer).

innerout commented 3 years ago

The value of emacs-everywhere-window-id is nil .

tecosaur commented 3 years ago

As I suspected from your backtrace :thinking:. Some more requests:

innerout commented 3 years ago

(emacs-everywhere-window-info-linux) output ("Emacs" 75497646 "Emacs Everywhere :: Google-chrome — Error when trying to write in apps - Issue #…" 2 58 1916 1020) xdotool getactivewindow output 88080394 (emacs-everywhere-call "xdotool" "getactivewindow") output "75497646"

tecosaur commented 3 years ago

Interesting. It seems like emacs-everywhere-window-id should be set then. If you call (emacs-everywhere) within your current Emacs does it work? From the info you just gave me it looks like it should.

innerout commented 3 years ago

No, it does not work it throws call-process: Wrong type argument: numberp, nil .

tecosaur commented 3 years ago

Hmmmmmmm. This is beginning to confound me. Could you try re-defining the emacs-everywhere function as

(defun emacs-everywhere ()
  "Lanuch the emacs-everywhere frame from emacsclient."
  (let ((win-info (emacs-everywhere-window-info)))
    (pp win-info)
    (message "cmd: emacsclient -c -F %s --eval %s"
             (prin1-to-string emacs-everywhere-frame-parameters)
             (prin1-to-string
              `(emacs-everywhere-initialise ,@win-info)))
    (call-process "emacsclient" nil 0 nil
                  "-c" "-F" (prin1-to-string emacs-everywhere-frame-parameters)
                  "--eval" (prin1-to-string
                            `(emacs-everywhere-initialise ,@win-info)))))

Then, re-testing this by executing (emacs-everywhere), looking in *Messages* and let me know what you find. I'm looking for something like:

("Emacs" 75509290 " *Minibuf-1* \342\227\211 emacs-everywhere" 2723 128 1996 792)

cmd: emacsclient -c -F ((name . "emacs-everywhere") (width . 80) (height . 12)) --eval (emacs-everywhere-initialise "Emacs" 75509290 " *Minibuf-1* \342\227\211 emacs-everywhere" 2723 128 1996 792)
innerout commented 3 years ago

When trying to execute emacs-everywhere the following error is thrown

Debugger entered--Lisp error: (void-function emacs-everywhere-window-info)
  (emacs-everywhere-window-info)
  (let ((win-info (emacs-everywhere-window-info))) (pp win-info) (message "cmd: emacsclient -c -F %s --eval %s" (prin1-to-string emacs-everywhere-frame-parameters) (prin1-to-string (cons 'emacs-everywhere-initialise win-info))) (call-process "emacsclient" nil 0 nil "-c" "-F" (prin1-to-string emacs-everywhere-frame-parameters) "--eval" (prin1-to-string (cons 'emacs-everywhere-initialise win-info))))
  emacs-everywhere()
  eval((emacs-everywhere) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)
tecosaur commented 3 years ago

Ah, when it's redefined it won't be autoloader, so try (require 'emacs-everywhere) first.

innerout commented 3 years ago

OK the error is not thrown anymore but nothing is printed in Messages.

tecosaur commented 3 years ago

Erm, this should be functionally identical just with some logging. For a particular Emacs instance, you're running (emacs-everywhere) and checking *Messages* in that same instance (not the popup), yes?

innerout commented 3 years ago

Yes, I am checking the same Emacs instance, only a nil is printed but I don't know if it is from your code.

tecosaur commented 3 years ago

@innerout can you check to see if you still have this issue?

innerout commented 3 years ago

It does not throw call-process: Wrong type argument: numberp, nil anymore but when I close the frame it does not paste the text back. When I press C-c C-c or C-x 5 0 the same error is thrown. By mistake, I pressed C-x C-c previously when I wrote the initial message.

tecosaur commented 3 years ago

Thanks for the update @innerout. I wish I knew how to proceed, but I've never seen that behaviour and am at a bit of a loss :sweat_smile:.

innerout commented 3 years ago

What information could I provide that may help you solve this?

innerout commented 3 years ago

@tecosaur The only thing that may impact the plugin is that I am using i3+Gnome as my DE, which I never had a problem with. Could something not be registered as it should from the DE that you expect to be initialized, which messes the whole process? The weird thing is that emacs-anywhere works as it should without any problem occurring.

tecosaur commented 3 years ago

The best way to proceed is probably going back to https://github.com/tecosaur/emacs-everywhere/issues/3#issuecomment-775397180. Given that there are (message ...) lines, there should either be content printed to *Messages* or an error.