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: Tue, 2 Oct 2018 14:11:09 +0200 Message-ID: <87efd8v99e.fsf@tu-berlin.de> References: <8636ts4jz3.fsf@zoho.com> <86zhvyzq4c.fsf@zoho.com> <86muryype2.fsf@zoho.com> <87in2lvikf.fsf@tu-berlin.de> <875zyl1yls.fsf@gmail.com> Reply-To: wildgruber@tu-berlin.de NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1538482189 32023 195.159.176.226 (2 Oct 2018 12:09:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 2 Oct 2018 12:09:49 +0000 (UTC) User-Agent: mu4e 1.1.0; emacs 27.0.50 Cc: help-gnu-emacs@gnu.org, Emanuel Berg To: Robert Pluim Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 02 14:09: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 1g7JUk-0008BP-6b for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Oct 2018 14:09:42 +0200 Original-Received: from localhost ([::1]:43394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7JWq-0002xU-Rq for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Oct 2018 08:11:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7JWP-0002xO-D9 for help-gnu-emacs@gnu.org; Tue, 02 Oct 2018 08:11:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g7JWL-0003U9-Bh for help-gnu-emacs@gnu.org; Tue, 02 Oct 2018 08:11:25 -0400 Original-Received: from exchange.tu-berlin.de ([130.149.7.70]:5295) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g7JWK-0003QZ-UX for help-gnu-emacs@gnu.org; Tue, 02 Oct 2018 08:11:21 -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 4DDBA6C9C1_BB3605EB; Tue, 2 Oct 2018 12:11:10 +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 C4A1D6C924_BB3605DF; Tue, 2 Oct 2018 12:11:09 +0000 (GMT) Original-Received: from corax (178.198.8.89) by ex-mbx-10.tubit.win.tu-berlin.de (172.26.35.180) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 2 Oct 2018 14:11:09 +0200 In-Reply-To: <875zyl1yls.fsf@gmail.com> X-ClientProxiedBy: EX-CAS-02.tubit.win.tu-berlin.de (172.26.35.182) To ex-mbx-10.tubit.win.tu-berlin.de (172.26.35.180) 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:content-transfer-encoding; s=dkim-tub; bh=p5wXmkPKhTUFN4UbPvtc0KpTi1v82/m809Qv3toQQVE=; b=XIJ3dq5bpH7rNYiRvx79g+I57DcgZY+07f8HeZLf7uxwQPHMSnNb0NvQS3fGTM/PBPisOZ2XPBSnKRSz4YsV1cnHsvr2IwWZA4eST4DpBqEMuC8V2y8H7zJo1igiiLo4o+KGLJcTEif/VgexY0Ee15tYiJjVtxjoAy0YmkLGaxA= 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:118091 Archived-At: Thanks Emanuel and Robert for explanations: I now have a script unfill.el containing these lines: ------------------------------------------------------------ (require 'org) ;; https://www.emacswiki.org/emacs/UnfillParagraph (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))) (dolist (f argv) (find-file f) (mark-whole-buffer) (unfill-paragraph t) (org-forward-paragraph) (save-buffer)) ------------------------------------------------------------ I call this from a terminal like so: emacs -Q --batch --script unfill.el FILE.org Unfortunately, nothing happens; I get two "Mark set" messages in the termin= al, but the file itself remains untouched. It isn't edited at all, same tim= estamp etc. Sorry for the inconvenience, but I have the impression I'm getting somethin= g completely wrong here, but can't see what. Do you? On Mo, Okt 01 2018, Robert Pluim wrote: > Gerald Wildgruber writes: > >> On Mo, Okt 01 2018, Emanuel Berg wrote: >> >>> Gerald Wildgruber wrote: >>> >>>> But how can I use the unfill-paragraph >>>> function programmatically (non-interactively) >>>> in a script >>> >>> (unfill-paragraph ARGS) >> >> Yes, that is the whole point I didn't understand! What does "ARGS" have = to be when called non-interactively in a script. From the doc string of the= function: >> >> (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))) > > It=CA=BCs optional, which means it will be 'nil' if you don=CA=BCt specif= y it, > which means (from the docsting of 'fill-paragraph') > > The REGION argument is non-nil if called interactively; in that > case, if Transient Mark mode is enabled and the mark is active, > call `fill-region' to fill each of the paragraphs in the active > region, instead of just filling the current paragraph. > > So 'nil' just means 'fill the current paragraph'. It might work for > you if you mark the whole buffer, and call > > (unfill-paragraph t) > > instead, since that should take care of iterating over all the > paragraphs (untested). > > Robert --=20 Dr. Gerald Wildgruber Institut f=C3=BCr Philosophie, Literatur-, Wissenschafts- und Technikgeschi= chte Literaturwissenschaft mit Schwerpunkt Literatur und Wissenschaft Technische Universit=C3=A4t Berlin Stra=C3=9Fe des 17. Juni 135 D-10623 Berlin http://www.philosophie.tu-berlin.de/menue/home/ T. +49 (0)30 314 25924 F. +49 (0)30 314 23107 wildgruber@tu-berlin.de --------------------- Sent with mu4e