unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [ELPA] some tex-related packages
@ 2024-05-19 17:06 Paul Nelson
  2024-05-20  6:33 ` Philip Kaludercic
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-05-19 17:06 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 987 bytes --]

I have a few tex-related packages that I'd like to submit to ELPA.  They
all rely on AUCTeX 14.0.5, which was just released today.  (I'd be happy to
make a separate post for each, if that'd be easier.)

https://github.com/ultronozm/tex-numbers.el
https://github.com/ultronozm/tex-continuous.el
https://github.com/ultronozm/preview-auto.el

tex-numbers provides an interface for retrieving label numbers from tex
documents and uses this to augment some features of AUCTeX (previews,
folds, ...) with correct numbering.

tex-continuous provides a minor mode in which a tex document is compiled
continuously using latexmk, the error log is parsed using AUCTeX, and
errors are reported via flymake.

preview-auto provides a minor mode in which AUCTeX previews generate
automatically in the visible part of the buffer.

I've shared these primarily via word-of-mouth to colleagues, and have
received positive feedback.  Any other feedback or suggestions would be
welcome.

Thanks, best,

Paul

[-- Attachment #2: Type: text/html, Size: 1269 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-19 17:06 [ELPA] some tex-related packages Paul Nelson
@ 2024-05-20  6:33 ` Philip Kaludercic
  2024-05-20  9:01   ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Philip Kaludercic @ 2024-05-20  6:33 UTC (permalink / raw)
  To: Paul Nelson; +Cc: emacs-devel

Paul Nelson <ultrono@gmail.com> writes:

