nsis-mode.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Thu, 30 Mar 2017 00:34:44 +0300
changeset 1521 df20553d4bd2
parent 1250 73c10c73c63f
permissions -rw-r--r--
Fix: Warning: "string-to-int" is an obsolete function (as of 22.1); use "string-to-number" instead.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
257
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
     1
;;; iar-linker-config-mode.el --- major mode for highlighting NSIS scripts
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
     2
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
     3
;; Copyright (C) 2009, 2010 by Oleksandr Gavenko <gavenkoa@gmail.com>
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
     4
279
fd6164dfec82 Update copyright statement and year.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 274
diff changeset
     5
;; You can do anything with this file without any warranty.
fd6164dfec82 Update copyright statement and year.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 274
diff changeset
     6
257
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
     7
;; Author: Oleksandr Gavenko <gavenkoa@gmail.com>
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
     8
;; Maintainer: Oleksandr Gavenko <gavenkoa@gmail.com>
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
     9
;; Created: 2009-09-14
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    10
;; Version: 0.1
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    11
;; Keywords: languages
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    12
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    13
;;; Commentary:
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    14
;;
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    15
;; Very pure syntax highlighting.
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    16
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    17
;;; Code:
2f3ac763c340 Make docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 164
diff changeset
    18
659
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    19
(defun nsis-mode-modify-syntax-entry ()
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    20
  (modify-syntax-entry ?_ "w")
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    21
  (modify-syntax-entry ?. "w")
706
7f0d6be0a3ed Mark '$' as punctuation mark in nsis-mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 705
diff changeset
    22
  (modify-syntax-entry ?$ ".")
659
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    23
  )
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    24
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    25
(defun nsis-mode-set-comment-style ()
847
d38ced086516 Customise more variables for comment highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 708
diff changeset
    26
  (set (make-local-variable 'comment-start) "; ")
d38ced086516 Customise more variables for comment highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 708
diff changeset
    27
  (set (make-local-variable 'comment-continue) nil)
d38ced086516 Customise more variables for comment highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 708
diff changeset
    28
  (set (make-local-variable 'comment-end) "")
d38ced086516 Customise more variables for comment highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 708
diff changeset
    29
  (set (make-local-variable 'comment-end-skip) nil)
d38ced086516 Customise more variables for comment highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 708
diff changeset
    30
  (set (make-local-variable 'comment-multi-line) nil)
d38ced086516 Customise more variables for comment highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 708
diff changeset
    31
  (set (make-local-variable 'comment-use-syntax) t)
659
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    32
  )
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    33
274
7c18567f0754 Added autoload magic comment for main mode function.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 271
diff changeset
    34
;;;###autoload
659
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    35
(define-generic-mode nsis-mode
661
95d6a3c48afd Fix char syntax.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 659
diff changeset
    36
  (list ?\; ?# '("/*" . "*/"))
281
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    37
  '(
286
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    38
    "Section" "SectionEnd" "SectionIn" "SectionGroup" "SectionGroupEnd" "Function" "FunctionEnd" "File"
283
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    39
    "SectionSetFlags" "SectionGetFlags" "SectionSetText" "SectionGetText" "SectionSetInstTypes" "SectionGetInstTypes" "SectionSetSize" "SectionGetSize" "SetCurInstType" "GetCurInstType" "InstTypeSetText" "InstTypeGetText"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    40
    "Name" "ShowInstDetails" "Caption"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    41
    "LicenseText" "LicenseData" "LicenseForceSelection" "ComponentText" "BrandingText" "DetailsButtonText" "CompletedText" "UninstallText"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    42
    "DirText" "DirVar" "DirVerify"
286
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    43
    "Exec" "ExecWait" "ExecShell" "Goto" "goto" "Call" "Return" "Abort" "Quit" "ClearErrors" "SetErrors"
283
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    44
    "Reboot" "SetRebootFlag"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    45
    "IfSilent" "IfAbort" "IfRebootFlag" "IfErrors" "IfFileExists"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    46
    "GetCurrentAddress" "GetFunctionAddress" "GetLabelAddress"
282
a119108fd2ca Added comment pattern.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 281
diff changeset
    47
    "Page" "UninstPage" "PageEx" "PageCallbacks" "PageExEnd"
281
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    48
    "Delete" "CopyFiles" "CreateDirectory" "RMDir" "OutFile" "ReserveFile" "CreateShortCut"
283
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    49
    "CallInstDLL" "GetDLLVersion" "GetDLLVersionLocal" "RegDLL" "UnRegDLL"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    50
    "GetFileTime" "GetFileTimeLocal" "GetFullPathName" "GetTempFileName" "SearchPath" "SetFileAttributes"
286
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    51
    "ReadRegStr" "WriteRegStr" "DeleteRegKey" "DeleteRegValue" "EnumRegKey" "EnumRegValue" "WriteRegDWORD" "ReadRegDWORD" "WriteRegDword" "WriteRegBin" "WriteRegDWORD" "WriteRegExpandStr"
283
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    52
    "ExpandEnvStrings" "ReadEnvStr"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    53
    "DeleteINISec" "DeleteINIStr" "FlushINI" "ReadINIStr" "WriteINIStr"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    54
    "Var" "Pop" "Push" "Exch"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    55
    "StrLen" "StrCpy" "StrCmp" "StrCmpS" "IntCmp" "IntCmpU" "IntFmt" "IntOp"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    56
    "FileClose" "FileOpen" "FileRead" "FileReadByte" "FileSeek" "FileWrite" "FileWriteByte" "FindClose" "FindFirst" "FindNext"
286
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    57
    "InitPluginsDir" "addplugindir" "InstallDir" "InstallDirRegKey" "InstType" "Nop" "Sleep"
281
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    58
    "RequestExecutionLevel" "CRCCheck" "XPStyle"
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    59
    "ReadIniStr" "WriteIniStr"
283
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    60
    "LogSet" "LogText"
281
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    61
    "Icon" "UninstallIcon"
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    62
    "SendMessage" "MessageBox" "GetDlgItem"
286
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    63
    "FindWindow" "EnableWindow" "LockWindow" "ShowWindow" "HideWindow" "IsWindow" "AutoCloseWindow"
283
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    64
    "SetAutoClose" "CreateFont" "SetCtlColors" "SetBrandingImage" "SetDetailsView" "SetDetailsPrint" "SetSilent" "BringToFront" "DetailPrint"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    65
    "LoadLanguageFile" "LangString" "LicenseLangString"
281
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    66
    "SubCaption" "UninstallSubCaption"
283
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    67
    "SetPluginUnload" "DetailPrint" "SetOutPath" "WriteUninstaller"
d80322acbbce Added instruction from doc.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 282
diff changeset
    68
    "GetErrorLevel" "SetErrorLevel" "GetInstDirError" "SetRegView" "SetShellVarContext"
286
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    69
    "SetDateSave" "SetDatablockOptimize" "BGGradient" "InstallColors" "CheckBitmap" "SilentInstall" "SetOverwrite"
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    70
    "SetCompress"
281
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    71
    )
457b9057a35a Added keyword and comment char.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 279
diff changeset
    72
  '(
286
bdbe49f5dea5 Added new words and fix comment highliting as command can be on same line as label.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 283
diff changeset
    73
    ("!\\(insertmacro\\|define\\|ifdef\\|ifndef\\|else\\|endif\\|echo\\|verbose\\|include\\|macroend\\|macro\\|undef\\|packhdr\\|warning\\|error\\)" (1 'font-lock-builtin-face))
271
bf0c4a022c5a Always define nsis mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 270
diff changeset
    74
    ("$[({]?\\([A-Za-z0-9_]+\\)[)}]?" (1 'font-lock-variable-name-face))
310
dca63c827ac1 Improved func name highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 287
diff changeset
    75
    ("^[[:blank:]]*\\([[:alpha:].][[:alnum:]_.]*:\\)\\([^:]\\|$\\)" (1 'font-lock-function-name-face))
dca63c827ac1 Improved func name highlighting.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 287
diff changeset
    76
    ("^[[:blank:]]*\\(Function\\|Goto\\|Call\\)[[:blank:]]+\\([[:alnum:]_.]*\\)" (2 'font-lock-function-name-face))
271
bf0c4a022c5a Always define nsis mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 270
diff changeset
    77
    )
659
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    78
  '("\\.nsi\\'" "\\.nsh\\'")
3ab316034e6c Eliminate hook and add nsis-mode-set-comment-style.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 651
diff changeset
    79
  '(nsis-mode-modify-syntax-entry nsis-mode-set-comment-style)
271
bf0c4a022c5a Always define nsis mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 270
diff changeset
    80
  "Generic mode for nsis files.")
258
29533873ee3e Fix docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 257
diff changeset
    81
1250
73c10c73c63f Fix: Warning: reference/assignment to free variable `which-func-modes'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 847
diff changeset
    82
(defvar nsis-imenu-generic-expression
650
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
    83
      '(
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
    84
        ("Defines"  "^!define[[:blank:]]+\\([[:word:]]+\\)" 1)
708
659c1d14b849 Section name can contain spaces. Handle this situation.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 707
diff changeset
    85
        ("Sections"  "^Section[[:blank:]]+\"?\\(-?[[:word:] ]+\\)\"?" 1)
650
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
    86
        ("Functions"  "^Function[[:blank:]]+\\([[:word:]]+\\)" 1)
705
3fc05a3170ca Add macros to imenu for nsis-mode.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 661
diff changeset
    87
        ("Macros"  "^!macro[[:blank:]]+\\([[:word:]]+\\)" 1)
650
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
    88
        ))
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
    89
651
e71e91de1915 Move code from add-hook lambda to separate functions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 650
diff changeset
    90
(defun nsis-set-imenu-generic-expression ()
e71e91de1915 Move code from add-hook lambda to separate functions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 650
diff changeset
    91
  (setq imenu-generic-expression nsis-imenu-generic-expression)
e71e91de1915 Move code from add-hook lambda to separate functions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 650
diff changeset
    92
  )
e71e91de1915 Move code from add-hook lambda to separate functions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 650
diff changeset
    93
e71e91de1915 Move code from add-hook lambda to separate functions.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 650
diff changeset
    94
(add-hook 'nsis-mode-hook 'nsis-set-imenu-generic-expression)
650
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
    95
1250
73c10c73c63f Fix: Warning: reference/assignment to free variable `which-func-modes'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 847
diff changeset
    96
(eval-when-compile
73c10c73c63f Fix: Warning: reference/assignment to free variable `which-func-modes'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 847
diff changeset
    97
  (defvar which-func-modes))
73c10c73c63f Fix: Warning: reference/assignment to free variable `which-func-modes'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 847
diff changeset
    98
650
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
    99
(eval-after-load 'which-func
1250
73c10c73c63f Fix: Warning: reference/assignment to free variable `which-func-modes'
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 847
diff changeset
   100
  '(add-to-list 'which-func-modes 'nsis-mode))
650
d21c5ae9b7e6 Add support for 'imenu' and 'which-func' to 'nsis-mode'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 320
diff changeset
   101
258
29533873ee3e Fix docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 257
diff changeset
   102
(provide 'nsis-mode)
29533873ee3e Fix docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 257
diff changeset
   103
29533873ee3e Fix docs headers according to 'Conventional Headers for Emacs Libraries'.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 257
diff changeset
   104
;;; nsis-mode.el ends here