[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [AUCTeX] Adding macro support, TeX-arg-file hook

From: Arash Esbati
Subject: Re: [AUCTeX] Adding macro support, TeX-arg-file hook
Date: Thu, 15 Sep 2016 09:17:17 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1

Tyler Smith <address@hidden> 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

--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-prompt optional nil "File"))

 (lambda ()
    '("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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]