[Top][All Lists]

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

Re: sort list w/o the mouse

From: Emanuel Berg
Subject: Re: sort list w/o the mouse
Date: Thu, 27 Jan 2022 00:05:08 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> (defun erc-sort-list (col)
>   "Pretty COL function."
>   (interactive (list (read-number "column: " 2)))
>   (let ((buffer-read-only nil)
>         (beg (point-min))
>         (end (point-max)) )
>     (if (= col 1)
>         (sort-fields col beg end)
>       (sort-numeric-fields col beg end) )
>     (reverse-region beg end) ))

Maybe a better version:

(defun erc-sort-list (col)
  "Use after /list.
Sort table by  column COL.
A negative value will reverse the result after sorting."
  (interactive (list (read-number "column [- to reverse]: " -2)))
  (let ((colu (abs col))
        (buffer-read-only nil)
        (beg (point-min))
        (end (point-max)) )
    (if (= colu 1)
        (sort-fields colu beg end)
      (sort-numeric-fields colu beg end) )
    (when (< col 0)
      (reverse-region beg end) )
    (goto-char beg) ))


underground experts united

reply via email to

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