From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id SJgOBy3bT2NIywAAbAwnHQ (envelope-from ) for ; Wed, 19 Oct 2022 13:10:37 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id mJjwBi3bT2MvbgEAauVa8A (envelope-from ) for ; Wed, 19 Oct 2022 13:10:37 +0200 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 D7C219A2F for ; Wed, 19 Oct 2022 13:10:36 +0200 (CEST) Received: from localhost ([::1]:56832 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ol6y4-0000ri-1m for larch@yhetil.org; Wed, 19 Oct 2022 07:10:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54650) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ol6wI-0000pF-28 for emacs-orgmode@gnu.org; Wed, 19 Oct 2022 07:08:47 -0400 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]:44756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ol6wC-00014k-Ix for emacs-orgmode@gnu.org; Wed, 19 Oct 2022 07:08:45 -0400 Received: by mail-lf1-x12d.google.com with SMTP id p8so1307720lfu.11 for ; Wed, 19 Oct 2022 04:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=+ZN+x6OygiOlL5sn8pX2La94WDuq0DliyUgTrF2JnA8=; b=iKZhENLx97Np+2DHC+sXf/bc4s0Cp+uXO047PdKIZwAxZsWhCct5Nel9jGZMYIN40u 8GTcU4ND3npn2MEDO5Y9/ZFAV9QS6HwEJ5RUaAXojIgOPIIWzJipAA4CCiP9UenZvmgH kgI3McQbc0jAFMHOxhf7xM3/LdI/VJlryTPeWsJmTSSR744+BX+2n2qeUR5FT1iJO/df Nb7zIGCqQxltbM4sxZmkIJJvwTTHsjG0Vl+cKs1j5qTjG4+HAyxp56bd1R77rYBqobjm itkq93vZtV/BuAqU4WbHZFy4UK1pvH9LwDNwCfz2yp/TAflecD8bINMEk4x7auT7KkUA PjBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+ZN+x6OygiOlL5sn8pX2La94WDuq0DliyUgTrF2JnA8=; b=7+4BSWNEYgUR6qWBKZyfjOCOwgp/LUNbugiym6ECubfR7OwdABVtbNFcRKVuoE2ifH eyHhAM/PNpFv95nrrX1ddzfmFEMCDmrSpRuufGyqvgGjaaFmwfnnkiRHMiTdSLMio4CR /HxV+AXDukzfdS5JVajo29tL24dHm5cZNQRQ4qC8srJJu+ge+Ct4SdTLLEsm2gAcC5Wh lKKIr7x2qpDs7vV6HEV/cwCA9ak0hp0xVg6EFz3pEmhoTqYwniJZeMdxFjBxfVJu1Dg2 9nRsAeW/PeZBsCUloVxAOfEZz+5XAVPjn+BGQ2ntcLBT4wZpYxQO+PRnCZbxU/4SmAyn pNng== X-Gm-Message-State: ACrzQf07y3IgaSGpHPHYkElm9QsbTbU/Woofitj/gpx4aFakWTzim0Dn 3DJlrrcDL2n5Oe2JTtoQ4So= X-Google-Smtp-Source: AMsMyM525XIfij2mghpt2hFivlQZH8Tjq79q6Valh/sHDirefChG9bOBk8F2MGYPBGKnKeMZnIQN4Q== X-Received: by 2002:ac2:4f03:0:b0:495:ec98:bcac with SMTP id k3-20020ac24f03000000b00495ec98bcacmr2555503lfr.339.1666177714715; Wed, 19 Oct 2022 04:08:34 -0700 (PDT) Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id o7-20020a056512050700b0049f530939aasm2247619lfb.126.2022.10.19.04.08.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Oct 2022 04:08:33 -0700 (PDT) Message-ID: <7d0019ad-cf64-3e76-c52a-1ccb4edfd1b2@gmail.com> Date: Wed, 19 Oct 2022 18:08:32 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Verse block and separations (was: [bug] `org-latex-line-break-safe' breaks the export of verse blocks to LaTeX) Content-Language: en-US To: =?UTF-8?Q?Juan_Manuel_Mac=c3=adas?= Cc: emacs-orgmode@gnu.org References: <875ygk6a8z.fsf@posteo.net> <87h703iv8t.fsf_-_@posteo.net> From: Max Nikulin In-Reply-To: <87h703iv8t.fsf_-_@posteo.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::12d; envelope-from=manikulin@gmail.com; helo=mail-lf1-x12d.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, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1666177836; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=+ZN+x6OygiOlL5sn8pX2La94WDuq0DliyUgTrF2JnA8=; b=Q3bl6SO9qLwmJvLtZTrzCU6NbgY7E0sXzDrzi/e/urswSSIe+ldjVnrrt4oo+6kRWGuab7 csskQ8iNcRh3Cx+Xp4C/ZH7TyyEIOAvHIKFKWqF8R2TzwKNYczpojKMd/kGnWM5HJEtAjE s7S1i/dnm+pZMB5YvmuPcmfsmXSPgTdd+BVXPWlJlNll2EXWP1k/3IZlz61eqBM6gt2U3B jYAQmlxyHBFCx4BkqNz6ymJCMr8Cmbaipf0qhEt5/Fpy06YE0pvwWbuezp9nYSttAltP7M SG1zZya4VVrX68jHZjJIIvy8HQWDnCVKCN4bupmEyDFIXT6fR0dNyZhUJ/okkQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1666177836; a=rsa-sha256; cv=none; b=M41BlinNOyxXyr0nvPNd99T44TWBKaADN/Z5UOWA6ObFKUSd52Cp1j328GxNpmRErRDHnT 2gMyrHr4vqfvXSB6CoucVxkL3DRuVDJfXkXmaObHNIeFpLuDy0HuvdYtt+lejO1LQm5F2r WmCczumgOjSqm8JF4j5y7r3LVmcbveCBUa1ShegYiDuMmGmKhkES3V9TMoaZHpMR0nWI3A vg9WQLRjhwnLLMUhofMW1FbIr2xioQRRszyir7oTF+gIfpqPnTL6iy/8BAPIivAts06Sy/ RRzXruO+ZImrmvWVo8AlVPrCmYzQt1QpNhqVe1oc7GJ+Quut6C5Q5wqz8uH6ZQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=iKZhENLx; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 7.27 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=iKZhENLx; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: D7C219A2F X-Spam-Score: 7.27 X-Migadu-Scanner: scn0.migadu.com X-TUID: GvEEYrFfB2Ny On 16/10/2022 23:33, Juan Manuel MacĂ­as wrote: > (replace-regexp-in-string > "^[ \t]+" (lambda (m) (format "\\hspace*{%dem}" (length m))) > (replace-regexp-in-string > "\\(\\\\\\\\\n\\)+\\([ \t]*\\\\\\\\\\)+" "\n" > (replace-regexp-in-string > "\\([ \t]*\\\\\\\\\\)?[ \t]*\n" "\\\\\n" > (setq contents > (if lin > (replace-regexp-in-string "\\(\n\\)+\\([ \t]*\n\\)+" "\\\\\\\\!\n\n" > contents) > contents)) nil t) nil t) nil t) linreset) I had a hope, it is possible to do it in a single pass of `replace-regexp-in-string', but unfortunately the function does not allow to make conditional substitution based on (rx (optional (group string-start))) (a bug?). I still prefer to avoid replacement of latex newlines back to empty string. Though I am really happy with the following code, I expected a more concise snippet. Unit tests may found bugs in it. (let ((contents "\n\n 0 \n\n\na b\nc d e \n\n\nf g \n h i\n\n")) ;; Strip leading newlines. (setq contents (replace-regexp-in-string (rx string-start (1+ (0+ blank) ?\n)) "" contents 'fixed-case 'literal)) ;; Add explicit line breaks and strip trailing spaces. (setq contents (replace-regexp-in-string (rx (0+ blank) ?\n (optional (group (1+ (0+ blank) ?\n))) (optional (group (0+ blank) (not (any blank ?\n))))) (lambda (m) (let ((par (match-string 1 m)) (next (match-string 2 m))) (if next (concat (if par "\n\n" "\\\\\n") next) ""))) contents 'fixed-case 'literal)) ;; Indented lines. (replace-regexp-in-string (rx line-start (1+ blank)) (lambda (m) (format "\\hspace*{%dem}" (length m))) contents 'fixed-case 'literal)) Feel free to use it for inspiration during your work on a patch.