all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Gerald Wildgruber <wildgruber@tu-berlin.de>
To: Robert Pluim <rpluim@gmail.com>
Cc: help-gnu-emacs@gnu.org, Emanuel Berg <moasen@zoho.com>
Subject: Re: How to do a massive unfill paragraph operation over several hundred files?
Date: Tue, 2 Oct 2018 14:11:09 +0200	[thread overview]
Message-ID: <87efd8v99e.fsf@tu-berlin.de> (raw)
In-Reply-To: <875zyl1yls.fsf@gmail.com>


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 terminal, but the file itself remains untouched. It isn't edited at all, same timestamp etc.

Sorry for the inconvenience, but I have the impression I'm getting something completely wrong here, but can't see what.

Do you?


On Mo, Okt 01 2018, Robert Pluim <rpluim@gmail.com> wrote:

> Gerald Wildgruber <wildgruber@tu-berlin.de> writes:
>
>> On Mo, Okt 01 2018, Emanuel Berg <moasen@zoho.com> 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ʼs optional, which means it will be 'nil' if you donʼt specify 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


-- 
Dr. Gerald Wildgruber
Institut für Philosophie, Literatur-, Wissenschafts- und Technikgeschichte
Literaturwissenschaft mit Schwerpunkt Literatur und Wissenschaft
Technische Universität Berlin
Straße 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



  reply	other threads:[~2018-10-02 12:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1463.1538170475.1284.help-gnu-emacs@gnu.org>
2018-09-29 11:32 ` How to do a massive unfill paragraph operation over several hundred files? Emanuel Berg
2018-09-29 12:04   ` history of argv (was: Re: How to do a massive unfill paragraph operation over several hundred files?) Emanuel Berg
2018-09-29 12:44     ` Skip Montanaro
2018-09-29 23:20       ` John Yates
     [not found]       ` <mailman.1503.1538263274.1284.help-gnu-emacs@gnu.org>
2018-09-30 18:20         ` Emanuel Berg
     [not found]     ` <mailman.1481.1538225108.1284.help-gnu-emacs@gnu.org>
2018-09-29 15:14       ` Emanuel Berg
2018-09-29 18:07       ` Barry Margolin
2018-09-29 21:20     ` James K. Lowden
2018-09-30 19:47   ` How to do a massive unfill paragraph operation over several hundred files? Gerald Wildgruber
     [not found]   ` <mailman.1577.1538336869.1284.help-gnu-emacs@gnu.org>
2018-09-30 20:28     ` Emanuel Berg
2018-10-01  5:48       ` Gerald Wildgruber
     [not found]       ` <mailman.1589.1538372941.1284.help-gnu-emacs@gnu.org>
2018-10-01  9:42         ` Emanuel Berg
2018-10-01 14:37           ` Gerald Wildgruber
2018-10-01 15:21             ` Robert Pluim
2018-10-02 12:11               ` Gerald Wildgruber [this message]
2018-10-02 15:37                 ` Noam Postavsky
2018-10-03 10:11                   ` Gerald Wildgruber
2018-10-03 23:52                     ` Noam Postavsky
2018-10-08  5:42                       ` Gerald Wildgruber
     [not found]                   ` <mailman.1666.1538561477.1284.help-gnu-emacs@gnu.org>
2018-10-03 14:12                     ` Emanuel Berg
     [not found]               ` <mailman.1650.1538482287.1284.help-gnu-emacs@gnu.org>
2018-10-02 15:11                 ` Emanuel Berg
     [not found]           ` <mailman.1626.1538404685.1284.help-gnu-emacs@gnu.org>
2018-10-01 15:12             ` Emanuel Berg
2018-09-28  8:16 Gerald Wildgruber
2018-09-29  2:04 ` ken
     [not found] ` <mailman.1466.1538186663.1284.help-gnu-emacs@gnu.org>
2018-09-29 11:34   ` Emanuel Berg
2018-09-30  5:10     ` Van L

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87efd8v99e.fsf@tu-berlin.de \
    --to=wildgruber@tu-berlin.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=moasen@zoho.com \
    --cc=rpluim@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.