> I have a few tex-related packages that I'd like to submit to ELPA.  They
> all rely on AUCTeX 14.0.5, which was just released today.  (I'd be happy to
> make a separate post for each, if that'd be easier.)

That's not necessary.

> https://github.com/ultronozm/tex-numbers.el
> https://github.com/ultronozm/tex-continuous.el
> https://github.com/ultronozm/preview-auto.el
>
> tex-numbers provides an interface for retrieving label numbers from tex
> documents and uses this to augment some features of AUCTeX (previews,
> folds, ...) with correct numbering.

At first the name made me think the package dealt with built-in numbers
in TeX (e.g. to simplify arithmetic).  But a cursory look at the sources
makes it seems like it is LaTeX specific.  Perhaps it should be renamed
to something like "latex-numbering"?

> tex-continuous provides a minor mode in which a tex document is compiled
> continuously using latexmk, the error log is parsed using AUCTeX, and
> errors are reported via flymake.

That sounds interesting.  Here again, tex- implies one thing but latexmk
another.  Is the dependency on latexmk hard, or could you re-use
AUCTeX's facilities?

> preview-auto provides a minor mode in which AUCTeX previews generate
> automatically in the visible part of the buffer.

This makes me think, have you communicated any of these features to the
AUCTeX developers?  Perhaps it would make more sense to upstream these
as patches instead of having too many little packages?

> I've shared these primarily via word-of-mouth to colleagues, and have
> received positive feedback.  Any other feedback or suggestions would be
> welcome.
>
> Thanks, best,
>
> Paul

-- 
	Philip Kaludercic on peregrine



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-20  6:33 ` Philip Kaludercic
@ 2024-05-20  9:01   ` Paul Nelson
  2024-05-20  9:18     ` Philip Kaludercic
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-05-20  9:01 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: emacs-devel, Arash Esbati

[-- Attachment #1: Type: text/plain, Size: 3703 bytes --]

Hi Philip (CC: Arash, in case you have further thoughts),


>   Perhaps it should be renamed to something like "latex-numbering"?
>

Thanks for this suggestion, agreed.


>
> > tex-continuous provides a minor mode in which a tex document is compiled
> > continuously using latexmk, the error log is parsed using AUCTeX, and
> > errors are reported via flymake.
>
> That sounds interesting.  Here again, tex- implies one thing but latexmk
> another.


How about "latexmk-continuous"?  (The names latex-flymake and
auctex-latexmk are both taken, and those packages do different things.  The
new feature is that the compilation takes place continuously rather than on
demand, with the errors reported in the buffer.)


> Is the dependency on latexmk hard, or could you re-use AUCTeX's facilities?
>

AUCTeX provides TeX-command-run-all, which does something similar to
latexmk (and also runs "View" at the end, displaying the PDF, which I
suppose could be disabled somehow).  I considered swapping latexmk for
TeX-command-run-all + after-save-hook, but this seemed troublesome for a
few reasons.  One was that the timer for preview-auto (my other package,
mentioned below) doesn't fire when AUCTeX's processes are active, so if we
use AUCTeX to regularly recompile the document, then there will be
stretches of time in which the previews don't update.  The use of a
separate (latexmk) process adds something like a secondary compilation
thread, keeping the primary thread free for preview-auto.

I don't view the dependency on latexmk as serious, since I believe it is
included nowadays in all tex distributions (and I have colleagues who have
been using my package on each of the major OS's, so it seems portable in
practice).  My package does re-use AUCTeX's error parsing facilities, which
in some sense provide the heavy lifting, and also respects some AUCTeX
configuration variables, such as TeX-output-dir.  I'd be happy to update
the package to use more of AUCTeX's facilities if someone spotted a way to
do so without the issues that I encountered.



>
> > preview-auto provides a minor mode in which AUCTeX previews generate
> > automatically in the visible part of the buffer.
>
> This makes me think, have you communicated any of these features to the
> AUCTeX developers?  Perhaps it would make more sense to upstream these
> as patches instead of having too many little packages?
>
>
They've been communicated, and the first two have been discussed:

https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00043.html
https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00066.html
https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00086.html

They rely on recent AUCTeX patches:

https://lists.gnu.org/archive/html/bug-auctex/2024-04/threads.html

The question of upstreaming one of them was raised:

https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00173.html

I'd be happy with whatever makes the most sense, but figured submitting to
ELPA would make them readily available without introducing additional
burden on the AUCTeX maintainers.

On the topic of "too many little packages", I'll confess that I have a few
more in the queue, e.g.:

https://github.com/ultronozm/tex-parens.el
https://github.com/ultronozm/tex-item.el
https://github.com/ultronozm/preview-auto.el

(plus a few more, listed at https://github.com/ultronozm/emacsd, that I'd
like to think about more before "formally" publishing)

I've been trying to split the functionality accumulated in my config into
the smallest coherent packages that I can, but would welcome feedback or
other suggestions, especially if there are trade-offs with having too many
little packages.

Thanks, best,

Paul

[-- Attachment #2: Type: text/html, Size: 6015 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-20  9:01   ` Paul Nelson
@ 2024-05-20  9:18     ` Philip Kaludercic
  2024-05-20 17:37       ` Arash Esbati
  0 siblings, 1 reply; 19+ messages in thread
From: Philip Kaludercic @ 2024-05-20  9:18 UTC (permalink / raw)
  To: Paul Nelson; +Cc: emacs-devel, Arash Esbati

Paul Nelson <ultrono@gmail.com> writes:

> Hi Philip (CC: Arash, in case you have further thoughts),
>
>
>>   Perhaps it should be renamed to something like "latex-numbering"?
>>
>
> Thanks for this suggestion, agreed.
>
>>
>> > tex-continuous provides a minor mode in which a tex document is compiled
>> > continuously using latexmk, the error log is parsed using AUCTeX, and
>> > errors are reported via flymake.
>>
>> That sounds interesting.  Here again, tex- implies one thing but latexmk
>> another.
>
>
> How about "latexmk-continuous"?  (The names latex-flymake and
> auctex-latexmk are both taken, and those packages do different things.  The
> new feature is that the compilation takes place continuously rather than on
> demand, with the errors reported in the buffer.)

Sounds good and descriptive!

>
>> Is the dependency on latexmk hard, or could you re-use AUCTeX's facilities?
>>
>
> AUCTeX provides TeX-command-run-all, which does something similar to
> latexmk (and also runs "View" at the end, displaying the PDF, which I
> suppose could be disabled somehow).  I considered swapping latexmk for
> TeX-command-run-all + after-save-hook, but this seemed troublesome for a
> few reasons.  One was that the timer for preview-auto (my other package,
> mentioned below) doesn't fire when AUCTeX's processes are active, so if we
> use AUCTeX to regularly recompile the document, then there will be
> stretches of time in which the previews don't update.  The use of a
> separate (latexmk) process adds something like a secondary compilation
> thread, keeping the primary thread free for preview-auto.
>
> I don't view the dependency on latexmk as serious, since I believe it is
> included nowadays in all tex distributions (and I have colleagues who have
> been using my package on each of the major OS's, so it seems portable in
> practice).  My package does re-use AUCTeX's error parsing facilities, which
> in some sense provide the heavy lifting, and also respects some AUCTeX
> configuration variables, such as TeX-output-dir.  I'd be happy to update
> the package to use more of AUCTeX's facilities if someone spotted a way to
> do so without the issues that I encountered.

As it is an external package, I don't think the dependency on the
external package is an issue either (especially if the name makes it
explicit to prevent an unpleasant surprise).

>>
>> > preview-auto provides a minor mode in which AUCTeX previews generate
>> > automatically in the visible part of the buffer.
>>
>> This makes me think, have you communicated any of these features to the
>> AUCTeX developers?  Perhaps it would make more sense to upstream these
>> as patches instead of having too many little packages?
>>
>>
> They've been communicated, and the first two have been discussed:
>
> https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00043.html
> https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00066.html
> https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00086.html
>
> They rely on recent AUCTeX patches:
>
> https://lists.gnu.org/archive/html/bug-auctex/2024-04/threads.html
>
> The question of upstreaming one of them was raised:
>
> https://lists.gnu.org/archive/html/auctex-devel/2024-04/msg00173.html
>
> I'd be happy with whatever makes the most sense, but figured submitting to
> ELPA would make them readily available without introducing additional
> burden on the AUCTeX maintainers.

I'll let the AUCTeX maintainers decide.  That being said, I am sure
they'd always appreciate a helping hand in general.

> On the topic of "too many little packages", I'll confess that I have a few
> more in the queue, e.g.:
>
> https://github.com/ultronozm/tex-parens.el
> https://github.com/ultronozm/tex-item.el
> https://github.com/ultronozm/preview-auto.el
>
> (plus a few more, listed at https://github.com/ultronozm/emacsd, that I'd
> like to think about more before "formally" publishing)
>
> I've been trying to split the functionality accumulated in my config into
> the smallest coherent packages that I can, but would welcome feedback or
> other suggestions, especially if there are trade-offs with having too many
> little packages.

It might just be my view, but having too many little packages makes it
difficult for newcomers to get an overview and understand what they want
or need.  Having code under the maintainance of a group of people
usually makes it more future-proof, both by reducing the bus-factor but
also by having more time to fine polish the code.

> Thanks, best,
>
> Paul

-- 
	Philip Kaludercic on peregrine



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-20  9:18     ` Philip Kaludercic
@ 2024-05-20 17:37       ` Arash Esbati
  2024-05-22 16:10         ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Arash Esbati @ 2024-05-20 17:37 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Paul Nelson, emacs-devel

Philip Kaludercic <philipk@posteo.net> writes:

> Paul Nelson <ultrono@gmail.com> writes:
>
>> How about "latexmk-continuous"?  (The names latex-flymake and
>> auctex-latexmk are both taken, and those packages do different things.  The
>> new feature is that the compilation takes place continuously rather than on
>> demand, with the errors reported in the buffer.)
>
> Sounds good and descriptive!

My suggestion is: For everything that depends on AUCTeX, prefix it with
auctex-, and for others which work with built-in mode as well, take tex-
as prefix.  Rationale: it makes things easier to find once you do 'M-x
list-packages RET'.

>>> This makes me think, have you communicated any of these features to the
>>> AUCTeX developers?  Perhaps it would make more sense to upstream these
>>> as patches instead of having too many little packages?
>>>
>>>
>> They've been communicated, and the first two have been discussed:

I think the agreement was to patch AUCTeX in order to provide enough
compat code so Paul's package would run smoothly.

>> I'd be happy with whatever makes the most sense, but figured submitting to
>> ELPA would make them readily available without introducing additional
>> burden on the AUCTeX maintainers.
>
> I'll let the AUCTeX maintainers decide.  That being said, I am sure
> they'd always appreciate a helping hand in general.

Disussion about upstreaming parts of Paul's code would be the next step,
I think, based on user feedback and request.  Reg. helping hands: Always
welcome, but I really wish that people take over which actually use
LaTeX/AUCTeX/RefTeX on a regular basis.  I can tell for Tassilo and
myself that we don't use LaTeX anymore, and that for many years now.

> It might just be my view, but having too many little packages makes it
> difficult for newcomers to get an overview and understand what they want
> or need.

I think that having small packages which do the job right isn't that
bad.  I wish package writers would be more in contact with AUCTeX
developers (Paul did it right), and the developers would be more
responsive to package author's requests (I tried to help as far as I
could).

