From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen Newsgroups: gmane.emacs.help Subject: Re: Temporary notes in Emacs buffers? Date: Thu, 09 Jan 2020 04:57:53 +0100 Message-ID: <87sgkpp9ha.fsf@web.de> References: <87zhfecbpt.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="21692"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Help Gnu Emacs mailing list To: Marcin Borkowski Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 09 05:02:07 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ipOzE-000EVj-B2 for geh-help-gnu-emacs@m.gmane-mx.org; Thu, 09 Jan 2020 04:59:56 +0100 Original-Received: from localhost ([::1]:54938 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipOzB-0002SS-QS for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 08 Jan 2020 22:59:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43218) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipOxN-0002Of-Pa for help-gnu-emacs@gnu.org; Wed, 08 Jan 2020 22:58:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipOxL-0006XE-8h for help-gnu-emacs@gnu.org; Wed, 08 Jan 2020 22:58:01 -0500 Original-Received: from mout.web.de ([212.227.15.4]:48169) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipOxK-0006Tn-Mr for help-gnu-emacs@gnu.org; Wed, 08 Jan 2020 22:57:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1578542274; bh=GIiDhz+nPEE5/8NEj6RBD3ScTq/UxwegTXdaXOdc1qw=; h=X-UI-Sender-Class:From:To:Cc:Subject:References:Date:In-Reply-To; b=N2seKqCleHWrxj7h2RX9wNwqv5sMMGw5wW235W6QbTnb/SeHavnIN+3cWMa0IxTPI x2Y8RkR+t2Es/LfegJkJluM6XJRNLK8RL0fu6+7j/hlxENYFw1vLT6Lod9bO7FtBAi Hd3Di4b0GRr525UDdQQ810wb9rOeht1scnpCmUkI= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Original-Received: from drachen.dragon ([88.67.106.182]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MZliY-1j7cpb48gY-00LWH4; Thu, 09 Jan 2020 04:57:54 +0100 In-Reply-To: <87zhfecbpt.fsf@mbork.pl> (Marcin Borkowski's message of "Fri, 27 Dec 2019 11:19:26 +0100") X-Provags-ID: V03:K1:XbHfbcCGAGhjcEcVWR10aDh4k8qXSX64yfHhxdUir998UZbIHJP PjG/sjVyuAd7TAjgs2/4kkkcdYJspi2GSNDRwewt3KVAp8cyiar6v0hn9Nji1Gno1t+5bfJ 5PGxYlzZbedLvowDXg+guiX7/tb5pmi0ofPrvl/qhpqRAKj70gmSq8rV/2py2mLly2loW3o bzWsOlIWIPVAlw8bL1elw== X-UI-Out-Filterresults: notjunk:1;V03:K0:RdINlZhFKbw=:j4X2Ryz+QqMoWFhVFRXWOD BXeQOj+IwRDWEmb5yCiOxizSdoguWaxm91fRXCFmNZt08IW02gzst1LDUppHybyOLVVoV+HB7 vulVNSYYv+/BNCRBa2qpgt1s03A3Lvw5BV8JGbrrrixP0AX/JUwEIEFUa0ogAzYWMCsfn/dqS wPW36jIAz1NvYQvL4gZ6AB3V/DUzoYMBTz080VG1oNPqJfelyBVe20lLekg4JND6Sy1z9UjLa EiR+qrw7LCuEqe39VUTx5oH5mdX6f2WnhoZX9ZNLgJClUAFyVl13AOTaJmD/kCZSsd1p+o6j2 swFSC1y4mCpNAqj9tMKSN4hxvJ4ZQRSUaYkb7GzFylHkgfSpuXmwn9ezy3X6C75kJNnrMRiWb SefDx4sSeiAc4cShwbrGD0Lad0eJswKlzuVJYiS8VUi3c3XU6K8jkAwNI1fCHmrGCuyQUx9jA LB2MiMBzFlakbY88XB0frWhbpBlS/d3hC5Cxf1iNfc5XWjdnwCIXIAxJw9DCWOlkogEZ0s7Zj n7XGbVog/60xchToNuOoYTUex5seeYHzUudfsZbTfYTSYC4wEuFXkDRsVJBs4hHyRI/fYnQ7G WHoLCIGN8Zgu174GFV/Fr0cE13UXIC0WsayJCEeHHj1ZmoSO92kKVYsgdLR/stvHN8ryKDup/ /ejveTOjcJVbOUsCFAk+24y2ZUOMomrdXOsDjN96lR2qIGuAKKAu4l9ToO/02Svmb1ZxBcI/V Qec7doIl3ro2xd80zZBcc7u8pwrBD8SYCgvSEi/vjUll9DrE4wZNx13bAhmImpG20uombEUZ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.15.4 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:122185 Archived-At: --=-=-= Content-Type: text/plain Marcin Borkowski writes: > I've been wondering if there is some package which could let me make > "temporary notes" in Emacs buffers, similar to (but different than) the > "yellow notes" in some pdf viewers. Just for fun I've created a template for how the least common multiple of our expectations could look like. I guess there are many different expectations of how contents, visualizations and ways of saving for notes could look like, so I made it so that all of that is changeable and extensible. I'm not yet sure what would have to be done to support mass annotation from occur buffers since I don't use them a lot. I'm also not sure where in the implementation I could rely on existing code - especially for saving (eieio-persistent maybe?). --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=side-note.el Content-Transfer-Encoding: quoted-printable ;;; side-note.el --- Visual and durable side note annotations -*- lexica= l-binding: t -*- ;; Copyright (C) 2020 Free Software Foundation, Inc ;; Author: Michael Heerdegen ;; Maintainer: Michael Heerdegen ;; Created: 08 Jan 2020 ;; Keywords: k1, k2 ;; Compatibility: GNU Emacs ?? ;; Version: 0.0.1 ;; Package-Requires: ((emacs "25") (cl-lib "0")) ;; 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: ;; Side notes for Emacs. ;; TODO: A lot. ;;; Code: ;;;; Requirements (eval-when-compile (require 'eieio) (require 'cl-lib)) ;;;; Configuration stuff ;;;; Helpers and Definitions (defvar-local side-note-list '() "List of buffer side notes.") (defclass side-note () ((text :initarg :text) ;i.e. content (remove))) ;function to remove visualization (cl-defstruct side-note-save-location "Holding type and data of a buffer's save location for side notes." tag data) (cl-defgeneric side-note-list-notes-in-location (location) "Create an occur-like overview for side notes saved in side-note-save-loc= ation LOCATION.") (defvar-local side-note-save-location nil ;must be set explicitly "Describes place of storing side notes." ;; Should multiple places be supported? ) (cl-defgeneric side-note-visualize (side-note) "Visualize SIDE-NOTE. How this is done can depend on note type and the major-mode. Should return a function to remove the visualization.") (cl-defgeneric side-note-get-save-form (note) "Return a form suitable for saving the SIDE-NOTE." note) (cl-defgeneric side-note-save-in-location (location) "Save current buffer's side-notes in LOCATION.") ;;;; Main Stuff (defun side-note-save () (interactive) (side-note-save-in-location side-note-save-location)) (defun side-note-add (note) (oset note remove (side-note-visualize note)) (push note side-note-list) (if buffer-file-name (set-buffer-modified-p t) (side-note-save))) (defun side-note-remove (note) (funcall (oref note remove)) (cl-callf2 delq note side-note-list)) (defun side-note-load-notes (&optional buffer) ;; Look for side notes for BUFFER (defaulting to the current buffer) ;; in all implemented locations, in some defined order; setup ;; `side-note-save-location' and `side-note-list', and display the ;; side notes ) (define-minor-mode side-note-mode "Minor mode for creation of durable side nodes." ;;of course there will be a useful keymap... ) (define-globalized-minor-mode global-side-note-mode side-note-mode side-not= e-load-notes) ;;; Simplest type: Position side notes (defclass side-note-pos-note (side-note) ((pos :initarg :pos))) (defun side-note-add-note-at-pos (pos text) (interactive (list (point) (read-string "Note text: "))) (side-note-add (side-note-pos-note :pos (copy-marker pos) :text text))) (cl-defmethod side-note-visualize ((note side-note-pos-note)) (let* ((pos (oref note pos)) (ov (make-overlay pos (1+ pos)))) (overlay-put ov 'face 'highlight) (overlay-put ov 'help-echo (oref note text)) (lambda () (delete-overlay ov)))) (provide 'side-note) ;;; side-note.el ends here --=-=-= Content-Type: text/plain Thanks, Michael. --=-=-=--