1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;;; iss-mode.el --- Mode for InnoSetup install scripts
4 ;; Copyright (C) 2000-2007 by Stefan Reichoer
6 ;; Emacs Lisp Archive Entry
7 ;; Filename: iss-mode.el
8 ;; Author: Stefan Reichoer, <stefan@xsteve.at>
11 ;; iss-mode.el is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; iss-mode.el is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
28 ;; InnoSetup is an Application Installer for Windows
29 ;; See: http://www.jrsoftware.org/isinfo.php
30 ;; This version of iss-mode.el is tested with InnoSetup v5.0
32 ;; iss-mode provides the following features:
33 ;; * Syntax coloring for InnoSetup scripts
34 ;; * Integration of the InnoSetup commandline compiler iscc.exe
35 ;; - Compilation via M-x iss-compile
36 ;; - Jump to compilation error via M-x next-error
37 ;; * Start Innosetup help via M-x iss-compiler-help
38 ;; * Test the installation via M-x iss-run-installer
40 ;; Of course you can bind this commands to keys (e.g. in the iss-mode-hook)
42 ;; My initialization for InnoSetup looks like this:
43 ;; (autoload 'iss-mode "iss-mode" "Innosetup Script Mode" t)
44 ;; (setq auto-mode-alist (append '(("\\.iss$" . iss-mode)) auto-mode-alist))
45 ;; (setq iss-compiler-path "c:/Programme/Inno Setup 5/")
46 ;; (add-hook 'iss-mode-hook 'xsteve-iss-mode-init)
47 ;; (defun xsteve-iss-mode-init ()
49 ;; (define-key iss-mode-map [f6] 'iss-compile)
50 ;; (define-key iss-mode-map [(meta f6)] 'iss-run-installer)))
52 ;; The latest version of iss-mode.el can be found at:
53 ;; http://www.xsteve.at/prg/emacs/iss-mode.el
55 ;; Comments / suggestions welcome!
61 ;; - Add some new flags to keywords
65 (eval-and-compile (require 'compile))
67 (defvar iss-compiler-path nil "Path to the iss compiler")
69 ;;; End of user settings
71 (defvar iss-mode-syntax-table
72 (let ((table (make-syntax-table)))
73 ;; ";" starts a comment
74 ;;(modify-syntax-entry ?\; "<" iss-mode-syntax-table)
75 (modify-syntax-entry ?\; ". 12" table)
76 ;; and \n and \^M end a comment
77 (modify-syntax-entry ?\n ">" table)
78 (modify-syntax-entry ?\^M ">" table)
80 (modify-syntax-entry ?\" "." table)
82 (modify-syntax-entry ?_ "w" table)
84 "Syntax table in use in iss-mode buffers.")
87 (defvar iss-font-lock-keywords
89 (cons (concat "^;\.*")
90 'font-lock-comment-face)
91 (cons (concat "\\sw+: ")
92 'font-lock-keyword-face)
93 (cons "^[ \t]*\\[\.+\\]" 'font-lock-function-name-face) ;font-lock-constant-face)
94 (cons "^[ \t]*#include[ \t]*\".+\"" 'font-lock-preprocessor-face)
95 (cons (concat "^[ \t]*\\<\\(appname\\|appvername\\|appversion\\|appcopyright\\|appid\\|"
96 "appmutex\\|beveledlabel\\|defaultdirname\\|versioninfoversion"
97 "\\|defaultgroupname\\|minversion\\|outputdir\\|outputbasefilename\\|"
98 "allownoicons\\|uninstallfilesdir\\|"
99 "sourcedir\\|disableprogramgrouppage\\|alwayscreateuninstallicon\\)\\>")
100 'font-lock-type-face)
101 (cons (concat "\\<\\(alwaysskipifsameorolder\\|uninsneveruninstall\\|"
102 "comparetimestampalso\\|restartreplace\\|isreadme\\|"
103 "unchecked\\|nowait\\|postinstall\\|skipifsilent\\|ignoreversion\\|"
104 "uninsdeletekeyifempty\\|uninsdeletekey\\|"
105 "runasoriginaluser\\|runascurrentuser"
107 'font-lock-variable-name-face)
108 (cons (concat "\\<\\(HKCU\\|HKLM\\|dirifempty\\|files\\|filesandordirs\\)\\>")
109 'font-lock-constant-face)
110 (list 'iss-fontify-options '(1 'font-lock-variable-name-face) '(2 'font-lock-keyword-face))
112 "Expressions to highlight in iss mode.")
114 (defun iss-fontify-options (bound)
115 (message "iss-fontify-options %s" bound)
116 (when (re-search-forward "^[ \t]*\\([^=]+\\)[ \t]*\\(=\\)" bound t)
119 (defvar iss-mode-map (make-sparse-keymap)
120 "Keymap used in iss-mode buffers.")
125 "InnoSetup script menu"
128 ["Compile" (iss-compile) t]
129 ["Run Installer" (iss-run-installer) t]
130 ["InnoSetup Help" (iss-compiler-help) t]
132 (easy-menu-add iss-menu)
134 (defvar compilation-file-regexp-alist) ;; silence compiler, don't know the var.
138 "Major mode for editing InnoSetup script files. Upon startup iss-mode-hook is run."
140 (kill-all-local-variables)
141 (use-local-map iss-mode-map)
142 (setq major-mode 'iss-mode)
143 (setq mode-name "iss")
144 (set-syntax-table iss-mode-syntax-table)
145 (set (make-local-variable 'comment-start) ";")
146 (set (make-local-variable 'comment-end) "")
147 (set (make-local-variable 'comment-multi-line) nil)
149 (set (make-local-variable 'compilation-error-regexp-alist)
150 '(("\\(Error on line\\) \\([0-9]+\\):" nil 2)))
151 (set (make-local-variable 'compilation-file-regexp-alist)
152 '(("iscc \\(.*\\)$" 1)))
155 (make-local-variable 'font-lock-defaults)
156 (setq font-lock-defaults '(iss-font-lock-keywords nil t))
157 (run-hooks 'iss-mode-hook))
159 (defun iss-compiler-help ()
160 "Start the online documentation for the InnoSetup compiler"
162 (let ((default-directory (or iss-compiler-path default-directory)))
163 (w32-shell-execute 1 "ISetup.chm")))
165 (defun iss-compile ()
166 "Compile the actual file with the InnoSetup compiler"
168 (let ((default-directory (or iss-compiler-path default-directory))
169 (compilation-process-setup-function 'iss-process-setup))
170 (compile (concat "iscc " (buffer-file-name)))))
172 (defun iss-process-setup ()
173 "Set up `compilation-exit-message-function' for `iss-compile'."
174 (set (make-local-variable 'compilation-exit-message-function)
175 'iss-compilation-exit-message-function))
177 (defun iss-compilation-exit-message-function (process-status exit-status msg)
180 (let ((buffer-read-only nil))
181 (goto-char (point-min))
182 ;;scroll down one line, so that the compile command is parsed to:
183 ;; -> get the filename of the compiled file
185 (cons msg exit-status))
187 (defun iss-find-option (option)
189 (concat option "[ \t]*=[ \t]*\\(.*\\)$")))
191 (goto-char (point-min))
192 (when (search-forward-regexp search-regexp nil t)
193 (buffer-substring-no-properties (match-beginning 1) (match-end 1))))))
195 (defun iss-run-installer ()
198 (concat (or (iss-find-option "outputdir") "Output\\")
199 (or (iss-find-option "outputbasefilename") "setup")
201 (w32-shell-execute 1 executable)))
205 ;; arch-tag: b07b7119-d591-465e-927f-d0be0bcf7cab