From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.help Subject: Re: How to do a massive unfill paragraph operation over several hundred files? Date: Wed, 3 Oct 2018 19:52:52 -0400 Message-ID: References: <8636ts4jz3.fsf@zoho.com> <86zhvyzq4c.fsf@zoho.com> <86muryype2.fsf@zoho.com> <87in2lvikf.fsf@tu-berlin.de> <875zyl1yls.fsf@gmail.com> <87efd8v99e.fsf@tu-berlin.de> <877eizwdag.fsf@tu-berlin.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1538610710 24857 195.159.176.226 (3 Oct 2018 23:51:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 3 Oct 2018 23:51:50 +0000 (UTC) Cc: Robert Pluim , moasen@zoho.com, Help Gnu Emacs mailing list To: wildgruber@tu-berlin.de Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Oct 04 01:51:45 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g7qvg-0006MO-V3 for geh-help-gnu-emacs@m.gmane.org; Thu, 04 Oct 2018 01:51:45 +0200 Original-Received: from localhost ([::1]:53591 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7qxn-0007nf-3y for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Oct 2018 19:53:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46624) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7qxJ-0007nM-VG for help-gnu-emacs@gnu.org; Wed, 03 Oct 2018 19:53:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7qxA-0002b8-EP for help-gnu-emacs@gnu.org; Wed, 03 Oct 2018 19:53:18 -0400 Original-Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]:37229) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g7qx5-0002XL-PY for help-gnu-emacs@gnu.org; Wed, 03 Oct 2018 19:53:13 -0400 Original-Received: by mail-oi1-x22d.google.com with SMTP id e17-v6so6026591oib.4 for ; Wed, 03 Oct 2018 16:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2x4Zab162lLlsHbMZ2qJSmflJ05n5hmZwtHp/Qyauc4=; b=UPCDfS8zbdEV0L5H4UeaZjJGVdMf5Q2shSMIn9xxa38yQP9RgLN7j2N9aXCC7UE3o6 tZGw9aMrCNmq1VXA9I4uC3fme1Ux7iu8lXAVyfCeMP+hwLy6Z7At1CbmuKbR4noD32sD 9ihlw0tQ+JH/K6IVXJabn6fTw0QfdfTdbqqyxWmSThKxepdExmy/WpYe6JhPLm6+OGVT 1wFQVZCim1IJ+BeGsebPyh7mmWJlTP+hXP8wrPc3UR2MCf667aOQkC1X1XsSW4UWAGq2 F1zhjpce/TuRGdrcvttu1RxI4YOZKjyh5f8rfS/wLPZXWgJ+kJHscMqgrl7gVUxoqcJ+ 9isA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2x4Zab162lLlsHbMZ2qJSmflJ05n5hmZwtHp/Qyauc4=; b=CPO6JpmK64MoH3HrkXP5pMRQuSorI+CidaTU3mr3Z32CXB0vTo3tqggpJd8U0q/3cA XAsm5rJg9eoJQa7/ZDqcfFb8x5Q7ADrElV4rrdE0KZopE76GteQxplaHeeAIoWinILUL 9zUje1UD9Tv6IElyqC/23r6crYjNL7MULc5U9lDIIrTC0XVY3MpOTCIhVhNCmXUiw6Si c9M+AbeSEx8M+5aBfGuIPGEmbuFmXoNSSnXjfGZ7wOonG2Kz4L5gcF/jPxJmmKcv1jKd YW5vTDXoBIgQ/6DTK5YlIWtIoGr/0BpdmU0Ew4FIuPfDIdTrd9lNcjTIPQqoxJ4iN547 l3iQ== X-Gm-Message-State: ABuFfohEaXaH8djic2PEvQbVibzBA5W3MGnIrf4kH7IWGJ6x98nAu7fE Y8ZVpPBl9+Jg0RoKOZI+59IYB8sVrtM0tF7MQ60= X-Google-Smtp-Source: ACcGV60Ts51UyNIXoEOqomc1C0t5ApYKL9WWehIJbonfJlaRc0qDXtKH9UCN7vuvUofGRdUcf08dKbNOxDuvnopdUwM= X-Received: by 2002:aca:401:: with SMTP id 1-v6mr1916644oie.229.1538610790651; Wed, 03 Oct 2018 16:53:10 -0700 (PDT) In-Reply-To: <877eizwdag.fsf@tu-berlin.de> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::22d X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:118107 Archived-At: On Wed, 3 Oct 2018 at 06:11, Gerald Wildgruber wrote: > (dolist (f argv) > (with-current-buffer (find-file-noselect f) > (mark-whole-buffer) > (unfill-paragraph t) > (org-forward-paragraph) > (save-buffer))) > > It turns out that this works just on the FIRST paragraph of the file! Only this one is edited. The script does not move to the next paragraph. Right, I guess the mark-whole-buffer thing doesn't have the intended effect because it relies on transient-mark-mode, which is probably tied up with the command loop. > So, what works well in a kbd macro (moving point forward to next paragraph via org-forward-paragraph) does not in this script. It makes sense that the paragraph movement doesn't work, because you only call it once per file, so you unfill the 1st paragraph, move to the 2nd, and then leave. > Main problem seems to be: how to iterate through ALL paragraphs of the buffer programmatically, applying "fill-paragraph" each time anew. Perhaps this? (let ((fill-column most-positive-fixnum)) (dolist (f (directory-files-recursively "dir/with/my/files/" (rx (or ".tex" ".org") eos))) (with-current-buffer (find-file-noselect f) (while (not (eobp)) (fill-paragraph) (org-forward-paragraph)) (save-buffer))))