Subject: tiny extension to sort.el

From: dupayrat bertrand <[email-masked]>
Date: Sun, 9 Oct 2011 09:12:24 +0200 (CEST)

;;
;; the snippet : "indirect value" how-to :
;; (defconst to-nil nil) <-- C-x e ;;i don't found such a canonic thing in emacs . 
;; 
;; (progn (setq var "testv" testv "hit") (eval(read var))) <-- C-x e
;; (progn (setq var "to-nil" testv "any-value") (eval(read var))) <-- C-X e
;;
;; _application_ : add an option reverse to sort-fields-1 this behind the scene .
;;
(defconst to-nil nil "to-nil := nil : invariant")
(defvar reverse-sort-field-var-name nil "see sort-fields-1") ;; add it to custom default value to-nil

(defun sort-fields-1 (field beg end startkeyfun endkeyfun) "sort-field-1 with direct/reverse feature"
(let ((tbl (syntax-table)))
(if (zerop field) (setq field 1))
(unwind-protect
(save-excursion
(save-restriction
(narrow-to-region beg end)
(goto-char (point-min))
(set-syntax-table sort-fields-syntax-table)
(sort-subr (eval (read reverse-sort-field-var-name)) ; the backward compatible (tiny) extension.
; !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! and not "nil"
'forward-line 'end-of-line
startkeyfun endkeyfun)))
(set-syntax-table tbl)))))
;;

;;