Some tweaks
This commit is contained in:
parent
79f0af91c0
commit
92130e2524
4 changed files with 230 additions and 187 deletions
|
|
@ -317,6 +317,8 @@
|
||||||
(interactive)
|
(interactive)
|
||||||
(indent-region (point-min) (point-max) nil))
|
(indent-region (point-min) (point-max) nil))
|
||||||
|
|
||||||
|
;; (global-set-key (read-kbd-macro "C-i") 'indent-buffer)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;; C# Mode support
|
;;; C# Mode support
|
||||||
;;;
|
;;;
|
||||||
|
|
|
||||||
|
|
@ -71,3 +71,17 @@ function prompt
|
||||||
|
|
||||||
return ' '
|
return ' '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Get-APFile($Path, $Cockpit="BLUINFDPXYIH802:80")
|
||||||
|
{
|
||||||
|
$localFile = join-path $pwd (split-path -leaf $Path)
|
||||||
|
$uri = "http://$Cockpit/files?cmd=get&path=$Path"
|
||||||
|
Write-Host "Getting $Path to $localFile via $uri"
|
||||||
|
(New-Object System.Net.Webclient).DownloadFile($uri, $localFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-Url($Url)
|
||||||
|
{
|
||||||
|
(New-Object System.Net.Webclient).DownloadString($Url)
|
||||||
|
}
|
||||||
Binary file not shown.
|
|
@ -1,213 +1,240 @@
|
||||||
;; powershell-mode.el, version 0.5jd
|
;;; powershell-mode.el --- Mode for editing Powershell scripts
|
||||||
|
|
||||||
|
;; Copyright (C) 2009, 2010 Frédéric Perrin
|
||||||
|
|
||||||
|
;; Author: Frédéric Perrin <frederic (dot) perrin (arobas) resel (dot) fr>
|
||||||
|
;; Keywords: Powershell, Monad, MSH
|
||||||
|
|
||||||
|
;; This file is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published
|
||||||
|
;; by the Free Software Foundation, either version 3 of the License,
|
||||||
|
;; or (at your option) any later version.
|
||||||
|
|
||||||
|
;; GNU Emacs is distributed in the hope that it will be useful, but
|
||||||
|
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
;; General Public License for more details.
|
||||||
|
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Comment:
|
||||||
|
;; This is still WIP.
|
||||||
;;
|
;;
|
||||||
;; Author: John Doty (http://friendlyhedgehog.com)
|
;; This was written from scratch, without using Vivek Sharma's code:
|
||||||
;; Based on the work by Vivek Sharma (http://www.viveksharma.com/techlog)
|
;; it had issues I wanted to correct, but unfortunately there were no
|
||||||
;; Provides: Major mode for editing PS (PowerShell) scripts
|
;; licence indication, and Vivek didn't answered my mails.
|
||||||
;; Last Updated: 04/29/11
|
|
||||||
;;
|
;;
|
||||||
;; DONE
|
;; This is still pretty basic: there is indentation, syntax
|
||||||
;; - Indentation support (done)
|
;; hilighting, speedbar/imenu support. The indentation is pretty naïve
|
||||||
;; - support here strings (done)
|
;; but robust, and sufficient for my current needs.
|
||||||
;;
|
|
||||||
;; TODO
|
|
||||||
;; - C# class support
|
|
||||||
;; - PowerShell v2 support
|
|
||||||
;;
|
|
||||||
;; CHANGES
|
|
||||||
;; 0.1 - initial version with text highlighting support and indenting
|
|
||||||
;; 0.2 - fixed file based on feedback to handle xemacs and syntax file changes
|
|
||||||
;; 0.3 - updated to reflect Monad --> PowerShell name change
|
|
||||||
;; 0.4 - added manual indentation support, not totally what I'd like, but good enough
|
|
||||||
;; 0.5 - update from Richard Bielawski (email address excluded till he grants permission to
|
|
||||||
;; include it :) - Many thanks Richard! Fixes: indenting fixed, elseif keyword added,
|
|
||||||
;; visiting file bug fixed, standard comment support added. I only tested with latest
|
|
||||||
;; EmacsWin32, YMMV
|
|
||||||
;; 0.5jd - JohnDoty started to work on this; nothing quite yet.
|
|
||||||
|
|
||||||
|
(setq debug-on-error t)
|
||||||
|
|
||||||
;; custom hooks
|
(defvar powershell-indent 4
|
||||||
(defvar powershell-mode-hook nil)
|
"Amount of horizontal space to indent after, for instance, an
|
||||||
|
opening brace")
|
||||||
|
|
||||||
;; default mode map, really simple
|
(defvar powershell-continuation-indent 2
|
||||||
(defvar powershell-mode-map
|
"Amount of horizontal space to indent a continuation line")
|
||||||
(let ((powershell-mode-map (make-keymap)))
|
|
||||||
;; (define-key powershell-mode-map "\r" 'powershell-indent-line)
|
|
||||||
(define-key powershell-mode-map "\t" 'powershell-indent-line)
|
|
||||||
;; (define-key powershell-mode-map "{" 'powershell-electric-brace)
|
|
||||||
;; (define-key powershell-mode-map "}" 'powershell-electric-brace)
|
|
||||||
powershell-mode-map)
|
|
||||||
"Keymap for PS major mode")
|
|
||||||
|
|
||||||
(defvar powershell-indent-width 4)
|
(defvar powershell-continued-regexp ".*\\(|[\\t ]*\\|`\\)$"
|
||||||
|
"Regexp matching a continued line (ending either with an
|
||||||
|
explicit backtick, or with a pipe).")
|
||||||
|
|
||||||
;; make braces indent properly
|
(defun powershell-continuation-line-p ()
|
||||||
(defun powershell-electric-brace (arg)
|
"Returns t is the current line is a continuation line (i.e. the
|
||||||
"Correct indentation for squigly brace"
|
previous line is a continued line, ending with a backtick or a pipe"
|
||||||
(interactive "P")
|
(interactive)
|
||||||
(self-insert-command (prefix-numeric-value arg))
|
|
||||||
(unless
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
(forward-line -1)
|
||||||
|
(looking-at powershell-continued-regexp)))
|
||||||
|
|
||||||
|
(defun powershell-indent-line-amount ()
|
||||||
|
"Returns the column to which the current line ought to be indented."
|
||||||
|
(interactive)
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(or
|
(let ((closing-paren (looking-at "[\t ]*[])}]")))
|
||||||
;; (looking-at "$\w+") ;Don't do this in a variable
|
;; a very simple indentation method: if on a continuation line (i.e. the
|
||||||
(looking-at "{\s*|[^}]") ;Don't do this in an open procedure block
|
;; previous line ends with a trailing backtick or pipe), we indent relative
|
||||||
(looking-at "\"[^\"]*$")) ;Don't do this in a open string
|
;; to the continued line; otherwise, we indent relative to the ([{ that
|
||||||
)
|
;; opened the current block.
|
||||||
(powershell-indent-line)
|
(if (powershell-continuation-line-p)
|
||||||
(forward-char 1)
|
(progn
|
||||||
)
|
(while (powershell-continuation-line-p)
|
||||||
)
|
(forward-line -1))
|
||||||
|
(+ (current-indentation) powershell-continuation-indent))
|
||||||
|
(condition-case nil
|
||||||
|
(progn
|
||||||
|
(backward-up-list)
|
||||||
|
;; indentation relative to the opening paren: if there is text (no
|
||||||
|
;; comment) after the opening paren, vertically align the block
|
||||||
|
;; with this text; if we were looking at the closing paren, reset
|
||||||
|
;; the indentation; otherwise, indent the block by powershell-indent.
|
||||||
|
(cond ((not (looking-at ".[\t ]*\\(#.*\\)?$"))
|
||||||
|
(forward-char)
|
||||||
|
(skip-chars-forward " \t")
|
||||||
|
(current-column))
|
||||||
|
(closing-paren
|
||||||
|
(current-indentation))
|
||||||
|
(t
|
||||||
|
(+ (current-indentation) powershell-indent))))
|
||||||
|
(scan-error ;; most likely, we are at the top-level
|
||||||
|
0)))))
|
||||||
|
|
||||||
;(add-to-list 'auto-mode-alist '("\\.ps1\\'" . powershell-mode))
|
|
||||||
|
|
||||||
;; Function to control indenting.
|
|
||||||
(defun powershell-indent-line ()
|
(defun powershell-indent-line ()
|
||||||
"Indent current PowerShell script line"
|
"Indent the current line of powershell mode, leaving the point
|
||||||
|
in place if it is inside the meat of the line"
|
||||||
(interactive)
|
(interactive)
|
||||||
|
(let ((savep (> (current-column) (current-indentation)))
|
||||||
|
(amount (save-excursion (powershell-indent-line-amount))))
|
||||||
|
(if savep
|
||||||
|
(save-excursion (indent-line-to amount))
|
||||||
|
(indent-line-to amount))))
|
||||||
|
|
||||||
;; Set the point to beginning of line.
|
|
||||||
(beginning-of-line)
|
;; Taken from <http://www.manning.com/payette/AppCexcerpt.pdf> which seems the
|
||||||
(if (bobp)
|
;; closest to a grammar definition for powershell. It is not complete, and
|
||||||
(indent-line-to 0)
|
;; contains some inaccuracies (e.g. it says that variables match \$[:alnum:]+,
|
||||||
|
;; so $_ is not a variable it seems...)
|
||||||
|
|
||||||
(let ((not-indented t) (lines-back 0) cur-indent)
|
(defvar powershell-keywords
|
||||||
(if (looking-at "^[ \t]*}") ; Check for closing brace
|
(regexp-opt '("begin" "break" "catch" "continue" "data" "do" "dynamicparam"
|
||||||
(progn
|
"else" "elseif" "end" "exit" "filter" "finally" "for" "foreach"
|
||||||
(save-excursion
|
"from" "function" "if" "in" "param" "process" "return"
|
||||||
(forward-line -1)
|
"switch" "throw" "trap" "try" "until" "while"))
|
||||||
(setq lines-back (+ lines-back 1))
|
"Powershell keywords")
|
||||||
(if (looking-at "^[ \t]*{") ; If now looking at opening block
|
|
||||||
(setq cur-indent (current-indentation)) ;; duplicate indent
|
|
||||||
(setq cur-indent (- (current-indentation) powershell-indent-width)))
|
|
||||||
)
|
|
||||||
|
|
||||||
;; Safety check to make sure we don't indent negative.
|
(defvar powershell-operators
|
||||||
(if (< cur-indent 0)
|
(regexp-opt '("and" "as" "band" "bnot" "bor" "bxor" "casesensitive"
|
||||||
(setq cur-indent 0)))
|
"ccontains" "ceq" "cge" "cgt" "cle" "clike" "clt" "cmatch"
|
||||||
|
"cne" "cnotcontains" "cnotlike" "cnotmatch" "contains"
|
||||||
|
"creplace" "eq" "exact" "f" "file" "ge" "gt" "icontains"
|
||||||
|
"ieq" "ige" "igt" "ile" "ilike" "ilt" "imatch" "ine"
|
||||||
|
"inotcontains" "inotlike" "inotmatch" "ireplace" "is"
|
||||||
|
"isnot" "le" "like" "lt" "match" "ne" "not" "notcontains"
|
||||||
|
"notlike" "notmatch" "or" "replace" "wildcard"))
|
||||||
|
"Powershell operators")
|
||||||
|
|
||||||
(save-excursion
|
(defvar powershell-scope-names
|
||||||
(if (looking-at "^[ \t]*{") ; Opening block
|
(regexp-opt
|
||||||
(progn
|
'("env" "function" "global" "local" "private" "script" "variable"))
|
||||||
(forward-line -1)
|
"Names of scopes in Powershell mode.")
|
||||||
(setq lines-back (+ lines-back 1))
|
|
||||||
(setq cur-indent (current-indentation))
|
|
||||||
(setq not-indented nil))
|
|
||||||
|
|
||||||
(while not-indented
|
;; Taken from Get-Variable on a fresh shell, merged with man
|
||||||
(forward-line -1)
|
;; about_automatic_variables
|
||||||
(setq lines-back (+ lines-back 1))
|
(defvar powershell-builtin-variables
|
||||||
(if (looking-at "^[ \t]*}") ; Closing block
|
(regexp-opt
|
||||||
(progn
|
'("^" "_" "$" "?" "Args" "ConfirmPreference" "ConsoleFileName"
|
||||||
(setq cur-indent (current-indentation))
|
"DebugPreference" "Error" "ErrorActionPreference" "ErrorView"
|
||||||
(setq not-indented nil))
|
"ExecutionContext" "foreach" "FormatEnumerationLimit" "HOME" "Host"
|
||||||
|
"Input" "LASTEXITCODE" "MaximumAliasCount" "MaximumDriveCount"
|
||||||
|
"MaximumErrorCount" "MaximumFunctionCount" "MaximumHistoryCount"
|
||||||
|
"MaximumVariableCount" "MyInvocation" "NestedPromptLevel" "OFS"
|
||||||
|
"OutputEncoding" "PID" "PROFILE" "PSHOME" "PWD" "ProgressPreference"
|
||||||
|
"ReportErrorShowExceptionClass" "ReportErrorShowInnerException"
|
||||||
|
"ReportErrorShowSource" "ReportErrorShowStackTrace" "ShellId"
|
||||||
|
"ShouldProcessPreference" "ShouldProcessReturnPreference" "StackTrace"
|
||||||
|
"VerbosePreference" "WarningPreference" "WhatIfPreference" "false"
|
||||||
|
"input" "lastWord" "line" "null" "true" ))
|
||||||
|
"Names of the built-in Powershell variables. They are hilighted
|
||||||
|
differently from the other variables.")
|
||||||
|
|
||||||
(if (looking-at "^[ \t]*{") ; Opening block
|
(defvar powershell-font-lock-keywords-1
|
||||||
(progn
|
`(;; Type annotations
|
||||||
(setq cur-indent (+ (current-indentation) powershell-indent-width))
|
("\\[\\([[:word:].]+\\(\\[\\]\\)?\\)\\]" 1 font-lock-type-face)
|
||||||
(setq not-indented nil))
|
;; syntaxic keywords
|
||||||
|
(,(concat "\\<" powershell-keywords "\\>") . font-lock-keyword-face)
|
||||||
|
;; operators
|
||||||
|
(,(concat "\\<-" powershell-operators "\\>") . font-lock-builtin-face)
|
||||||
|
;; the REQUIRES mark
|
||||||
|
("^#\\(REQUIRES\\)" 1 font-lock-warning-face t))
|
||||||
|
"Keywords for the first level of font-locking in Powershell mode.")
|
||||||
|
|
||||||
(if (looking-at "^[ \t]*\\(if\\|for\\|foreach\\|function\\|filter\\|else\\|do\\|while\\)\\>")
|
(defvar powershell-font-lock-keywords-2
|
||||||
(progn
|
(append
|
||||||
(setq cur-indent (current-indentation))
|
powershell-font-lock-keywords-1
|
||||||
(forward-line 1)
|
`(;; Built-in variables
|
||||||
(setq lines-back (- lines-back 1))
|
(,(concat "\\$\\(" powershell-builtin-variables "\\)\\>")
|
||||||
(if (looking-at "^[ \t]*{") ; Has block
|
1 font-lock-builtin-face t)))
|
||||||
(setq not-indented nil)
|
"Keywords for the second level of font-locking in Powershell mode.")
|
||||||
(if (equal lines-back 0) ; No block
|
|
||||||
(progn
|
|
||||||
(setq cur-indent (+ cur-indent powershell-indent-width))
|
|
||||||
(setq not-indented nil))
|
|
||||||
(setq not-indented nil)))
|
|
||||||
)
|
|
||||||
|
|
||||||
(if (bobp)
|
(defvar powershell-font-lock-keywords-3
|
||||||
(setq not-indented nil)))))))))
|
(append
|
||||||
(if cur-indent
|
powershell-font-lock-keywords-2
|
||||||
(indent-line-to cur-indent)
|
`(;; Variables in curly brackets
|
||||||
(indent-line-to 0)))))
|
("\\${\\([^}]+\\)}" 1 font-lock-variable-name-face)
|
||||||
|
;; Variables, with a scope
|
||||||
|
(,(concat "\\$\\(" powershell-scope-names "\\):"
|
||||||
|
"\\([[:alnum:]_]+\\)")
|
||||||
|
(1 (cons font-lock-type-face '(underline)))
|
||||||
|
(2 font-lock-variable-name-face))
|
||||||
|
;; Variables, without a scope. XXX: unify this with the
|
||||||
|
;; previous rule?
|
||||||
|
("\\$\\([[:alnum:]_]+\\)" 1 font-lock-variable-name-face)
|
||||||
|
;; hilight properties, but not the methods (personnal preference)
|
||||||
|
("\\.\\([[:alnum:]_.]+\\)\\>\\s *[^(]" 1 font-lock-variable-name-face)))
|
||||||
|
"Keywords for the maximum level of font-locking in Powershell mode.")
|
||||||
|
|
||||||
;; only defined one keyword list right now
|
|
||||||
|
(defvar powershell-mode-syntax-table (make-syntax-table)
|
||||||
|
"Syntax table for Powershell mode")
|
||||||
|
|
||||||
(defconst powershell-font-lock-keywords-3
|
(modify-syntax-entry ?# "<" powershell-mode-syntax-table)
|
||||||
(list
|
(modify-syntax-entry ?\n ">" powershell-mode-syntax-table)
|
||||||
'("\\<\\(d\\(?:o\\|efault\\)\\|else\\(if\\)?\\|f\\(?:oreach\\|unction\\|ilter\\)\\|if\\|switch\\|t\\(?:hrow\\|rap\\)\\|w\\(?:here\\|hile\\)\\)\\>" . font-lock-keyword-face)
|
;; Powershell uses a backtick as its escape character.
|
||||||
'("$[a-zA-Z0-9_\\.:{}]+\\>" . font-lock-variable-name-face)
|
(modify-syntax-entry ?` "\\" powershell-mode-syntax-table)
|
||||||
'("\\<\\w+-\\w+\\>" . font-lock-function-name-face)
|
(modify-syntax-entry ?\\ "_" powershell-mode-syntax-table)
|
||||||
'("\\<-\\w+\\>" . font-lock-builtin-face)
|
(modify-syntax-entry ?- "w" powershell-mode-syntax-table)
|
||||||
'("@'[A-z0-9\n\t ]+'@" . font-lock-string-face)
|
(modify-syntax-entry ?' "\"" powershell-mode-syntax-table)
|
||||||
'("@\"[A-z0-9\n\t ]+\"@" . font-lock-string-face)
|
|
||||||
'("\\(-\\)\\([a-z][a-zA-Z0-9]+\\)" . font-lock-type-face))
|
|
||||||
"Maximum highlighting for PowerShell major mode")
|
|
||||||
|
|
||||||
|
|
||||||
|
(defvar powershell-imenu-expression
|
||||||
|
`(("Functions" "function \\(\\w+\\)" 1)
|
||||||
|
("Top variables" ,(concat "^\\$\\(" powershell-scope-names "\\)?:?"
|
||||||
|
"\\([[:alnum:]_]+\\)")
|
||||||
|
2))
|
||||||
|
"List of regexps matching important expressions, for speebar & imenu.")
|
||||||
|
|
||||||
(defvar powershell-font-lock-keywords powershell-font-lock-keywords-3
|
(if (require 'speedbar nil t)
|
||||||
"Maximum highlighting for PowerShell major mode")
|
(speedbar-add-supported-extension ".ps1?"))
|
||||||
|
|
||||||
|
(require 'compile nil t)
|
||||||
|
;; A better command would be something like "powershell.exe -NoLogo
|
||||||
|
;; -NonInteractive -Command & (buffer-file-name)". But it will just
|
||||||
|
;; sit there waiting... The following will only work when .ps1 files
|
||||||
|
;; are associated with powershell.exe. And if they don't contain spaces.
|
||||||
|
(defvar powershell-compile-command
|
||||||
|
'(buffer-file-name)
|
||||||
|
"Default command used to invoke a powershell script")
|
||||||
|
|
||||||
;; is adding punctuation to word syntax appropriate??
|
;; The column number will be off whenever tabs are used. Since this is
|
||||||
|
;; the default in this mode, we will not capture the column number.
|
||||||
|
(setq compilation-error-regexp-alist
|
||||||
|
(cons '("At \\(.*\\):\\([0-9]+\\) char:\\([0-9]+\\)" 1 2)
|
||||||
|
compilation-error-regexp-alist))
|
||||||
|
|
||||||
(defvar powershell-mode-syntax-table
|
|
||||||
(let ((powershell-mode-syntax-table (make-syntax-table)))
|
;; the hook is automatically run by derived-mode
|
||||||
(modify-syntax-entry ?. "_" powershell-mode-syntax-table)
|
(defvar powershell-mode-hook '(imenu-add-menubar-index)
|
||||||
(modify-syntax-entry ?: "_" powershell-mode-syntax-table)
|
"Hook run after the initialization of Powershell mode.")
|
||||||
(modify-syntax-entry ?\\ "_" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?{ "(}" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?} "){" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?[ "(]" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?] ")[" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?( "()" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?) ")(" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?` "\\" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?_ "w" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?# "<" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?\n ">" powershell-mode-syntax-table)
|
|
||||||
(modify-syntax-entry ?' "\"" powershell-mode-syntax-table)
|
|
||||||
powershell-mode-syntax-table)
|
|
||||||
"Syntax for PowerShell major mode")
|
|
||||||
|
|
||||||
|
(define-derived-mode powershell-mode fundamental-mode "PS"
|
||||||
(defvar powershell-imenu-expressions
|
"A major mode for editing Powershell script files."
|
||||||
'((nil "^\\(?:function\\|Add-Class\\)\\s-+\\([-a-z0-9A-Z_^:.]+\\)[^-a-z0-9A-Z_^:.]" 1))
|
(set (make-local-variable 'indent-line-function) 'powershell-indent-line)
|
||||||
"alist of regexp identifying the start of powershell definitions"
|
|
||||||
)
|
|
||||||
|
|
||||||
(defun powershell-setup-imenu ()
|
|
||||||
"Installs powershell-imenu-expression."
|
|
||||||
(require 'imenu t)
|
|
||||||
|
|
||||||
;; imenu doc says these 3 are buffer-local by default
|
|
||||||
(setq imenu-generic-expression powershell-imenu-expressions)
|
|
||||||
(imenu-add-menubar-index)
|
|
||||||
(require 'which-func t)
|
|
||||||
(which-function-mode t)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
(defun powershell-mode ()
|
|
||||||
"Major mode for editing PowerShell files"
|
|
||||||
(interactive)
|
|
||||||
(kill-all-local-variables)
|
|
||||||
(setq major-mode 'powershell-mode)
|
|
||||||
(setq mode-name "PS")
|
|
||||||
(set-syntax-table powershell-mode-syntax-table)
|
|
||||||
(use-local-map powershell-mode-map)
|
|
||||||
(set (make-local-variable 'font-lock-defaults)
|
(set (make-local-variable 'font-lock-defaults)
|
||||||
'(powershell-font-lock-keywords))
|
'((powershell-font-lock-keywords-1
|
||||||
|
powershell-font-lock-keywords-2
|
||||||
(make-local-variable 'compile-command)
|
powershell-font-lock-keywords-3)
|
||||||
(if buffer-file-name
|
nil t))
|
||||||
(setq compile-command (format "PowerShell -noprofile -nologo -command %s"
|
(set (make-local-variable 'comment-start) "# ")
|
||||||
(expand-file-name buffer-file-name))))
|
(set (make-local-variable 'comment-start-skip) "#+\\s*")
|
||||||
|
;; not sure why this is not the default
|
||||||
; Here we register our line indentation function with Emacs. Now Emacs will
|
(set (make-local-variable 'parse-sexp-ignore-comments) t)
|
||||||
; call our function every time line indentation is required (like when the
|
(set-syntax-table powershell-mode-syntax-table)
|
||||||
; user calls indent-region).
|
(set (make-local-variable 'imenu-generic-expression)
|
||||||
;; (make-local-variable 'indent-line-function)
|
powershell-imenu-expression)
|
||||||
;; (setq indent-line-function 'powershell-indent-line)
|
(set (make-local-variable 'imenu-case-fold-search) nil)
|
||||||
; Set indentation defaults.
|
(set (make-local-variable 'compile-command) powershell-compile-command))
|
||||||
(make-local-variable 'powershell-indent-width)
|
|
||||||
(set (make-local-variable 'comment-start) "#")
|
|
||||||
(powershell-setup-imenu)
|
|
||||||
(run-hooks 'powershell-mode-hook))
|
|
||||||
|
|
||||||
(provide 'powershell-mode)
|
(provide 'powershell-mode)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue