auctex-devel
[Top][All Lists]
Advanced

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

Re: catchfilebetweentags the final version.


From: Uwe Brauer
Subject: Re: catchfilebetweentags the final version.
Date: Thu, 25 Aug 2022 08:43:36 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>>> "AE" == Arash Esbati <arash@gnu.org> writes:

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

Just to be on the safe side, you want a line break at char 74?


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

> Period at the end is missing.

ok

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

I just looked the line before and I understood that after three entries
a in a line \ is needed. Ok I change that.

>> +(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?

Ok, I will add that 

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

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

Do you mean 

LaTeX-catchfilebetweenfiletags

As a prefix? Uff, ok. I was not sure about the conventions.

>> +(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)

Frankly I use defcustom, as a user but I never dared to use in my elisp
files. So you also want me to change tex-style.el?

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

Ah I did not know that defvar-local existed, thanks

>> +;; 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))
>> +

Oops something got wrong here. My orginal code hat the unless
construction, but when rebasing there was a merge conflict (not sure why
and the old version was taken, autsch, thanks)

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

Aha, I did not know about that one, neither, thanks

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

Ok I will, and try to test it especially the defcustom and tex-style.ek stuff


Thanks

Uwe 
> Best, Arash



-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

Attachment: smime.p7s
Description: S/MIME cryptographic signature


reply via email to

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