emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Max Nikulin <manikulin@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: idea for capture anywhere in x
Date: Tue, 11 Oct 2022 01:06:11 +0300	[thread overview]
Message-ID: <Y0SXU/xwhuTrZyms@protected.localdomain> (raw)
In-Reply-To: <ti1k28$7dm$1@ciao.gmane.io>

> Jean, make a pause and think ones more. It does not mean extra click
> and implies nothing different from you recipe.

Instead of thinking, I am doing it. 

Did you try to invoke Emacs without having Emacs in front of you? Once
you try, come back and tell me how would you capture anything from X
selection into Emacs without having Emacs window in front of you.

I do not know how. My thinking stops right there. 

I have four workspaces, Emacs is not on each of them. 

How do I invoke Emacs without having it in front of me with just 1 key
binding?

One solution is the one which I have presented, to configure desktop
environment short cut.

Here is updated bash file, as what if server does not run? Then Emacs
has to be invoked. You see, solution is there without loading many
packages.

Problem is that Emacs will still try to load
"(rcd-handle-x-selection)" as file, so the frame remains. Solution is
to (kill-emacs) after capturing, as it was invoked because there was
no server running, it capture the note in Org file and it can exit.

#!/usr/bin/bash
TEMP=/tmp/xselection.txt
xsel -o > $TEMP
# Because emacsclient has to create new frame if none exists
emacsclient -c  -a "emacs -q -l /home/admin/.emacs.d/capture.el" -e "(rcd-handle-x-selection)"

