Skip to content

Commit

Permalink
version 1.2: Change the default behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
jh-min committed Dec 13, 2019
1 parent 9af03ab commit d05498c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ sublime [, options]

otpions | Description
---|:---
***i****nstalled* | set `StataEditor` assuming Sublime Text is installed on user’s system
***p****ortable* | set `StataEditor` assuming the path to portable version of Sublime Text is stored with `whereis`
***i****nstalled* | set `StataEditor` assuming Sublime Text has been installed on user’s system
***p****ortable* | set `StataEditor` assuming the path to portable version of Sublime Text has been stored with `whereis`
***keep****whereis* | force `sublime` not to remove the entry named `Sublime` from `whereis`
***m****anually* | write the settings file for `StataEditor` in current working directory

By default, `sublime` will locate the directory of Sublime Text assuming that Sublime Text is installed on your system. If `sublime` fails to locate the directory of installed version, it will use the path stored with SSC package [whereis][4] assuming that you are using portable version of Sublime Text. Then `sublime` will write the settings file for `StataEditor` in that directory.
By default, `sublime` will assume that you are using portable version of Sublime Text and locate the directory of Sublime Text by retrieving the path stored with SSC package [whereis][4]. If `sublime` fails to locate the directory of portable version, it will assume that Sublime Text has been installed on your system and depend on environment variable to locate the directory. Then `sublime` will write the settings file for `StataEditor` in that directory.

If `installed` is specified, `sublime` will not depend on `whereis` even if it fails to locate the installed version of Sublime Text.
If `installed` is specified, `sublime` will not depend on `whereis` even if you have stored the path to Sublime Text with `whereis`.

If `portable` is specified, `sublime` will depend on `whereis` even if Sublime Text is installed on your system. To specify this option, you should first install `whereis` from SSC archive and then create an entry named `Sublime` to store the location of portable version as follows:
If `portable` is specified, `sublime` will not locate the directory of installed version even if you have installed Sublime Text on your system. To specify this option, you should first install `whereis` from SSC archive and then create an entry named `Sublime` to store the location of portable version as follows:
```s
whereis Sublime "path/to/portable version/sublime_text.exe"
```
Expand Down
29 changes: 15 additions & 14 deletions sublime.ado
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*** version 1.1 13Dec2019
*** version 1.2 13Dec2019
*** contact information: [email protected]

