GNU bug report logs - #35964
TeX-strip-extension not doing what's documented, TeX-master-file always returning relative name

Previous Next

Package: auctex;

Reported by: Jan Seeger <jan.seeger+auctex <at> thenybble.de>

Date: Tue, 28 May 2019 16:33:02 UTC

Severity: normal

Tags: notabug

Done: Arash Esbati <arash <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35964 in the body.
You can then email your comments to 35964 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-auctex <at> gnu.org:
bug#35964; Package auctex. (Tue, 28 May 2019 16:33:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Jan Seeger <jan.seeger+auctex <at> thenybble.de>:
New bug report received and forwarded. Copy sent to bug-auctex <at> gnu.org. (Tue, 28 May 2019 16:33:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jan Seeger <jan.seeger+auctex <at> thenybble.de>
To: bug-auctex <at> gnu.org
Subject: TeX-strip-extension not doing what's documented,
 TeX-master-file  always returning relative name
Date: Tue, 28 May 2019 17:40:59 +0200
Hey!

While trying to get TeX-master-file to produce an absolute path, I found 
that the `nodir` argument to TeX-strip-extension was not doing what was 
expected. The filename was still getting stripped, and the code on lines 
4393 to 4398 in `tex.el` was responsible for that.

`TeX-strip-extension` is documented in the function's docstring to 
remove the directory name from the file name if (and only if):

(1) The NODIR argument is `t`
(2) The NODIR argument is `'path`, and the file is in the current 
directory or in the LaTeX macro path.

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`.

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`.

I hope these fixes make sense, if you need any more info please do not 
hesitate to ask.

Best regards,
Jan




Information forwarded to bug-auctex <at> gnu.org:
bug#35964; Package auctex. (Wed, 19 Jun 2019 12:22:02 GMT) Full text and rfc822 format available.

Message #8 received at 35964 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Jan Seeger <jan.seeger+auctex <at> thenybble.de>
Cc: 35964 <at> debbugs.gnu.org
Subject: Re: bug#35964: TeX-strip-extension not doing what's documented,
 TeX-master-file always returning relative name
Date: Wed, 19 Jun 2019 21:20:59 +0900
Hi Jan, sorry for very late reply.

>>>>> Jan Seeger <jan.seeger+auctex <at> thenybble.de> 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




Information forwarded to bug-auctex <at> gnu.org:
bug#35964; Package auctex. (Thu, 20 Jun 2019 10:43:02 GMT) Full text and rfc822 format available.

Message #11 received at 35964 <at> debbugs.gnu.org (full text, mbox):

From: Ikumi Keita <ikumi <at> ikumi.que.jp>
To: Jan Seeger <jan.seeger+auctex <at> thenybble.de>
Cc: 35964 <at> debbugs.gnu.org
Subject: Re: bug#35964: TeX-strip-extension not doing what's documented,
 TeX-master-file always returning relative name
Date: Thu, 20 Jun 2019 19:42:13 +0900
Hi Jan,

Please keep 35964 <at> debbugs.gnu.org in Cc: when you reply.

>>>>> Jan Seeger <jan.seeger+auctex <at> thenybble.de> writes:
> If there is a better way to get the absolute path of the master file,
> let me know!

How about "%a" defined in `TeX-expand-list-builtin' instead of your
"%(abs)"?
(Ah, but it seems to my eyes not to return the expected file name when
used with partical typeset like C-c C-r and so on...  If that is
problematic for you, please let us know.)

> To explain some backstory: I've added a custom viewer (Foxit) with an
> argument that allows automatic reloading on Windows. However, Foxit is
> a multi-document application, so the working directory of the current
> Foxit instance might not be the same as that of Emacs. So Foxit
> requires the absolute path to be able to open the file.

[ ... ]

> During this, I found out that `TeX-master-file` will not return
> absolute paths, even if the `nondirectory` argument is nil.

I have an impression that many part of of AUCTeX expects master file
name to be without directory part.  So I don't think that it is a good
idea to change `TeX-master-file' to return absolute path every time its
third argument is nil.

>> 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)
>> .

> This might be a version difference, I'll paste the modified code here
> for convenience:
> -----
>   (let ((my-name (if (buffer-file-name)
> 		     (TeX-strip-extension nil (list
> TeX-default-extension) nondirectory)
> 		   "<none>")))
> -----
> The existing code left out the `nondirectory` argument, causing
> `TeX-strip-extension` to return a relative filename again.

Thanks, I see.

>> (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.

> The original line is this:
> -----
> (let ((my-name (if (buffer-file-name)
> 		     (TeX-strip-extension nil (list TeX-default-extension) t)
> 		   "<none>")))
> -----
> which means that `my-name` is always the non-directory name, which is
> not what the documentation of TeX-master-file states.

IMHO, the sentence "If optional second argument NONDIRECTORY is non-nil,
do not include the directory." in the doc string of `TeX-master-file'
does not gurantee that it returns absolute path if NONDIRECTORY is nil.
It just states the case when NONDIRECTORY is non-nil, and nothing when
NONDIRECTORY is nil.  I think `TeX-master-file' is designed so that
(TeX-master-file) returns "main" in the buffer of main.tex and
"../master" in the buffer of sub.tex with local variable specification
%%% TeX-master: "../master"
.

Regards,
Ikumi Keita




Information forwarded to bug-auctex <at> gnu.org:
bug#35964; Package auctex. (Wed, 03 Apr 2024 18:40:02 GMT) Full text and rfc822 format available.

Message #14 received at 35964 <at> debbugs.gnu.org (full text, mbox):

From: Arash Esbati <arash <at> gnu.org>
To: Ikumi Keita <ikumi <at> ikumi.que.jp>
Cc: 35964 <at> debbugs.gnu.org, Jan Seeger <jan.seeger+auctex <at> thenybble.de>
Subject: Re: bug#35964: TeX-strip-extension not doing what's documented,
 TeX-master-file  always returning relative name
Date: Wed, 03 Apr 2024 20:38:43 +0200
Ikumi Keita <ikumi <at> ikumi.que.jp> writes:

> IMHO, the sentence "If optional second argument NONDIRECTORY is non-nil,
> do not include the directory." in the doc string of `TeX-master-file'
> does not gurantee that it returns absolute path if NONDIRECTORY is nil.
> It just states the case when NONDIRECTORY is non-nil, and nothing when
> NONDIRECTORY is nil.  I think `TeX-master-file' is designed so that
> (TeX-master-file) returns "main" in the buffer of main.tex and
> "../master" in the buffer of sub.tex with local variable specification
> %%% TeX-master: "../master"
> .

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

No more response, I'm therefore closing this, assuming that we will not
change the way `TeX-master-file' works.

Best, Arash




Added tag(s) notabug. Request was from Arash Esbati <arash <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 03 Apr 2024 18:40:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 35964 <at> debbugs.gnu.org and Jan Seeger <jan.seeger+auctex <at> thenybble.de> Request was from Arash Esbati <arash <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 03 Apr 2024 18:40:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 02 May 2024 11:24:09 GMT) Full text and rfc822 format available.

This bug report was last modified 1 day ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.