Skip to content

Search for latexmk in more places#584

Merged
jalvesaq merged 2 commits into
R-nvim:mainfrom
todmorrison:patch-2
Jun 6, 2026
Merged

Search for latexmk in more places#584
jalvesaq merged 2 commits into
R-nvim:mainfrom
todmorrison:patch-2

Conversation

@todmorrison

Copy link
Copy Markdown
Contributor

This follows up on PR #582, adding similar logic to search the home directory, cwd (typically the project root), and then file's directory for a ".latexmkrc" file to "nvimcom/R/interlace.R" (the other place where the latexmkrc file i searched for). As in the rmw.lua case, it does this in reverse of the stated order, so that the "most local" 'out_dir' configuration stands.

@jalvesaq

Copy link
Copy Markdown
Member

It would be good if this pull request could be reviewed by someone who edits Rnoweb files. Section CONFIGURATION/INITIALIZATION (RC) FILES of latexmk man page specifies the places where a latexmkrc can be found.

@jalvesaq

jalvesaq commented Jun 4, 2026

Copy link
Copy Markdown
Member

Looking at the code: shouldn't we have a break at the end of the if condition?

if (length(idx) == 1) {
    logf <- paste0(
        sub(".*\\$out_dir\\s*=\\s*['\"](.*)['\"].*", "\\1", lmk[idx]),
        "/",
        sub("\\....$", ".log", rnwf)
    )
    break
}

@jalvesaq

jalvesaq commented Jun 4, 2026

Copy link
Copy Markdown
Member

The man page of latexmk lists more places where a latexmkrc or .latexmkrc can be found than in your pull request...

@todmorrison

Copy link
Copy Markdown
Contributor Author

Looking at the code: shouldn't we have a break at the end of the if condition?

if (length(idx) == 1) {
    logf <- paste0(
        sub(".*\\$out_dir\\s*=\\s*['\"](.*)['\"].*", "\\1", lmk[idx]),
        "/",
        sub("\\....$", ".log", rnwf)
    )
    break
}

No, it shouldn't break in this case. It's scanning the files in reverse order of priority, so the last match should stand.

I do still need to add the other locations mentioned in the man page (and then those additional locations should be added to lua code from the previous PR).

@jalvesaq

jalvesaq commented Jun 5, 2026

Copy link
Copy Markdown
Member

No, it shouldn't break in this case. It's scanning the files in reverse order of priority, so the last match should stand.

It would be more efficient to scan the files in the order of priority and break on the first match.

@PMassicotte

Copy link
Copy Markdown
Collaborator

No, it shouldn't break in this case. It's scanning the files in reverse order of priority, so the last match should stand.

It would be more efficient to scan the files in the order of priority and break on the first match.

I think so too :)

Added all locations latexmk searches for the *user* rc file. Then, since we're only grabbing a single variable/entry, reversed the search to look at the highest priority first and break/terminate the search when found.
@todmorrison

Copy link
Copy Markdown
Contributor Author

No, it shouldn't break in this case. It's scanning the files in reverse order of priority, so the last match should stand.

It would be more efficient to scan the files in the order of priority and break on the first match.

I think so too :)

Fair enough, as long as we're only interested in one variable/setting, searching from the highest priority to the lowest and terminating the search when found is definitely more efficient. (This is the opposite of what latexmk does, however, as it is merging multiple values and the highest priority -- most "local" -- options should override less "local" ones.)

I've reversed the search order and added the break as well as added all the locations latexmk looks for the user rc.

@jalvesaq

jalvesaq commented Jun 6, 2026

Copy link
Copy Markdown
Member

Thank you! I'll merge it...

@jalvesaq jalvesaq merged commit 7a30958 into R-nvim:main Jun 6, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants