From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KKQEGxWYRGOidgEAbAwnHQ (envelope-from ) for ; Tue, 11 Oct 2022 00:09:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id GMMiGxWYRGPdbwEAauVa8A (envelope-from ) for ; Tue, 11 Oct 2022 00:09:25 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E18BE1F628 for ; Tue, 11 Oct 2022 00:09:24 +0200 (CEST) Received: from localhost ([::1]:35856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oi0xf-0007qi-VL for larch@yhetil.org; Mon, 10 Oct 2022 18:09:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51792) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi0vA-0005hs-56 for emacs-orgmode@gnu.org; Mon, 10 Oct 2022 18:06:48 -0400 Received: from stw1.rcdrun.com ([217.170.207.13]:41721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oi0v4-0001Kf-0l for emacs-orgmode@gnu.org; Mon, 10 Oct 2022 18:06:47 -0400 Received: from localhost ([::ffff:154.227.225.142]) (AUTH: PLAIN admin, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 00000000000BBD13.0000000063449770.00005C20; Mon, 10 Oct 2022 15:06:40 -0700 Date: Tue, 11 Oct 2022 01:06:11 +0300 From: Jean Louis To: Max Nikulin Cc: emacs-orgmode@gnu.org Subject: Re: idea for capture anywhere in x Message-ID: Mail-Followup-To: Max Nikulin , emacs-orgmode@gnu.org References: <87tuw31iub.fsf@mm.st> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02) Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1665439765; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=YlYy37OhPIHsgy2u5FGJ60LErUwu3/RiwiN+67i+C9Q=; b=rcsc4A2G0p7uJBBXdsdaNM+rK2L5z9L7F3LaDhdO9qUkf+fdoAHkqzbgtHJxeBfXOh2rMo OUWQE1epjEh3cLol0dilj6SvzfEv8XQyVm/QOmpHkTJM88j4R7AZprda/S2Xw65Wuo84P/ Jdb27+rOj7gWyKn0TVENUSMoaziiAEFfwMwoi+ay9G2zMQMPmOgNnJbMcQ41uMF168O8wO E+0ACOg3dGPmOdNJgJT4L2WKp29gdlcr/TlJv/hjaX1Sgfvs1WXIwyqBiaF2likfK7kEGA sbuIIZnR99yCmYrIHpzPThqcpl9k0YqqRE1j95ZEvZldHcnZw/wfX+6EOaEPPw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1665439765; a=rsa-sha256; cv=none; b=W7ehakyZZqrF6H6zEQemS6uPIcw4GCEXv2+qSiv56cmH3IphUhlwFu2zypBO1lTVhnHtYE RUqIrANHNUV6FWhX4qlDJeiiKZXK7NHjZoEY1vBUZsLWRcrmorEv3axYwSbOZOk16SYLGB iHxmmMkq005qcWslRLKTEaGraxafkhEd1qJ3x6B+HQdV1X3XNVgxyn8xqHihwv7Iun+zFZ 35Vd0OMxQj3Gdtej2OmKFOFvRJiRzrykpPnKCB+we1kkGTecSPsqCX8J4RMfGpSx3DY8AO ZN/a+Cl4bpRmp+TX+zNXBrsUot1J3prfJ1Gf8WRnsQpCnsEjcYULsBUNaDZWYA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.69 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: E18BE1F628 X-Spam-Score: -2.69 X-Migadu-Scanner: scn1.migadu.com X-TUID: nZBYilj9XdDS > 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/