Added emacs powered fortran beautification.
This commit is contained in:
parent
4915c38b2a
commit
a7b5799923
|
@ -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,37 @@
|
||||||
|
###
|
||||||
|
// Requires [f90ppr](http://www.ifremer.fr/ditigo/molagnon/fortran90/contenu.html)
|
||||||
|
###
|
||||||
|
|
||||||
|
"use strict"
|
||||||
|
fs = require("fs")
|
||||||
|
temp = require("temp").track()
|
||||||
|
|
||||||
|
getCmd = (inputPath, outputPath, options, cb) ->
|
||||||
|
if not options.emacs_script_path?
|
||||||
|
return new Error("'Emacs Script Path' not set!" +
|
||||||
|
" Please set this in the Atom Beautify package settings.")
|
||||||
|
|
||||||
|
path = options.emacs_path
|
||||||
|
console.debug "[fortran-beautify] options: " + JSON.stringify(options)
|
||||||
|
|
||||||
|
args = [
|
||||||
|
'--batch'
|
||||||
|
"-l \"#{options.emacs_script_path}\""
|
||||||
|
'-f f90-batch-indent-region'
|
||||||
|
"\"#{inputPath}\""
|
||||||
|
]
|
||||||
|
|
||||||
|
if path
|
||||||
|
cmd = "python \"#{path}\" " + args.join(' ')
|
||||||
|
else
|
||||||
|
cmd = "emacs " + args.join(' ')
|
||||||
|
|
||||||
|
console.debug "[fortran-beautify] cmd: " + cmd
|
||||||
|
|
||||||
|
fs.symlinkSync(inputPath, outputPath)
|
||||||
|
|
||||||
|
return cmd
|
||||||
|
|
||||||
|
cliBeautify = require("./cli-beautify")
|
||||||
|
isStdout = false
|
||||||
|
module.exports = cliBeautify(getCmd, isStdout)
|
|
@ -21,6 +21,7 @@ beautifyHTMLERB = null
|
||||||
beautifyMarkdown = null
|
beautifyMarkdown = null
|
||||||
beautifyTypeScript = null
|
beautifyTypeScript = null
|
||||||
beautifyTSS = null
|
beautifyTSS = null
|
||||||
|
beautifyFortran = null
|
||||||
Analytics = null
|
Analytics = null
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
|
@ -64,6 +65,7 @@ module.exports =
|
||||||
"pawn"
|
"pawn"
|
||||||
"vala"
|
"vala"
|
||||||
"typescript"
|
"typescript"
|
||||||
|
"fortran"
|
||||||
]
|
]
|
||||||
|
|
||||||
# Default options per language
|
# Default options per language
|
||||||
|
@ -279,6 +281,17 @@ module.exports =
|
||||||
default: ""
|
default: ""
|
||||||
description: "Specify a configuration file which will override the default name of .perltidyrc"
|
description: "Specify a configuration file which will override the default name of .perltidyrc"
|
||||||
|
|
||||||
|
# Fortran
|
||||||
|
fortran_emacs_path:
|
||||||
|
type: 'string'
|
||||||
|
default: ""
|
||||||
|
description: "Path to the `emacs` executable"
|
||||||
|
|
||||||
|
fortran_emacs_script_path:
|
||||||
|
type: 'string'
|
||||||
|
default: ""
|
||||||
|
description: "Path to the emacs script"
|
||||||
|
|
||||||
# PHP
|
# PHP
|
||||||
php_cs_fixer_path:
|
php_cs_fixer_path:
|
||||||
type: 'string'
|
type: 'string'
|
||||||
|
@ -511,6 +524,9 @@ module.exports =
|
||||||
when "TypeScript"
|
when "TypeScript"
|
||||||
beautifyTypeScript ?= require("./langs/typescript-beautify")
|
beautifyTypeScript ?= require("./langs/typescript-beautify")
|
||||||
beautifyTypeScript text, self.getOptions("js", allOptions), beautifyCompleted
|
beautifyTypeScript text, self.getOptions("js", allOptions), beautifyCompleted
|
||||||
|
when "Fortran - Modern"
|
||||||
|
beautifyFortran ?= require("./langs/fortran-beautify")
|
||||||
|
beautifyFortran text, self.getOptions("fortran", allOptions), beautifyCompleted
|
||||||
else
|
else
|
||||||
unsupportedGrammar = true
|
unsupportedGrammar = true
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue