Skip to content

Commit 846e1d0

Browse files
authored
Merge pull request #76 from markbirbeck/74-path-forced-to-use-suffix
74 path forced to use suffix
2 parents 299ce8a + b1f0a43 commit 846e1d0

File tree

7 files changed

+202
-126
lines changed

7 files changed

+202
-126
lines changed

CHANGELOG.md

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# Changelog
2+
All notable changes to this project will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6+
7+
8+
## [Unreleased]
9+
10+
## [0.17.0] - 2019-01-05
11+
### Added
12+
- Make the output of long-running tasks smoother. Closes #68. (@markbirbeck)
13+
- Add support for history of commands. Closes #27. (@kaste)
14+
- Support new syntax definition styles when using syntax option. Closes #74. (@gwenzek)
15+
16+
## [0.16.0] - 2016-02-26
17+
### Added
18+
- Allow the output of a command to overwrite the region used as input. Closes #9.
19+
20+
### Fixed
21+
- Fixed problem where output buffers were always being set to read only. This is only relevant when writing to the buffer being edited. Fixes #51.
22+
23+
## [0.15.2] - 2016-02-05
24+
### Fixed
25+
Fixed problem where a failing configuration script would prevent any command from running. Fixes #50.
26+
27+
## [0.15.1] - 2015-03-11
28+
### Fixed
29+
- Fixed an additional scenario relating to issue #47, where generated views could have a CWD of `None`. Fixes #47.
30+
31+
## [0.15.0] - 2015-03-11
32+
33+
### Fixed
34+
- Commands run from generated views no longer always have CWD of `None`. Fixes #47.
35+
- `root_dir` is now working again. (@Stentor) Fixes #45.
36+
37+
## [0.14.0] - 2015-02-13
38+
### Added
39+
- Added option to allow the shell used to be overridden. Closes issue #32.
40+
41+
## [0.13.1] - 2015-02-13
42+
### Added
43+
- Added option to allow the end of a view to always be visible. Closes issue #39.
44+
45+
## [0.13.0] - 2015-02-12
46+
### Changed
47+
- The module has been renamed to `ShellCommand` in the package manager so this release simply applies the name change to documents, prompts, and file paths.
48+
49+
## [0.12.2] - 2015-02-12
50+
### Added
51+
- Add blank line before list in README. (@kleinfreund) Fixes issue #41.
52+
- Provide method for running shell commands directly. (@markbirbeck) Fixes issue #42.
53+
- Add reference to [Git Mode](https://github.com/markbirbeck/sublime-text-gitmode/) as an example of using `ShellCommand` to create modes. (@markbirbeck)
54+
55+
## [0.12.1] - 2015-01-01
56+
### Added
57+
- Add substitution variables that mirror those used in the ST build system. See [Build System Variables](http://docs.sublimetext.info/en/latest/reference/build_systems.html#build-system-variables) for the full list and description. Fixes issue #35.
58+
59+
## [0.12.0] - 2015-01-01
60+
### Added
61+
- Commands can now get parameters from users. Thanks to @aflc for providing the code for this functionality. Fixes issue #36.
62+
63+
## [0.11.1] - 2014-06-26
64+
### Fixed
65+
- The working directory is set to be the directory of the current file, but if the 'root' (deduced from the current file) is required, the option `root_dir` can be set to `True`. (@markbirbeck) Fixes issue #25.
66+
67+
## [0.11.0] - 2014-06-26
68+
### Added
69+
- Working directory selection is now much smarter, based on using the current file's path to find out which folder or project the file belongs to. (@bergtholdt) Fixes issue #17.
70+
- The working directory is set to be the 'root' deduced from the current file, but if the directory of the current file is required, the option `root_dir` can be set to `False`. (@markbirbeck) Fixes issue #24.
71+
72+
### Changed
73+
- `CR/LF` sequences are now mapped to `LF` which improves display on Windows. (@markbirbeck) Fixes issue #21.
74+
75+
### Fixed
76+
- Commands were failing on Windows due to an unnecessary check that `stdout` was ready. (@markbirbeck) Fixes issue #13. Thanks to @bergtholdt who drew attention to the problem and proposed a slightly different solution.
77+
- Menu entries that were supposed to provide access to settings and key bindings were opening the wrong files. (@markbirbeck) Fixes issue #22.
78+
- A link to a wiki page from the README was incorrect. (@mrjoelkemp) Fixes issue #19 and #20. Thanks also to @reqshark who spotted the same problem and also provided a solution.
79+
80+
## [0.10.0] - 2014-03-20
81+
### Fixed
82+
- Passing a buffer with UTF-8 characters in as the stdin for a command caused the command to fail. (@markbirbeck) Fixes issue #16.
83+
84+
## [0.9.0] - 2014-03-15
85+
### Fixed
86+
- Commands were failing if run in a window with no open folders or files. (@mrvoss) Fixes issue #14.
87+
88+
## [0.8.0] - 2014-03-14
89+
### Added
90+
- Any text selected in the current buffer, or the entire buffer, can now be fed to a command as standard input, rather than as an argument. (@pcantrell) Fixes issue #5.
91+
92+
## [0.7.0] - 2014-03-11
93+
### Added
94+
- A shell configuration script can now be executed before commands. The script is either set in `$ENV` (as per `bash` conventions) or using the `shell_configuration_file` configuration setting. (@mikeerickson) Fixes issue #8.
95+
96+
## [0.6.0] - 2014-03-10
97+
### Added
98+
- The working directory is no longer derived primarily from the currently selected file. Instead any directory that has been saved in the view settings, or the project directory or the first open folder, is used. (@mikeerickson) Fixes issue #6.
99+
100+
## [0.5.0] - 2014-03-07
101+
### Fixed
102+
- If there is no output from a command then no panel or window is created. This used to work, until async commands were implemented, but now it really _does_ work. (@aldanor) Fixes issue #11.
103+
104+
## [0.4.0] - 2013-11-26
105+
### Added
106+
- Long-running commands will now update the buffer as and when data is available. For example, Grunt could be made to watch a project and update the buffer by running the command `grunt --no-color`. However, note that there is currently no way to terminate the process (see issue #10). Fixes issue #4.
107+
- To change the default behaviour for long running commands, use the 'wait for completion' flag.
108+
109+
## [0.3.0] - 2013-10-07
110+
### Added
111+
- Add `shell_command_on_region` to align with Emacs version.
112+
113+
### Fixed
114+
- Commands now *really are* run asynchronously. (@SirLenz0rlot)
115+
Fixes issue #2.
116+
117+
## [0.2.0] - 2013-10-07
118+
### Added
119+
- Some crucial text commands were not included (@bizoo).
120+
Fixes issue #1.
121+
122+
### Fixed
123+
- The region under the cursor was not being used as a parameter.
124+
125+
## [0.1.0] - 2013-10-04
126+
### Added
127+
- Initial release.
128+
129+
[Unreleased]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.17.0...HEAD
130+
[0.17.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.16.0...v0.17.0
131+
[0.16.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.15.2...v0.16.0
132+
[0.15.2]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.15.1...v0.15.2
133+
[0.15.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.15.0...v0.15.1
134+
[0.15.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.14.0...v0.15.0
135+
[0.14.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.13.1...v0.14.0
136+
[0.13.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.13.0...v0.13.1
137+
[0.13.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.12.2...v0.13.0
138+
[0.12.2]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.12.1...v0.12.2
139+
[0.12.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.12.0...v0.12.1
140+
[0.12.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.11.1...v0.12.0
141+
[0.11.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.11.0...v0.11.1
142+
[0.11.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.10.0...v0.11.0
143+
[0.10.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.9.0...v0.10.0
144+
[0.9.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.8.0...v0.9.0
145+
[0.8.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.7.0...v0.8.0
146+
[0.7.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.6.0...v0.7.0
147+
[0.6.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.5.0...v0.6.0
148+
[0.5.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.4.0...v0.5.0
149+
[0.4.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.3.0...v0.4.0
150+
[0.3.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.2.0...v0.3.0
151+
[0.2.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.1.0...v0.2.0
152+
[0.1.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/...v0.1.0

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2013-2015 Mark Birbeck
3+
Copyright (c) 2013-2019 Mark Birbeck
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of
66
this software and associated documentation files (the "Software"), to deal in

README.md

Lines changed: 4 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ To pass a string of text to a command use the `stdin` argument.
293293
]
294294
```
295295

296-
This will run `git diff` against whatever file is selected, and then use the `Diff` syntax file (`Packages/Diff/Diff.tmLanguage`) to format the output.
296+
This will run `git diff` against whatever file is selected, and then use the `Diff` syntax file (`Packages/Diff/Diff.sublime-syntax`) to format the output.
297+
298+
The value of the `syntax` property can be a full path to a syntax file, a file name without a path, but with a file extension, or a syntax name without a file extension (as in the above example). If the value specified is not found when treated as a path then `ShellCommand` will append a suffix of `.sublime-syntax` and try again. If there is still no match, a suffix of `.tmLanguage` will be tried, before finally, an error is reported.
297299

298300
## Restricting key bindings to a shell command view
299301

@@ -373,107 +375,4 @@ By default long-running commands will update the buffer as and when data is avai
373375

374376
# Changelog
375377

376-
## 2016-02-26 (v0.16.0)
377-
378-
Fixed problem where output buffers were always being set to read only. This is only relevant when writing to the buffer being edited. Fixes #51.
379-
380-
Allow the output of a command to overwrite the region used as input. Closes #9.
381-
382-
## 2016-02-05 (v0.15.2)
383-
384-
Fixed problem where a failing configuration script would prevent any command from running. Fixes #50.
385-
386-
## 2015-03-11 (v0.15.1)
387-
388-
Fixed an additional scenario relating to issue #47, where generated views could have a CWD of `None`. Fixes #47.
389-
390-
## 2015-03-11 (v0.15.0)
391-
392-
Commands run from generated views no longer always have CWD of `None`. Fixes #47.
393-
394-
`root_dir` is now working again. (@Stentor) Fixes #45.
395-
396-
## 2015-02-13 (v0.14.0)
397-
398-
Added option to allow the shell used to be overridden. Closes issue #32.
399-
400-
## 2015-02-13 (v0.13.1)
401-
402-
Added option to allow the end of a view to always be visible. Closes issue #39.
403-
404-
## 2015-02-12 (v0.13.0)
405-
406-
The module has been renamed to `ShellCommand` in the package manager so this release simply applies the name change to documents, prompts, and file paths.
407-
408-
## 2015-02-12 (v0.12.2)
409-
410-
* Add blank line before list in README. (@kleinfreund) Fixes issue #41.
411-
* Provide method for running shell commands directly. (@markbirbeck) Fixes issue #42.
412-
* Add reference to [Git Mode](https://github.com/markbirbeck/sublime-text-gitmode/) as an example of using `ShellCommand` to create modes. (@markbirbeck)
413-
414-
## 2015-01-01 (v0.12.1)
415-
416-
* Add substitution variables that mirror those used in the ST build system. See [Build System Variables](http://docs.sublimetext.info/en/latest/reference/build_systems.html#build-system-variables) for the full list and description. Fixes issue #35.
417-
418-
## 2015-01-01 (v0.12.0)
419-
420-
* Commands can now get parameters from users. Thanks to @aflc for providing the code for this functionality. Fixes issue #36.
421-
422-
## 2014-06-26 (v0.11.1)
423-
424-
* The working directory is set to be the directory of the current file, but if the 'root' (deduced from the current file) is required, the option `root_dir` can be set to `True`. (@markbirbeck) Fixes issue #25.
425-
426-
## 2014-06-26 (v0.11.0)
427-
428-
* Commands were failing on Windows due to an unnecessary check that `stdout` was ready. (@markbirbeck) Fixes issue #13. Thanks to @bergtholdt who drew attention to the problem and proposed a slightly different solution.
429-
* Working directory selection is now much smarter, based on using the current file's path to find out which folder or project the file belongs to. (@bergtholdt) Fixes issue #17.
430-
* The working directory is set to be the 'root' deduced from the current file, but if the directory of the current file is required, the option `root_dir` can be set to `False`. (@markbirbeck) Fixes issue #24.
431-
* Menu entries that were supposed to provide access to settings and key bindings were opening the wrong files. (@markbirbeck) Fixes issue #22.
432-
* `CR/LF` sequences are now mapped to `LF` which improves display on Windows. (@markbirbeck) Fixes issue #21.
433-
* A link to a wiki page from the README was incorrect. (@mrjoelkemp) Fixes issue #19 and #20. Thanks also to @reqshark who spotted the same problem and also provided a solution.
434-
435-
## 2014-03-20 (v0.10.0)
436-
437-
* Passing a buffer with UTF-8 characters in as the stdin for a command caused the command to fail. (@markbirbeck) Fixes issue #16.
438-
439-
## 2014-03-15 (v0.9.0)
440-
441-
* Commands were failing if run in a window with no open folders or files. (@mrvoss) Fixes issue #14.
442-
443-
## 2014-03-14 (v0.8.0)
444-
445-
* Any text selected in the current buffer, or the entire buffer, can now be fed to a command as standard input, rather than as an argument. (@pcantrell) Fixes issue #5.
446-
447-
## 2014-03-11 (v0.7.0)
448-
449-
* A shell configuration script can now be executed before commands. The script is either set in `$ENV` (as per `bash` conventions) or using the `shell_configuration_file` configuration setting. (@mikeerickson) Fixes issue #8.
450-
451-
## 2014-03-10 (v0.6.0)
452-
453-
* The working directory is no longer derived primarily from the currently selected file. Instead any directory that has been saved in the view settings, or the project directory or the first open folder, is used. (@mikeerickson) Fixes issue #6.
454-
455-
## 2014-03-07 (v0.5.0)
456-
457-
* If there is no output from a command then no panel or window is created. This used to work, until async commands were implemented, but now it really _does_ work. (@aldanor) Fixes issue #11.
458-
459-
## 2013-11-26 (v0.4.0)
460-
461-
* Long-running commands will now update the buffer as and when data is available. For example, Grunt could be made to watch a project and update the buffer by running the command `grunt --no-color`. However, note that there is currently no way to terminate the process (see issue #10). Fixes issue #4.
462-
463-
* To change the default behaviour for long running commands, use the 'wait for completion' flag.
464-
465-
## 2013-10-07 (v0.3.0)
466-
467-
* Commands now *really are* run asynchronously. (@SirLenz0rlot)
468-
Fixes issue #2.
469-
* Add `shell_command_on_region` to align with Emacs version.
470-
471-
## 2013-10-07 (v0.2.0)
472-
473-
* Some crucial text commands were not included (@bizoo).
474-
Fixes issue #1.
475-
* The region under the cursor was not being used as a parameter.
476-
477-
## 2013-10-04 (v0.1.0)
478-
479-
* Initial release.
378+
Moved to [CHANGELOG](./CHANGELOG.md).

ShellCommand.sublime-settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.16.0"
2+
"version": "0.17.0"
33

44
/**
55
* From Emacs: If comint-scroll-show-maximum-output is true, then

SublimeHelper.py

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,31 @@ def main_thread(callback, *args, **kwargs):
1212

1313
sublime.set_timeout_async(functools.partial(callback, *args, **kwargs), 0)
1414

15+
# Work out the name of a syntax file when we may only know the syntax:
16+
#
17+
def get_syntax_file(syntax):
18+
# First try to find the resource using the provided string:
19+
#
20+
resources = sublime.find_resources(syntax)
21+
22+
# If there is no match, then try with the newer .sublime-syntax
23+
# extension:
24+
#
25+
if not resources:
26+
resources = sublime.find_resources(syntax + '.sublime-syntax')
27+
28+
# If there is still no match then try for the older .tmLanguage extension:
29+
#
30+
if not resources:
31+
resources = sublime.find_resources(syntax + '.tmLanguage')
32+
33+
# If none of these approaches found a syntax file then throw an error, since
34+
# the user obviously wanted something:
35+
#
36+
if not resources:
37+
raise Exception('No resource found matching "%s".' % syntax)
38+
else:
39+
return resources[0]
1540

1641
class TextCommand(sublime_plugin.TextCommand):
1742

@@ -217,16 +242,8 @@ def __init__(self, window, data_key, command, working_dir, title=None, syntax=No
217242
# Set the syntax for the output:
218243
#
219244
if syntax is not None:
220-
if not (syntax.endswith('.tmLanguage') or
221-
syntax.endswith('.sublime-syntax')):
222-
syntax += '.tmLanguage'
223-
resources = sublime.find_resources(syntax)
224-
225-
if not resources:
226-
print('No resource found matching "%s". Using it as full syntax path.' % syntax)
227-
self.console.set_syntax_file(syntax)
228-
else:
229-
self.console.set_syntax_file(resources[0])
245+
syntax_file = get_syntax_file(syntax)
246+
self.console.set_syntax_file(syntax_file)
230247

231248
# Set a flag on the view that we can use in key bindings:
232249
#

message.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"install": "messages/install.txt",
3-
"0.12.0": "messages/0.12.0.txt",
4-
"0.12.1": "messages/0.12.1.txt",
5-
"0.12.2": "messages/0.12.2.txt",
6-
"0.13.0": "messages/0.13.0.txt",
7-
"0.13.1": "messages/0.13.1.txt",
8-
"0.14.0": "messages/0.14.0.txt",
9-
"0.15.0": "messages/0.15.0.txt",
10-
"0.15.1": "messages/0.15.1.txt",
3+
"0.17.0": "messages/0.17.0.txt",
4+
"0.16.0": "messages/0.16.0.txt",
115
"0.15.2": "messages/0.15.2.txt",
12-
"0.16.0": "messages/0.16.0.txt"
6+
"0.15.1": "messages/0.15.1.txt",
7+
"0.15.0": "messages/0.15.0.txt",
8+
"0.14.0": "messages/0.14.0.txt",
9+
"0.13.1": "messages/0.13.1.txt",
10+
"0.13.0": "messages/0.13.0.txt",
11+
"0.12.2": "messages/0.12.2.txt",
12+
"0.12.1": "messages/0.12.1.txt",
13+
"0.12.0": "messages/0.12.0.txt"
1314
}

messages/0.17.0.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Version 0.17.0 Release Notes
2+
3+
Lots of changes have been sitting unpublished on GitHub...sorry about that!
4+
5+
Make the output of long-running tasks smoother. Closes #68. (@markbirbeck)
6+
Add support for history of commands. Closes #27. (@kaste)
7+
Support new syntax definition styles when using syntax option. Closes #74. (@gwenzek)

0 commit comments

Comments
 (0)