program sublime
Expand All @@ -19,8 +19,8 @@ qui {
*** move to Sublime Text
if "`manually'"!="" {
* manually: on
noisily mata: printf("{cmd}sublime.ado{text} will create {cmd}StataEditor.sublime-settings{text} file in your working directory...\n")
noisily mata: printf("{text}Move this file to Packages/User directory of {cmd}Sublime Text\n")
noisily mata: printf("{cmd}sublime.ado{text} will create {result}StataEditor.sublime-settings{text} file in your working directory...\n")
noisily mata: printf("{text}Move this file to {result}Packages/User{text} directory of {result}Sublime Text\n")
}
else {
* manually: off
Expand All @@ -41,11 +41,10 @@ qui {
}
else {
* options: off
capture sublime_installed
global keepwhereis "`keepwhereis'"
capture noisily: sublime_portable
if _rc!=0 {
* Sublime Text seems not to be installed
global keepwhereis "`keepwhereis'"
noisily sublime_portable
noisily sublime_installed
}
}
capture macro drop keepwhereis
Expand Down Expand Up @@ -94,6 +93,7 @@ qui {
shell `statafl'`statabit' /Regserver

*** reset cd
noisily mata: printf("{cmd}sublime.ado{text} successfully set up {cmd}StataEditor\n")
cd "`current'"

}
Expand All @@ -105,6 +105,7 @@ program sublime_installed

qui {

noisily mata: printf("{cmd}sublime.ado{text} will assume that {result}Sublime Text{text} has been {result}installed{text} on your system...\n")
*** depend on environment variable %APPDATA%
local sldir : environ APPDATA
local sldir=subinstr("`sldir'", "\", "/", .)
Expand All @@ -122,9 +123,9 @@ qui {
capture cd "`sldir'/AppData/Roaming/Sublime Text 3/Packages/User"
if _rc!=0 {
* Sublime Text seems not to be installed
noisily mata: printf("{cmd}Sublime Text{error} could not be found on your system\n")
noisily mata: printf("{text}If you are using {result}portable version{text} of {cmd}Sublime Text{text},\n")
noisily mata: printf("{text}please save the directory of {cmd}Sublime Text{text} with ssc package {cmd}whereis{text} as follows:\n")
noisily mata: printf("{result}Sublime Text{error} could not be found on your system\n")
noisily mata: printf("{text}If you are using {result}portable version{text} of {result}Sublime Text{text},\n")
noisily mata: printf("{text}please store the directory of {result}Sublime Text{text} with ssc package {cmd}whereis{text} as follows:\n")
noisily mata: printf(`"{result}. whereis Sublime "path/to/Sublime Text/sublime_text.exe"\n"')
exit 601
}
Expand All @@ -139,6 +140,7 @@ program sublime_portable

qui {

noisily mata: printf("{cmd}sublime.ado{text} will assume that you are using {result}portable version{text} of {result}Sublime Text{text}...\n")
*** depend on whereis command
capture whereis Sublime
if _rc!=0 {
Expand All @@ -149,7 +151,7 @@ qui {
exit 199
}
else {
noisily mata: printf("{error}location of {cmd}Sublime Text{error} has not been stored with {cmd:whereis.ado}\n")
noisily mata: printf("{error}location of {result}Sublime Text{error} has not been stored with {cmd:whereis.ado}\n")
capture macro drop keepwhereis
exit 601
}
Expand All @@ -160,16 +162,15 @@ qui {
capture cd "`sldir'/Data/Packages/User"
if _rc!=0 {
* whereis command might have stored the directory of non-portable version
noisily mata: printf("{cmd}whereis.ado{error} seems to store the path to installed version of Sublime Text\n")
noisily mata: printf("{cmd}whereis.ado{error} seems to store the path to {result}installed version{error} of {result}Sublime Text\n")
if "$keepwhereis"!="" {
* keepwhereis: on
noisily mata: printf("{error}Please check the directory stored with {cmd}whereis.ado\n")
}
else {
* keepwhereis: off
sublime_whereis
noisily mata: printf("{cmd}sublime.ado{error} automatically removed the directory of Sublime Text stored with {cmd}whereis.ado\n")
noisily mata: printf("{text}Please re-execute {cmd}sublime.ado\n")
noisily mata: printf("{cmd}sublime.ado{error} automatically removed the directory of {result}Sublime Text{error} stored with {cmd}whereis.ado\n")
}
capture macro drop keepwhereis
exit 601
Expand Down
16 changes: 8 additions & 8 deletions sublime.sthlp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{smcl}
{* *! version 1.1 13December2019}{...}
{* *! version 1.2 13December2019}{...}
{viewerjumpto "Syntax" "sublime##syntax"}{...}
{viewerjumpto "Description" "sublime##description"}{...}
{viewerjumpto "Remarks" "sublime##remarks"}{...}
Expand All @@ -21,22 +21,22 @@
{synopthdr}
{synoptline}
{syntab:Main}
{synopt:{opt i:nstalled}}set {cmd:StataEditor} assuming Sublime Text is installed on user’s system{p_end}
{synopt:{opt p:ortable}}set {cmd:StataEditor} assuming the path to portable version of Sublime Text is stored with {cmd:whereis}{p_end}
{synopt:{opt i:nstalled}}set {cmd:StataEditor} assuming Sublime Text has been installed on user’s system{p_end}
{synopt:{opt p:ortable}}set {cmd:StataEditor} assuming the path to portable version of Sublime Text has been stored with {cmd:whereis}{p_end}
{synopt:{opt keep:whereis}}force {cmd:sublime} not to remove the entry named {it:Sublime} from {cmd:whereis}{p_end}
{synopt:{opt m:anually}}write the settings file for {cmd:StataEditor} in current working directory{p_end}
{synoptline}
{p2colreset}{...}

{p 4 6 2}
By default, {cmd:sublime} will locate the directory of Sublime Text assuming that Sublime Text is installed on your system.
If {cmd:sublime} fails to locate the directory of installed version, it will use the path stored with SSC package {search whereis} assuming that you are using portable version of Sublime Text.
By default, {cmd:sublime} will assume that you are using portable version of Sublime Text and locate the directory of Sublime Text by retrieving the path stored with SSC package {search whereis}.
If {cmd:sublime} fails to locate the directory of portable version, it will assume that Sublime Text has been installed on your system and depend on environment variable to locate the directory.
Then {cmd:sublime} will write the settings file for {cmd:StataEditor} in that directory.{p_end}
{p 4 6 2}
If {opt installed} is specified, {cmd:sublime} will not depend on {cmd:whereis} even if it fails to locate the installed version of Sublime Text.{p_end}
If {opt installed} is specified, {cmd:sublime} will not depend on {cmd:whereis} even if you have stored the path to Sublime Text with {cmd:whereis}.{p_end}
{p 4 6 2}
If {opt portable} is specified, {cmd:sublime} will depend on {cmd:whereis} even if Sublime Text is installed on your system.
To specify this option, you should first install {cmd:whereis} from SSC archive and then create an entry named {it:Sublime} to store the location of portable version as follows:{p_end}
If {opt portable} is specified, {cmd:sublime} will not locate the directory of installed version even if you have installed Sublime Text on your system.
To specify this option, you should first install {cmd:whereis} from SSC archive and then create an entry named {cmd:Sublime} to store the location of portable version as follows:{p_end}
{pmore}{cmd:. whereis Sublime "path/to/portable version/sublime_text.exe"}{p_end}

{p 4 6 2}
Expand Down

0 comments on commit d05498c

Please sign in to comment.