* How to alphabetasize sections?
@ 2014-09-12 0:29 Sharon Kimble
2014-09-12 7:11 ` Thien-Thi Nguyen
2014-09-12 7:11 ` Sharon Kimble
0 siblings, 2 replies; 11+ messages in thread
From: Sharon Kimble @ 2014-09-12 0:29 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 849 bytes --]
In the booklet that I am writing in latex, one chapter has about 20
sections, which have just been added to at the end when something else
has needed to be written about. They are of the form of -
--8<---------------cut here---------------start------------->8---
\section*{Rhubarb and custard}
Ipsum lorenzum alal balall aka blurb
\section*{Apple pie and cream}
Even more blurb, etc.
--8<---------------cut here---------------end--------------->8---
I now want to have all the sections in alphabetical order, but how can I
do it please? How can I move all the sections and their following text
From the commandline please?
Thanks
Sharon.
--
A taste of linux = http://www.sharons.org.uk
my git repo = https://bitbucket.org/boudiccas/dots
TGmeds = http://www.tgmeds.org.uk
Debian testing, fluxbox 1.3.5, emacs 24.3.93.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
2014-09-12 0:29 How to alphabetasize sections? Sharon Kimble
@ 2014-09-12 7:11 ` Thien-Thi Nguyen
2014-09-12 23:20 ` Robert Thorpe
2014-09-12 7:11 ` Sharon Kimble
1 sibling, 1 reply; 11+ messages in thread
From: Thien-Thi Nguyen @ 2014-09-12 7:11 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 791 bytes --]
() Sharon Kimble <boudiccas@skimble.plus.com>
() Fri, 12 Sep 2014 01:29:50 +0100
\section*{Rhubarb and custard}
Ipsum lorenzum alal balall aka blurb
\section*{Apple pie and cream}
Even more blurb, etc.
I now want to have all the sections in alphabetical order
One way is to add (or augment) the local variables block
in the file to read:
% Local variables:
% paragraph-separate: "\\section"
% End:
then save, then revert, then mark the region around all the
\section (and text), and type ‘M-x sort-paragraphs RET’.
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
2014-09-12 0:29 How to alphabetasize sections? Sharon Kimble
2014-09-12 7:11 ` Thien-Thi Nguyen
@ 2014-09-12 7:11 ` Sharon Kimble
1 sibling, 0 replies; 11+ messages in thread
From: Sharon Kimble @ 2014-09-12 7:11 UTC (permalink / raw)
To: Sharon Kimble; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1235 bytes --]
Sharon Kimble <boudiccas@skimble.plus.com> writes:
> In the booklet that I am writing in latex, one chapter has about 20
> sections, which have just been added to at the end when something else
> has needed to be written about. They are of the form of -
>
> \section*{Rhubarb and custard}
> Ipsum lorenzum alal balall aka blurb
>
> \section*{Apple pie and cream}
> Even more blurb, etc.
>
> I now want to have all the sections in alphabetical order, but how can I
> do it please? How can I move all the sections and their following text
> From the commandline please?
>
Sorted with a bit of lateral thinking! I wasn't able to 'fold it' with
auctex/latex so I did 'M-x org-mode' and then put a '* \section{etc}',
folded each one and was then able to arrange it as I want very quickly
and easily too. About 5-10 minutes and its all done and dusted! Then
unfold each section heading when its properly converted and delete the
star, and finally just do 'M-x latex-mode' and now everything is all
hunky dory again! :)
Sharon.
--
A taste of linux = http://www.sharons.org.uk
my git repo = https://bitbucket.org/boudiccas/dots
TGmeds = http://www.tgmeds.org.uk
Debian testing, fluxbox 1.3.5, emacs 24.3.93.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
2014-09-12 7:11 ` Thien-Thi Nguyen
@ 2014-09-12 23:20 ` Robert Thorpe
0 siblings, 0 replies; 11+ messages in thread
From: Robert Thorpe @ 2014-09-12 23:20 UTC (permalink / raw)
To: help-gnu-emacs; +Cc: help-gnu-emacs
Thien-Thi Nguyen <ttn@gnu.org> writes:
> One way is to add (or augment) the local variables block
> in the file to read:
>
> % Local variables:
> % paragraph-separate: "\\section"
> % End:
>
> then save, then revert, then mark the region around all the
> \section (and text), and type ‘M-x sort-paragraphs RET’.
Another way is to do search and replace (M-%):
\\section
with
^L
\\section
Then use sort-pages. Finally M-% again to get rid of the ^Ls.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
[not found] <mailman.8788.1410564074.1147.help-gnu-emacs@gnu.org>
@ 2014-09-13 0:00 ` Emanuel Berg
2014-09-13 0:58 ` Thorsten Jolitz
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Emanuel Berg @ 2014-09-13 0:00 UTC (permalink / raw)
To: help-gnu-emacs
Robert Thorpe <rt@robertthorpeconsulting.com> writes:
>> One way is to add (or augment) the local variables
>> block in the file to read: % Local variables: %
>> paragraph-separate: "\\section" % End: then save,
>> then revert, then mark the region around all the
>> \section (and text), and type ‘M-x sort-paragraphs
>> RET’.
>
> Another way is to do search and replace (M-%):
> \\section with ^L \\section
>
> Then use sort-pages. Finally M-% again to get rid of
> the ^Ls.
That's very creative, both of you, but isn't the best
way to move all the sections to separate files and then
put one-line references in the "motherfile", and simply
sort those with `sort-lines'?
--
underground experts united
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
2014-09-13 0:00 ` Emanuel Berg
@ 2014-09-13 0:58 ` Thorsten Jolitz
2014-09-13 1:29 ` Robert Thorpe
` (2 subsequent siblings)
3 siblings, 0 replies; 11+ messages in thread
From: Thorsten Jolitz @ 2014-09-13 0:58 UTC (permalink / raw)
To: help-gnu-emacs
Emanuel Berg <embe8573@student.uu.se> writes:
> Robert Thorpe <rt@robertthorpeconsulting.com> writes:
>
>>> One way is to add (or augment) the local variables
>>> block in the file to read: % Local variables: %
>>> paragraph-separate: "\\section" % End: then save,
>>> then revert, then mark the region around all the
>>> \section (and text), and type ‘M-x sort-paragraphs
>>> RET’.
>>
>> Another way is to do search and replace (M-%):
>> \\section with ^L \\section
>>
>> Then use sort-pages. Finally M-% again to get rid of
>> the ^Ls.
>
> That's very creative, both of you, but isn't the best
> way to move all the sections to separate files and then
> put one-line references in the "motherfile", and simply
> sort those with `sort-lines'?
With the trunk branch of outshine.el (and outshine and navi-mode
properly installed, and outline-minor-mode activated) you can just do:
,----[ C-h f outshine-latex-insert-headers-in-buffer RET ]
| outshine-latex-insert-headers-in-buffer is an interactive Lisp
| function in `outshine.el'.
|
| (outshine-latex-insert-headers-in-buffer &optional BUF-OR-NAME
| NO-PREAMBLE-P)
|
| Insert outshine-headers for all sections in latex-mode buffer.
| Use current-buffer, unless BUF-OR-NAME is given. Add a 1st-level
| preamble header unless NO-PREAMBLE-P is non-nil.
`----
to automatically insert meaningful outshine headers for all latex
sections in current buffer, call navi-mode and type e.g. '3' or '4'
(show headers up to level 3 or 4), and then kill and yank the subtrees
with 'k' and 'y'.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
2014-09-13 0:00 ` Emanuel Berg
2014-09-13 0:58 ` Thorsten Jolitz
@ 2014-09-13 1:29 ` Robert Thorpe
2014-09-13 7:50 ` Thien-Thi Nguyen
[not found] ` <mailman.8807.1410594408.1147.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 11+ messages in thread
From: Robert Thorpe @ 2014-09-13 1:29 UTC (permalink / raw)
To: Emanuel Berg; +Cc: help-gnu-emacs
Emanuel Berg <embe8573@student.uu.se> writes:
>
> That's very creative, both of you, but isn't the best
> way to move all the sections to separate files and then
> put one-line references in the "motherfile", and simply
> sort those with `sort-lines'?
I'd say it depends how long the sections they are. If they're quite
short it's probably best to put them in one file. If they're longer
than a few pages it's probably best to split them.
BR,
Robert Thorpe
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
[not found] <mailman.8797.1410571808.1147.help-gnu-emacs@gnu.org>
@ 2014-09-13 5:27 ` Emanuel Berg
0 siblings, 0 replies; 11+ messages in thread
From: Emanuel Berg @ 2014-09-13 5:27 UTC (permalink / raw)
To: help-gnu-emacs
Robert Thorpe <rt@robertthorpeconsulting.com> writes:
>> That's very creative, both of you, but isn't the
>> best way to move all the sections to separate files
>> and then put one-line references in the
>> "motherfile", and simply sort those with
>> `sort-lines'?
>
> I'd say it depends how long the sections they are. If
> they're quite short it's probably best to put them in
> one file. If they're longer than a few pages it's
> probably best to split them.
Yes, of course.
But: when you boil water, the changes from 50 degrees
to 51 degrees or 74 to 75 doesn't mean a thing. But
from 99 to 100 it means the water boils, i.e. has
changed state. Quantity has turned into quality.
If you, like the OP, has decided sorting is necessary
to keep it under control, then that tells me the switch
from 99 to 100 has already occurred. If there were few
or very short sections, sorting wouldn't cross your
mind to begin with, as the situation would have been
possible to grasp by inspection anyway.
Now, this is generally speaking. The OP knows her
situation and if she wants to sort it in one file, that
will be an improvement. But I wouldn't be surprised if
she, soon, will want to have separate files (at the
next stage of 99->100, or 999->1000 perhaps).
The advantages of an organized file system to express
purpose as well as all the practical boosts it gets you
- that's an overlooked thing. Many computer people do
it without thinking. But it still surprises me that you
very rarely read about it in books and tutorials.
--
underground experts united
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
2014-09-13 0:00 ` Emanuel Berg
2014-09-13 0:58 ` Thorsten Jolitz
2014-09-13 1:29 ` Robert Thorpe
@ 2014-09-13 7:50 ` Thien-Thi Nguyen
[not found] ` <mailman.8807.1410594408.1147.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 11+ messages in thread
From: Thien-Thi Nguyen @ 2014-09-13 7:50 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]
() Emanuel Berg <embe8573@student.uu.se>
() Sat, 13 Sep 2014 02:00:02 +0200
but isn't the best way to move all the sections to
separate files and then put one-line references in
the "motherfile", and simply sort those with
`sort-lines'?
I don't think there is a "best way" per se in Emacs
(although certainly there are many suboptimal ways,
including not using Emacs at all!), so it depends on
what other attributes one desires from the exercise.
I.e., YMMV.
Personally, i am inclined towards more declarative
approaches, and away from those that involve a lot of
(high(er) entropy) data motion and manularity. I
figure Emacs, my patient teacher and gracious host,
has all the crispy cookies i crave; the nice hack then
is simply finding a polite way to ask for them...
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
[not found] ` <mailman.8807.1410594408.1147.help-gnu-emacs@gnu.org>
@ 2014-09-13 19:22 ` Emanuel Berg
2014-09-15 7:27 ` Thien-Thi Nguyen
0 siblings, 1 reply; 11+ messages in thread
From: Emanuel Berg @ 2014-09-13 19:22 UTC (permalink / raw)
To: help-gnu-emacs
Thien-Thi Nguyen <ttn@gnu.org> writes:
> I don't think there is a "best way" per se in Emacs
> (although certainly there are many suboptimal ways,
> including not using Emacs at all!), so it depends on
> what other attributes one desires from the exercise.
> I.e., YMMV.
Yes.
> and away from those that involve a lot of (high(er)
> entropy)
Yeah? - the entropy is the directories and the files
and the references in the main file?
But that stuff contains information as well - OK, the
same information as would a huge file - but the same
information in a way that is much better suited to, in
turn, be communicated to a human.
At least those humans who are dealing with file trees
all day long: they see a file tree with file names and
they don't see slashes and letters and dots. They see
purpose and structure. (They see blondes and
brunettes...)
But: do you see those wenches by looking at a very,
very long LaTeX source file, with sections so long they
don't fit on a screen by far, making you not even
immediately notice there are sections? I think not!
> data motion
Do you mean when the subdivision is done, or in
compilation? That must be considered very slim data
motion in both cases. Compilation is already not
exactly manual and the subdivision can be automatized
if deemed necessary (i.e., large amount of sections).
Automatic movement that virtually never fails (at least
in the compilation case, just including some files) -
is such movement still of bad? (Why is data motion bad
at all by the way?)
> and manularity.
Yes: I don't mind doing it manually! Step one is to
realize there need to be order. Step two is to create
that order. This will often increase understanding
tenfold.
For example, a project in C++. Let's say it was somehow
implemented so you could have all the C++ source files,
the header files, the Makefile, and the object files in
one file - and it would even contain the executable
binary... Would you want that? No. So where does C++
cross the line where it makes sense to have different
files? And where would that line go for LateX?
--
underground experts united
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to alphabetasize sections?
2014-09-13 19:22 ` Emanuel Berg
@ 2014-09-15 7:27 ` Thien-Thi Nguyen
0 siblings, 0 replies; 11+ messages in thread
From: Thien-Thi Nguyen @ 2014-09-15 7:27 UTC (permalink / raw)
To: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 2351 bytes --]
() Emanuel Berg <embe8573@student.uu.se>
() Sat, 13 Sep 2014 21:22:39 +0200
Yeah? - the entropy is the directories and the files
and the references in the main file?
Entropy is everywhere. When it gets too involved w/ the
sorting of \section blocks, the disk drive dies sooner.
[hypothetical document organization]
I don't see how this relates to the OP's sorting issue.
> data motion
Do you mean when the subdivision is done, or in
compilation?
In this case, data motion of the actual sort is managed by
Emacs, so i have no choice in the matter. Under my control,
instead, is how to specify the data head and the data body.
In the procedure i sketched, there is a lot of bulk data
motion for that (writing to disk plus revert, all just to
set a buffer-local variable), because it was written for a
possibly non-expert audience. Personally, i would have:
(setq ttn "\\section")
(rotatef ttn paragraph-separate)
;; mark region
;; M-x sort-paragraphs RET
(rotatef ttn paragraph-separate)
(makunbound 'ttn)
which neither sullies the buffer nor touches disk. (Now,
someone will say "hey ttn, Emacs now has commands to push /
pop buffer-local vars -- check it out!", you just watch!)
(Why is data motion bad at all by the way?)
It's not good or bad per se. However, when you have an old
computer, the consequences of too much disk activity becomes
a worry. Although the OP did not specify the computer's
age, i try to factor-in that worry in my advice anyway,
because computers grow older and people suffer when theirs
dies, universally. Obviously, here i somewhat failed...
> and manularity.
[hypothetical C++ project organization]
The other suggestion is essentially the same as the one i
made, except that there is formfeed (i.e., ‘^L’) involved.
That's the kind of manularity i understand but try to avoid.
Luckily Emacs lets us surf at many levels...
[OT: BTW, if anyone wants to donate to me a less than
ancient computer (and is willing to pay shipping :-D),
please feel free to contact me off list.]
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-09-15 7:27 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-12 0:29 How to alphabetasize sections? Sharon Kimble
2014-09-12 7:11 ` Thien-Thi Nguyen
2014-09-12 23:20 ` Robert Thorpe
2014-09-12 7:11 ` Sharon Kimble
[not found] <mailman.8788.1410564074.1147.help-gnu-emacs@gnu.org>
2014-09-13 0:00 ` Emanuel Berg
2014-09-13 0:58 ` Thorsten Jolitz
2014-09-13 1:29 ` Robert Thorpe
2014-09-13 7:50 ` Thien-Thi Nguyen
[not found] ` <mailman.8807.1410594408.1147.help-gnu-emacs@gnu.org>
2014-09-13 19:22 ` Emanuel Berg
2014-09-15 7:27 ` Thien-Thi Nguyen
[not found] <mailman.8797.1410571808.1147.help-gnu-emacs@gnu.org>
2014-09-13 5:27 ` Emanuel Berg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).