From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 4DPiMRLefmD2dgEAgWs5BA (envelope-from ) for ; Tue, 20 Apr 2021 15:58:42 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id iUBiLRLefmAcUgAAbx9fmQ (envelope-from ) for ; Tue, 20 Apr 2021 13:58:42 +0000 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 53EB622AD0 for ; Tue, 20 Apr 2021 15:58:42 +0200 (CEST) Received: from localhost ([::1]:42634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYqtl-0002Ev-0M for larch@yhetil.org; Tue, 20 Apr 2021 09:58:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49410) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYqsz-0002B4-58 for emacs-orgmode@gnu.org; Tue, 20 Apr 2021 09:57:53 -0400 Received: from relay12.mail.gandi.net ([217.70.178.232]:46577) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYqsw-00039E-GQ for emacs-orgmode@gnu.org; Tue, 20 Apr 2021 09:57:52 -0400 Received: from localhost (40-67.ipv4.commingeshautdebit.fr [185.131.40.67]) (Authenticated sender: admin@nicolasgoaziou.fr) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 2C4A720000C; Tue, 20 Apr 2021 13:57:46 +0000 (UTC) From: Nicolas Goaziou To: Maxim Nikulin Subject: Re: [Patch] to correctly sort the items with emphasis marks in a list References: <87a6qg1rjx.fsf@posteo.net> <874kgft7n1.fsf@nicolasgoaziou.fr> <87blanxb1z.fsf@posteo.net> <87lf9fa3ak.fsf@posteo.net> <87sg3n8f33.fsf@posteo.net> <87tuo2d670.fsf@nicolasgoaziou.fr> <87r1j6b6ku.fsf@nicolasgoaziou.fr> Mail-Followup-To: Maxim Nikulin , emacs-orgmode@gnu.org Date: Tue, 20 Apr 2021 15:57:46 +0200 In-Reply-To: (Maxim Nikulin's message of "Tue, 20 Apr 2021 19:20:19 +0700") Message-ID: <87a6pt9hyd.fsf@nicolasgoaziou.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=217.70.178.232; envelope-from=mail@nicolasgoaziou.fr; helo=relay12.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1618927122; 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:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=EW18Iyt0NmZfiamxoAFvjpQJQU0QdeLR9nKLNrr5XYM=; b=jIvI0Ho4VfqsWf9Szx4Ttw8JvORYpgkGNS4iabIj20aTUa2I6rTBE0Akm99NZq/UAd+xZ6 IfwjjAB8rS+AZH9cOrAR6jXRJvpFuMuX+kdowJwESU6g6eghFEMvMIeXZM3RBoJa6L+lTZ aoOn+4uN57/w0P7uAIKDHA8ODjFjqBZtYatfJOk7j8Nx2Efh5E4gEInyJTA7iMmDwKTz8Z IP2lfUUHrhC8K+yUUUKnHvJ14gFO23U45nlakc68ym+2Xia2eG96wf3VkmRv4cTzqlY1kw r9bja76sMgHB3iCrESEj3u4WYy9TljWMWgTE3fprc1HufVKswkq5ea6qnm5oFA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618927122; a=rsa-sha256; cv=none; b=ZmRQ21eCVy4SYdxXJEvtnDhLocQggINedbUIhBJRPUKjLWY2+miD+yuLKIhBWHpI8HyGIX LwI4QvRsl9ACbYHyapJIny8NZ7uCivKQsrswNRfVA88Yn0kKpFPyljdmg0Ynwv3TcEMqz2 gFKG3+ofZ8bWEsV/90tUMMtXzdnpMEPsSYqPcr/qAgstoN90qGZraH+51COF4utNHu8svK WLlu9/e9c4uJWY3iuN/iQNKyaqUsds/ADi7yth97JBu0Rf2lNJRu4waNp/YblGPQdWBydW WafcUZggRmsNtyUt+x6G1Ikfa64aSrl0gdPmYnrtvWNDyleCYSeRCrjOOxqfvg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -2.44 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 53EB622AD0 X-Spam-Score: -2.44 X-Migadu-Scanner: scn0.migadu.com X-TUID: UZv5c8+DrPeB Hello, Maxim Nikulin writes: > Maybe first variant deserves to be committed while discussion of a > better option is in progress. I'd rather not, since we're currently considering a somewhat different path. The problem has been there for ages anyway. > I can not even determine what type of structure is returned when > `org-sort-remove-invisible' is called from ert or from scratch buffer: > > (org-sort-remove-invisible "A") > #("A" 0 1 (:parent (#("A" 0 1 ...)))) This is a string. > A couple of obvious problems: > > 1. Link handling > > #+begin_src elisp > (org-sort-remove-invisible > "- [[https://orgmode.org/submit?a=bc%20d&e=t+r#1234][a link]]") > #+end_src > > > #+RESULTS: > : - [[https://orgmode.org/submit?a=bc%20d&e=t+r#1234][a link]] Ah! I forgot the link part! Hopefully done here. --8<---------------cut here---------------start------------->8--- (defun org-sort-remove-invisible (s) "Remove emphasis markers and any invisible property from string S. Assume S may contain only objects." ;; org-element-interpret-data clears any text property, including ;; invisible part. (org-element-interpret-data (let ((tree (org-element-parse-secondary-string s (org-element-restriction 'paragraph)))) (org-element-map tree '(bold code italic link strike-through underline verbatim) (lambda (o) (pcase (org-element-type o) ;; Terminal object. Replace it with its value. ((or `code `verbatim) (let ((new (org-element-property :value o))) (org-element-insert-before new o) (org-element-put-property new :post-blank (org-element-property :post-blank o)))) ;; Non-terminal objects. Splice contents. (type (let ((contents (or (org-element-contents o) (and (eq type 'link) (list (org-element-property :raw-link o))))) (c nil)) (while contents (setq c (pop contents)) (org-element-insert-before c o)) (org-element-put-property c :post-blank (org-element-property :post-blank o))))) (org-element-extract-element o))) ;; Return modified tree. tree))) --8<---------------cut here---------------end--------------->8--- > 2. Missed spaces > > #+begin_src elisp > (org-sort-remove-invisible "A *b* /i/ t.") > #+end_src > > #+RESULTS: > : A bit. You need to update Org. I added a fix for that in "org-element" yesterday. Regards, -- Nicolas Goaziou