all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [Patch] Draw and scribble notes in GNU Emacs
@ 2021-09-09  7:54 Anand Tamariya
  2021-09-09  8:33 ` Po Lu
  2021-09-09 14:50 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 13+ messages in thread
From: Anand Tamariya @ 2021-09-09  7:54 UTC (permalink / raw)
  To: emacs-devel


[-- Attachment #1.1: Type: text/plain, Size: 963 bytes --]

Here's a proposal for drawing and scribbling notes in GNU Emacs.
*Features:*

   - Draw simple shapes and text
   - Scribble freehand
   - Visual selection using mouse
   - Zoom
   - Undo/delete selection
   - Erase

*Code: https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/svg.el
<https://gitlab.com/atamariya/emacs/-/blob/dev/lisp/svg.el>*
*Screenshots:*
https://lifeofpenguin.blogspot.com/2021/08/scribble-notes-in-gnu-emacs.html
*Video:* https://youtu.be/oj2OR5ytHx

I have few questions:
- Can this be included in Emacs core?
- I've copied two functions from Lars (
https://github.com/larsmagne/ewp/blob/master/ewp.el ). How should
attribution work in this case?

Additionally, following are mandatory patches for svg.el:
- polyline point uses CSV pairs separated by space.
- id should ideally be unique. This will allow changing element type when
different element with same id is added.
- If value is nil, don't include the attribute in the print output.

[-- Attachment #1.2: Type: text/html, Size: 1540 bytes --]

[-- Attachment #2: diff.txt --]
[-- Type: text/plain, Size: 1741 bytes --]

diff --git a/lisp/svg.el b/lisp/svg.el
index 7aadbc2359..45870e0bfe 100644
--- a/lisp/svg.el
+++ b/lisp/svg.el
@@ -154,9 +154,9 @@ svg-polyline
    (dom-node
     'polyline
     `((points . ,(mapconcat (lambda (pair)
-			      (format "%s %s" (car pair) (cdr pair)))
+			      (format "%s,%s" (car pair) (cdr pair)))
 			    points
-			    ", "))
+			    " "))
       ,@(svg--arguments svg args)))))
 
 (defun svg-polygon (svg points &rest args)
@@ -214,16 +214,17 @@ svg--encode-text
     (buffer-string)))
 
 (defun svg--append (svg node)
+  ;; id is expected to be unique.
   (let ((old (and (dom-attr node 'id)
 		  (dom-by-id svg
                              (concat "\\`" (regexp-quote (dom-attr node 'id))
                                      "\\'")))))
     (if old
-        ;; FIXME: This was (dom-set-attributes old (dom-attributes node))
-        ;; and got changed by commit f7ea7aa11f6211b5142bbcfc41c580d75485ca56
-        ;; without any explanation.
-	(setcdr (car old) (cdr node))
-      (dom-append-child svg node)))
+        ;; Remove old node. New node might be a different type.
+        (mapc (lambda (a)
+                  (dom-remove-node svg a))
+                old))
+    (dom-append-child svg node))
   (svg-possibly-update-image svg))
 
 (defun svg--image-data (image image-type datap)
@@ -311,7 +312,8 @@ svg-print
     (insert (format "<%s" (car dom)))
     (dolist (attr (nth 1 dom))
       ;; Ignore attributes that start with a colon.
-      (unless (= (aref (format "%s" (car attr)) 0) ?:)
+      (unless (or (= (aref (format "%s" (car attr)) 0) ?:)
+                  (null (cdr attr)))
         (insert (format " %s=\"%s\"" (car attr) (cdr attr)))))
     (insert ">")
     (dolist (elem (nthcdr 2 dom))

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-09-13  8:47 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-09  7:54 [Patch] Draw and scribble notes in GNU Emacs Anand Tamariya
2021-09-09  8:33 ` Po Lu
2021-09-09 12:00   ` Eli Zaretskii
2021-09-09 12:23     ` Po Lu
2021-09-09 14:51       ` Lars Ingebrigtsen
2021-09-10 21:45         ` dalanicolai
2021-09-13  5:32           ` Anand Tamariya
2021-09-13  5:15   ` Anand Tamariya
2021-09-09 14:50 ` Lars Ingebrigtsen
2021-09-13  5:36   ` Anand Tamariya
2021-09-13  8:25     ` Lars Ingebrigtsen
2021-09-13  8:31       ` Anand Tamariya
2021-09-13  8:47         ` Lars Ingebrigtsen

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.