Function: TeX-strip-extension

TeX-strip-extension is a byte-compiled function defined in tex.el.

Signature

(TeX-strip-extension &optional STRING EXTENSIONS NODIR NOSTRIP)

Documentation

Return STRING without any trailing extension in EXTENSIONS.

If NODIR is t, also remove directory part of STRING. If NODIR is path, remove directory part of STRING if it is equal to the current directory or is a member of TeX-macro-private(var)/TeX-macro-private(fun) or TeX-macro-global(var)/TeX-macro-global(fun). If NOSTRIP is set, do not remove extension after all. STRING defaults to the name of the current buffer. EXTENSIONS defaults to TeX-file-extensions.

Source Code

;; Defined in ~/.emacs.d/elpa/auctex-14.1.2/tex.el
(defun TeX-strip-extension (&optional string extensions nodir nostrip)
  "Return STRING without any trailing extension in EXTENSIONS.
If NODIR is t, also remove directory part of STRING.
If NODIR is `path', remove directory part of STRING if it is
equal to the current directory or is a member of
`TeX-macro-private' or `TeX-macro-global'.
If NOSTRIP is set, do not remove extension after all.
STRING defaults to the name of the current buffer.
EXTENSIONS defaults to `TeX-file-extensions'."

  (if (null string)
      (setq string (or (TeX-buffer-file-name) "<none>")))

  (if (null extensions)
      (setq extensions TeX-file-extensions))

  (let* ((strip (if (and (not nostrip)
                         (TeX-match-extension string extensions))
                    (substring string 0 (match-beginning 0))
                  string))
         (dir (expand-file-name (or (file-name-directory strip) "./"))))
    (if (or (eq nodir t)
            (string-equal dir (expand-file-name "./"))
            (member dir (mapcar #'file-name-as-directory TeX-macro-global))
            (member dir (mapcar #'file-name-as-directory TeX-macro-private)))
        (file-name-nondirectory strip)
      strip)))