Skip to content

Commit

Permalink
Merge pull request #76 from markbirbeck/74-path-forced-to-use-suffix
Browse files Browse the repository at this point in the history
74 path forced to use suffix
  • Loading branch information
markbirbeck authored Jan 5, 2019
2 parents 299ce8a + b1f0a43 commit 846e1d0
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 126 deletions.
152 changes: 152 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## [Unreleased]

## [0.17.0] - 2019-01-05
### Added
- Make the output of long-running tasks smoother. Closes #68. (@markbirbeck)
- Add support for history of commands. Closes #27. (@kaste)
- Support new syntax definition styles when using syntax option. Closes #74. (@gwenzek)

## [0.16.0] - 2016-02-26
### Added
- Allow the output of a command to overwrite the region used as input. Closes #9.

### Fixed
- 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.

## [0.15.2] - 2016-02-05
### Fixed
Fixed problem where a failing configuration script would prevent any command from running. Fixes #50.

## [0.15.1] - 2015-03-11
### Fixed
- Fixed an additional scenario relating to issue #47, where generated views could have a CWD of `None`. Fixes #47.

## [0.15.0] - 2015-03-11

### Fixed
- Commands run from generated views no longer always have CWD of `None`. Fixes #47.
- `root_dir` is now working again. (@Stentor) Fixes #45.

## [0.14.0] - 2015-02-13
### Added
- Added option to allow the shell used to be overridden. Closes issue #32.

## [0.13.1] - 2015-02-13
### Added
- Added option to allow the end of a view to always be visible. Closes issue #39.

## [0.13.0] - 2015-02-12
### Changed
- 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.