(defun rcd-handle-x-selection ()
  "Sample function to read X selection from file and switch to buffer."
  (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: ")
  (setq my-x
	(when (file-exists-p "/tmp/xselection.txt")
	  (with-temp-buffer
	    (insert-file-contents "/tmp/xselection.txt")
	    (buffer-string))))
  "\n\n")

(rcd-handle-x-selection)
(kill-emacs)

In fact that solution does not even need to have Emacs as server
running, emacs client may default to Emacs, without server.

1. If Emacs is in front of you, you are not in other window, so no
   bothering, and you can capture selection straight. That is what you
   are describing. I am describing contexts below.

2. If you are in other window, your key bindings will work on that
   other window, and not on Emacs, so you first need to find Emacs and
   that means using mouse or keys before you can invoke Emacs key
   binding to capture anything.

3. What if there are no Emacs frames visible? Your desktop environment
   shortcut will bring Emacs in front of you, provided you are running
   emacs server.

4. What if you are not running Emacs server? You do not need to, it
   will simply capture by invoking new Emacs instance, without loading
   your init files and what else.

Desktop shortcut or key binding is not Emacs keybinding. 

> Years ago I was taught to the following approach: when you came to a
> solution, look at it and try to figure out if it is possible to achieve the
> same in a shorter and more clear way.

Thanks, must be that you have better solution 👁️

> If `yank' command can get selection contents then you can do the same in
> your function and avoid problems with intermediate files.

Of course, however, for yank to work condition is that you have Emacs
in front of you. And if you wish to capture selection from other
windows, condition is that you need to use mouse to at least move
focus from other X program to Emacs and then invoke yank.

When you do not have Emacs in front of you, when you do not have
Emacs server running, that is when you can use desktop environment
shortcuts.

> In Org it can be achieved with a simple capture template (even org-protocol
> is not necessary), but you prefer your own solution having enough
> limitations.

Capturing notes shall not IMHO be limited to Org mode as that limits
users to specific lightweight markup language (Org).

> If Emacs had generic enough functions to create captures then Org would
> reuse it as it extends outline mode. Maybe such tools should be added to
> Emacs, but they should be designed at first.

The example given with skeleton function will work for any type of
files.

Though I find skeleton way too complicated for final users just as
org-capture templates. To tell that templates are simple is not
objective. Good that I don't use it.

And is THIS below for end users?

It requires thoroughly reading manual until end user can understand
that. That is not a just a simple template, it is configuration set.

Hide Org Capture Templates:
Repeat:
INS DEL Choice: Value Menu Template entry:
            Keys           : p
            Description    : Protocol
            Capture Type   : Value Menu Org entry
            Target location: Value Menu File & Headline:
            Filename       : Value Menu Literal: ~/Documents/Orgnotes.org
              Headline: Inbox
            Template       : Value Menu String: * %^{Title}
Source: %u, %c
 #+BEGIN_QUOTE
%i
#+END_QUOTE


%?
            Plist:
            [ ] Key: :prepend t
            [ ] Key: :immediate-finish t
            [ ] Key: :jump-to-captured t
            [ ] Key: :empty-lines 1
            [ ] Key: :empty-lines-before 1
            [ ] Key: :empty-lines-after 1
            [ ] Key: :clock-in t
            [ ] Key: :clock-keep t
            [ ] Key: :clock-resume t
            [ ] Key: :time-prompt t
            [ ] Key: :tree-type week
            [ ] Key: :unnarrowed t
            [ ] Key: :table-line-pos String: 
            [ ] Key: :kill-buffer t

And those functions above are nothing good for end users. In general
if your sibling, parent or child can't do it, forget it. 

I find such design rather misconduct of what user interface should
look like.

Good that there is plethora of normal and human friendly note taking
applifcations apart from Org, let us say such as Osmo which are
intuitive and easy to use for any person. It has 4 distinctive and
visible main features, calendar, tasks, contacts, notes. One can use
tags and categories. Cherrytree, Leoeditor, and bunch of others also
show how user interfaces shall look like. Literate programming
included.

https://www.youtube.com/results?search_query=cherrytree+editor

> A browser extension is a straightforward way to add page URL to the
> quoted text.

I don't know which quoted text you mean and how to add page URL to
quoted text.

Though I understand you wish to add some more text to your files. 

In general we need more interfaces and connections between various
formats and files. 

Example:
https://addons.mozilla.org/en-US/firefox/addon/websites-notes/

That extension is way quicker to add notes related to domains and
pages. It is not perfect, does not provide title, but it is quick, and
need no immediate Emacs.

Emacs has json parsing funtions built-in so export from that
application to Emacs notes, or Org mode or any kind of lightweight
markup is possible.

There is plethora of note taking applications for browser:
https://addons.mozilla.org/en-US/firefox/search/?q=notes

Many of them are very usable, beautiful, useful, handy, way faster,
with almost no configuration. 

It would be useful having interfaces or conversion from their formats
like SQLite, json, to text files like Org, markdown, Asciidoc, simple
text, other databases.

> > In fact when we speak of capturing any selection from X, I would not
> > like relying on Emacs, it would be better using SQLite or PostgreSQL
> > for that.
> 
> Plain text files stored in a version control system allows to review
> changes done at specific time interval.

To use version control system is non-trivial. To use Emacs is
non-trivial. Org, anything. What is trivial is to use simple
applications how they are designed on mobile devices.

Database version control is not hard, I have diff between any version
to any version and single click or automatic version storage straight
into the database. It updates my package version number as well.

Emacs: RCD Version Control system with PostgreSQL backend:
https://hyperscope.link/3/6/7/9/6/Emacs-RCD-Version-Control-system-with-PostgreSQL-backend-36796.html

> Databases require a non-trivial layer to allow reverting of
> particular changes. So a database is not better, it is *different*
> use case.

Just as it is matter of thinking and setting up version control
system, so it is thinking on how to make version control for database. 

Database has tables and columns. If there is a function to update
COLUMN in TABLE having ID number, then one can run simple function to
story the entry in other database tabl before the new entry:

(rcd-vc-db-revision table column id)

Then the function does it:

(defun rcd-vc-db-revision (table column id &optional description)
  "Insert database entry into RCD Version Control."
  (rcd-sql-first "INSERT INTO vc (vc_table, vc_column, vc_tableid,
                                  vc_value, vc_description)
                                  values ($1, $2, $3, $4, $5)
                                  RETURNING vc_id"
		 rcd-vc-db table column id (rcd-db-get-entry table column id rcd-vc-db) description))

It is that simple. That is much less programming then let us say RCD
which does about some thing more or less, just this time without
thinking. The surrounding functions are just few.

Statistics is also trivial:

SELECT vc_table AS "Table", vc_column AS "Most Edited Database Columns",
  count(vc_table) AS "Count"
FROM vc
GROUP by vc_table, vc_column
ORDER BY "Count" DESC
LIMIT 30;

┌───────────┬──────────────────────────────┬───────┐
│   Table   │ Most Edited Database Columns │ Count │
├───────────┼──────────────────────────────┼───────┤
│ hyobjects │ hyobjects_rank               │ 21428 │
│ hyobjects │ hyobjects_parent             │ 11155 │
│ hyobjects │ hyobjects_text               │  5424 │
│ hlinks    │ hlinks_rank                  │  4842 │
│ hyobjects │ hyobjects_priorities         │  3978 │
│ hyobjects │ hyobjects_name               │  3321 │
│ hyobjects │ hyobjects_actionstatuses     │  2198 │
│ people    │ people_rank                  │  1973 │
│ pages     │ pages_content                │  1832 │
│ hyobjects │ hyobjects_link               │  1525 │
│ hlinks    │ hlinks_priorities            │  1356 │
│ people    │ people_lastname              │  1295 │
│ people    │ people_account1              │  1194 │
│ hlinks    │ hlinks_tags                  │   998 │
│ hyobjects │ hyobjects_description        │   907 │
│ people    │ people_firstname             │   841 │
│ people    │ people_leadsource            │   819 │
│ hyobjects │ hyobjects_hyobjectypes       │   732 │
│ hlinks    │ hlinks_description           │   672 │
│ hyobjects │ hyobjects_hyobjectstatuses   │   611 │
│ hlinks    │ hlinks_name                  │   587 │
│ accounts  │ accounts_name                │   568 │
│ people    │ people_description           │   563 │
│ hlinks    │ hlinks_text                  │   532 │
│ hyobjects │ hyobjects_hyobjectsubtypes   │   519 │
│ hyobjects │ hyobjects_hash               │   517 │
│ people    │ people_name                  │   482 │
│ people    │ people_introducedby          │   475 │
│ commlines │ commlines_commlinestatuses   │   454 │
│ hyobjects │ hyobjects_report             │   394 │
└───────────┴──────────────────────────────┴───────┘

I also have headings, text, properties, and each heading is in the
version control without me thinking. 

Computer thinks for me.

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/


  reply	other threads:[~2022-10-10 22:09 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
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 [this message]
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=Y0SXU/xwhuTrZyms@protected.localdomain \
    --to=bugs@gnu.support \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    /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).