[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: idea for capture anywhere in x
From: |
Jean Louis |
Subject: |
Re: idea for capture anywhere in x |
Date: |
Sun, 9 Oct 2022 17:47:07 +0300 |
User-agent: |
Mutt/2.2.7+37 (a90f69b) (2022-09-02) |
* Samuel Wales <samologist@gmail.com> [2022-06-10 05:37]:
> with the org capture firefox extension broken, i recalled this old
> thread, thinking it might be a fix, and i think i understand the
> issue. so i thought i would summarize here in this one post.
>
> i think i was not clear in this thread in a few places. apologies for that.
>
> 1.
>
> [current need, urgent] i want to select text with mouse in firefox,
> then have plain text and url save to an org entry.
>
> this would then replace the need for the firefox org-capture
> extension.
I have basic concept to capture X selection in file and get it in
Emacs. It is not really related to Org, one can capture X selection
and record it anyhow. There is no need for org-protocol this way.
File: ~/bin/capture-x-selection.sh
#!/usr/bin/bash
TEMP=/tmp/xselection.txt
xsel -o > $TEMP
emacsclient -e "(rcd-handle-x-selection)"
Settings in my IceWM window manager, in the file: ~/.icewm/keys:
key Ctrl+F9 /home/data1/protected/bin/rcd/capture-x-selection.sh
That means anywhere in X I press C-F9 and will invoke the function
'rcd-handle-x-selection
(defun rcd-handle-x-selection ()
"Sample function to read X selection from file and switch to buffer."
(raise-frame)
(let* ((my-org-files '("~/myorg1.org" "~/myorg2.org"))
(my-org-file (completing-read "Choose Org file: " my-org-files)))
(find-file my-org-file)
(goto-char (point-max))
(rcd-my-note)
(save-some-buffers t)))
(define-skeleton rcd-my-note
"Fill template by using variables"
nil
"** " (skeleton-read "Heading: ") "\n\n"
(skeleton-read "Describe this capture: ")
(when (file-exists-p "/tmp/xselection.txt")
(with-temp-buffer
(insert-file-contents "/tmp/xselection.txt")
(buffer-string)))
"\n\n")
I could as well connect it to org-protocol, but I ask myself why, as I
do not append stuff to Org files, I don't like feeling maltreated by
limitations of Org programs. 👀
Workflow:
Condition is to use Emacs server with emacsclient.
1. Mark anything in X like any selection;
2. Press your favorite key binding in the X manager like Ctrl-F9
3. Emacs appears and runs skeleton rcd-my-note which in this case does
something similar like Org, but it is not related to Org
really. One can as well make this way Markdown notes or any other
types of notes by using Emacs.
Let us say this way for Asciidoc notes:
---------------------------------------
File: ~/bin/capture-x-selection.sh
#!/usr/bin/bash
TEMP=/tmp/xselection.txt
xsel -o > $TEMP
emacsclient -e "(rcd-handle-x-selection)"
Settings in my IceWM window manager, in the file: ~/.icewm/keys:
key Ctrl+F9 /home/data1/protected/bin/rcd/capture-x-selection.sh
(defun rcd-handle-x-selection ()
"Sample function to read X selection from file and switch to buffer."
(raise-frame)
(let* ((my-files '("~/mynotes1.adoc" "~/mynotes2.adoc"))
(my-file (completing-read "Choose Asciidoc file: " my-files)))
(find-file my-file)
(goto-char (point-max))
(rcd-my-note)
(save-some-buffers t)))
(define-skeleton rcd-my-note
"Fill template by using variables"
nil
"== " (skeleton-read "Heading: ") "\n\n"
(skeleton-read "Describe this capture: ")
(when (file-exists-p "/tmp/xselection.txt")
(with-temp-buffer
(insert-file-contents "/tmp/xselection.txt")
(buffer-string)))
"\n\n")
--
Jean
Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns
In support of Richard M. Stallman
https://stallmansupport.org/
- Re: idea for capture anywhere in x,
Jean Louis <=
- Re: idea for capture anywhere in x, Max Nikulin, 2022/10/09
- Re: idea for capture anywhere in x, Jean Louis, 2022/10/09
- Re: idea for capture anywhere in x, Max Nikulin, 2022/10/10
- Re: idea for capture anywhere in x, Jean Louis, 2022/10/10
- Re: idea for capture anywhere in x, Juan Manuel MacÃas, 2022/10/11
- Re: idea for capture anywhere in x, Samuel Wales, 2022/10/11
- Re: idea for capture anywhere in x, Max Nikulin, 2022/10/14
- Re: idea for capture anywhere in x, Samuel Wales, 2022/10/26
- Re: idea for capture anywhere in x, Ihor Radchenko, 2022/10/26
- Re: idea for capture anywhere in x, Samuel Wales, 2022/10/26