Function: define-ibuffer-sorter

define-ibuffer-sorter is an autoloaded macro defined in ibuf-macs.el.gz.

Signature

(define-ibuffer-sorter NAME DOCUMENTATION (&key DESCRIPTION) &rest BODY)

Documentation

Define a method of sorting named NAME.

DOCUMENTATION is the documentation of the function, which will be called ibuffer-do-sort-by-NAME. DESCRIPTION is a short string describing the sorting method.

For sorting, the forms in BODY will be evaluated with a bound to one buffer object, and b bound to another. BODY should return a non-nil value if and only if a is "less than" b.

Source Code

;; Defined in /usr/src/emacs/lisp/ibuf-macs.el.gz
;;;###autoload
(cl-defmacro define-ibuffer-sorter (name documentation
				       (&key
					description)
				       &rest body)
  "Define a method of sorting named NAME.
DOCUMENTATION is the documentation of the function, which will be called
`ibuffer-do-sort-by-NAME'.
DESCRIPTION is a short string describing the sorting method.

For sorting, the forms in BODY will be evaluated with `a' bound to one
buffer object, and `b' bound to another.  BODY should return a non-nil
value if and only if `a' is \"less than\" `b'.

\(fn NAME DOCUMENTATION (&key DESCRIPTION) &rest BODY)"
  (declare (indent 1) (doc-string 2))
  `(progn
     (defun ,(intern (concat "ibuffer-do-sort-by-" (symbol-name name))) ()
       ,(or documentation "No :documentation specified for this sorting method.")
       (interactive)
       (setq ibuffer-sorting-mode ',name)
       (when (eq ibuffer-sorting-mode ibuffer-last-sorting-mode)
	 (setq ibuffer-sorting-reversep (not ibuffer-sorting-reversep)))
       (ibuffer-redisplay t)
       (setq ibuffer-last-sorting-mode ',name))
     (push (list ',name ,description
                 (lambda (a b)
                   ,@body))
	   ibuffer-sorting-functions-alist)
     :autoload-end))