Best, Arash



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-20 17:37       ` Arash Esbati
@ 2024-05-22 16:10         ` Paul Nelson
  2024-05-27 16:13           ` Arash Esbati
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-05-22 16:10 UTC (permalink / raw)
  To: Arash Esbati; +Cc: Philip Kaludercic, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1415 bytes --]

>
>
> My suggestion is: For everything that depends on AUCTeX, prefix it with
> auctex-, and for others which work with built-in mode as well, take tex-
> as prefix.  Rationale: it makes things easier to find once you do 'M-x
> list-packages RET'.
>

Copy.  So maybe "auctex-numbering" (or "auctex-latex-numbering"?) and
"auctex-latexmk-continuous"?  (unless these are considered suitable for
upstreaming, in which case the point is moot)


> >> I'd be happy with whatever makes the most sense, but figured submitting
> to
> >> ELPA would make them readily available without introducing additional
> >> burden on the AUCTeX maintainers.
> >
> > I'll let the AUCTeX maintainers decide.  That being said, I am sure
> > they'd always appreciate a helping hand in general.
>
> Disussion about upstreaming parts of Paul's code would be the next step,
> I think, based on user feedback and request.


Let me know what, if anything, I should do to help with this.


> Reg. helping hands: Always
> welcome, but I really wish that people take over which actually use
> LaTeX/AUCTeX/RefTeX on a regular basis.  I can tell for Tassilo and
> myself that we don't use LaTeX anymore, and that for many years now.
>

I qualify as a long-time daily user of latex/auctex (and until fairly
recently, reftex), but am ignorant of tex more broadly.  Happy to help how
I can.


> (I tried to help as far as I could).
>
>
(Thanks again!)

[-- Attachment #2: Type: text/html, Size: 2291 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-22 16:10         ` Paul Nelson
@ 2024-05-27 16:13           ` Arash Esbati
  2024-05-27 19:07             ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Arash Esbati @ 2024-05-27 16:13 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Philip Kaludercic, emacs-devel

Paul Nelson <ultrono@gmail.com> writes:

> Copy.  So maybe "auctex-numbering" (or "auctex-latex-numbering"?) and
> "auctex-latexmk-continuous"?

"auctex-label-numbers" or "auctex-cont-latexmk" come to my mind. 

> (unless these are considered suitable for upstreaming, in which case
> the point is moot)

I'd like to see the functionality of

• tex-item.el
• tex-parens.el and
• tex-numbers.el

in AUCTeX.  But I'd suggest you make all your packages available via
ELPA now in order to get some feedback.  You can
remove/obsolete/whatever them once the code is merged.  I think it will
take some time to review/polish the code, e.g.:

--8<---------------cut here---------------start------------->8---
(defun tex-parens--beginning-of-defun ()
  "Move to the beginning of the current defun.
Here `defun' means top-level environment."
  (interactive)
  (re-search-backward "^\\\\begin{[^}]+}" nil t))
--8<---------------cut here---------------end--------------->8---

Why do you use an internal name for a command, or:

