From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sanjib Sikder Subject: Re: Sort Phrases Date: Mon, 22 Oct 2012 23:48:36 +0530 Message-ID: References: <1350906016.77719.YahooMailNeo@web29804.mail.ird.yahoo.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d044787d32a9e5004cca9e485 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:57962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQMas-0007ZY-JL for emacs-orgmode@gnu.org; Mon, 22 Oct 2012 14:19:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQMar-0003sr-FN for emacs-orgmode@gnu.org; Mon, 22 Oct 2012 14:19:18 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:38604) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQMar-0003sj-6x for emacs-orgmode@gnu.org; Mon, 22 Oct 2012 14:19:17 -0400 Received: by mail-ie0-f169.google.com with SMTP id 10so5302619ied.0 for ; Mon, 22 Oct 2012 11:19:16 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Giovanni Ridolfi Cc: "emacs-orgmode@gnu.org" --f46d044787d32a9e5004cca9e485 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Giovanni, - substitute "," with \n > - sort region > - substitute \n with "," > 1. I am new in org-mode and emacs. Can you please tell me what is "sort region" and what are the key bindings ? 2. Is there a way by which I can replace all the ',' with '\n' and do the reverse automatically ? Thanks. ----------------------------- *Sanjib Sikder *Ph.D. Fellow Chemical Engineering IIT Bombay* * On Mon, Oct 22, 2012 at 11:44 PM, Sanjib Sikder wro= te: > Hi Giovanni, > > You need to put the following lines into your .emacs to sort WORDS and > LINES. > > --8<---------------cut here---------------start------------->8--- > > ;;;Sort words > (defun sort-words (reverse beg end) > "Sort words in region alphabetically, in REVERSE if negative. > Prefixed with negative \\[universal-argument], sorts in reverse. > The variable `sort-fold-case' determines whether alphabetic case > affects the sort order. > See `sort-regexp-fields'." > (interactive "*P\nr") > (sort-regexp-fields reverse "\\w+" "\\&" beg end)) > > --8<---------------cut here---------------start------------->8--- > > Then to sort words like > > apple, mango, oranges, cat, elephant > > You need to do > > M-x sort-words > > To sort lines, similarly do > > M-x sort-lines > > > > ----------------------------- > *Sanjib Sikder > *Ph.D. Fellow > Chemical Engineering > IIT Bombay* > > * > > > > On Mon, Oct 22, 2012 at 5:10 PM, Giovanni Ridolfi < > giovanni.ridolfi@yahoo.it> wrote: > >> Da: Sanjib Sikder >> >> Inviato: Luned=EC 22 Ottobre 2012 13:27 >> >> >> > I know it is possible to sort words and sort lines alphabetically in >> emacs org-mode >> >> Would you please be so kind to explain to me how? >> >> I have only: >> org-sort-entries M-x ... RET Sort entries on a certain leve= l >> of an outline tree. >> org-sort-list M-x ... RET Sort list items. >> org-table-sort-lines in >> a table. >> >> >> Is it possible to sort words like: >> >> banana fruit chees apple >> >> or lines like >> >> >> banana >> >> fruit >> chees >> >> apple >> >> >> >> > but is it possible to sort phrases ? >> >> > Face the music, Fifteen minutes of fame, A beautiful mind. >> > I want to sort it alphabetically like, >> > A beautiful mind, Face the music, Fifteen minutes of fame. >> >> In Emacs everything is possible. >> >> - substitute "," with \n >> - sort region >> - substitute \n with "," >> >> Cheers, >> >> Giovanni >> >> > --f46d044787d32a9e5004cca9e485 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Giovanni,

- sub= stitute "," with \n
- sort region
- substitute \n with ","

1. I am new in org-m= ode and emacs. Can you please tell me what is "sort region" and w= hat are the key bindings ?
2. Is there a way by which I can replace all = the ',' with '\n' and do the reverse automatically ?

Thanks.


-----------------------------
Sanjib Sikder
Ph.D. Fellow
Chemica= l Engineering
IIT Bombay






On Mon, Oct 22, 2012 at 11:44 PM, Sanjib= Sikder <sanjibju2002@gmail.com> wrote:
Hi Giovanni,

You need to put the following lines into your .emacs to= sort WORDS and LINES.

--8<---------------cut here---------------start------------->8---
=
;;;Sort words
=A0(defun sort-words (reverse beg end)
=A0=A0=A0=A0= =A0 "Sort words in region alphabetically, in REVERSE if negative.
= =A0=A0=A0 Prefixed with negative \\[universal-argument], sorts in reverse.<= br> =A0=A0=A0 The variable `sort-fold-case' determines whether alphabetic c= ase
=A0=A0=A0 affects the sort order.
=A0=A0=A0 See `sort-regexp-fiel= ds'."
=A0=A0=A0=A0=A0 (interactive "*P\nr")
=A0=A0= =A0=A0=A0 (sort-regexp-fields reverse "\\w+" "\\&" = beg end))

--8<---------------cut here---------------start------------->8---

Then to sort words like

apple, mango, oranges, ca= t, elephant

You need to do

M-x sort-words

To sort line= s, similarly do

M-x sort-lines



--------------------= ---------
Sanjib Sikder
Ph.D.= Fellow
Chemical Engineering
IIT Bombay






On Mon, Oct 22, 2012 at 5:10 PM, Giovanni Ridolfi &= lt;giovanni.= ridolfi@yahoo.it> wrote:
Da: Sanjib Sikder <sanjibju2002@gmail.com>

Inviato: Luned=EC 22 Ottobre 2012 13:27


> I know it is possible to sort words and sort lines alphabetically in e= macs org-mode

Would you please be so kind to explain to me how?

I have only:
org-sort-entries=A0=A0=A0 =A0=A0=A0=A0=A0 M-x ... RET =A0 =A0 Sort entries = on a certain level of an outline tree.
org-sort-list=A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0=A0 M-x ... RET =A0 =A0 =A0 So= rt list items.
org-table-sort-lines=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0 <Sort lines in region> in a table.


Is it possible to sort words like:

banana fruit chees=A0 apple

or lines like


banana

fruit
chees

apple



> but is it possible to sort phrases ?

> Face the music, Fifteen minutes of fame, A beautiful mind.<= br> > I want to sort it alphabetically like,
>=A0 A beautiful mind, Face the music, Fifteen minutes of fame.

In Emacs everything is possible.

- substitute "," with \n
- sort region
- substitute \n with ","

Cheers,

Giovanni



--f46d044787d32a9e5004cca9e485--