From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Gerald Wildgruber Newsgroups: gmane.emacs.help Subject: Re: How to do a massive unfill paragraph operation over several hundred files? Date: Sun, 30 Sep 2018 21:47:32 +0200 Message-ID: <87pnwuvkbv.fsf@tu-berlin.de> References: <8636ts4jz3.fsf@zoho.com> Reply-To: wildgruber@tu-berlin.de NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1538336767 14694 195.159.176.226 (30 Sep 2018 19:46:07 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 30 Sep 2018 19:46:07 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: help-gnu-emacs@gnu.org To: Emanuel Berg Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 30 21:46:03 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 1g6hfG-0003j5-R3 for geh-help-gnu-emacs@m.gmane.org; Sun, 30 Sep 2018 21:46:03 +0200 Original-Received: from localhost ([::1]:57087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6hhN-00007s-1l for geh-help-gnu-emacs@m.gmane.org; Sun, 30 Sep 2018 15:48:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6hgy-00007n-8t for help-gnu-emacs@gnu.org; Sun, 30 Sep 2018 15:47:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6hgt-0001iS-83 for help-gnu-emacs@gnu.org; Sun, 30 Sep 2018 15:47:48 -0400 Original-Received: from exchange.tu-berlin.de ([130.149.7.70]:11144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6hgs-0001f8-U7 for help-gnu-emacs@gnu.org; Sun, 30 Sep 2018 15:47:43 -0400 Original-Received: from SPMA-03.tubit.win.tu-berlin.de (localhost.localdomain [127.0.0.1]) by localhost (Email Security Appliance) with SMTP id EC8F76BC1F_BB12855B; Sun, 30 Sep 2018 19:47:33 +0000 (GMT) Original-Received: from exchange.tu-berlin.de (exchange.tu-berlin.de [130.149.7.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "exchange.tu-berlin.de", Issuer "DFN-Verein Global Issuing CA" (not verified)) by SPMA-03.tubit.win.tu-berlin.de (Sophos Email Appliance) with ESMTPS id 8E75F6B082_BB12855F; Sun, 30 Sep 2018 19:47:33 +0000 (GMT) Original-Received: from corax (178.198.8.89) by ex-mbx-10.tubit.win.tu-berlin.de (130.149.6.164) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Sun, 30 Sep 2018 21:47:33 +0200 In-Reply-To: <8636ts4jz3.fsf@zoho.com> X-ClientProxiedBy: ex-mbx-10.tubit.win.tu-berlin.de (130.149.6.164) To ex-mbx-10.tubit.win.tu-berlin.de (130.149.6.164) X-PMWin-Version: 4.0.1, Antivirus-Engine: 3.73.0, Antivirus-Data: 5.55 X-PureMessage: [Scanned] X-SASI-RCODE: 200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tu-berlin.de; h=references:from:to:cc:subject:reply-to:in-reply-to:date:message-id:mime-version:content-type; s=dkim-tub; bh=HFY5Cul1Oy3NWAmh9YND0ZHE5WU1J+2w2HE3dlRi4Nk=; b=KUlXRtiuf7F/o/dwrUOZZrLFur77OK3MKiT4Upb8R2YrB8NZFC5I1RwaIrJ65GVUDgBSRFcBzDfy47R5gSTSz+xDbtWY6lqbnhzgq7gAAeKoGY9ncAzUjX7lMX1VxYMKVo3ffIYpjhwhU97s2TZh6mwTz0BGAO6VLuXhPeU79Qg= X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 130.149.7.70 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:118081 Archived-At: Hi, thanks for the hint! What I do now is the following: in every file I want to normalize (= unwrap) I use a kbd macro consisting of two consecutive functions: 1. an unfill function (originally posted by Stefan Monnier if I remember correctly): (defun unfill-paragraph (&optional region) "Takes a multi-line paragraph and makes it into a single line of text." (interactive (progn (barf-if-buffer-read-only) '(t))) (let ((fill-column (point-max))) (fill-paragraph nil region))) 2. org-forward-paragraph I then repeat the macro with an infinite argument. This works quite well and the result requires very little manual correction; all Org mode constructs like lists, blocks etc are preserved. But these are of course interactive functions; how would I script them to non-interactive code in the way you proposed for emacs batch processing, i.e. not expecting any input except a number files to operate on? Can I load org-mode on the fly in order for emacs to understand the second function (org-forward-paragraph)? Thanks Gerald. On Sa, Sep 29 2018, Emanuel Berg wrote: > Gerald Wildgruber wrote: > >> MY QUESTION: What would be a good way to >> AUTOMATE such an unfill operation, removing all >> line breaks from all paragraphs over a large >> number of files? > > Script to insert a string into files > 1, 2, and 3: > > #! /bin/zsh > > local script=do-this.el > > emacs -Q --batch --script $script 1 2 3 > > Elisp to do it: > > ;; do-this.el > > (dolist (f argv) > (find-file f) > (insert "Sail Ho!") ; do your thing here > (save-buffer) ) --------------------- Sent with mu4e