Migrated Fortran support to new layout.

This commit is contained in:
Jan-Cornelius Molnar 2015-06-01 19:48:37 +02:00
parent 3ea91c6a10
commit c75ad31778
5 changed files with 134 additions and 1 deletions

View File

@ -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)
))))))

View File

@ -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)
)

View File

@ -39,6 +39,7 @@ module.exports = class Beautifiers
'htmlbeautifier' 'htmlbeautifier'
'csscomb' 'csscomb'
'gofmt' 'gofmt'
'fortran-emacs-beautify'
'js-beautify' 'js-beautify'
'perltidy' 'perltidy'
'php-cs-fixer' 'php-cs-fixer'

View File

@ -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"
}

View File

@ -29,6 +29,7 @@ module.exports = class Languages
"ejs" "ejs"
"erb" "erb"
"go" "go"
"fortran"
"handlebars" "handlebars"
"html" "html"
"java" "java"
@ -86,4 +87,4 @@ module.exports = class Languages
_.filter(@languages, (language) -> _.isEqual(language.namespace, namespace)) _.filter(@languages, (language) -> _.isEqual(language.namespace, namespace))
_.filter(@languages, (language) -> _.contains(language.grammars, grammar)) _.filter(@languages, (language) -> _.contains(language.grammars, grammar))
_.filter(@languages, (language) -> _.contains(language.extensions, extension)) _.filter(@languages, (language) -> _.contains(language.extensions, extension))
) )