# Emacs everywhere rewrite?

**URL:** <https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526>\
**Category:** Emacs Lisp\
**Created:** [March 31, 2025, 6:09am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526 "2025-03-31T06:09:32Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [March 31, 2025, 6:09am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/1 "2025-03-31T06:09:32Z")

</div>

I used Emacs Everywhere on KDE and it worked well. However, since I  
moved to Sway, it has been a struggle to get it working. I eventually  
gave up on trying to make it work and wrote this [make shift version](https://codeberg.org/tusharhero/ecfpaw/src/branch/master/config.org#headline-157) in  
my configuration instead.

My makeshift version currently types the content into the window  
below. It seems to work well on Sway, since it automatically switches  
focus to the correct text area after the frame is deleted. Emacs  
Everywhere copies the text into the clipboard and then pastes it into  
the text area; I think it also manually switches focus.

I was wondering if I should create a separate package for this,  
exclusive to Sway or potentially other Wayland compositors, provided  
it doesn’t require too much work.

---

<div class="post-metadata">

**Author:** ![zororg](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@zororg](https://forum.systemcrafters.net/u/zororg)\
**Post date:** [April 2, 2025, 5:44am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/2 "2025-04-02T05:44:40Z")

</div>

I was looking forward for this PR; [Dotool support by msin32 · Pull Request #92 · tecosaur/emacs-everywhere · GitHub](https://github.com/tecosaur/emacs-everywhere/pull/92)

I use niri as wm. Maybe with few tweaks we can get it working.

But previously to get similar functionality, I was using a custom keybind in WM to open emacsclient on some tmp/scratch file. Then with save and exit, wtype or dotool would insert those content into the browser or wherever focus is.

But still i dont find usecase for it, as I always have emacs window open. Manually i just do copy and paste if I really need emacs editing.

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 2, 2025, 9:52am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/3 "2025-04-02T09:52:27Z")

</div>

> I use niri as wm. Maybe with few tweaks we can get it working.

I think the current code will just work™.

> But previously to get similar functionality, I was using a custom  
> keybind in WM to open emacsclient on some tmp/scratch file. Then with  
> save and exit, wtype or dotool would insert those content into the  
> browser or wherever focus is.

I never save, I directly ask wtype to write the contents of the buffer  
into whatever the focus is. I do not like the copy paste nature of  
emacs-everywhere, because it is not universal (many programs have  
different keybindings for copy-paste).

> But still i dont find usecase for it, as I always have emacs window  
> open. Manually i just do copy and paste if I really need emacs  
> editing.

Same here, but emacs-everywhere is just more convenient. I can say  
that after using my make-shift version for a while.

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 9, 2025, 4:03am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/4 "2025-04-09T04:03:14Z")

</div>

@zororg, Did you try it out yet?

---

<div class="post-metadata">

**Author:** ![zororg](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@zororg](https://forum.systemcrafters.net/u/zororg)\
**Post date:** [April 16, 2025, 4:36pm UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/5 "2025-04-16T16:36:14Z")

</div>

Hey Hi. Sorry for delayed response.

Ya i tried your make shift version which works like charm.

I could not get emacs-everywhere, since I use niri wm, I need to write own function.

Thank for the heads up, I think I will make use of it

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 19, 2025, 10:10am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/6 "2025-04-19T10:10:45Z")

</div>

If it works like a charm, why do you need to write own function? Can  
you clarify what adjustments you had to make?

---

<div class="post-metadata">

**Author:** ![zororg](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@zororg](https://forum.systemcrafters.net/u/zororg)\
**Post date:** [April 19, 2025, 11:14am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/7 "2025-04-19T11:14:32Z")

</div>

Thats not what I meant.  
I meant, your make-shift version (ECFPAW/ee) works like charm. Instead of wtype I replaced it with dotool.

> I could not get emacs-everywhere, since I use niri wm, I need to write own function.

Then I meant, with OG emacs-everywhere package by tecosaur, it did not work. Since it only has functions for Sway and KDE.  
Some custom function is required to get windows from WM i guess.

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 19, 2025, 11:37am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/8 "2025-04-19T11:37:57Z")

</div>

> [@zororg](#):
>
> dotool

Wow, didn’t know about it.

Do you think we should package this code separately? I guess we can  
make it support both `wtype` and `dotool`. I think `tinee` (This Is Not  
Emacs Everywhere), as in it is not as featureful as Emacs Everywhere,  
but it is tiny as a result, is a good name.

---

<div class="post-metadata">

**Author:** ![zororg](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@zororg](https://forum.systemcrafters.net/u/zororg)\
**Post date:** [April 20, 2025, 8:17am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/9 "2025-04-20T08:17:42Z")

</div>

Yeah sounds good.  
You can make it as package, support it with an blog post (or readme) and share with emacs community (reddit & mailing lists)

Edit: A caution: I have to admit that this might have unexpected outcome as well.

I think it was due to how dotool works or it did not read string properly.  
I had different keybindings pressed doing many things to my system.  
I guess it was due to not double quoting my input (bash) and word splitting

---

<div class="post-metadata">

**Author:** ![zororg](https://avatars.discourse-cdn.com/v4/letter/z/8e7dd6/32.png) [@zororg](https://forum.systemcrafters.net/u/zororg)\
**Post date:** [April 20, 2025, 9:10am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/10 "2025-04-20T09:10:50Z")

</div>

okay, as I try it again. Looking at emacs-everywhere code, I think copy to clipboard is reliable than auto typing the content.

I make use of [GitHub - sentriz/cliphist: Wayland clipboard manager with support for multimedia](https://github.com/sentriz/cliphist) (cliphist) very much with fuzzel.  
So I modified it in a way that creates files in tmp dir, and copies the content to kill-ring.

Here is my version: [d-nix/d-setup.org at gol-d · idlip/d-nix · GitHub](https://github.com/idlip/d-nix/blob/gol-d/d-setup.org#emacs-write-anywhere)

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 20, 2025, 9:23am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/11 "2025-04-20T09:23:54Z")

</div>

Happens to me sometimes as well. Also, just pass the arguments  
directly instead of going through the shell.

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 20, 2025, 9:27am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/12 "2025-04-20T09:27:43Z")

</div>

Even if we were to do it. Why not do it like this?

1. Call `gui-select-text` with buffer text.
2. Run C-v using wtype.

Why do you need to go through, a temp file, another external program,  
etc?

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 23, 2025, 9:58am UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/13 "2025-04-23T09:58:40Z")

</div>

```lisp
(defun ECFPAW/ee-paste (string)
  "Paste STRING into Wayland windows from within Emacs."
  (let ((select-enable-primary t)
	(select-enable-secondary nil))
    (gui-select-text string))
  (start-process "ee-paste" nil 
		 "wtype" "-s" "500" "-M" "Shift" "-P" "Insert"
		 "-m" "Shift" "-p" "Insert"))

(defun ECFPAW/ee-done (&optional arg)
  "Write the current buffer using `ECFPAW/ee-write'.

  If ARG is 4, export the buffer as Markdown. Otherwise, directly use
  the org markup.

  This function deletes the current frame after pasting the text."
  (interactive "p")
  (require 'ox-md)
  (let* ((raw-text (buffer-substring-no-properties (point-min) (point-max)))
	 ;; No idea why the 3rd argument of `org-export-with-toc' doesn't work for this.
	 (org-export-with-toc nil)
	 (text (pcase arg
		 (4 (org-export-string-as raw-text 'md t))
		 (_ raw-text))))
    (delete-frame)
    (ECFPAW/ee-paste text)))

(define-minor-mode ECFPAW/ee-mode
  "ee minor mode"
  :keymap `((,(kbd "C-c C-c") . ECFPAW/ee-done)))

(defun ECFPAW/ee ()
  "Start ee."
  (with-current-buffer
      (get-buffer-create (format "ee-%d"
				 (time-convert (current-time) 'integer)))
    (org-mode)
    (ECFPAW/ee-mode)
    (modify-frame-parameters
     (make-frame '((name . "ee -float-")))
     '((width . 80)
       (height . 20)))))

```

Can you try this out? I tried implementing the copy paste version. But  
it doesn’t work for firefox (works on other windows).

---

<div class="post-metadata">

**Author:** ![tusharhero](https://avatars.discourse-cdn.com/v4/letter/t/e99b99/32.png) [@tusharhero](https://forum.systemcrafters.net/u/tusharhero)\
**Post date:** [April 23, 2025, 4:40pm UTC](https://forum.systemcrafters.net/t/emacs-everywhere-rewrite/1526/14 "2025-04-23T16:40:27Z")

</div>

Actually, just try the package instead:

> **[tinee](https://codeberg.org/tusharhero/tinee)**
>
> tinee

You can configure which method it uses.
