auctex-devel
[Top][All Lists]
Advanced

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

Re: catchfilebetweentags the final version.


From: Arash Esbati
Subject: Re: catchfilebetweentags the final version.
Date: Wed, 24 Aug 2022 22:35:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50

Hi Uwe,

Uwe Brauer <oub@mat.ucm.es> writes:

> I am really sorry, I did some renaming of variables that I did not
> tested. Now it should be ok.

Thanks for the patch.  I still have some comments before installing
this:

> Add support for catchfilebetweentags
>
> * style/catchfilebetweentags.el: Add support for catchfilebetweentags, 
> including optional automatic labeling.

Can you please fill the line above?  AUCTeX repo has a .dir-locals.el
file which does this:

 (change-log-mode . ((mode . bug-reference)
                     (add-log-time-zone-rule . t)
                     (fill-column . 74)))

So hitting M-q on the line should do the job.

> * Makefile.in (STYLEELC): Add style/catchfilebetweentags.el

Period at the end is missing.

> diff --git a/Makefile.in b/Makefile.in
> --- a/Makefile.in
> +++ b/Makefile.in
> @@ -183,7 +183,7 @@
>          style/ifpdf.el     style/iftex.el     style/ifvtex.el \
>          style/ifxetex.el   style/multibib.el  style/ltcaption.el \
>          style/keyval.el    style/kvoptions.el style/kvsetkeys.el \
> -        style/proc.el      style/microtype.el
> +        style/proc.el      style/microtype.el style/catchfilebetweentags.el \

No need to hide the end of line with \ after your addition.

> +(TeX-add-style-hook
> + "catchfilebetweentags"
> + (lambda ()
> +   (TeX-add-symbols
> +    '("ExecuteMetaData"
> +      ;; Act like \include and not like \input:
> +      [TeX-arg-input-file "File" t] "Tag")
> +    '("ExecuteMetaData*"
> +      ;; Act like \include and not like \input:
> +      [TeX-arg-input-file "File" t] "Tag"))

What about the other macros provided by the package?
\CatchFileBetweenTags and \CatchFileBetweenDelims?

> +   (LaTeX-add-environments
> +    '("catchfilebetweenfiletags"  catchbetween-insert-environment))

Please prefix your variables and functions with LaTeX-<packagename>.

> +(defvar catchbetween-use-numeric-label t
> +  "Variable to insert automatic numerical labels.")
> +(make-variable-buffer-local 'catchbetween-use-numeric-label)

I think this one should be customizable variable, right?  Then it should
go in tex-style.el and look like this:

(defcustom LaTeX-catchfilebetweentags-use-numeric-label t
  "Insert automatic numerical labels if non-nil."
  :type 'boolean)

> +(defvar catchbetween-counter 0
> +  "Counter for catchfilebetweentags  numbers.")
> +(make-variable-buffer-local 'catchbetween-counter)

I suggest to initialize this one to nil and add it
`TeX-normal-mode-reset-list' in the style hook.  Then a user can reset
the variable with 'C-u C-c C-n' if it gets out of sync.  Do:

(defvar-local LaTeX-catchfilebetweentags-counter nil
  "Counter for LaTeX-catchfilebetweentags numbers.")

And drop the (make-variable-buffer-local 'catchbetween-counter).

> +;; scanning function, stolen from markdown-mode, simplified thanks to Arash 
> Esbati <arash@gnu.org> 
> +(defun catchbetween-counter-inc () 
> +  "Increment `catchbetween-counter' and return the new value."
> +  (when (= catchbetween-counter 0)
> +    (save-excursion
> +      (goto-char (point-min))
> +      (while (re-search-forward (concat "%<\\*\\([^>]+\\)>$")
> +                                (point-max) t)
> +        (let ((fn (string-to-number (match-string 1))))
> +          (when (> fn catchbetween-counter)
> +            (setq catchbetween-counter fn))))))
> +  (setq catchbetween-counter (1+ catchbetween-counter)))

I'd re-write this one, see the file attached.

> +(defun catchbetween-environment ()
> +  "Insert a skeleton with a counter for the `LaTeX' package 
> `catchfilebetweentags'."
> +  (interactive)
> +  (save-excursion
> +    (when catchbetween-use-numeric-label
> +      (let ((fn (catchbetween-counter-inc)))
> +        (insert (concat "%<*" (format "%s" fn)  ">\n\n%</" (format "%s" fn) 
> ">" ))))
> +    (unless catchbetween-use-numeric-label
> +      (insert (concat "%<*"   ">\n\n%</"  ">" ))))
> +  (forward-line))
> +
> +(defun catchbetween-insert-environment (environment)
> +  (catchbetween-environment))

Note that the compiler will bark about unused argument `environment',
prefix it with an underscore to suppress it, i.e., `_environment'.

Have a look at file attached, that is my comments on this.  Tell me what
you think.

Best, Arash

Attachment: catchfilebetweentags.el
Description: application/emacs-lisp


reply via email to

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