;;AUTOLOAD: file-basename
;;AUTODOC: file-basename "strips file name from path and extension"
;;(file-basename path)
;;
;;returns a string consisting of the filename stripped from pathname 
;;information on the left and any pending extension on the right
;;possible extensions being the elements of the variable *load-extensions*
;;
;;(file-basename "toto")              ==> toto
;;(setq *load-extensions* '(".el"))
;;(file-basename "/foo/bar/titi.el")  ==> titi
;;(file-basename "/foo/bar/titi.c")   ==> titi.c


(defun file-basename (name &aux len)
  (if (match "[/]" name)
    (setq name (match "^.*[/]([^/]*)$" name 1))
  )
  (dolist (ext *load-extensions*)
    (if (setq len (length ext)) (progn
	(if (= ext (subseq name (- (length name) len)))
	  (setq name (subseq name 0 (- (length name) len)))
  ))))
  name
)
