From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hongyi Zhao Newsgroups: gmane.emacs.help Subject: Re: Run `fill-paragraph' on all the paragraphs in the currently opened LaTeX document. Date: Mon, 18 Oct 2021 16:56:57 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5535"; mail-complaints-to="usenet@ciao.gmane.io" Cc: help-gnu-emacs To: Yuri Khan Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 18 10:58:15 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1mcOTH-0001AS-7K for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 18 Oct 2021 10:58:15 +0200 Original-Received: from localhost ([::1]:42194 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mcOTF-0000Wp-Or for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 18 Oct 2021 04:58:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40556) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mcOSG-00085B-Lo for help-gnu-emacs@gnu.org; Mon, 18 Oct 2021 04:57:12 -0400 Original-Received: from mail-ua1-x930.google.com ([2607:f8b0:4864:20::930]:38780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mcOSF-0000HS-4y for help-gnu-emacs@gnu.org; Mon, 18 Oct 2021 04:57:12 -0400 Original-Received: by mail-ua1-x930.google.com with SMTP id h19so462549uax.5 for ; Mon, 18 Oct 2021 01:57:09 -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:content-transfer-encoding; bh=BneJlTG9UIjuC51u+hFcu8q6gKR67j8iSP+3rg2kuKM=; b=j8R5+tCW9bStvWeq5dAt3ujDvnG1nCmW9UzEHzzUjg2Xl4yhuIBMHzzetQ3TaFBPvB 1PZFViH7eAS9DfVzNGGdMIs08fQffskwixNZk5t1kI63iWCEr/VHw/mBUB0MLooJf+cb AgUWIWx+CvzmcSMPl56TAqyhHXYQY3KzScWpS97r2hC6ZkuPummyQKGGTu3MTNb+zHVl FEwJy6GDhc5vIsWriPFua+IQVJ5NZOY3nOSju9PLXvJshjdHE6oMcG8w6dgIe31/Zarg D+QXpnr+Qmmzq2IOEjS1SfflELowcgeLJH4tdi0r6sKDYjkvMCNyz7CwnaENU8rEB4F8 6Sfg== 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:content-transfer-encoding; bh=BneJlTG9UIjuC51u+hFcu8q6gKR67j8iSP+3rg2kuKM=; b=TUnxCiNRqLu+WSwlylKZF3ucKasMUwQF7r5T3K2kOoKxPC/LMpPCo8EAnpRyKTrcmy Z6ss5uXKjvQV/1PvZbWQWarrfo21AxYXnkf/Uw8xx7DBHSPktOFqfYnhdXDawPQVCKLz tbr27Fhh3j4dsH0nlBHS0HIerqrp2tB8nLz8v66IBWC+HcdhUzPrc8uV/ViVO3eaUE2x co0McQ8mFiM18rPsRRb34BfN2BwA+6SCNdCSopbPT02PqNOhHd5rCljT2taTMLizAJBK ikYeZpBvbYeIRuQU03zoyiY7he9nr6fAPeVm3uCwxpQLM0//HPtlXp+5iXHb4kMdZYsW ltog== X-Gm-Message-State: AOAM533vdMUL+iFfVF9nOerxjfgxCr8RLrKMTlL5ZmdJjgA6nO3Edjgv BaFl89J+LS3xxp1WB3HK6oCDQWhAHjF5HZJv3zA= X-Google-Smtp-Source: ABdhPJx8iC4uHa5vuIYTJqch544gXnVeyiB7ne1iPTpJ0n+VPhkODs6fV8l7ptoYmhvdN2US2ZG6hOhM0zNLUOuAf5M= X-Received: by 2002:a67:c29d:: with SMTP id k29mr25944599vsj.51.1634547428885; Mon, 18 Oct 2021 01:57:08 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::930; envelope-from=hongyi.zhao@gmail.com; helo=mail-ua1-x930.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, 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: 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.io gmane.emacs.help:133855 Archived-At: On Mon, Oct 18, 2021 at 12:43 PM Yuri Khan wrote: > > On Mon, 18 Oct 2021 at 07:22, Hongyi Zhao wrote: > > > > Why do you even want that? > > > > I use SyncTeX to do the forward and backward search, which is based on > > linefeed separated line to locate the position in the source LaTeX > > document. If a paragraph is arranged in one line, the backward search > > will always jump to a very inaccurate location. > > I=E2=80=99m not suggesting > keeping each paragraph as a single long line. > What I=E2=80=99m suggesting is > dividing paragraphs into sentences > and sentences into phrases > while keeping each line reasonably short > but without trying to cram as much as possible into each line. > > (This mail uses semantic line breaks, > as a demonstration.) So the idea suggested by Emanuel Berg and you now can be combined into the following: Iterate the whole buffer line-by-line with a semantic line as the unit block, and check each line if it starts with '\' or not, e.g. with (looking-at "\\\\"). When you find one "beg", start looking for where it ends, and when you find that push (beg end) onto a list. Then loop through the list and do (fill-region beg end) for each list pair item ... HZ