|
1 ;;; iar-linker-config-mode.el --- major mode for highlighting NSIS scripts |
|
2 |
|
3 ;; Copyright (C) 2009, 2010 by Oleksandr Gavenko <gavenkoa@gmail.com> |
|
4 |
|
5 ;; You can do anything with this file without any warranty. |
|
6 |
|
7 ;; Author: Oleksandr Gavenko <gavenkoa@gmail.com> |
|
8 ;; Maintainer: Oleksandr Gavenko <gavenkoa@gmail.com> |
|
9 ;; Created: 2009-09-14 |
|
10 ;; Version: 0.1 |
|
11 ;; Keywords: languages |
|
12 |
|
13 ;;; Commentary: |
|
14 ;; |
|
15 ;; Very pure syntax highlighting. |
|
16 |
|
17 ;;; Code: |
|
18 |
|
19 (defun nsis-mode-modify-syntax-entry () |
|
20 (modify-syntax-entry ?_ "w") |
|
21 (modify-syntax-entry ?. "w") |
|
22 (modify-syntax-entry ?$ ".") |
|
23 ) |
|
24 |
|
25 (defun nsis-mode-set-comment-style () |
|
26 (set (make-local-variable 'comment-start) "; ") |
|
27 (set (make-local-variable 'comment-continue) nil) |
|
28 (set (make-local-variable 'comment-end) "") |
|
29 (set (make-local-variable 'comment-end-skip) nil) |
|
30 (set (make-local-variable 'comment-multi-line) nil) |
|
31 (set (make-local-variable 'comment-use-syntax) t) |
|
32 ) |
|
33 |
|
34 ;;;###autoload |
|
35 (define-generic-mode nsis-mode |
|
36 (list ?\; ?# '("/*" . "*/")) |
|
37 '( |
|
38 "Section" "SectionEnd" "SectionIn" "SectionGroup" "SectionGroupEnd" "Function" "FunctionEnd" "File" |
|
39 "SectionSetFlags" "SectionGetFlags" "SectionSetText" "SectionGetText" "SectionSetInstTypes" "SectionGetInstTypes" "SectionSetSize" "SectionGetSize" "SetCurInstType" "GetCurInstType" "InstTypeSetText" "InstTypeGetText" |
|
40 "Name" "ShowInstDetails" "Caption" |
|
41 "LicenseText" "LicenseData" "LicenseForceSelection" "ComponentText" "BrandingText" "DetailsButtonText" "CompletedText" "UninstallText" |
|
42 "DirText" "DirVar" "DirVerify" |
|
43 "Exec" "ExecWait" "ExecShell" "Goto" "goto" "Call" "Return" "Abort" "Quit" "ClearErrors" "SetErrors" |
|
44 "Reboot" "SetRebootFlag" |
|
45 "IfSilent" "IfAbort" "IfRebootFlag" "IfErrors" "IfFileExists" |
|
46 "GetCurrentAddress" "GetFunctionAddress" "GetLabelAddress" |
|
47 "Page" "UninstPage" "PageEx" "PageCallbacks" "PageExEnd" |
|
48 "Delete" "CopyFiles" "CreateDirectory" "RMDir" "OutFile" "ReserveFile" "CreateShortCut" |
|
49 "CallInstDLL" "GetDLLVersion" "GetDLLVersionLocal" "RegDLL" "UnRegDLL" |
|
50 "GetFileTime" "GetFileTimeLocal" "GetFullPathName" "GetTempFileName" "SearchPath" "SetFileAttributes" |
|
51 "ReadRegStr" "WriteRegStr" "DeleteRegKey" "DeleteRegValue" "EnumRegKey" "EnumRegValue" "WriteRegDWORD" "ReadRegDWORD" "WriteRegDword" "WriteRegBin" "WriteRegDWORD" "WriteRegExpandStr" |
|
52 "ExpandEnvStrings" "ReadEnvStr" |
|
53 "DeleteINISec" "DeleteINIStr" "FlushINI" "ReadINIStr" "WriteINIStr" |
|
54 "Var" "Pop" "Push" "Exch" |
|
55 "StrLen" "StrCpy" "StrCmp" "StrCmpS" "IntCmp" "IntCmpU" "IntFmt" "IntOp" |
|
56 "FileClose" "FileOpen" "FileRead" "FileReadByte" "FileSeek" "FileWrite" "FileWriteByte" "FindClose" "FindFirst" "FindNext" |
|
57 "InitPluginsDir" "addplugindir" "InstallDir" "InstallDirRegKey" "InstType" "Nop" "Sleep" |
|
58 "RequestExecutionLevel" "CRCCheck" "XPStyle" |
|
59 "ReadIniStr" "WriteIniStr" |
|
60 "LogSet" "LogText" |
|
61 "Icon" "UninstallIcon" |
|
62 "SendMessage" "MessageBox" "GetDlgItem" |
|
63 "FindWindow" "EnableWindow" "LockWindow" "ShowWindow" "HideWindow" "IsWindow" "AutoCloseWindow" |
|
64 "SetAutoClose" "CreateFont" "SetCtlColors" "SetBrandingImage" "SetDetailsView" "SetDetailsPrint" "SetSilent" "BringToFront" "DetailPrint" |
|
65 "LoadLanguageFile" "LangString" "LicenseLangString" |
|
66 "SubCaption" "UninstallSubCaption" |
|
67 "SetPluginUnload" "DetailPrint" "SetOutPath" "WriteUninstaller" |
|
68 "GetErrorLevel" "SetErrorLevel" "GetInstDirError" "SetRegView" "SetShellVarContext" |
|
69 "SetDateSave" "SetDatablockOptimize" "BGGradient" "InstallColors" "CheckBitmap" "SilentInstall" "SetOverwrite" |
|
70 "SetCompress" |
|
71 ) |
|
72 '( |
|
73 ("!\\(insertmacro\\|define\\|ifdef\\|ifndef\\|else\\|endif\\|echo\\|verbose\\|include\\|macroend\\|macro\\|undef\\|packhdr\\|warning\\|error\\)" (1 'font-lock-builtin-face)) |
|
74 ("$[({]?\\([A-Za-z0-9_]+\\)[)}]?" (1 'font-lock-variable-name-face)) |
|
75 ("^[[:blank:]]*\\([[:alpha:].][[:alnum:]_.]*:\\)\\([^:]\\|$\\)" (1 'font-lock-function-name-face)) |
|
76 ("^[[:blank:]]*\\(Function\\|Goto\\|Call\\)[[:blank:]]+\\([[:alnum:]_.]*\\)" (2 'font-lock-function-name-face)) |
|
77 ) |
|
78 '("\\.nsi\\'" "\\.nsh\\'") |
|
79 '(nsis-mode-modify-syntax-entry nsis-mode-set-comment-style) |
|
80 "Generic mode for nsis files.") |
|
81 |
|
82 (defvar nsis-imenu-generic-expression |
|
83 '( |
|
84 ("Defines" "^!define[[:blank:]]+\\([[:word:]]+\\)" 1) |
|
85 ("Sections" "^Section[[:blank:]]+\"?\\(-?[[:word:] ]+\\)\"?" 1) |
|
86 ("Functions" "^Function[[:blank:]]+\\([[:word:]]+\\)" 1) |
|
87 ("Macros" "^!macro[[:blank:]]+\\([[:word:]]+\\)" 1) |
|
88 )) |
|
89 |
|
90 (defun nsis-set-imenu-generic-expression () |
|
91 (setq imenu-generic-expression nsis-imenu-generic-expression) |
|
92 ) |
|
93 |
|
94 (add-hook 'nsis-mode-hook 'nsis-set-imenu-generic-expression) |
|
95 |
|
96 (eval-when-compile |
|
97 (defvar which-func-modes)) |
|
98 |
|
99 (eval-after-load 'which-func |
|
100 '(add-to-list 'which-func-modes 'nsis-mode)) |
|
101 |
|
102 (provide 'nsis-mode) |
|
103 |
|
104 ;;; nsis-mode.el ends here |