emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possibility to copy text outside EMACS and send it to orgmode docume


From: Gerardo Moro
Subject: Re: Possibility to copy text outside EMACS and send it to orgmode document
Date: Wed, 6 Jan 2021 22:46:10 +0200

This is very cool, thanks, and I very much use Automator.
I will have a look later, but it seems that you have to move focus to Emacs, so it does not directly send something to a orgmode document straight from the copy action in the browser.

El mié, 6 ene 2021 a las 17:56, Tim Visher (<tim.visher@gmail.com>) escribió:
On Wed, Jan 6, 2021 at 1:43 AM Gerardo Moro <gerardomoro37@gmail.com> wrote:
Basically that: as I copy (Control-C) text from the browser (Chrome), I would like those copied sentences to be sent to a ordered list in an OrgMode document:

- copied text 1
- copied text 2
- etc.

Any ideas? This would be very useful.

On macOS I've done _similar_  things to this (albeit not exactly what you're asking) by simply generating org text for me to paste in.

For instance I have an applescript `org-current-tab`:

```

on org_current_tab()
    tell application "Google Chrome"
        set the_title to title of active tab of front window
        set the_title to my replace_chars(the_title, "[", " ")
        set the_title to my replace_chars(the_title, "]", " ")
        return "[[" & URL of active tab of front window & "][" & the_title & "]]" as text
    end tell
end org_current_tab

```

Then from anywhere I can activate this applescript and all I need to do is whack `C-y` in emacs and I get the link pasted in.

It's not hard then to extend this directly into emacs via the `osascript` executable:

```
(defun org-current-tab
    ()
  (interactive)
  (unless (eq major-mode 'org-mode)
    (user-error "This command must be triggered in an org buffer."))
  (let* ((output (with-temp-buffer
                   (call-process
                    "osascript" nil t nil
                    "-e" "tell application \"Finder\" to set current_tab_handlers to (load script file \"current_tab_handlers.scpt\" of folder \"Dropbox\" of home as alias)"
                    "-e" "tell current_tab_handlers to org_current_tab()")
                   (substring-no-properties (thing-at-point 'line t) 0 -1))))
    (insert output)))

```

I'm not sure what environment you're in so you may not have access to a system's scripting tool like Applescript but depending on the scripting facilities of whatever you're targeting maybe you can get most of the way there. At the worst you could add whatever text you want to your clipboard and then write some elisp that processes it before writing it to your org buffer.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]