--8<---------------cut here---------------start------------->8---
(defun tex-numbers-update-cache (aux-file)
  "Update the cache for AUX-FILE.
Return the updated cache, or nil if the aux file does not exist."
  (when (file-exists-p aux-file)
    (with-temp-buffer
      (insert-file-contents aux-file)
      (let ((cache (make-hash-table :test 'equal))
            (pattern "\\newlabel{\\([^}]+\\)}{{\\([^}]+\\)}"))
        (save-excursion
          (goto-char (point-min))
          (while (re-search-forward pattern nil t)
            (let ((label (match-string 1))
                  (number (match-string 2)))
              (puthash label number cache))))
        (puthash 'timestamp (current-time) cache)
        (puthash aux-file cache tex-numbers-cache)
        cache))))
--8<---------------cut here---------------end--------------->8---

I think pattern should be "\\\\newlabel{\\([^}]+\\)}{{\\([^}]+\\)}"
if you want to pass it to `re-search-forward'.

But I suggest we move the discussion about "which part to upstream" to
auctex-devel.

> I qualify as a long-time daily user of latex/auctex (and until fairly
> recently, reftex), but am ignorant of tex more broadly.  Happy to help
> how I can.

I think you qualify to start hacking on AUCTeX and push it in any
direction you (and other users) think it should go :-)

> (Thanks again!)

My pleasure.

Best, Arash



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-27 16:13           ` Arash Esbati
@ 2024-05-27 19:07             ` Paul Nelson
  2024-06-02 12:51               ` Arash Esbati
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-05-27 19:07 UTC (permalink / raw)
  To: Arash Esbati; +Cc: Philip Kaludercic, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2293 bytes --]

OK, many thanks.  I renamed as suggested (the links should redirect), and
will wait for Philip's instructions on the next steps re. ELPA, so as to
get more feedback.  (I've thus far incorporated feedback from colleagues,
e.g., five people on my hallway, and a few elsewhere, who have been using
some of these packages over the past year or so.)

I'll respond to the specific issues you noted here, saving further
discussion re. AUCTeX for auctex-devel:

--8<---------------cut here---------------start------------->8---
> (defun tex-parens--beginning-of-defun ()
>   "Move to the beginning of the current defun.
> Here `defun' means top-level environment."
>   (interactive)
>   (re-search-backward "^\\\\begin{[^}]+}" nil t))
> --8<---------------cut here---------------end--------------->8---
>
> Why do you use an internal name for a command
>

The idea was that this function would be used only in the setup function,
like so: (setq-local beginning-of-defun-function
#'tex-parens--beginning-of-defun).  I guess I didn't need to make it
(interactive).  I've removed the (interactive) for now, but could just as
well keep it and give the command an external name.


>
> --8<---------------cut here---------------start------------->8---
> (defun tex-numbers-update-cache (aux-file)
>   "Update the cache for AUX-FILE.
> Return the updated cache, or nil if the aux file does not exist."
>   (when (file-exists-p aux-file)
>     (with-temp-buffer
>       (insert-file-contents aux-file)
>       (let ((cache (make-hash-table :test 'equal))
>             (pattern "\\newlabel{\\([^}]+\\)}{{\\([^}]+\\)}"))
>         (save-excursion
>           (goto-char (point-min))
>           (while (re-search-forward pattern nil t)
>             (let ((label (match-string 1))
>                   (number (match-string 2)))
>               (puthash label number cache))))
>         (puthash 'timestamp (current-time) cache)
>         (puthash aux-file cache tex-numbers-cache)
>         cache))))
> --8<---------------cut here---------------end--------------->8---
>
> I think pattern should be "\\\\newlabel{\\([^}]+\\)}{{\\([^}]+\\)}"
> if you want to pass it to `re-search-forward'.
>

Thanks.  (I had failed to notice this error because, by luck, it worked
anyway: the regexp "\\n" matches "n".)

Paul

[-- Attachment #2: Type: text/html, Size: 3064 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-05-27 19:07             ` Paul Nelson
@ 2024-06-02 12:51               ` Arash Esbati
  2024-06-02 18:44                 ` Philip Kaludercic
  0 siblings, 1 reply; 19+ messages in thread
From: Arash Esbati @ 2024-06-02 12:51 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Paul Nelson, emacs-devel

Paul Nelson <ultrono@gmail.com> writes:

> OK, many thanks.  I renamed as suggested (the links should redirect),
> and will wait for Philip's instructions on the next steps re. ELPA, so
> as to get more feedback.

Philip, can you please have a look at Paul's request and get the process
rolling?  TIA.

Best, Arash



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-02 12:51               ` Arash Esbati
@ 2024-06-02 18:44                 ` Philip Kaludercic
  2024-06-02 19:11                   ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Philip Kaludercic @ 2024-06-02 18:44 UTC (permalink / raw)
  To: Arash Esbati; +Cc: Paul Nelson, emacs-devel

Arash Esbati <arash@gnu.org> writes:

> Paul Nelson <ultrono@gmail.com> writes:
>
>> OK, many thanks.  I renamed as suggested (the links should redirect),
>> and will wait for Philip's instructions on the next steps re. ELPA, so
>> as to get more feedback.
>
> Philip, can you please have a look at Paul's request and get the process
> rolling?  TIA.

My backlog has been increasing to an uncomfortable degree, and I am
afraid I don't have an overview of the packages that are currently being
discussed.  Could someone (I presume Paul) just provide me the URLs to
the Git repositories, so I can take a look and add them to elpa.git?
Sorry for the inconvenience and the slowdown.

> Best, Arash

-- 
	Philip Kaludercic on peregrine



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-02 18:44                 ` Philip Kaludercic
@ 2024-06-02 19:11                   ` Paul Nelson
  2024-06-02 19:53                     ` Philip Kaludercic
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-06-02 19:11 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Arash Esbati, emacs-devel

> > Philip, can you please have a look at Paul's request and get the process
> > rolling?  TIA.
>
> My backlog has been increasing to an uncomfortable degree, and I am
> afraid I don't have an overview of the packages that are currently being
> discussed.  Could someone (I presume Paul) just provide me the URLs to
> the Git repositories, so I can take a look and add them to elpa.git?
> Sorry for the inconvenience and the slowdown.

https://github.com/ultronozm/auctex-label-numbers.el
https://github.com/ultronozm/auctex-cont-latexmk.el
https://github.com/ultronozm/preview-auto.el
https://github.com/ultronozm/tex-parens.el
https://github.com/ultronozm/tex-item.el
https://github.com/ultronozm/preview-tailor.el

Please don't hesitate to let me know if there's anything I can do to help.

Thanks, best,

Paul



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-02 19:11                   ` Paul Nelson
@ 2024-06-02 19:53                     ` Philip Kaludercic
  2024-06-02 20:03                       ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Philip Kaludercic @ 2024-06-02 19:53 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Arash Esbati, emacs-devel

Paul Nelson <ultrono@gmail.com> writes:

>> > Philip, can you please have a look at Paul's request and get the process
>> > rolling?  TIA.
>>
>> My backlog has been increasing to an uncomfortable degree, and I am
>> afraid I don't have an overview of the packages that are currently being
>> discussed.  Could someone (I presume Paul) just provide me the URLs to
>> the Git repositories, so I can take a look and add them to elpa.git?
>> Sorry for the inconvenience and the slowdown.
>
> https://github.com/ultronozm/auctex-label-numbers.el
> https://github.com/ultronozm/auctex-cont-latexmk.el
> https://github.com/ultronozm/preview-auto.el
> https://github.com/ultronozm/tex-parens.el
> https://github.com/ultronozm/tex-item.el
> https://github.com/ultronozm/preview-tailor.el

Thanks.

> Please don't hesitate to let me know if there's anything I can do to help.

Can you just confirm that you are proposing for these packages to be
added to GNU ELPA?

> Thanks, best,
>
> Paul

-- 
	Philip Kaludercic on peregrine



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-02 19:53                     ` Philip Kaludercic
@ 2024-06-02 20:03                       ` Paul Nelson
  2024-06-16 16:20                         ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-06-02 20:03 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Arash Esbati, emacs-devel

> Can you just confirm that you are proposing for these packages to be
> added to GNU ELPA?
>

Yes



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-02 20:03                       ` Paul Nelson
@ 2024-06-16 16:20                         ` Paul Nelson
  2024-06-17 10:45                           ` Philip Kaludercic
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-06-16 16:20 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Arash Esbati, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 297 bytes --]

Hi Philip, just thought I’d check in on this and offer again to help
however I can. Thanks, best,  Paul

On Sun, 2 Jun 2024 at 13:03, Paul Nelson <ultrono@gmail.com> wrote:

> > Can you just confirm that you are proposing for these packages to be
> > added to GNU ELPA?
> >
>
> Yes
>

[-- Attachment #2: Type: text/html, Size: 729 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-16 16:20                         ` Paul Nelson
@ 2024-06-17 10:45                           ` Philip Kaludercic
  2024-06-17 10:52                             ` Philip Kaludercic
  0 siblings, 1 reply; 19+ messages in thread
From: Philip Kaludercic @ 2024-06-17 10:45 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Arash Esbati, emacs-devel

Paul Nelson <ultrono@gmail.com> writes:

> Hi Philip, just thought I’d check in on this and offer again to help
> however I can. Thanks, best,  Paul

Sorry, the message got buried in my inbox.  I'll all the packages now,
but it remains too much to review for me now.  I hope to return back to
that at some point.

> On Sun, 2 Jun 2024 at 13:03, Paul Nelson <ultrono@gmail.com> wrote:
>
>> > Can you just confirm that you are proposing for these packages to be
>> > added to GNU ELPA?
>> >
>>
>> Yes
>>

-- 
	Philip Kaludercic on peregrine



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-17 10:45                           ` Philip Kaludercic
@ 2024-06-17 10:52                             ` Philip Kaludercic
  2024-06-18  0:53                               ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Philip Kaludercic @ 2024-06-17 10:52 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Arash Esbati, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

Philip Kaludercic <philipk@posteo.net> writes:

> Paul Nelson <ultrono@gmail.com> writes:
>
>> Hi Philip, just thought I’d check in on this and offer again to help
>> however I can. Thanks, best,  Paul
>
> Sorry, the message got buried in my inbox.  I'll all the packages now,
> but it remains too much to review for me now.  I hope to return back to
> that at some point.

Worse still, I have actually added the packages already by accident!  It
seems I was inattentive when updating cobol-mode[0], my apologies...
But the reason your packages haven't appeared on the archive yet is that
the copyright line doesn't list the "Free Software Foundation, Inc.",
which all packages on ELPA must do.  So just apply a patch like this to
your packages, and make sure to bump the version tag while you are at
it:


[-- Attachment #2: Type: text/plain, Size: 462 bytes --]

diff --git a/auctex-cont-latexmk.el b/auctex-cont-latexmk.el
index 37b4bcc475..58d0860aa0 100644
--- a/auctex-cont-latexmk.el
+++ b/auctex-cont-latexmk.el
@@ -1,6 +1,6 @@
 ;;; auctex-cont-latexmk.el --- run latexmk continuously, report errors via Flymake  -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2023  Paul D. Nelson
+;; Copyright (C) 2023, 2024  Free Software Foundation, Inc.
 
 ;; Author: Paul D. Nelson <nelson.paul.david@gmail.com>
 ;; Version: 0.1

[-- Attachment #3: Type: text/plain, Size: 340 bytes --]


[0] https://git.savannah.gnu.org/cgit/emacs/elpa.git/commit/?id=8e73eaf44e0ae1ac6f5cded4033cb5e312b38604

>> On Sun, 2 Jun 2024 at 13:03, Paul Nelson <ultrono@gmail.com> wrote:
>>
>>> > Can you just confirm that you are proposing for these packages to be
>>> > added to GNU ELPA?
>>> >
>>>
>>> Yes
>>>

-- 
	Philip Kaludercic on peregrine

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-17 10:52                             ` Philip Kaludercic
@ 2024-06-18  0:53                               ` Paul Nelson
  2024-06-18  6:38                                 ` Philip Kaludercic
  0 siblings, 1 reply; 19+ messages in thread
From: Paul Nelson @ 2024-06-18  0:53 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Arash Esbati, emacs-devel

Hi Philip,

OK, thanks.  I adjusted the copyrights as suggested, and bumped the
version numbers -- I don't see the packages listed yet, but assume
this will happen automatically after some time.

Sorry to hear again about the backlog.  Whenever you get the chance,
I'd very much welcome any feedback, even on just one or two of the
packages, since I'm sure I'd learn something from it.

Thanks, best,

Paul



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-18  0:53                               ` Paul Nelson
@ 2024-06-18  6:38                                 ` Philip Kaludercic
  2024-06-26  5:59                                   ` Paul Nelson
  0 siblings, 1 reply; 19+ messages in thread
From: Philip Kaludercic @ 2024-06-18  6:38 UTC (permalink / raw)
  To: Paul Nelson; +Cc: Arash Esbati, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

Paul Nelson <ultrono@gmail.com> writes:

> Hi Philip,
>
> OK, thanks.  I adjusted the copyrights as suggested, and bumped the
> version numbers -- I don't see the packages listed yet, but assume
> this will happen automatically after some time.

Right, a cron job synchronises the repositories on a regular basis, and
should pick up your commit soon enough.

> Sorry to hear again about the backlog.  Whenever you get the chance,
> I'd very much welcome any feedback, even on just one or two of the
> packages, since I'm sure I'd learn something from it.

I've taken a look at one package, and am adding the comments to this
message, and hope to do the same for the others, step by step:


[-- Attachment #2: Type: text/plain, Size: 9007 bytes --]

diff --git a/auctex-cont-latexmk.el b/auctex-cont-latexmk.el
index 442972475d..9bdcf465c7 100644
--- a/auctex-cont-latexmk.el
+++ b/auctex-cont-latexmk.el
@@ -63,10 +63,7 @@
   (let ((error-alist
          (append TeX-error-description-list
                  TeX-error-description-list-local)))
-    (catch 'found
-      (dolist (error error-alist)
-        (when (string-match (car error) message)
-          (throw 'found (cdr error)))))))
+    (alist-get message error-alist nil nil #'string-match-p)))
 
 (defun auctex-cont-latexmk-help-at-point ()
   "Display the AUCTeX help for the error at point."
@@ -81,48 +78,47 @@ The arguments are as in `TeX-error-list'.  Return either nil or a
 triple (ERROR-P DESCRIPTION (BEG . END)), where ERROR-P is non-nil if it
 is an error rather than a warning."
   (or
-   (and
-    (not ignore)
-    (stringp file)
-    (or (not bad-box) TeX-debug-bad-boxes)
-    (when-let
-        ((region
-          (save-restriction
-            (widen)
-            (cond
-             ((file-equal-p
-               file
-               (or buffer-file-name (buffer-file-name (buffer-base-buffer))))
-              (when line
-                (if (eq type 'error)
+   (and-let*
+       (((not ignore))
+        ((stringp file))
+        ((or (not bad-box) TeX-debug-bad-boxes))
+        (region
+         (save-restriction
+           (widen)
+           (cond
+            ((file-equal-p
+              file
+              (or buffer-file-name (buffer-file-name (buffer-base-buffer))))
+             (when line
+               (if (eq type 'error)
+                   (save-excursion
+                     (goto-char (point-min))
+                     (forward-line (+ line offset -1))
+                     (unless (string= search-string " ")
+                       (search-forward search-string nil t)
+                       (cons (point) (1+ (point)))))
+                 (flymake-diag-region (current-buffer) (+ line offset)))))
+            ((file-equal-p file (TeX-master-output-file "aux"))
+             (and auctex-cont-latexmk-report-multiple-labels
+                  (string-match-p "multiply defined" message)
+                  (not (eq type 'error))
+                  (let* ((label (progn
+                                  (string-match "`\\(.*\\)'" message)
+                                  (match-string 1 message)))
+                         (label-re
+                          (concat "\\\\label\\(?:\\[[^]]+\\]\\)?{"
+                                  (regexp-quote label) "}")))
                     (save-excursion
                       (goto-char (point-min))
-                      (forward-line (+ line offset -1))
-                      (unless (string= search-string " ")
-                        (search-forward search-string nil t)
-                        (cons (point) (1+ (point)))))
-                  (flymake-diag-region (current-buffer) (+ line offset)))))
-             ((file-equal-p file (TeX-master-output-file "aux"))
-              (and auctex-cont-latexmk-report-multiple-labels
-                   (string-match-p "multiply defined" message)
-                   (not (eq type 'error))
-                   (let* ((label (progn
-                                   (string-match "`\\(.*\\)'" message)
-                                   (match-string 1 message)))
-                          (label-re
-                           (concat "\\\\label\\(?:\\[[^]]+\\]\\)?{"
-                                   (regexp-quote label) "}")))
-                     (save-excursion
-                       (goto-char (point-min))
-                       (when (re-search-forward label-re nil t)
-                         ;; Return the full line so the diagnostic is
-                         ;; not covered by preview overlays when
-                         ;; \\label appears after \\begin{equation}.
-                         (cons (line-beginning-position)
-                               (line-end-position)))))))))))
-      (list (eq type 'error)
-            (replace-regexp-in-string "\n" "" message)
-            region)))
+                      (when (re-search-forward label-re nil t)
+                        ;; Return the full line so the diagnostic is
+                        ;; not covered by preview overlays when
+                        ;; \\label appears after \\begin{equation}.
+                        (cons (line-beginning-position)
+                              (line-end-position)))))))))))
+     (list (eq type 'error)
+           (replace-regexp-in-string "\n" "" message)
+           region))
    ;; Put errors without file or line at bottom of buffer.
    (when (eq type 'error)
      (list t
@@ -133,9 +129,11 @@ is an error rather than a warning."
   "Format the current log buffer by joining lines suitably.
 Adapted from `TeX-format-filter'."
   (goto-char (point-max))
-  (while (> (point) (point-min))
+  (while (not (bobp))
     (end-of-line 0)
-    (when (and (memq (- (point) (line-beginning-position)) '(79 80))
+    (when (and (<= 79 (current-column) 80)
+               ;; I was imagining if this could be replaced by a clever regular expression like
+               ;; (not (looking-back (rx "." point (syntax word)) (line-beginning-position)))
                (not (memq (char-after (1+ (point))) '(?\n ?\()))
                (not (and (eq (char-before) ?.)
                          (char-after (1+ (point)))
@@ -155,10 +153,11 @@ Adapted from `TeX-format-filter'."
   "Process log file for current LaTeX document.
 Return a list of triples as in the docstring of
 `auctex-cont-latexmk-process-item'."
-  (delq nil
-        (mapcar (lambda (item)
-                  (apply #'auctex-cont-latexmk-process-item item))
-                (auctex-cont-latexmk--error-list (TeX-master-output-file "log")))))
+  (mapcan
+   (lambda (item)
+     (and-let* ((item (apply #'auctex-cont-latexmk-process-item item)))
+       (list item)))
+   (auctex-cont-latexmk--error-list (TeX-master-output-file "log"))))
 
 (defvar-local auctex-cont-latexmk--report-fn nil
   "Function provided by Flymake for reporting diagnostics.")
@@ -204,7 +203,7 @@ Flymake report function to propagate to indirect buffers."
 ;;; Continuous Compilation
 
 (defcustom auctex-cont-latexmk-command
-  '("latexmk -pvc -shell-escape -pdf -view=none -e "
+  '("latexmk -pvc -shell-escape -pdf -view=none -e " ;is it safe to have "shell-escape" in by default?
     ("$pdflatex=q/pdflatex %O -synctex=1 -interaction=nonstopmode %S/"))
   "Command to compile LaTeX documents.
 This is a list consisting of strings or lists of strings.  It is
@@ -218,6 +217,10 @@ file."
 (defun auctex-cont-latexmk--compilation-command ()
   "Return the command used to compile the current LaTeX document."
   (let ((quote
+         ;; I am surprised to see that this is necessary, but I don't
+         ;; know the background.  does `shell-quote-argument' quote
+         ;; incorrectly?  A comment explaining what is going on would
+         ;; be nice.
          (if (memq system-type '(ms-dos windows-nt))
              "\""
            "'")))
@@ -267,11 +270,9 @@ either in a watching state or has not updated recently."
      (when-let ((buf auctex-cont-latexmk--compilation-buffer))
        (with-current-buffer buf
          (or
-          (progn
-            (goto-char (point-max))
-            (forward-line -1)
-            (equal (buffer-substring (point) (line-end-position))
-                   auctex-cont-latexmk--watching-str))
+          (search-forward-regexp
+           (rx (literal auctex-cont-latexmk--watching-str) (? ?\n) eos)
+           nil t)
           (and (or
                 auctex-cont-latexmk--last-update-time
                 (time-less-p (time-subtract (current-time)
@@ -314,7 +315,7 @@ empty, except when NOKILL is non-nil."
         (let ((process (get-buffer-process comp-buf)))
           (when (process-live-p process)
             (interrupt-process process)
-            (sit-for 0.1)
+            (sit-for 0.1)               ;isn't this racy?  or is that not a problem?
             (delete-process process))
           (unless nokill
             (kill-buffer comp-buf)))))))
@@ -390,7 +391,7 @@ Saved and restored by `auctex-cont-latexmk-toggle'.")
 (defcustom auctex-cont-latexmk-retained-flymake-backends
   '(eglot-flymake-backend)
   "Flymake backends to retain when enabling `auctex-cont-latexmk-mode'."
-  :type 'boolean)
+  :type 'boolean)                       ;I don't think the type is right
 
 (defun auctex-cont-latexmk-turn-on ()
   "Enable `auctex-cont-latexmk-mode' and set up Flymake."
@@ -425,7 +426,7 @@ Saved and restored by `auctex-cont-latexmk-toggle'.")
 (defun auctex-cont-latexmk-toggle ()
   "Toggle `auctex-cont-latexmk-mode' and its Flymake backend."
   (interactive)
-  (cond (auctex-cont-latexmk-mode
+  (cond (auctex-cont-latexmk-mode       ;isn't this more of a `if'-place?
          (auctex-cont-latexmk-turn-off))
         (t
          (auctex-cont-latexmk-turn-on))))

[-- Attachment #3: Type: text/plain, Size: 63 bytes --]


> Thanks, best,
>
> Paul

-- 
	Philip Kaludercic on peregrine

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [ELPA] some tex-related packages
  2024-06-18  6:38                                 ` Philip Kaludercic
@ 2024-06-26  5:59                                   ` Paul Nelson
  0 siblings, 0 replies; 19+ messages in thread
From: Paul Nelson @ 2024-06-26  5:59 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: Arash Esbati, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 8328 bytes --]

Hi Philip,

Many thanks for this feedback, which I've incorporated (except that
I've shied away from trying to optimize the function
auctex-cont-latexmk--format-log-buffer, whose code is taken from an
AUCTeX function that has proven reliable over the decades). The
updated code is available at
https://github.com/ultronozm/auctex-cont-latexmk.el.  I copy below the
patch that I've applied on top of your patch (attaching as well, just
in case gmail messes up the formatting).  Any further comments or
feedback on this or the other packages would of course be very
helpful.

Paul

diff --git a/auctex-cont-latexmk.el b/auctex-cont-latexmk.el
index 6019767..29be6b0 100644
--- a/auctex-cont-latexmk.el
+++ b/auctex-cont-latexmk.el
@@ -64,6 +64,7 @@
          (append TeX-error-description-list
                  TeX-error-description-list-local)))
     (alist-get message error-alist nil nil #'string-match-p)))
+
 (defun auctex-cont-latexmk-help-at-point ()
   "Display the AUCTeX help for the error at point."
   (interactive)
@@ -77,7 +78,7 @@ The arguments are as in `TeX-error-list'.  Return
either nil or a
 triple (ERROR-P DESCRIPTION (BEG . END)), where ERROR-P is non-nil if it
 is an error rather than a warning."
   (or
-   (and-let*
+   (when-let*
        (((not ignore))
         ((stringp file))
         ((or (not bad-box) TeX-debug-bad-boxes))
@@ -131,8 +132,6 @@ Adapted from `TeX-format-filter'."
   (while (not (bobp))
     (end-of-line 0)
     (when (and (<= 79 (current-column) 80)
-               ;; I was imagining if this could be replaced by a
clever regular expression like
-               ;; (not (looking-back (rx "." point (syntax word))
(line-beginning-position)))
                (not (memq (char-after (1+ (point))) '(?\n ?\()))
                (not (and (eq (char-before) ?.)
                          (char-after (1+ (point)))
@@ -153,12 +152,14 @@ Adapted from `TeX-format-filter'."
 Return a list of triples as in the docstring of
 `auctex-cont-latexmk-process-item'."
   (mapcan
-   (lambda (item)
-     (and-let* ((item (apply #'auctex-cont-latexmk-process-item item)))
+   (lambda (err)
+     (when-let ((item (apply #'auctex-cont-latexmk-process-item err)))
        (list item)))
    (auctex-cont-latexmk--error-list (TeX-master-output-file "log"))))
+
 (defvar-local auctex-cont-latexmk--report-fn nil
   "Function provided by Flymake for reporting diagnostics.")
+
 (defvar-local auctex-cont-latexmk-force-enable nil
   "Whether to enable the Flymake backend unconditionally.
 This is non-nil if we should enable the Flymake backend independent of
@@ -198,38 +199,37 @@ Flymake report function to propagate to indirect buffers."
   (setq auctex-cont-latexmk--report-fn nil))

 ;;; Continuous Compilation
+
 (defcustom auctex-cont-latexmk-command
-  '("latexmk -pvc -shell-escape -pdf -view=none -e " ;is it safe to
have "shell-escape" in by default?
+  '("latexmk -pvc -pdf -view=none -e "
     ("$pdflatex=q/pdflatex %O -synctex=1 -interaction=nonstopmode %S/"))
   "Command to compile LaTeX documents.
 This is a list consisting of strings or lists of strings.  It is
-compiled to a single string by concatenating the strings and quoting the
-lists, using system-specific quotes.  To produce the compilation
-command, it is combined with an additional option to output build files
-to a directory (if `TeX-output-dir' is set) and the name of the master
-file."
+compiled to a single string by
+
+ - concatenating the strings, and
+
+ - concatenating the contents of each list and quoting the result as a
+shell argument.
+
+To produce the compilation command, the result is combined with an
+additional option to output build files to a directory (if
+`TeX-output-dir' is set) and the name of the master file."
   :type '(repeat (choice string (repeat string))))

 (defun auctex-cont-latexmk--compilation-command ()
   "Return the command used to compile the current LaTeX document."
-  (let ((quote
-         ;; I am surprised to see that this is necessary, but I don't
-         ;; know the background.  does `shell-quote-argument' quote
-         ;; incorrectly?  A comment explaining what is going on would
-         ;; be nice.
-         (if (memq system-type '(ms-dos windows-nt))
-             "\""
-           "'")))
-    (concat
-     (mapconcat (lambda (item)
-                  (if (listp item)
-                      (concat quote (mapconcat #'identity item) quote)
-                    item))
-                auctex-cont-latexmk-command)
-     (when TeX-output-dir
-       (concat " -outdir=" (shell-quote-argument TeX-output-dir)))
-     " "
-     (shell-quote-argument (TeX-master-file "tex")))))
+  (concat
+   (mapconcat
+    (lambda (item)
+      (if (listp item)
+          (shell-quote-argument (mapconcat #'identity item))
+        item))
+    auctex-cont-latexmk-command)
+   (when TeX-output-dir
+     (concat " -outdir=" (shell-quote-argument TeX-output-dir)))
+   " "
+   (shell-quote-argument (TeX-master-file "tex"))))

 (defun auctex-cont-latexmk--compilation-buffer-name ()
   "Return the name of the buffer used for LaTeX compilation."
@@ -258,7 +258,13 @@ file."
 This is the case if the current buffer is not modified, the current
 buffer is a file, the current buffer has a log file, the log file is
 newer than the current buffer, and the current latexmk compilation is
-either in a watching state or has not updated recently."
+either in a watching state or has not updated recently.
+
+The reason we check if the latexmk has not been updated recently is
+because it seems that on Windows, the latexmk script doesn't always
+display the most recent message.  I haven't been able to debug why this
+is the case.  Checking that the compilation has not been updated
+recently serves as a workaround."
   (when-let* ((file
                (or buffer-file-name (buffer-file-name (buffer-base-buffer))))
               (log-file (TeX-master-output-file "log")))
@@ -266,9 +272,12 @@ either in a watching state or has not updated recently."
      (when-let ((buf auctex-cont-latexmk--compilation-buffer))
        (with-current-buffer buf
          (or
-          (search-forward-regexp
-           (rx (literal auctex-cont-latexmk--watching-str) (? ?\n) eos)
-           nil t)
+          (progn
+            (goto-char (point-max))
+            (forward-line -1)
+            (re-search-forward
+             (rx (literal auctex-cont-latexmk--watching-str) (? ?\n) eos)
+             nil t))
           (and (or
                 auctex-cont-latexmk--last-update-time
                 (time-less-p (time-subtract (current-time)
@@ -308,12 +317,8 @@ empty, except when NOKILL is non-nil."
         (when (null auctex-cont-latexmk--subscribed-buffers)
           (setq done t)))
       (when done
-        (let ((process (get-buffer-process comp-buf)))
-          (when (process-live-p process)
-            (interrupt-process process)
-            (sit-for 0.1)               ;isn't this racy?  or is that
not a problem?
-            (delete-process process))
-          (unless nokill
+        (unless nokill
+          (let ((kill-buffer-query-functions nil)) ; don't ask to kill process
             (kill-buffer comp-buf)))))))

 (defvar-local auctex-cont-latexmk--disable-function nil
@@ -387,8 +392,9 @@ Saved and restored by `auctex-cont-latexmk-toggle'.")
 (defcustom auctex-cont-latexmk-retained-flymake-backends
   '(eglot-flymake-backend)
   "Flymake backends to retain when enabling `auctex-cont-latexmk-mode'."
-  :type 'boolean)                       ;I don't think the type is right
- (defun auctex-cont-latexmk-turn-on ()
+  :type '(repeat symbol))
+
+(defun auctex-cont-latexmk-turn-on ()
   "Enable `auctex-cont-latexmk-mode' and set up Flymake."
   (interactive)
   (auctex-cont-latexmk-mode 1)
@@ -421,10 +427,9 @@ Saved and restored by `auctex-cont-latexmk-toggle'.")
 (defun auctex-cont-latexmk-toggle ()
   "Toggle `auctex-cont-latexmk-mode' and its Flymake backend."
   (interactive)
-  (cond (auctex-cont-latexmk-mode       ;isn't this more of a `if'-place?
-         (auctex-cont-latexmk-turn-off))
-        (t
-         (auctex-cont-latexmk-turn-on))))
+  (if auctex-cont-latexmk-mode
+      (auctex-cont-latexmk-turn-off)
+    (auctex-cont-latexmk-turn-on)))

 (provide 'auctex-cont-latexmk)
 ;;; auctex-cont-latexmk.el ends here

[-- Attachment #2: test.patch --]
[-- Type: application/octet-stream, Size: 7753 bytes --]

diff --git a/auctex-cont-latexmk.el b/auctex-cont-latexmk.el
index 6019767..29be6b0 100644
--- a/auctex-cont-latexmk.el
+++ b/auctex-cont-latexmk.el
@@ -64,6 +64,7 @@
          (append TeX-error-description-list
                  TeX-error-description-list-local)))
     (alist-get message error-alist nil nil #'string-match-p)))
+
 (defun auctex-cont-latexmk-help-at-point ()
   "Display the AUCTeX help for the error at point."
   (interactive)
@@ -77,7 +78,7 @@ The arguments are as in `TeX-error-list'.  Return either nil or a
 triple (ERROR-P DESCRIPTION (BEG . END)), where ERROR-P is non-nil if it
 is an error rather than a warning."
   (or
-   (and-let*
+   (when-let*
        (((not ignore))
         ((stringp file))
         ((or (not bad-box) TeX-debug-bad-boxes))
@@ -131,8 +132,6 @@ Adapted from `TeX-format-filter'."
   (while (not (bobp))
     (end-of-line 0)
     (when (and (<= 79 (current-column) 80)
-               ;; I was imagining if this could be replaced by a clever regular expression like
-               ;; (not (looking-back (rx "." point (syntax word)) (line-beginning-position)))
                (not (memq (char-after (1+ (point))) '(?\n ?\()))
                (not (and (eq (char-before) ?.)
                          (char-after (1+ (point)))
@@ -153,12 +152,14 @@ Adapted from `TeX-format-filter'."
 Return a list of triples as in the docstring of
 `auctex-cont-latexmk-process-item'."
   (mapcan
-   (lambda (item)
-     (and-let* ((item (apply #'auctex-cont-latexmk-process-item item)))
+   (lambda (err)
+     (when-let ((item (apply #'auctex-cont-latexmk-process-item err)))
        (list item)))
    (auctex-cont-latexmk--error-list (TeX-master-output-file "log"))))
+
 (defvar-local auctex-cont-latexmk--report-fn nil
   "Function provided by Flymake for reporting diagnostics.")
+
 (defvar-local auctex-cont-latexmk-force-enable nil
   "Whether to enable the Flymake backend unconditionally.
 This is non-nil if we should enable the Flymake backend independent of
@@ -198,38 +199,37 @@ Flymake report function to propagate to indirect buffers."
   (setq auctex-cont-latexmk--report-fn nil))
 
 ;;; Continuous Compilation
+
 (defcustom auctex-cont-latexmk-command
-  '("latexmk -pvc -shell-escape -pdf -view=none -e " ;is it safe to have "shell-escape" in by default?
+  '("latexmk -pvc -pdf -view=none -e "
     ("$pdflatex=q/pdflatex %O -synctex=1 -interaction=nonstopmode %S/"))
   "Command to compile LaTeX documents.
 This is a list consisting of strings or lists of strings.  It is
-compiled to a single string by concatenating the strings and quoting the
-lists, using system-specific quotes.  To produce the compilation
-command, it is combined with an additional option to output build files
-to a directory (if `TeX-output-dir' is set) and the name of the master
-file."
+compiled to a single string by
+
+ - concatenating the strings, and
+
+ - concatenating the contents of each list and quoting the result as a
+shell argument.
+
+To produce the compilation command, the result is combined with an
+additional option to output build files to a directory (if
+`TeX-output-dir' is set) and the name of the master file."
   :type '(repeat (choice string (repeat string))))
 
 (defun auctex-cont-latexmk--compilation-command ()
   "Return the command used to compile the current LaTeX document."
-  (let ((quote
-         ;; I am surprised to see that this is necessary, but I don't
-         ;; know the background.  does `shell-quote-argument' quote
-         ;; incorrectly?  A comment explaining what is going on would
-         ;; be nice.
-         (if (memq system-type '(ms-dos windows-nt))
-             "\""
-           "'")))
-    (concat
-     (mapconcat (lambda (item)
-                  (if (listp item)
-                      (concat quote (mapconcat #'identity item) quote)
-                    item))
-                auctex-cont-latexmk-command)
-     (when TeX-output-dir
-       (concat " -outdir=" (shell-quote-argument TeX-output-dir)))
-     " "
-     (shell-quote-argument (TeX-master-file "tex")))))
+  (concat
+   (mapconcat
+    (lambda (item)
+      (if (listp item)
+          (shell-quote-argument (mapconcat #'identity item))
+        item))
+    auctex-cont-latexmk-command)
+   (when TeX-output-dir
+     (concat " -outdir=" (shell-quote-argument TeX-output-dir)))
+   " "
+   (shell-quote-argument (TeX-master-file "tex"))))
 
 (defun auctex-cont-latexmk--compilation-buffer-name ()
   "Return the name of the buffer used for LaTeX compilation."
@@ -258,7 +258,13 @@ file."
 This is the case if the current buffer is not modified, the current
 buffer is a file, the current buffer has a log file, the log file is
 newer than the current buffer, and the current latexmk compilation is
-either in a watching state or has not updated recently."
+either in a watching state or has not updated recently.
+
+The reason we check if the latexmk has not been updated recently is
+because it seems that on Windows, the latexmk script doesn't always
+display the most recent message.  I haven't been able to debug why this
+is the case.  Checking that the compilation has not been updated
+recently serves as a workaround."
   (when-let* ((file
                (or buffer-file-name (buffer-file-name (buffer-base-buffer))))
               (log-file (TeX-master-output-file "log")))
@@ -266,9 +272,12 @@ either in a watching state or has not updated recently."
      (when-let ((buf auctex-cont-latexmk--compilation-buffer))
        (with-current-buffer buf
          (or
-          (search-forward-regexp
-           (rx (literal auctex-cont-latexmk--watching-str) (? ?\n) eos)
-           nil t)
+          (progn
+            (goto-char (point-max))
+            (forward-line -1)
+            (re-search-forward
+             (rx (literal auctex-cont-latexmk--watching-str) (? ?\n) eos)
+             nil t))
           (and (or
                 auctex-cont-latexmk--last-update-time
                 (time-less-p (time-subtract (current-time)
@@ -308,12 +317,8 @@ empty, except when NOKILL is non-nil."
         (when (null auctex-cont-latexmk--subscribed-buffers)
           (setq done t)))
       (when done
-        (let ((process (get-buffer-process comp-buf)))
-          (when (process-live-p process)
-            (interrupt-process process)
-            (sit-for 0.1)               ;isn't this racy?  or is that not a problem?
-            (delete-process process))
-          (unless nokill
+        (unless nokill
+          (let ((kill-buffer-query-functions nil)) ; don't ask to kill process
             (kill-buffer comp-buf)))))))
 
 (defvar-local auctex-cont-latexmk--disable-function nil
@@ -387,8 +392,9 @@ Saved and restored by `auctex-cont-latexmk-toggle'.")
 (defcustom auctex-cont-latexmk-retained-flymake-backends
   '(eglot-flymake-backend)
   "Flymake backends to retain when enabling `auctex-cont-latexmk-mode'."
-  :type 'boolean)                       ;I don't think the type is right
- (defun auctex-cont-latexmk-turn-on ()
+  :type '(repeat symbol))
+
+(defun auctex-cont-latexmk-turn-on ()
   "Enable `auctex-cont-latexmk-mode' and set up Flymake."
   (interactive)
   (auctex-cont-latexmk-mode 1)
@@ -421,10 +427,9 @@ Saved and restored by `auctex-cont-latexmk-toggle'.")
 (defun auctex-cont-latexmk-toggle ()
   "Toggle `auctex-cont-latexmk-mode' and its Flymake backend."
   (interactive)
-  (cond (auctex-cont-latexmk-mode       ;isn't this more of a `if'-place?
-         (auctex-cont-latexmk-turn-off))
-        (t
-         (auctex-cont-latexmk-turn-on))))
+  (if auctex-cont-latexmk-mode
+      (auctex-cont-latexmk-turn-off)
+    (auctex-cont-latexmk-turn-on)))
 
 (provide 'auctex-cont-latexmk)
 ;;; auctex-cont-latexmk.el ends here

^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-06-26  5:59 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-19 17:06 [ELPA] some tex-related packages Paul Nelson
2024-05-20  6:33 ` Philip Kaludercic
2024-05-20  9:01   ` Paul Nelson
2024-05-20  9:18     ` Philip Kaludercic
2024-05-20 17:37       ` Arash Esbati
2024-05-22 16:10         ` Paul Nelson
2024-05-27 16:13           ` Arash Esbati
2024-05-27 19:07             ` Paul Nelson
2024-06-02 12:51               ` Arash Esbati
2024-06-02 18:44                 ` Philip Kaludercic
2024-06-02 19:11                   ` Paul Nelson
2024-06-02 19:53                     ` Philip Kaludercic
2024-06-02 20:03                       ` Paul Nelson
2024-06-16 16:20                         ` Paul Nelson
2024-06-17 10:45                           ` Philip Kaludercic
2024-06-17 10:52                             ` Philip Kaludercic
2024-06-18  0:53                               ` Paul Nelson
2024-06-18  6:38                                 ` Philip Kaludercic
2024-06-26  5:59                                   ` Paul Nelson

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).