help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting directory-files on their extension


From: Harry Putnam
Subject: Re: Sorting directory-files on their extension
Date: Wed, 07 Oct 2009 10:59:10 -0500
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1.50 (gnu/linux)

Nordlöw <per.nordlow@gmail.com> writes:

> Does Emacs contain any built-in features for sorting file-names (list
> of strings) on their (file) extension?

Someone here will have better help sooner or later but to get started.
Investigate the `sort-lines' command like this:

M-x apropos <RET> sort-lines <RET>

In the resulting buffer click or press enter on the command shown to
get the full documentation string.

sort-lines is an interactive compiled Lisp function in `sort.el'.

(sort-lines REVERSE BEG END)

,----
| Sort lines in region alphabetically; argument means descending order.
| Called from a program, there are three arguments:
| REVERSE (non-nil means reverse order), BEG and END (region to sort).
| The variable `sort-fold-case' determines whether alphabetic case affects
| the sort order.
`----

It looks like that BEG and END is indicating you can set the region to
sort on... I'm not sure if that means you can set it to the extension but
there is a start.

Another whole approach would be to call the external sort command
(assuming a unix or unix like OS) it has enough flags to set about
anything to sort on.

You can call an external command with `shell-command-on-region'
  C+Shift+\

It will give you a chance to setup the flags to sort at a command line.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]