emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Samuel Wales <samologist@gmail.com>
Cc: Nick Econopouly <wry@mm.st>, Maxim Nikulin <manikulin@gmail.com>,
	emacs-orgmode@gnu.org
Subject: Re: idea for capture anywhere in x
Date: Sun, 9 Oct 2022 17:47:07 +0300	[thread overview]
Message-ID: <Y0Le69MWpZSomdxz@protected.localdomain> (raw)
In-Reply-To: <CAJcAo8tdBaY81ft_h5yULbLu_JasmKw0R-sCqJr6+MMknV597A@mail.gmail.com>

* 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/


  parent reply	other threads:[~2022-10-09 14:48 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-08  4:22 idea for capture anywhere in x Samuel Wales
2020-09-08  5:01 ` Tim Cross
2020-09-08  5:05   ` Samuel Wales
2020-09-08  5:21     ` Tim Cross
2020-09-08  7:18       ` Maxim Nikulin
2020-09-08  8:03         ` Diego Zamboni
2020-09-08 16:08           ` Maxim Nikulin
2020-09-08  5:39     ` Maxim Nikulin
2020-09-08 22:40       ` Samuel Wales
2020-09-09  4:52         ` Maxim Nikulin
2020-09-10 14:23           ` Maxim Nikulin
2020-09-12  8:48             ` Nick Econopouly
2022-06-10  2:35               ` Samuel Wales
2022-06-10  9:59                 ` Charles Philip Chan
2022-06-11  4:11                 ` Ihor Radchenko
2022-06-13  7:46                 ` Max Nikulin
2022-06-13  9:10                 ` Michal Politowski
2022-06-13 10:04                   ` Max Nikulin
2022-06-13 14:02                     ` Michal Politowski
2022-10-12  1:09                       ` Samuel Wales
2022-10-09 14:47                 ` Jean Louis [this message]
2022-10-09 16:40                   ` Max Nikulin
2022-10-09 17:08                     ` Jean Louis
2022-10-10 17:16                       ` Max Nikulin
2022-10-10 22:06                         ` Jean Louis
2022-10-11  9:11                           ` Juan Manuel Macías
2022-10-12  1:09                             ` Samuel Wales
2022-10-15  3:40                               ` Max Nikulin
2022-10-26  4:40                                 ` Samuel Wales
2022-10-26  4:58                                   ` Ihor Radchenko
2022-10-26  5:05                                     ` Samuel Wales
2022-10-26  6:05                                       ` desktop notifications (Re: idea for capture anywhere in x) Max Nikulin
2022-10-26  6:22                                         ` Samuel Wales
2022-10-26  7:41                                           ` Max Nikulin
2022-10-26  8:07                                             ` Samuel Wales
2022-10-26  8:29                                               ` Max Nikulin
2022-10-27  6:33                                     ` Getting X selection reliably " Max Nikulin
2022-10-28  4:59                                       ` Samuel Wales
2022-10-28  5:16                                         ` Max Nikulin
2022-10-28  8:39                                           ` Dr. Arne Babenhauserheide
2022-10-28 16:38                                             ` Max Nikulin
2022-10-28 23:07                                               ` Samuel Wales
2022-10-29  3:21                                                 ` Max Nikulin
2022-10-29  2:59                                           ` Ihor Radchenko
2022-10-29  3:30                                             ` Max Nikulin
2022-10-29  6:03                                               ` Samuel Wales
2022-10-29  7:33                                                 ` Max Nikulin
2022-10-29 22:33                                                 ` Samuel Wales
2022-10-29  4:50                                             ` Samuel Wales
2022-10-29  4:59                                               ` Ihor Radchenko
2022-10-29  7:44                                                 ` desktop notifications " Max Nikulin
2022-10-29 23:07                                                   ` Samuel Wales
2022-10-30  4:49                                                     ` Ihor Radchenko
2022-11-13  4:54                                       ` Getting X selection reliably " Ihor Radchenko
2022-11-13 11:03                                         ` Max Nikulin
2022-11-14  2:06                                           ` Ihor Radchenko
2022-11-16  4:03                                             ` Samuel Wales
2022-11-16 16:46                                               ` Debugging firefox extension " Max Nikulin
2022-11-17  3:16                                                 ` Samuel Wales
2022-11-17  9:42                                                   ` Jean Louis
2022-11-17 16:12                                                   ` Max Nikulin
2022-11-17  7:18                                               ` Getting X selection reliably " Jean Louis
2022-11-17 15:30                                                 ` Reliability of org-protocol browser extensions Max Nikulin
2022-12-04  5:21                                             ` Getting X selection reliably (Re: idea for capture anywhere in x) Max Nikulin
2022-10-12 17:16                           ` idea for capture anywhere in x Max Nikulin
2022-10-12 20:06                             ` Jean Louis
2020-09-09  8:40     ` Russell Adams
2020-09-09 21:11       ` Samuel Wales
2020-09-09  1:07 ` Ihor Radchenko
     [not found] <mailman.51.1599580808.12104.emacs-orgmode@gnu.org>
2020-09-08 23:15 ` No Wayman
2020-09-13 20:29   ` Bastien
  -- strict thread matches above, loose matches on Subject: below --
2022-10-09 20:15 Ypo
2022-10-12  9:34 ` Ihor Radchenko
2022-10-12 10:43   ` Ypo
2022-10-12 11:37     ` Ihor Radchenko
2022-10-12 16:55       ` Jean Louis
2022-10-12 23:14         ` Ihor Radchenko
2022-10-13 11:16           ` Jean Louis
2022-10-12 14:22     ` Juan Manuel Macías

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y0Le69MWpZSomdxz@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    --cc=samologist@gmail.com \
    --cc=wry@mm.st \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).