Switch Fortran beautifier (using Emacs) to using Executables, other minor improvements

This commit is contained in:
Glavin Wiechert 2017-06-01 02:47:39 -03:00
parent 5648aa34a1
commit bee7b2573a
7 changed files with 83 additions and 14 deletions

View File

@ -158,6 +158,27 @@ Options for Rscript executable.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Rscript*" and change it to your desired configuration.
##### [Emacs](#emacs)
**Namespace**: ``
**Key**: `emacs`
**Type**: `object`
**Supported Beautifiers**: [`Fortran Beautifier`](#fortran-beautifier)
**Description**:
Options for Emacs executable.
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Emacs*" and change it to your desired configuration.
##### [PHP](#php)
**Namespace**: ``
@ -183,7 +204,7 @@ Options for PHP executable.
**Namespace**: ``
**Key**: `php_cs_fixer`
**Key**: `php-cs-fixer`
**Type**: `object`
@ -15873,6 +15894,27 @@ Path to the emacs script (Supported by Fortran Beautifier)
}
```
##### [Emacs](#emacs)
**Namespace**: ``
**Key**: `emacs`
**Type**: `object`
**Supported Beautifiers**: [`Fortran Beautifier`](#fortran-beautifier)
**Description**:
Options for Emacs executable.
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Emacs*" and change it to your desired configuration.
### Gherkin formatter
@ -17733,7 +17775,7 @@ Options for PHP executable.
**Namespace**: ``
**Key**: `php_cs_fixer`
**Key**: `php-cs-fixer`
**Type**: `object`

View File

@ -185,8 +185,7 @@ buildOptionsForExecutables = function(beautifiers) {
const properties = {}
_.forEach(executables, (executable) => {
const { name, cmd, beautifiers } = executable;
const sanitizedCmd = cmd.split('-').join('_');
const key = sanitizedCmd;
const key = cmd;
const option = {
key: key,
title: name,

View File

@ -26,7 +26,7 @@ module.exports = class Executable
throw new Error("The command (i.e. cmd property) is required for an Executable.")
@name = options.name
@cmd = options.cmd
@key = @cmd.split('-').join('_')
@key = @cmd
@homepage = options.homepage
@installation = options.installation
if options.version?

View File

@ -16,10 +16,7 @@ module.exports = class R extends Beautifier
homepage: "https://github.com/yihui/formatR"
installation: "https://github.com/yihui/formatR"
version: {
parse: (text) ->
r = /version (\d\.\d\.\d) /
console.log("parse version", text, r, text.match(r))
text.match(r)[1]
parse: (text) -> text.match(/version (\d+\.\d+\.\d+) /)[1]
runOptions: {
returnStderr: true
}

View File

@ -9,7 +9,17 @@ path = require("path")
module.exports = class FortranBeautifier extends Beautifier
name: "Fortran Beautifier"
link: "https://www.gnu.org/software/emacs/"
isPreInstalled: false
executables: [
{
name: "Emacs"
cmd: "emacs"
homepage: "https://www.gnu.org/software/emacs/"
installation: "https://www.gnu.org/software/emacs/"
version: {
parse: (text) -> text.match(/Emacs (\d+\.\d+\.\d+)/)[1]
}
}
]
options: {
Fortran: true
@ -17,6 +27,7 @@ module.exports = class FortranBeautifier extends Beautifier
beautify: (text, language, options) ->
@debug('fortran-beautifier', options)
emacs = @exe("emacs")
emacs_path = options.emacs_path
emacs_script_path = options.emacs_script_path
@ -36,12 +47,13 @@ module.exports = class FortranBeautifier extends Beautifier
]
if emacs_path
@deprecate("The \"emacs_path\" has been deprecated. Please switch to using the config with path \"Executables - Emacs - Path\" in Atom-Beautify package settings now.")
@run(emacs_path, args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)
else
@run("emacs", args, {ignoreReturnCode: false})
emacs.run(args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)

View File

@ -78,7 +78,7 @@ module.exports = class PHPCSFixer extends Beautifier
# Find php-cs-fixer.phar script
if options.cs_fixer_path
@deprecate("The \"cs_fixer_path\" has been deprecated. Please change to using the config with path \"Executables - PHP - Path\" in Atom-Beautify package settings.")
@deprecate("The \"cs_fixer_path\" has been deprecated. Please switch to using the config with path \"Executables - PHP-CS-Fixer - Path\" in Atom-Beautify package settings now.")
@Promise.all([
@which(options.cs_fixer_path) if options.cs_fixer_path

View File

@ -9130,6 +9130,25 @@
"order": -1,
"description": "Configure executables used by beautifiers.",
"properties": {
"emacs": {
"key": "emacs",
"title": "Emacs",
"type": "object",
"collapsed": true,
"description": "Options for Emacs executable.",
"beautifiers": [
"Fortran Beautifier"
],
"properties": {
"path": {
"key": "path",
"title": "Executable Path",
"type": "string",
"default": "",
"description": "Absolute path to the \"emacs\" executable."
}
}
},
"php": {
"key": "php",
"title": "PHP",
@ -9149,8 +9168,8 @@
}
}
},
"php_cs_fixer": {
"key": "php_cs_fixer",
"php-cs-fixer": {
"key": "php-cs-fixer",
"title": "PHP-CS-Fixer",
"type": "object",
"collapsed": true,