Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "open .sty file" to right click menu on commands and packages #2467

Closed
RamonAbudAlcala opened this issue Jul 11, 2022 · 10 comments
Closed

Comments

@RamonAbudAlcala
Copy link
Contributor

RamonAbudAlcala commented Jul 11, 2022

I find really helpful to have the documentation open by going to a command and using ctrl+click or right click + "open package documentation" (are there any other shortcuts?). But sometimes I'd like to see the package .sty file instead. It would be great to have a shortcut to it just below "open documentation".

The current alternative (correct me if I am wrong) is to navigate the local LaTeX distribution and find the particular package in question, which sometimes I do, but most times it feels like too much effort.

Who will benefit with this feature?

All users would benefit, sometimes it is just helpful to know how the package actually loads, even if the user can only read basic TeX. Advanced users could quickly check for inconsistencies or tweaks, etc...

@sunderme
Copy link
Member

no, looking at sty files is really very specific.

@samcarter
Copy link
Contributor

samcarter commented Jul 15, 2022

The current alternative (correct me if I am wrong) is to navigate the local LaTeX distribution and find the particular package in question, which sometimes I do, but most times it feels like too much effort.

Instead of looking in your distribution for the package you could also open it directly, if you get the path from

  1. kpsewhich, e.g. run in a terminal kpsewhich indentfirst.sty
  2. open your .log file and search for the package

On mac I'm using the following texstudio user macro to directly open .sty files (I assume this could also be adapted to other operating systems by replacing open with its equivalent on the system or replacing it with your favourite editor):

%SCRIPT
var selection=cursor.selectedText();
system('zsh -c "open `kpsewhich ' + selection + '.sty`"')

Screenshot 2022-07-15 at 21 25 05

@sunderme
Copy link
Member

as there is a macro solution, I close this.

@RamonAbudAlcala
Copy link
Contributor Author

RamonAbudAlcala commented Aug 14, 2022

@samcarter Thanks! I have not had the time to play with this until now. I have one windows computer and after a bit of searching online I managed to put together the following user macro / script.

%SCRIPT
var selection=cursor.selectedText();
system('powershell "start (kpsewhich ' + selection + '.sty)"')

I couldn't figure out how to make it work with cmd instead of powershell. Also, I don't know if I'm missing the equivalent flag for -c that you have. For now, it works as is. I'll leave it here for other people to find.

@goyalyashpal
Copy link

goyalyashpal commented Dec 10, 2022

hi!

... navigate the local LaTeX distribution and find the particular package ...
- @ RamonAbudAlcala at issue description: #2467 (comment)

if you get the path from ... kpsewhich ...
- @ samcarter at #2467 (comment)

as there is a macro solution, I close this.
- @ sunderme at #2467 (comment)

from the initial description, and closing action based on the kpsewhich solution...

  • only the distribution wide packages situation was addressed
  • the self made packages, for which this is even more crucial, seem to be forgotten entirely
  • self made packages: the custom .sty style files which reside in the project home directory itself - kpsewhich can't find these, hence the solution based on it won't work

looking at sty files is really very specific
- @ sunderme at #2467 (comment)

no. one whole point of LaTeX workflow is separation of styling from content, the M in WYSIWYM

  • styling constitutes the major part while working on foundations of any project
  • i have my own style files in every project: be it for general styling, custom commands, package specific styling, or whatever
  • anyone using any form of drawing, or code listing packages knows that style files are common part of the project

other than that, for an existing example: the texlab LSP (for vs code and others) also has this feature of ctrl + click on \usepackage command to open the custom in-directory .sty files (recording shared below:)

on these grounds, i propose this issue to be reopened

@goyalyashpal
Copy link

goyalyashpal commented Dec 10, 2022

here's the screenrecord if that'd help for that:

  • ctrl+click to open only custom style files
  • by texlab LSP for LaTeX
  • in vscodium
VSCodium_gfzeFVERZ9.mp4

@goyalyashpal
Copy link

goyalyashpal commented Dec 12, 2022

hi @sunderme , can you please reopen this?

again, i am not asking to open distribution wide packages, only the custom per directory packages. the issue's description and title can be modified to reflect that

@goyalyashpal

This comment was marked as duplicate.

@samcarter
Copy link
Contributor

kpswchich works only for the distribution wide packages, it doesn't work on custom packages, so, there is NO solution for those.

If you place your custom packages somewhere where texlive can find them, e.g. in your TEXMFHOME tree, you can get their path with kpsewhich

@goyalyashpal
Copy link

goyalyashpal commented Dec 12, 2022

If you place your custom packages somewhere where texlive can find them, e.g. in your TEXMFHOME tree, you can get their path with kpsewhich

my custom packages are project specific, tuned to and inherent part of the individual projects

but thanks for the tip, I was thinking of "global"-ising some of my custom packages

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

No branches or pull requests

4 participants