Tyler Smith <ty...@plantarum.ca> writes: > I'm trying to define a style hook for a personal macro that takes a file > name, without the extension, as an argument. From the manual, I think > this should be possible via the `TeX-arg-file` argument hook: > > 'TeX-arg-file' > Prompt for a filename in the current directory, and use it without > the extension. > > My style file looks like this: > > (TeX-add-style-hook > "cba" > (lambda () > (TeX-add-symbols > '("ColumnFigure" ["caption"] TeX-arg-file) > '("ColumnPhoto" ["caption"] TeX-arg-file-name) > '("FullPhoto" ["caption"] TeX-arg-file-name-sans-extension) > '("featureAuthor" 1)))) > > The result is that \ColumnFigure prompts me for the caption, and > completes a file name, but the inserted file includes the extension. You > see I also tried 'TeX-arg-file-name', and > 'TeX-arg-file-name-sans-extension', but those don't provide filename > completion, just a prompt. `TeX-arg-input-file` provides completion, but > only for items in TeX's search path, not the current directory. > > Looking at the code for TeX-arg-file, neither the code or the doc string > indicate that the extension will be trimmed. > > 1) Is this a bug in the documentation?
I think it is a bug in the documentation. Can you please file a bug report for this? > 2) Is there a way to prompt the user for an extension-less filename via > style hooks? You can roll your own function in the style. Adapt this one to your needs. --8<---------------cut here---------------start------------->8--- (defun TeX-arg-cba-file-sans-extension (optional) "Prompt for a filename in the current directory. If OPTIONAL is non-nil, insert the resulting value as an optional argument, otherwise as a mandatory one. The filename is included sans extension and relative to directory of master file." (TeX-argument-insert (file-name-sans-extension (file-relative-name (read-file-name (TeX-argument-prompt optional nil "File")) (TeX-master-directory))) optional)) (TeX-add-style-hook "cba" (lambda () (TeX-add-symbols '("ColumnFigure" ["caption"] TeX-arg-file) '("ColumnPhoto" ["caption"] TeX-arg-file-name) '("FullPhoto" ["caption"] TeX-arg-file-name-sans-extension) '("AllPhoto" TeX-arg-cba-file-sans-extension) '("featureAuthor" 1)))) --8<---------------cut here---------------end--------------->8--- Best, Arash _______________________________________________ auctex mailing list auctex@gnu.org https://lists.gnu.org/mailman/listinfo/auctex