Subject: Re: bug#35964: TeX-strip-extension not doing what's documented, TeX-master-file always returning relative name

From: Ikumi Keita <[email-masked]>
Date: Wed, 19 Jun 2019 21:20:59 +0900

Hi Jan, sorry for very late reply.

>>>>> Jan Seeger <[email-masked]> writes:
> However, the second case check is implemented without regard for the
> special value 'path, and strips the directory even when NODIR is nil.

> I've modified the check to

>     (if (or (eq nodir t)
> 	    (and (eq nodir 'path)
> 		 (or
> 		  (string-equal dir (expand-file-name "./"))
> 		  (member dir TeX-macro-global)
> 		  (member dir TeX-macro-private))))
> 	(file-name-nondirectory strip)

> and this gives me an absolute path from `TeX-strip-extension`.

Thanks for your suggestion.  If I understand correctly, this change only
affects the case NODIR is nil (or, more precisely, NODIR is neither t
nor `path'.)  Right?

Though I agree that the current implementation of `TeX-strip-extension'
doesn't match its doc string and the proposed change seems sensible, I'm
worrying about the impact of this change.  In `TeX-master-file', we read
----------------------------------------------------------------------
      (if (TeX-match-extension name)
	  ;; If it already has an extension...
	  (if (equal extension TeX-default-extension)
	      ;; Use instead of the default extension
	      (setq extension nil)
	    ;; Otherwise drop it.
	    (setq name (TeX-strip-extension name))))
----------------------------------------------------------------------
.  This is the only place, if my brief survey is correct, in the current
AUCTeX source where `TeX-strip-extension' is called with NODIR argument
being nil.  Are you sure that the proposed change brings no bad side
effects?

> Relatedly, `TeX-master-file` also fails to return an absolute path to
> the master file if the `NONDIR` argument is nil because the `NONDIR`
> argument is not forwarded to TeX-strip-extension, and thus always
> returns a filename without directory part. The relevant line is line
> 2332 in `tex.el`.

Sorry, I don't quite understand what you write here:
(1) The line 2332 in tex.el of the current git master branch is just
(defun TeX-master-file (&optional extension nondirectory ask)
.
(2) Presuming that your NONDIR actually means NONDIRECTORY of
`TeX-master-file', that must be non-nil in order to make difference in
the behavior of `TeX-master-file' if NONDIRECTORY is forwarded to
`TeX-strip-extension'.  So the case that NONDIRECTORY is nil is not
relevant.

Best regards,
Ikumi Keita