Giter VIP home page Giter VIP logo

Comments (6)

zachcurry avatar zachcurry commented on June 14, 2024

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.

tecosaur avatar tecosaur commented on June 14, 2024

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.

d1egoaz avatar d1egoaz commented on June 14, 2024

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.

tecosaur avatar tecosaur commented on June 14, 2024

@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.

d1egoaz avatar d1egoaz commented on June 14, 2024

yeah, it doesn't work for OSX 😞

from emacs-anywhere.

tecosaur avatar tecosaur commented on June 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.