## [0.12.2] - 2015-02-12
### Added
- Add blank line before list in README. (@kleinfreund) Fixes issue #41.
- Provide method for running shell commands directly. (@markbirbeck) Fixes issue #42.
- Add reference to [Git Mode](https://github.com/markbirbeck/sublime-text-gitmode/) as an example of using `ShellCommand` to create modes. (@markbirbeck)

## [0.12.1] - 2015-01-01
### Added
- 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.

## [0.12.0] - 2015-01-01
### Added
- Commands can now get parameters from users. Thanks to @aflc for providing the code for this functionality. Fixes issue #36.

## [0.11.1] - 2014-06-26
### Fixed
- 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.

## [0.11.0] - 2014-06-26
### Added
- 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.
- 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.

### Changed
- `CR/LF` sequences are now mapped to `LF` which improves display on Windows. (@markbirbeck) Fixes issue #21.

### Fixed
- 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.
- Menu entries that were supposed to provide access to settings and key bindings were opening the wrong files. (@markbirbeck) Fixes issue #22.
- 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.

## [0.10.0] - 2014-03-20
### Fixed
- Passing a buffer with UTF-8 characters in as the stdin for a command caused the command to fail. (@markbirbeck) Fixes issue #16.

## [0.9.0] - 2014-03-15
### Fixed
- Commands were failing if run in a window with no open folders or files. (@mrvoss) Fixes issue #14.

## [0.8.0] - 2014-03-14
### Added
- 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.

## [0.7.0] - 2014-03-11
### Added
- 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.

## [0.6.0] - 2014-03-10
### Added
- 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.

## [0.5.0] - 2014-03-07
### Fixed
- 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.

## [0.4.0] - 2013-11-26
### Added
- 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.
- To change the default behaviour for long running commands, use the 'wait for completion' flag.

## [0.3.0] - 2013-10-07
### Added
- Add `shell_command_on_region` to align with Emacs version.

### Fixed
- Commands now *really are* run asynchronously. (@SirLenz0rlot)
Fixes issue #2.

## [0.2.0] - 2013-10-07
### Added
- Some crucial text commands were not included (@bizoo).
Fixes issue #1.

### Fixed
- The region under the cursor was not being used as a parameter.

## [0.1.0] - 2013-10-04
### Added
- Initial release.

[Unreleased]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.17.0...HEAD
[0.17.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.16.0...v0.17.0
[0.16.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.15.2...v0.16.0
[0.15.2]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.15.1...v0.15.2
[0.15.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.15.0...v0.15.1
[0.15.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.14.0...v0.15.0
[0.14.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.13.1...v0.14.0
[0.13.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.13.0...v0.13.1
[0.13.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.12.2...v0.13.0
[0.12.2]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.12.1...v0.12.2
[0.12.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.12.0...v0.12.1
[0.12.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.11.1...v0.12.0
[0.11.1]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.11.0...v0.11.1
[0.11.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.10.0...v0.11.0
[0.10.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.9.0...v0.10.0
[0.9.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.8.0...v0.9.0
[0.8.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.7.0...v0.8.0
[0.7.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.6.0...v0.7.0
[0.6.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.5.0...v0.6.0
[0.5.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.4.0...v0.5.0
[0.4.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.3.0...v0.4.0
[0.3.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.2.0...v0.3.0
[0.2.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/v0.1.0...v0.2.0
[0.1.0]: https://github.com/markbirbeck/sublime-text-shell-command/compare/...v0.1.0
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2013-2015 Mark Birbeck
Copyright (c) 2013-2019 Mark Birbeck

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
109 changes: 4 additions & 105 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ To pass a string of text to a command use the `stdin` argument.
]
```

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.
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.

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.

## Restricting key bindings to a shell command view

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

# Changelog

## 2016-02-26 (v0.16.0)

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.

Allow the output of a command to overwrite the region used as input. Closes #9.

## 2016-02-05 (v0.15.2)

Fixed problem where a failing configuration script would prevent any command from running. Fixes #50.

## 2015-03-11 (v0.15.1)

Fixed an additional scenario relating to issue #47, where generated views could have a CWD of `None`. Fixes #47.

## 2015-03-11 (v0.15.0)

Commands run from generated views no longer always have CWD of `None`. Fixes #47.

`root_dir` is now working again. (@Stentor) Fixes #45.

## 2015-02-13 (v0.14.0)

Added option to allow the shell used to be overridden. Closes issue #32.

## 2015-02-13 (v0.13.1)

Added option to allow the end of a view to always be visible. Closes issue #39.

## 2015-02-12 (v0.13.0)

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.

## 2015-02-12 (v0.12.2)

* Add blank line before list in README. (@kleinfreund) Fixes issue #41.
* Provide method for running shell commands directly. (@markbirbeck) Fixes issue #42.
* Add reference to [Git Mode](https://github.com/markbirbeck/sublime-text-gitmode/) as an example of using `ShellCommand` to create modes. (@markbirbeck)

## 2015-01-01 (v0.12.1)

* 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.

## 2015-01-01 (v0.12.0)

* Commands can now get parameters from users. Thanks to @aflc for providing the code for this functionality. Fixes issue #36.

## 2014-06-26 (v0.11.1)

* 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.

## 2014-06-26 (v0.11.0)

* 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.
* 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.
* 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.
* Menu entries that were supposed to provide access to settings and key bindings were opening the wrong files. (@markbirbeck) Fixes issue #22.
* `CR/LF` sequences are now mapped to `LF` which improves display on Windows. (@markbirbeck) Fixes issue #21.
* 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.

## 2014-03-20 (v0.10.0)

* Passing a buffer with UTF-8 characters in as the stdin for a command caused the command to fail. (@markbirbeck) Fixes issue #16.

## 2014-03-15 (v0.9.0)

* Commands were failing if run in a window with no open folders or files. (@mrvoss) Fixes issue #14.

## 2014-03-14 (v0.8.0)

* 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.

## 2014-03-11 (v0.7.0)

* 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.

## 2014-03-10 (v0.6.0)

* 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.

## 2014-03-07 (v0.5.0)

* 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.

## 2013-11-26 (v0.4.0)

* 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.

* To change the default behaviour for long running commands, use the 'wait for completion' flag.

## 2013-10-07 (v0.3.0)

* Commands now *really are* run asynchronously. (@SirLenz0rlot)
Fixes issue #2.
* Add `shell_command_on_region` to align with Emacs version.

## 2013-10-07 (v0.2.0)

* Some crucial text commands were not included (@bizoo).
Fixes issue #1.
* The region under the cursor was not being used as a parameter.

## 2013-10-04 (v0.1.0)

* Initial release.
Moved to [CHANGELOG](./CHANGELOG.md).
2 changes: 1 addition & 1 deletion ShellCommand.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.16.0"
"version": "0.17.0"

/**
* From Emacs: If comint-scroll-show-maximum-output is true, then
Expand Down
37 changes: 27 additions & 10 deletions SublimeHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ def main_thread(callback, *args, **kwargs):

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

# Work out the name of a syntax file when we may only know the syntax:
#
def get_syntax_file(syntax):
# First try to find the resource using the provided string:
#
resources = sublime.find_resources(syntax)

# If there is no match, then try with the newer .sublime-syntax
# extension:
#
if not resources:
resources = sublime.find_resources(syntax + '.sublime-syntax')

# If there is still no match then try for the older .tmLanguage extension:
#
if not resources:
resources = sublime.find_resources(syntax + '.tmLanguage')

# If none of these approaches found a syntax file then throw an error, since
# the user obviously wanted something:
#
if not resources:
raise Exception('No resource found matching "%s".' % syntax)
else:
return resources[0]

class TextCommand(sublime_plugin.TextCommand):

Expand Down Expand Up @@ -217,16 +242,8 @@ def __init__(self, window, data_key, command, working_dir, title=None, syntax=No
# Set the syntax for the output:
#
if syntax is not None:
if not (syntax.endswith('.tmLanguage') or
syntax.endswith('.sublime-syntax')):
syntax += '.tmLanguage'
resources = sublime.find_resources(syntax)

if not resources:
print('No resource found matching "%s". Using it as full syntax path.' % syntax)
self.console.set_syntax_file(syntax)
else:
self.console.set_syntax_file(resources[0])
syntax_file = get_syntax_file(syntax)
self.console.set_syntax_file(syntax_file)

# Set a flag on the view that we can use in key bindings:
#
Expand Down
19 changes: 10 additions & 9 deletions message.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"install": "messages/install.txt",
"0.12.0": "messages/0.12.0.txt",
"0.12.1": "messages/0.12.1.txt",
"0.12.2": "messages/0.12.2.txt",
"0.13.0": "messages/0.13.0.txt",
"0.13.1": "messages/0.13.1.txt",
"0.14.0": "messages/0.14.0.txt",
"0.15.0": "messages/0.15.0.txt",
"0.15.1": "messages/0.15.1.txt",
"0.17.0": "messages/0.17.0.txt",
"0.16.0": "messages/0.16.0.txt",
"0.15.2": "messages/0.15.2.txt",
"0.16.0": "messages/0.16.0.txt"
"0.15.1": "messages/0.15.1.txt",
"0.15.0": "messages/0.15.0.txt",
"0.14.0": "messages/0.14.0.txt",
"0.13.1": "messages/0.13.1.txt",
"0.13.0": "messages/0.13.0.txt",
"0.12.2": "messages/0.12.2.txt",
"0.12.1": "messages/0.12.1.txt",
"0.12.0": "messages/0.12.0.txt"
}
7 changes: 7 additions & 0 deletions messages/0.17.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Version 0.17.0 Release Notes

Lots of changes have been sitting unpublished on GitHub...sorry about that!

Make the output of long-running tasks smoother. Closes #68. (@markbirbeck)
Add support for history of commands. Closes #27. (@kaste)
Support new syntax definition styles when using syntax option. Closes #74. (@gwenzek)

0 comments on commit 846e1d0

Please sign in to comment.