Migrated Fortran support to new layout.
This commit is contained in:
parent
3ea91c6a10
commit
c75ad31778
|
@ -0,0 +1,46 @@
|
|||
(defun f90-batch-indent-region ()
|
||||
"Run `f90-batch-beatify-region' on the specified filename.
|
||||
Use this from the command line, with `-batch';
|
||||
it won't work in an interactive Emacs.
|
||||
For example, invoke \"emacs -batch -l ~/.emacs-batch-f90-indent -f f90-batch-indent-region file.f\""
|
||||
(if (not noninteractive)
|
||||
(error "`f90-batch-indent-region' is to be used only with -batch"))
|
||||
(let ((make-backup-files nil)
|
||||
(version-control nil)
|
||||
(auto-save-default nil)
|
||||
(find-file-run-dired nil)
|
||||
(kept-old-versions 259259)
|
||||
(kept-new-versions 259259))
|
||||
(let ((error 0)
|
||||
file
|
||||
(files ()))
|
||||
(while command-line-args-left
|
||||
(setq file (expand-file-name (car command-line-args-left)))
|
||||
(cond ((not (file-exists-p file))
|
||||
(message ">> %s does not exist!" file)
|
||||
(setq error 1
|
||||
command-line-args-left (cdr command-line-args-left)))
|
||||
((file-directory-p file)
|
||||
(setq command-line-args-left
|
||||
(nconc (directory-files file)
|
||||
(cdr command-line-args-left))))
|
||||
(t
|
||||
(setq files (cons file files)
|
||||
command-line-args-left (cdr command-line-args-left)))))
|
||||
(while files
|
||||
(setq file (car files)
|
||||
files (cdr files))
|
||||
(condition-case err
|
||||
(progn
|
||||
(if buffer-file-name (kill-buffer (current-buffer)))
|
||||
(find-file file)
|
||||
(buffer-disable-undo (current-buffer))
|
||||
(set-buffer-modified-p nil)
|
||||
(f90-mode)
|
||||
(message (file-name-nondirectory buffer-file-name))
|
||||
; compute indentation of first
|
||||
; line
|
||||
(f90-indent-subprogram)
|
||||
(f90-upcase-keywords)
|
||||
(save-buffer)
|
||||
))))))
|
|
@ -0,0 +1,51 @@
|
|||
###
|
||||
Requires https://github.com/FriendsOfPHP/PHP-CS-Fixer
|
||||
###
|
||||
|
||||
"use strict"
|
||||
Beautifier = require('./beautifier')
|
||||
path = require("path")
|
||||
|
||||
module.exports = class FortranBeautifier extends Beautifier
|
||||
name: "Fortran Beautifier"
|
||||
|
||||
options: {
|
||||
Fortran: true
|
||||
}
|
||||
|
||||
beautify: (text, language, options) ->
|
||||
@debug('fortran-beautifier', options)
|
||||
|
||||
console.debug 'fortran-beautifier' + options
|
||||
|
||||
emacs_path = options.emacs_path
|
||||
emacs_script_path = options.emacs_script_path
|
||||
|
||||
if not emacs_script_path
|
||||
emacs_script_path = path.resolve(__dirname, "emacs/emacs-fortran-beautify.lisp")
|
||||
|
||||
@debug('fortran-beautifier', 'emacs script path: ' + emacs_script_path)
|
||||
|
||||
args = [
|
||||
'--batch'
|
||||
'-l'
|
||||
emacs_script_path
|
||||
'-f'
|
||||
'f90-batch-indent-region'
|
||||
tempFile = @tempFile("temp", text)
|
||||
]
|
||||
|
||||
if emacs_path
|
||||
args.unshift("#{emacs_path}")
|
||||
|
||||
@run("python", args, {ignoreReturnCode: true})
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
||||
else
|
||||
@debug('fortran-beautifier', "running emacs with args " + args)
|
||||
|
||||
@run("emacs", args, {ignoreReturnCode: true})
|
||||
.then(=>
|
||||
@readFile(tempFile)
|
||||
)
|
|
@ -39,6 +39,7 @@ module.exports = class Beautifiers
|
|||
'htmlbeautifier'
|
||||
'csscomb'
|
||||
'gofmt'
|
||||
'fortran-emacs-beautify'
|
||||
'js-beautify'
|
||||
'perltidy'
|
||||
'php-cs-fixer'
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
module.exports = {
|
||||
|
||||
name: "Fortran"
|
||||
namespace: "fortran"
|
||||
|
||||
###
|
||||
Supported Grammars
|
||||
###
|
||||
grammars: [
|
||||
"Fortran - Modern"
|
||||
]
|
||||
|
||||
###
|
||||
Supported extensions
|
||||
###
|
||||
extensions: [
|
||||
"f90"
|
||||
]
|
||||
|
||||
###
|
||||
|
||||
###
|
||||
options:
|
||||
# JavaScript
|
||||
emacs_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the `emacs` executable"
|
||||
emacs_script_path:
|
||||
type: 'string'
|
||||
default: ""
|
||||
description: "Path to the emacs script"
|
||||
|
||||
}
|
|
@ -29,6 +29,7 @@ module.exports = class Languages
|
|||
"ejs"
|
||||
"erb"
|
||||
"go"
|
||||
"fortran"
|
||||
"handlebars"
|
||||
"html"
|
||||
"java"
|
||||
|
@ -86,4 +87,4 @@ module.exports = class Languages
|
|||
_.filter(@languages, (language) -> _.isEqual(language.namespace, namespace))
|
||||
_.filter(@languages, (language) -> _.contains(language.grammars, grammar))
|
||||
_.filter(@languages, (language) -> _.contains(language.extensions, extension))
|
||||
)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue