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

2024-04-03 Thread Arash Esbati
Ikumi Keita  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



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex


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

2019-06-20 Thread Ikumi Keita
Hi Jan,

Please keep 35...@debbugs.gnu.org in Cc: when you reply.

> Jan Seeger  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)
>  "")))
> -
> 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)
>  "")))
> -
> 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



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex


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

2019-06-19 Thread Ikumi Keita
Hi Jan, sorry for very late reply.

> Jan Seeger  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



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex


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

2019-05-28 Thread Jan Seeger

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



___
bug-auctex mailing list
bug-auctex@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-auctex