[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to do a massive unfill paragraph operation over several hundred
From: |
Gerald Wildgruber |
Subject: |
Re: How to do a massive unfill paragraph operation over several hundred files? |
Date: |
Tue, 2 Oct 2018 14:11:09 +0200 |
User-agent: |
mu4e 1.1.0; emacs 27.0.50 |
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
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?, Emanuel Berg, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?, Robert Pluim, 2018/10/01
- Re: How to do a massive unfill paragraph operation over several hundred files?,
Gerald Wildgruber <=
- Re: How to do a massive unfill paragraph operation over several hundred files?, Noam Postavsky, 2018/10/02
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/03
- Re: How to do a massive unfill paragraph operation over several hundred files?, Noam Postavsky, 2018/10/03
- Re: How to do a massive unfill paragraph operation over several hundred files?, Gerald Wildgruber, 2018/10/08
- Message not available
- Re: How to do a massive unfill paragraph operation over several hundred files?, Emanuel Berg, 2018/10/03
- Message not available
- Re: How to do a massive unfill paragraph operation over several hundred files?, Emanuel Berg, 2018/10/02
Message not available