From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.bugs Subject: bug#33005: 27.0.50; Data loss with Gnus registry Date: Thu, 11 Oct 2018 22:28:50 +0200 Message-ID: <87sh1cxm65.fsf@web.de> References: <871s8yvsrq.fsf@web.de> <87in29x33z.fsf@ericabrahamsen.net> <87r2gxygox.fsf@web.de> <87efcxwzr2.fsf@ericabrahamsen.net> <874ldtlcks.fsf@web.de> <87ftxdl7w1.fsf@ericabrahamsen.net> <87a7nkhcu2.fsf@web.de> <87r2gwzl1b.fsf@web.de> <87in281hf0.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1539289690 18356 195.159.176.226 (11 Oct 2018 20:28:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 11 Oct 2018 20:28:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 33005@debbugs.gnu.org To: Eric Abrahamsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 11 22:28:05 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAhYx-0004dE-QE for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Oct 2018 22:28:04 +0200 Original-Received: from localhost ([::1]:36973 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAhb4-0006LT-AK for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Oct 2018 16:30:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gAhax-0006Ho-TG for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 16:30:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gAhas-0005Vf-UO for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 16:30:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41289) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gAhas-0005V6-B2 for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 16:30:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gAhas-0001tg-4k for bug-gnu-emacs@gnu.org; Thu, 11 Oct 2018 16:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 11 Oct 2018 20:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33005 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33005-submit@debbugs.gnu.org id=B33005.15392897487203 (code B ref 33005); Thu, 11 Oct 2018 20:30:02 +0000 Original-Received: (at 33005) by debbugs.gnu.org; 11 Oct 2018 20:29:08 +0000 Original-Received: from localhost ([127.0.0.1]:45547 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAhZz-0001s7-MK for submit@debbugs.gnu.org; Thu, 11 Oct 2018 16:29:07 -0400 Original-Received: from mout.web.de ([212.227.17.11]:41013) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gAhZy-0001re-6D for 33005@debbugs.gnu.org; Thu, 11 Oct 2018 16:29:06 -0400 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MK24P-1g9KfG2Xhd-001SGf; Thu, 11 Oct 2018 22:28:51 +0200 Original-Received: from drachen.dragon ([94.218.210.177]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MK24P-1g9KfG2Xhd-001SGf; Thu, 11 Oct 2018 22:28:51 +0200 In-Reply-To: <87in281hf0.fsf@ericabrahamsen.net> (Eric Abrahamsen's message of "Thu, 11 Oct 2018 11:12:35 -0700") X-Provags-ID: V03:K1:npoKFWGacYOjzXWEA5xh6dmborrRu5cGdOaAyVBHNqx+YNgY4ke zB1wyNJS9SLaf4+ffTjruqJU8WIMAuWSmfLs5Z5sQa1t9ulvmEwMlvPOoI3zajUZ/Uw7b+5 bStvXgUnfI8MKuTd3X9nfhcWrMGdWMr+aj1R149uN2hU85tIjq96Ld8Yt/Nj5smVUmRFclI NGwTa/49w5vWgoU0BOZbQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:sNW910GtR3g=:LaDWEq4CT8NbV5oRbwCAyy dzej9RadQivCU0XhEecOgSG89e78i/KZFFh8UuVqEOCHVqhG8eIOeAHmmq8xxo8C+XhSfPNeh yFx1LDU3PHHLDifYo9h2hcP3wOT7ziCI89cpEeqiRw9TfATvHFgLue8PKhiT3vu4NxPDnnVJH a7DsvLB2ExuLJEG+4i472Ueom7yH8Z3VSR2WYYfFn5t8ZxPrVXrdN0ry31OjbNlFsHEwme5rS B0Vq4XQt12UGA4teqhhXDNWr399yuTrAMOLbq7jOoVRC1s+N+HsgE0EHsRSbw2RO9b7XACGYx Jif32mLehlCsyAN4N0Q7VQgH2PcIoh3aZUjutEpbhHZdQmjhUPe0iqWw0lT0FyBVCRblJOb1b Ju+ZhiIKKr7i+pd4WXspvcDpNqMkR1n6/LRAW5C97+vSytbquwJFamxXOdeLUqMnB0zktsGYh /cQDvdlNohZojZP9cNX5yMFeT+ec8VgYapz845cCk9Ot++4zFgjxes1WdeAdLE2OzoYJBe1eg K+S5rMg5cdz10OZSnVvquO2epZLctxEJ4XDpW4+ZtZEDEyTAeq/LIM1th2ikZyEaesu9FSyE0 hYxa8tDEMOo2OBce59WBfJNz9bkMaTqpzXGlRQbbr/AzjCNvQLy1oQ/gcEBq3jk6APxFUTrBv MWjUlUCmg5PejbH2KCMxKrNF45luHNpyvmDBMS4npmTDoON8T7+SglYkU+oXu0j1qveAceKfD ga2J986VKZJ1KHkxScMR4I4pDwm2mnqv6d2asYdtXMi+FUDfwPM15xvaxy262wWq5GF5ARSi X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151141 Archived-At: --=-=-= Content-Type: text/plain Eric Abrahamsen writes: > > Should we even make a NEWS entry along the fix saying that the feature > > can actually be used now? > > I don't think so, bug fixes don't usually get a NEWS entry. Well, it's at least the first time that you can actually use it. > But I can say something on the gnus.general list. Ok. > Also, I really like the idea of using the registry to attach notes to > mails -- that's something I've intended for Gnorb for a while. If you'd > like to contribute that to Gnorb I'd be very happy to accept it, or > maybe it's something that could even go into the registry proper. Of > course, if you'd prefer to keep it a separate package that's fine too -- > I'd install it! I wanted something really really simple, in particular, something that is not linked to org. It's an approach different from Gnorb, but maybe it would fit into Gnus, dunno. I attach what I have so far - feedback welcome. Michael. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=gnus-article-notes.el Content-Transfer-Encoding: quoted-printable ;;; gnus-article-notes.el --- Attach notes to messages in Gnus -*- lexica= l-binding: t -*- ;; Copyright (C) 2018 Free Software Foundation, Inc ;; Author: Michael Heerdegen ;; Maintainer: Michael Heerdegen ;; Created: 2017_12_11 ;; Keywords: news registry ;; Version: 0.1 ;; Package-Requires: () ;; This file is not part of GNU Emacs. ;; GNU Emacs is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs. If not, see . ;;; Commentary: ;; This simple package allows to attach text notes to articles in ;; Gnus. This is actually just a trivial convenience wrapper around ;; `gnus-registry-set-id-key' and `gnus-registry-get-id-key'. ;; ;; For something less simplistic see the Gnorb package in Gnu Elpa. ;; It can save notes in org files, track discussions, and much more. ;; ;; ;; Usage ;; =3D=3D=3D=3D=3D ;; ;; The main command is `gnus-article-notes-set-note' bound to "@" in ;; the summary keymap. ;; ;; If the current article has not yet an attached note, hit @ to add ;; one. The article is also flagged with an "@" to indicate that a ;; note has been attached. ;; ;; When an article has already an attached note, "@" displays the note ;; in the echo area, and hitting "@" again let's you edit the note. ;; "@" with a prefix argument 0 deletes the note after confirmation. ;; "@" with any other prefix arg also reads in a note text but using a ;; pop-up buffer instead of the minibuffer making editing multi-line ;; notes more convenient. ;; ;; ;; Setup ;; =3D=3D=3D=3D=3D ;; ;; Somewhere in your initialization you need to enable the Gnus ;; registry (where this package saves your notes), load this file, and ;; make the key binding: ;; ;; (gnus-registry-initialize) ;; (require 'gnus-article-notes) ;; (add-hook ;; 'gnus-summary-mode-hook ;; (defun my-gnus-summary-mode-hook-bind-key-for-article-notes () ;; (define-key gnus-summary-mode-map [?@] #'gnus-article-notes-set-not= e))) ;; ;; It is a good idea to read about what enabling the registry means if ;; you haven't yet used it: (info "(gnus) The Gnus Registry"). It is ;; easy stuff. You may want to limit how much data Gnus stores in the ;; registry to avoid delays when saving (it stores a lot by default). ;; I do (setq gnus-registry-max-entries 2000). Note that pruning a ;; full registry will never delete notes unless you change ;; `gnus-registry-extra-entries-precious' to not contain `mark'. ;; Loading this package adds a "Note" named custom mark to ;; `gnus-registry-marks' (by default). ;; ;; To see the "@" marker for messages with attached notes in the ;; summary buffer, you also want something like ;; ;; (defalias 'gnus-user-format-function-M ;; 'gnus-registry-article-marks-to-chars) ;; ;; which allows you to use "%uM" (or better with a padding like in ;; "%2uM") in `gnus-summary-line-format' to show registry marks - see ;; (info "(gnus) Store custom flags and keywords") for details. ;; ;; Finally you may also want to look at the few customizable options ;; defined in this file. ;;; Code: (eval-when-compile (require 'subr-x)) (require 'gnus) (require 'gnus-registry) (defvar gnus-article-notes-registry-field 'Note) (defvar gnus-article-notes-marker-char ?@) (defvar gnus-article-notes-auto-tick nil) (defvar gnus-article-notes-show-in-summary t) (defun gnus-article-notes-registry-delete-id-key (id key) (let* ((db gnus-registry-db) (entry (gnus-registry-get-or-make-entry id))) (registry-delete db (list id) nil) (setq entry (assq-delete-all key entry)) (gnus-registry-insert db id entry) entry)) (with-eval-after-load 'gnus-registry (add-to-list 'gnus-registry-marks `(,gnus-article-notes-registry-field :char ,gnus-article-not= es-marker-char :image nil))) (defvar gnus-article-notes-popup-window-action '()) ;; We could make the major mode customizable... (defun gnus-article-notes-read-string-with-buffer (&optional initial-input = keymap comment) (cl-callf or comment ";; Hit C-c C-c when done\n\n") ;FIXME: add key to a= bort (save-window-excursion (with-temp-buffer (let ((win (display-buffer (current-buffer) gnus-article-notes-popup-= window-action))) (select-window win) (insert comment) (when initial-input (insert initial-input)) (set-window-point win (point-max)) (use-local-map (let ((map (make-sparse-keymap))) (set-keymap-parent map (or keymap text-mode-map)) (define-key map [(control ?c) (control ?c)] #'exit= -recursive-edit) map)) (recursive-edit) (string-trim (replace-regexp-in-string (concat "\\`" (regexp-quote comment)) "" (buffer-string))))))) (defun gnus-article-notes-set-note (id new-content) (if (not new-content) (gnus-article-notes-registry-delete-id-key id gnus-article-notes-regi= stry-field) (gnus-registry-set-id-key id gnus-article-notes-registry-field new-cont= ent))) (defun gnus-article-notes-display-or-set-note (article id &optional content) "Doc..." (interactive (let* ((articles (gnus-summary-work-articles nil)) (article (if (cdr articles) (user-error "Cannot operate on multip= le articles") (car articles))) (id (mail-header-id (gnus-summary-article-header article))) (current-content (gnus-registry-get-id-key id gnus-article-notes-= registry-field))) (list article id (if (or (eq this-command last-command) (not current-content) cur= rent-prefix-arg) (let ((new-content (if current-prefix-arg (if (eq 0 (prefix-numeric-value current-prefix-ar= g)) (if (yes-or-no-p "Really delete note? ") nil (user-error "Abort")) (gnus-article-notes-read-string-with-buffer cur= rent-content)) (read-string "New note: " current-content)))) (if (equal "" new-content) nil new-content)) `(display . ,current-content))))) (pcase content (`(display . ,content) (message "%s" content)) (_ (when (and content gnus-article-notes-auto-tick) (gnus-summary-tick-= article-forward 1)) (gnus-article-notes-set-note id content) (gnus-registry--set/remove-mark 'Note (not content) (list article)))= )) (defun gnus-article-notes-get-additional-articles (group-name) (delq nil (mapcar (lambda (id) (cdr (gnus-request-head id group-name))) (cl-loop for key being the hash-keys of (oref gnus-registry= -db data) using (hash-values v) when (assoc gnus-article-notes-registry-field v) collect key)))) (defun gnus-articles-notes-alter-articles-to-read-function (f group-name ar= ticle-list) (let ((others (funcall f group-name article-list))) (if gnus-article-notes-show-in-summary (cl-union (gnus-article-notes-get-additional-articles group-name) others) others))) (add-function :around gnus-alter-articles-to-read-function #'gnus-articles-notes-alter-articles-to-read-function) (provide 'gnus-article-notes) ;;; gnus-article-notes.el ends here --=-=-=--