Achim Gratz <strom...@nexgo.de> writes: > You could ask on the Emacs devel list if that'd be OK.
I suggest using this code: (defun org-lookup (val s-list r-list lastp &optional predicate) "Look for VAL in S-LIST and return the corresponding element in R-LIST. If LASTP, ignore all matching VAL in SEARCH-LIST except the last one. If PREDICATE is not nil, use this instead of `equal' to match VAL." (let ((p (or predicate 'equal)) (c 0) r) (nth (dolist (i search-list r) (setq c (1+ c)) (if (and (funcall p val i) (or lastp (not r))) (setq r (1- c)))) return-list))) (defun org-lookup-first (val s-list r-list &optional predicate) "Look for VAL in S-LIST and return the corresponding element in R-LIST. If PREDICATE is not nil, use this instead of `equal' to match VAL." (org-lookup val s-list r-list nil predicate)) (defun org-lookup-last (val s-list r-list &optional predicate) "Look for VAL in S-LIST and return the corresponding element in R-LIST. If PREDICATE is not nil, use this instead of `equal' to match VAL." (org-lookup val s-list r-list t predicate)) ;; (org-lookup-first 2 '(1 2 3 2) '(A B C D E)) => B ;; (org-lookup-last 2 '(1 2 3 2) '(A B C D E)) => D No `cl-position' anymore. Less dense and elegant, of course, but more explicit. Users will be able to check the docstring of org-lookup-first/last, which I think is good for functions that we advertize in the manual. Jarmo, would you be okay if I commit this? Then you can commit a <20 lines patch for the documentation :) Or you commit the code (19 lines!) and I commit the doc patch, as you want! Thanks, -- Bastien