mylisp-obsolete/nsis-mode.el
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 16 Jun 2021 12:50:08 +0300
changeset 1734 ae2c6a001464
parent 1718 9d72f4424570
permissions -rw-r--r--
Add some standard places to PATH if they are not set by login script. Rearrange the order of paths so system's are first, user's are last. For Cygwin this helps with Cygwin's paths to be situated before "C:/Windows" (Emacs is not started from a login shell on Windows!).

;;; iar-linker-config-mode.el --- major mode for highlighting NSIS scripts

;;; Commentary:
;;
;; Very pure syntax highlighting.

;;; Code:

(defun nsis-mode-modify-syntax-entry ()
  (modify-syntax-entry ?_ "w")
  (modify-syntax-entry ?. "w")
  (modify-syntax-entry ?$ ".")
  )

(defun nsis-mode-set-comment-style ()
  (set (make-local-variable 'comment-start) "; ")
  (set (make-local-variable 'comment-continue) nil)
  (set (make-local-variable 'comment-end) "")
  (set (make-local-variable 'comment-end-skip) nil)
  (set (make-local-variable 'comment-multi-line) nil)
  (set (make-local-variable 'comment-use-syntax) t)
  )

;;;###autoload
(define-generic-mode nsis-mode
  (list ?\; ?# '("/*" . "*/"))
  '(
    "Section" "SectionEnd" "SectionIn" "SectionGroup" "SectionGroupEnd" "Function" "FunctionEnd" "File"
    "SectionSetFlags" "SectionGetFlags" "SectionSetText" "SectionGetText" "SectionSetInstTypes" "SectionGetInstTypes" "SectionSetSize" "SectionGetSize" "SetCurInstType" "GetCurInstType" "InstTypeSetText" "InstTypeGetText"
    "Name" "ShowInstDetails" "Caption"
    "LicenseText" "LicenseData" "LicenseForceSelection" "ComponentText" "BrandingText" "DetailsButtonText" "CompletedText" "UninstallText"
    "DirText" "DirVar" "DirVerify"
    "Exec" "ExecWait" "ExecShell" "Goto" "goto" "Call" "Return" "Abort" "Quit" "ClearErrors" "SetErrors"
    "Reboot" "SetRebootFlag"
    "IfSilent" "IfAbort" "IfRebootFlag" "IfErrors" "IfFileExists"
    "GetCurrentAddress" "GetFunctionAddress" "GetLabelAddress"
    "Page" "UninstPage" "PageEx" "PageCallbacks" "PageExEnd"
    "Delete" "CopyFiles" "CreateDirectory" "RMDir" "OutFile" "ReserveFile" "CreateShortCut"
    "CallInstDLL" "GetDLLVersion" "GetDLLVersionLocal" "RegDLL" "UnRegDLL"
    "GetFileTime" "GetFileTimeLocal" "GetFullPathName" "GetTempFileName" "SearchPath" "SetFileAttributes"
    "ReadRegStr" "WriteRegStr" "DeleteRegKey" "DeleteRegValue" "EnumRegKey" "EnumRegValue" "WriteRegDWORD" "ReadRegDWORD" "WriteRegDword" "WriteRegBin" "WriteRegDWORD" "WriteRegExpandStr"
    "ExpandEnvStrings" "ReadEnvStr"
    "DeleteINISec" "DeleteINIStr" "FlushINI" "ReadINIStr" "WriteINIStr"
    "Var" "Pop" "Push" "Exch"
    "StrLen" "StrCpy" "StrCmp" "StrCmpS" "IntCmp" "IntCmpU" "IntFmt" "IntOp"
    "FileClose" "FileOpen" "FileRead" "FileReadByte" "FileSeek" "FileWrite" "FileWriteByte" "FindClose" "FindFirst" "FindNext"
    "InitPluginsDir" "addplugindir" "InstallDir" "InstallDirRegKey" "InstType" "Nop" "Sleep"
    "RequestExecutionLevel" "CRCCheck" "XPStyle"
    "ReadIniStr" "WriteIniStr"
    "LogSet" "LogText"
    "Icon" "UninstallIcon"
    "SendMessage" "MessageBox" "GetDlgItem"
    "FindWindow" "EnableWindow" "LockWindow" "ShowWindow" "HideWindow" "IsWindow" "AutoCloseWindow"
    "SetAutoClose" "CreateFont" "SetCtlColors" "SetBrandingImage" "SetDetailsView" "SetDetailsPrint" "SetSilent" "BringToFront" "DetailPrint"
    "LoadLanguageFile" "LangString" "LicenseLangString"
    "SubCaption" "UninstallSubCaption"
    "SetPluginUnload" "DetailPrint" "SetOutPath" "WriteUninstaller"
    "GetErrorLevel" "SetErrorLevel" "GetInstDirError" "SetRegView" "SetShellVarContext"
    "SetDateSave" "SetDatablockOptimize" "BGGradient" "InstallColors" "CheckBitmap" "SilentInstall" "SetOverwrite"
    "SetCompress"
    )
  '(
    ("!\\(insertmacro\\|define\\|ifdef\\|ifndef\\|else\\|endif\\|echo\\|verbose\\|include\\|macroend\\|macro\\|undef\\|packhdr\\|warning\\|error\\)" (1 'font-lock-builtin-face))
    ("$[({]?\\([A-Za-z0-9_]+\\)[)}]?" (1 'font-lock-variable-name-face))
    ("^[[:blank:]]*\\([[:alpha:].][[:alnum:]_.]*:\\)\\([^:]\\|$\\)" (1 'font-lock-function-name-face))
    ("^[[:blank:]]*\\(Function\\|Goto\\|Call\\)[[:blank:]]+\\([[:alnum:]_.]*\\)" (2 'font-lock-function-name-face))
    )
  '("\\.nsi\\'" "\\.nsh\\'")
  '(nsis-mode-modify-syntax-entry nsis-mode-set-comment-style)
  "Generic mode for nsis files.")

(defvar nsis-imenu-generic-expression
      '(
        ("Defines"  "^!define[[:blank:]]+\\([[:word:]]+\\)" 1)
        ("Sections"  "^Section[[:blank:]]+\"?\\(-?[[:word:] ]+\\)\"?" 1)
        ("Functions"  "^Function[[:blank:]]+\\([[:word:]]+\\)" 1)
        ("Macros"  "^!macro[[:blank:]]+\\([[:word:]]+\\)" 1)
        ))

(defun nsis-set-imenu-generic-expression ()
  (setq imenu-generic-expression nsis-imenu-generic-expression)
  )

(add-hook 'nsis-mode-hook 'nsis-set-imenu-generic-expression)

(eval-when-compile
  (defvar which-func-modes))

(eval-after-load 'which-func
  '(add-to-list 'which-func-modes 'nsis-mode))

(provide 'nsis-mode)

;;; nsis-mode.el ends here