Comments (6)
Hi @awkspace,
There is no option for automating this use case via the package. We've had discussions about this use case in the past and decided that selecting, copying, and pasting was preferable to automation because it gives the user more control over how text is edited, but If you can think of a clever way of providing this feature in such a way that the hook function(s) have a say in whether or not to select and copy the text to the buffer, then I'd be open to adding this feature to the package.
The path of least resistance for your purposes might be to just wrap the shell script from this package with a tiny script of your own to do the select and copy steps. Then, paste to your Emacs buffer using the hook function.
from emacs-anywhere.
I thought I might just contribute my approach here. I also run into the situation where I want to over-write some text, and populate emacs-anywhere with it. I do this by selecting the text, which if you want to do in say a textbox is of course as easy as Ctrl A
, then add the following into my ea-popup-handler
hook:
(if (x-selection-exists-p 'PRIMARY)
(insert (x-selection)))
When exiting emacs, via default OS behaviour, the selection is overwritten 🎉.
from emacs-anywhere.
not sure if its' because I'm on OSX but your idea @tecosaur doesn't work for me.
I've tried:
(insert (gui-selection-value))
(insert (gui-get-selection 'PRIMARY))
(insert (x-get-selection 'PRIMARY))
even with the when
clause:
(when (gui-get-primary-selection)
(insert (gui-get-selection 'PRIMARY)))
it doesn't work, my doom-emacs closes the window immediately, not sure why apparently the call to (gui-get-selection 'PRIMARY)
makes the frame to close
from emacs-anywhere.
@d1egoaz I went through a few iterations after that initial comment, I now have
(when (gui-get-selection 'PRIMARY)
(insert (gui-get-selection 'PRIMARY)))
Which works for me. I'm on linux though so...
from emacs-anywhere.
yeah, it doesn't work for OSX 😞
from emacs-anywhere.
I've got another iteration of this to make up for (gui-get-selection 'PRIMARY)
often giving a bogus non-active selection, thanks to some help I got.
(defun ea-popup-handler (app-name window-title x y w h)
;; other stuff here
(when (gui-get-selection 'PRIMARY) (insert (gui-get-selection 'PRIMARY)))
(set-transient-map (let ((keymap (make-sparse-keymap)))
(define-key keymap (kbd "DEL") (lambda! (delete-region (point-min) (point-max))))
(define-key keymap (kbd "C-SPC") (lambda! (delete-region (point-min) (point-max))))
keymap)))
Press DEL or C-SPC immidiately after pulling up EmacsAnywhere and it will clear the buffer.
You can find my complete config for EA here if it's of any use to anyone,
https://github.com/tecosaur/emacs-config/blob/e9a8ce2bff967436def88a75135fa4bbe6c86224/config.el#L155-L215
from emacs-anywhere.
Related Issues (20)
- Do not hardcore installation directory HOT 3
- Does not work with the freecodecamp editor HOT 2
- Does this work on mojave? HOT 4
- Question: How to launch under cursor? HOT 6
- More robust pasting HOT 1
- How to define my keyborad shortcut HOT 1
- README should be more clear about where to put configuration
- Paste not working when there is a physical key pressed HOT 1
- Mac
- Macos HOT 1
- Would you recommend an especific keybinding (shortcut) on macOS?
- Is emacs-anywhere compatible with tiling window managers?
- Is it really necessary to use `C-x 5 0`? Why can't I use classic `C-x C-x` to quit? HOT 2
- Please, package this for NixOS
- Is it possible to configure emacs-anywhere with Karabiner-elements instead of setting a hotkey via the GUI SystemPreferences/keyboard/shortcuts/services/general?
- Feature request: save content of frame on kill ring before it is deletion
- Feature request: bring content already written on the text box to the frame created by Emacs Anywhere
- Thank you
- trouble on ubuntu 22.04
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emacs-anywhere.