> On Dec 20, 2014, at 6:57 AM, Nicolas Goaziou wrote: >> + extractfun comparefun tempfun extract-string-p) > > EXTRACT-STRING-P, and possibly TEMPFUN, are bound too early. See below. I moved EXTRACT-STRING-P to a lower let but TEMPFUN has to be available to the call to sort so I left it in the outer let. > I suggest something like > > (let* ((tempfun (or getkey-func > (intern ...))) > (extract-string-p (stringp (funcall tempfun (caar table))))) > (setq extractfun (if (and extract-string-p (not with-case)) > `(lambda (x) (downcase (funcall ',tempfun x))) > tempfun)) > (setq comparefun > (cond (compare-func) > (extract-string-p (if (= sorting-type ?f) #'string< #'org-string>)) > ((= sorting-type ?f) #'<) > (t #'>)))) I followed this suggestion modulo leaving TEMPFUN in the outer let. Thanks for your suggestions. The attached patch was against the latest master branch at the time I generated it.