From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Anand Tamariya Newsgroups: gmane.emacs.devel Subject: Re: [Patch] Draw and scribble notes in GNU Emacs Date: Mon, 13 Sep 2021 11:06:46 +0530 Message-ID: References: <87fsudu7jm.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000778a3f05cbd9da50" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27468"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Lars Ingebrigtsen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 13 07:41:43 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mPeit-00072J-54 for ged-emacs-devel@m.gmane-mx.org; Mon, 13 Sep 2021 07:41:43 +0200 Original-Received: from localhost ([::1]:58842 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPeir-00080p-BM for ged-emacs-devel@m.gmane-mx.org; Mon, 13 Sep 2021 01:41:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPeeK-0005Nu-7b for emacs-devel@gnu.org; Mon, 13 Sep 2021 01:37:00 -0400 Original-Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]:46071) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPeeI-0000wY-NI for emacs-devel@gnu.org; Mon, 13 Sep 2021 01:36:59 -0400 Original-Received: by mail-il1-x131.google.com with SMTP id b8so7082940ilh.12 for ; Sun, 12 Sep 2021 22:36:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4CTJEQnZD0B6nxvm26hcSB9suIz+bX4X/qKVpIchT0Q=; b=Ap5OI01HjUJrWquDSha2fpm6HItJlnzyjv0JlTABTQO6mejhtsH0HF91psIPHNxyWM nFTIJyLr+D1bx7ec2fI3wxyBUcW/c7r0+xY7ErcbUtgLf/eExthoMsw0i9pcqFM8wYcQ a6KM8ZKISiamsr37RPDaOlVF6Gd/IUo7SVz5FoOC74ryDO5uGxSMhdYn78f7kQZ6bhN9 izDNlb7aoLnPOTgR36EWQssksvrrB7GkjIIbGJBwYyZyPwFvSAcuZuzz+z0MF/ucEVAw DFv+qXvkG1d1RiuyGQosAMyH+WICwLZ4bNt/t0ZGN+0eRSeC36hP0KdCHP3PQDbLQac5 jwhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4CTJEQnZD0B6nxvm26hcSB9suIz+bX4X/qKVpIchT0Q=; b=dgmQxwlv+1Bfec0GXTNsNHQcXTxll9E9M+O8VepZfDkQC62Hl//mDUyr4TZpuL+meg 0vmfTdJaMIsO8BBRc5TJpe0y4UvGFzLSU9Jw4fRp22Y3+hx0MREMVixuS+6fSbW52bKi dKMQ5jMnyUM0ZYNleAwp22NqM9ptwAgQrF1W0EV68ilRyIgYGJP+lxVRY+g0rApUCszu vq9rD+WikRVlHl6m3UG/lEENusR8dnq2hEdpOs1Dkoc1Jfjru/D//yhsu34TVwZKyHPK O6Z2sYYoIZK8hQGmiHAbGy7Lz5Q4FP0H6E7+cIOJQndP+GIfdfxW+bdrSB3dWoxLwlF9 /Sbw== X-Gm-Message-State: AOAM5330Dl9/oDWcPF4uEs6hPfUzS2DkxHdGhMsiT98st+c39fssXOXX DDRCf6162/Wmsiydah3FpiGSzlWkd0XVXyN8y9Q= X-Google-Smtp-Source: ABdhPJycLrqgJ1bW0SIj+wdWukiwj0VqgUr6T8Xdk7fXfmawMDyOU4xxk1MDrJAxbJOrKWU52WHHpNV9yZLF2Uu5obE= X-Received: by 2002:a92:c8c7:: with SMTP id c7mr4109267ilq.62.1631511417159; Sun, 12 Sep 2021 22:36:57 -0700 (PDT) In-Reply-To: <87fsudu7jm.fsf@gnus.org> Received-SPF: pass client-ip=2607:f8b0:4864:20::131; envelope-from=atamariya@gmail.com; helo=mail-il1-x131.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:274618 Archived-At: --000000000000778a3f05cbd9da50 Content-Type: text/plain; charset="UTF-8" > > > (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)) > > Hm... I think this is basically correct, but it's a behaviour change -- > previously svg--append wouldn't append if the ID already existed, but > would keep the save place in the structure, but with this change, it > really always appends. > > So I don't think that's quite right -- the old behaviour was OK, I think > (but undocumented). > Existing code doesn't ensure ids are unique. Furthermore, in case id is duplicated, only the attributes on the first tag gets replaced. That's a little unpredictable behaviour from an API perspective. --000000000000778a3f05cbd9da50 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
>=C2=A0 (defun svg--append (svg node)
> +=C2=A0 ;; id is expected to be unique.
>=C2=A0 =C2=A0 (let ((old (and (dom-attr node 'id)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(dom-by-i= d svg
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(concat "\\`" (regexp-qu= ote (dom-attr node 'id))
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"= \\'")))))
>=C2=A0 =C2=A0 =C2=A0 (if old
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; FIXME: This was (dom-set-attributes ol= d (dom-attributes node))
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; and got changed by commit f7ea7aa11f62= 11b5142bbcfc41c580d75485ca56
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; without any explanation.
> -=C2=A0 =C2=A0 =C2=A0(setcdr (car old) (cdr node))
> -=C2=A0 =C2=A0 =C2=A0 (dom-append-child svg node)))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 ;; Remove old node. New node might be a d= ifferent type.
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 (mapc (lambda (a)
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (dom-r= emove-node svg a))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 old))
> +=C2=A0 =C2=A0 (dom-append-child svg node))

Hm...=C2=A0 I think this is basically correct, but it's a behaviour cha= nge --
previously svg--append wouldn't append if the ID already existed, but would keep the save place in the structure, but with this change, it
really always appends.

So I don't think that's quite right -- the old behaviour was OK, I = think
(but undocumented).
Existing code doesn't ensure ids ar= e unique. Furthermore, in case id is duplicated, only the attributes on the= first tag gets replaced. That's a little unpredictable behaviour from = an API perspective.
--000000000000778a3f05cbd9da50--