Mercurial > emacs
comparison lisp/progmodes/idlwave.el @ 27606:0396e9e8d57b
(idlwave-template): Respect `idlwave-abbrev-change-case'.
(idlwave-rw-case, idlwave-elif, idlwave-case, idlwave-for,
idlwave-if, idlwave-procedure, idlwave-function, idlwave-repeat,
idlwave-while): respect `idlwave-reserved-word-upcase'.
(idlwave-rw-case): New function.
(idlwave-statement-match): Fixed problem with assignment regexp.
(idlwave-font-lock-keywords): Improved regexp for keyword
parameters.
(idlwave-surround): New argument LENGTH to support padding of
operators longer than 1 char.
author | Carsten Dominik <dominik@science.uva.nl> |
---|---|
date | Fri, 04 Feb 2000 10:09:56 +0000 |
parents | ae5b17b9c403 |
children | 8eff9cc9cbae |
comparison
equal
deleted
inserted
replaced
27605:4f9bc702d860 | 27606:0396e9e8d57b |
---|---|
3 ;; Copyright (c) 1999 Carsten Dominik | 3 ;; Copyright (c) 1999 Carsten Dominik |
4 ;; Copyright (c) 1999 Free Software Foundation | 4 ;; Copyright (c) 1999 Free Software Foundation |
5 | 5 |
6 ;; Author: Chris Chase <chase@att.com> | 6 ;; Author: Chris Chase <chase@att.com> |
7 ;; Maintainer: Carsten Dominik <dominik@strw.leidenuniv.nl> | 7 ;; Maintainer: Carsten Dominik <dominik@strw.leidenuniv.nl> |
8 ;; Version: 3.12 | 8 ;; Version: 3.15 |
9 ;; Date: $Date: 2000/01/05 12:39:30 $ | 9 ;; Date: $Date: 2000/02/04 09:19:36 $ |
10 ;; Keywords: languages | 10 ;; Keywords: languages |
11 | 11 |
12 ;; This file is part of the GNU Emacs. | 12 ;; This file is part of the GNU Emacs. |
13 | 13 |
14 ;; GNU Emacs is free software; you can redistribute it and/or modify | 14 ;; GNU Emacs is free software; you can redistribute it and/or modify |
107 ;; emacs abbrev expansion done by the self-insert-command. It ends | 107 ;; emacs abbrev expansion done by the self-insert-command. It ends |
108 ;; up inserting the character that expanded the abbrev after moving | 108 ;; up inserting the character that expanded the abbrev after moving |
109 ;; point backward, e.g., "\cl" expanded with a space becomes | 109 ;; point backward, e.g., "\cl" expanded with a space becomes |
110 ;; "LONG( )" with point before the close paren. This is solved by | 110 ;; "LONG( )" with point before the close paren. This is solved by |
111 ;; using a temporary function in `post-command-hook' - not pretty, | 111 ;; using a temporary function in `post-command-hook' - not pretty, |
112 ;; but it works.< | 112 ;; but it works. |
113 ;; | 113 ;; |
114 ;; Tabs and spaces are treated equally as whitespace when filling a | 114 ;; Tabs and spaces are treated equally as whitespace when filling a |
115 ;; comment paragraph. To accomplish this, tabs are permanently | 115 ;; comment paragraph. To accomplish this, tabs are permanently |
116 ;; replaced by spaces in the text surrounding the paragraph, which | 116 ;; replaced by spaces in the text surrounding the paragraph, which |
117 ;; may be an undesirable side-effect. Replacing tabs with spaces is | 117 ;; may be an undesirable side-effect. Replacing tabs with spaces is |
126 ;; | 126 ;; |
127 ;; It is possible that the parser which decides what to complete has | 127 ;; It is possible that the parser which decides what to complete has |
128 ;; problems with pointer dereferencing statements. I don't use | 128 ;; problems with pointer dereferencing statements. I don't use |
129 ;; pointers often enough to find out - please report any problems. | 129 ;; pointers often enough to find out - please report any problems. |
130 ;; | 130 ;; |
131 ;; Completion of keywords for SETPROPERTY and GETPROPERTY assumes that | |
132 ;; all INIT keywords are allowed in these methods as well. In some | |
133 ;; cases, there are exceptions to this rule and IDLWAVE will offer | |
134 ;; a few illegal keyword parameters. | |
135 ;; | |
136 ;; Completion and Routine Info do not know about inheritance. Thus, | 131 ;; Completion and Routine Info do not know about inheritance. Thus, |
137 ;; Keywords inherited from superclasses are not displayed and cannot | 132 ;; Keywords inherited from superclasses are not displayed and cannot |
138 ;; completed. | 133 ;; completed. |
139 ;; | 134 ;; |
140 ;; When forcing completion of method keywords, the initial | 135 ;; When forcing completion of method keywords, the initial |
141 ;; query for a method has multiple entries for some methods. Would | 136 ;; query for a method has multiple entries for some methods. Would |
142 ;; be too difficult to fix this hardly used problem. | 137 ;; be too difficult to fix this hardly used case. |
143 ;; | 138 ;; |
144 | 139 |
145 ;;; Code: | 140 ;;; Code: |
146 | 141 |
147 (eval-when-compile (require 'cl)) | 142 (eval-when-compile (require 'cl)) |
159 (defgroup idlwave nil | 154 (defgroup idlwave nil |
160 "Major mode for editing IDL/WAVE CL .pro files" | 155 "Major mode for editing IDL/WAVE CL .pro files" |
161 :tag "IDLWAVE" | 156 :tag "IDLWAVE" |
162 :link '(url-link :tag "Home Page" | 157 :link '(url-link :tag "Home Page" |
163 "http://strw.leidenuniv.nl/~dominik/Tools/idlwave") | 158 "http://strw.leidenuniv.nl/~dominik/Tools/idlwave") |
164 :link '(emacs-commentary-link :tag "Commentary in idlwave-shell.el" | 159 :link '(emacs-commentary-link :tag "Commentary in idlw-shell.el" |
165 "idlwave-shell.el") | 160 "idlw-shell.el") |
166 :link '(emacs-commentary-link :tag "Commentary in idlwave.el" "idlwave.el") | 161 :link '(emacs-commentary-link :tag "Commentary in idlwave.el" "idlwave.el") |
167 :link '(custom-manual "(idlwave)Top") | 162 :link '(custom-manual "(idlwave)Top") |
168 :prefix "idlwave" | 163 :prefix "idlwave" |
169 :group 'languages) | 164 :group 'languages) |
170 | 165 |
305 IDLWAVE can under UNIX query the shell for the exact search path. | 300 IDLWAVE can under UNIX query the shell for the exact search path. |
306 However, under Windows and MacOS, the IDLWAVE shell does not work. In this | 301 However, under Windows and MacOS, the IDLWAVE shell does not work. In this |
307 case, this variable specifies the path where IDLWAVE can find library files. | 302 case, this variable specifies the path where IDLWAVE can find library files. |
308 The shell will only be asked when this variable is nil. | 303 The shell will only be asked when this variable is nil. |
309 The value is a list of directories. A directory preceeded by a `+' will | 304 The value is a list of directories. A directory preceeded by a `+' will |
310 be search recursively." | 305 be searched recursively. If you set this variable on a UNIX system, the shell |
306 will not be asked." | |
311 :group 'idlwave-routine-info-and-completion | 307 :group 'idlwave-routine-info-and-completion |
312 :type '(repeat (directory))) | 308 :type '(repeat (directory))) |
313 | 309 |
314 (defcustom idlwave-libinfo-file nil | 310 (defcustom idlwave-libinfo-file nil |
315 "*File for routine information of the IDL library. | 311 "*File for routine information of the IDL library. |
566 :group 'idlwave-abbrev-and-indent-action | 562 :group 'idlwave-abbrev-and-indent-action |
567 :type 'string) | 563 :type 'string) |
568 | 564 |
569 (defcustom idlwave-surround-by-blank nil | 565 (defcustom idlwave-surround-by-blank nil |
570 "*Non-nil means, enable `idlwave-surround'. | 566 "*Non-nil means, enable `idlwave-surround'. |
571 If non-nil, `=',`<',`>',`&',`,' are surrounded with spaces by | 567 If non-nil, `=',`<',`>',`&',`,', `->' are surrounded with spaces by |
572 `idlwave-surround'. | 568 `idlwave-surround'. |
573 See help for `idlwave-indent-action-table' for symbols using `idlwave-surround'. | 569 See help for `idlwave-indent-action-table' for symbols using `idlwave-surround'. |
574 | 570 |
575 Also see the default key bindings for keys using `idlwave-surround'. | 571 Also see the default key bindings for keys using `idlwave-surround'. |
576 Keys are bound and made into actions calling `idlwave-surround' with | 572 Keys are bound and made into actions calling `idlwave-surround' with |
781 (defgroup idlwave-external-programs nil | 777 (defgroup idlwave-external-programs nil |
782 "Miscellaneous options for IDLWAVE mode." | 778 "Miscellaneous options for IDLWAVE mode." |
783 :group 'idlwave) | 779 :group 'idlwave) |
784 | 780 |
785 ;; WARNING: The following variable has recently been moved from | 781 ;; WARNING: The following variable has recently been moved from |
786 ;; idlwave-shell.el to this file. I hope this does not break | 782 ;; idlw-shell.el to this file. I hope this does not break |
787 ;; anything. | 783 ;; anything. |
788 | 784 |
789 (defcustom idlwave-shell-explicit-file-name "idl" | 785 (defcustom idlwave-shell-explicit-file-name "idl" |
790 "*If non-nil, is the command to run IDL. | 786 "*If non-nil, is the command to run IDL. |
791 Should be an absolute file path or path relative to the current environment | 787 Should be an absolute file path or path relative to the current environment |
883 (<= emacs-minor-version 29)))) | 879 (<= emacs-minor-version 29)))) |
884 | 880 |
885 ;; The following are the reserved words in IDL. Maybe we should | 881 ;; The following are the reserved words in IDL. Maybe we should |
886 ;; highlight some more stuff as well? | 882 ;; highlight some more stuff as well? |
887 (idl-keywords | 883 (idl-keywords |
888 ; '("and" "or" "xor" "not" | 884 ;; To update this regexp, update the list of keywords and |
889 ; "eq" "ge" "gt" "le" "lt" "ne" | 885 ;; evaluate the form. |
890 ; "for" "do" "endfor" | 886 ; (insert |
891 ; "if" "then" "endif" "else" "endelse" | 887 ; (concat |
892 ; "case" "of" "endcase" | 888 ; "\"\\\\<" |
893 ; "begin" "end" | 889 ; (regexp-opt |
894 ; "repeat" "until" "endrep" | 890 ; '("and" "or" "xor" "not" |
895 ; "while" "endwhile" | 891 ; "eq" "ge" "gt" "le" "lt" "ne" |
896 ; "goto" "return" | 892 ; "for" "do" "endfor" |
897 ; "inherits" "mod" "on_error" "on_ioerror") ;; on_error is not reserved | 893 ; "if" "then" "endif" "else" "endelse" |
894 ; "case" "of" "endcase" | |
895 ; "begin" "end" | |
896 ; "repeat" "until" "endrep" | |
897 ; "while" "endwhile" | |
898 ; "goto" "return" | |
899 ; "inherits" "mod" | |
900 ; "on_error" "on_ioerror")) ; on_error is not officially reserved | |
901 ; "\\\\>\"")) | |
898 (concat "\\<\\(" | 902 (concat "\\<\\(" |
899 "and\\|begin\\|case\\|do\\|e\\(lse\\|nd\\(case\\|else\\|" | 903 "and\\|begin\\|case\\|do\\|e\\(lse\\|nd\\(case\\|else\\|" |
900 "for\\|if\\|rep\\|while\\)?\\|q\\)\\|for\\|g\\(oto\\|[et]\\)" | 904 "for\\|if\\|rep\\|while\\)?\\|q\\)\\|for\\|g\\(oto\\|[et]\\)" |
901 "\\|i\\(f\\|nherits\\)\\|l[et]\\|mod\\|n\\(e\\|ot\\)\\|" | 905 "\\|i\\(f\\|nherits\\)\\|l[et]\\|mod\\|n\\(e\\|ot\\)\\|" |
902 "o\\(n_ioerror\\|[fr]\\)\\|re\\(peat\\|turn\\)\\|then\\|" | 906 "o\\(n_ioerror\\|[fr]\\)\\|re\\(peat\\|turn\\)\\|then\\|" |
940 (1 font-lock-keyword-face) | 944 (1 font-lock-keyword-face) |
941 (2 font-lock-reference-face))) | 945 (2 font-lock-reference-face))) |
942 | 946 |
943 ;; Named parameters, like /xlog or ,xrange=[] | 947 ;; Named parameters, like /xlog or ,xrange=[] |
944 ;; This is anchored to the comma preceeding the keyword. | 948 ;; This is anchored to the comma preceeding the keyword. |
945 ;; With continuation lines, works only during whole buffer fontification. | 949 ;; Treats continuation lines, works only during whole buffer |
950 ;; fontification. Slow, use it only in fancy fontification. | |
946 (keyword-parameters | 951 (keyword-parameters |
947 '("[(,][ \t]*\\(\\$[ \t]*\n[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)" | 952 '("[(,][ \t]*\\(\\$[ \t]*\\(;.*\\)?\\(\n[ \t]*;.*\\)*\n[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)" |
948 (2 font-lock-reference-face))) | 953 (4 font-lock-reference-face))) |
949 | 954 |
950 ;; System variables stars with a bang. | 955 ;; System variables start with a bang. |
951 (system-variables | 956 (system-variables |
952 '("\\(![a-zA-Z_]+\\(\\.\\sw+\\)?\\)" | 957 '("\\(![a-zA-Z_]+\\(\\.\\sw+\\)?\\)" |
953 (1 font-lock-variable-name-face))) | 958 (1 font-lock-variable-name-face))) |
954 | 959 |
955 ;; Special and unusual operators (not used because too noisy) | 960 ;; Special and unusual operators (not used because too noisy) |
1100 '(while . ("while\\>" "do")) | 1105 '(while . ("while\\>" "do")) |
1101 '(repeat . ("repeat\\>" "repeat")) | 1106 '(repeat . ("repeat\\>" "repeat")) |
1102 '(goto . ("goto\\>" nil)) | 1107 '(goto . ("goto\\>" nil)) |
1103 '(case . ("case\\>" nil)) | 1108 '(case . ("case\\>" nil)) |
1104 (cons 'call (list (concat idlwave-identifier "\\(\\s *$\\|\\s *,\\)") nil)) | 1109 (cons 'call (list (concat idlwave-identifier "\\(\\s *$\\|\\s *,\\)") nil)) |
1105 '(assign . ("[^=\n]*=" nil))) | 1110 '(assign . ("[^=>\n]*=" nil))) |
1106 | 1111 |
1107 "Associated list of statement matching regular expressions. | 1112 "Associated list of statement matching regular expressions. |
1108 Each regular expression matches the start of an IDL statement. The | 1113 Each regular expression matches the start of an IDL statement. The |
1109 first element of each association is a symbol giving the statement | 1114 first element of each association is a symbol giving the statement |
1110 type. The associated value is a list. The first element of this list | 1115 type. The associated value is a list. The first element of this list |
1132 | 1137 |
1133 (defconst idlwave-continuation-char ?$ | 1138 (defconst idlwave-continuation-char ?$ |
1134 "Character which is inserted as a last character on previous line by | 1139 "Character which is inserted as a last character on previous line by |
1135 \\[idlwave-split-line] to begin a continuation line. Normally $.") | 1140 \\[idlwave-split-line] to begin a continuation line. Normally $.") |
1136 | 1141 |
1137 (defconst idlwave-mode-version " 3.12") | 1142 (defconst idlwave-mode-version " 3.15") |
1138 | 1143 |
1139 (defmacro idlwave-keyword-abbrev (&rest args) | 1144 (defmacro idlwave-keyword-abbrev (&rest args) |
1140 "Creates a function for abbrev hooks to call `idlwave-check-abbrev' with args." | 1145 "Creates a function for abbrev hooks to call `idlwave-check-abbrev' with args." |
1141 (` (quote (lambda () | 1146 (` (quote (lambda () |
1142 (, (append '(idlwave-check-abbrev) args)))))) | 1147 (, (append '(idlwave-check-abbrev) args)))))) |
1238 cmd | 1243 cmd |
1239 (list cmd))))))) | 1244 (list cmd))))))) |
1240 | 1245 |
1241 (fset 'idlwave-debug-map (make-sparse-keymap)) | 1246 (fset 'idlwave-debug-map (make-sparse-keymap)) |
1242 | 1247 |
1248 (define-key idlwave-mode-map "\C-c " 'idlwave-hard-tab) | |
1249 ;(define-key idlwave-mode-map "\C-c\C- " 'idlwave-hard-tab) | |
1243 (define-key idlwave-mode-map "'" 'idlwave-show-matching-quote) | 1250 (define-key idlwave-mode-map "'" 'idlwave-show-matching-quote) |
1244 (define-key idlwave-mode-map "\"" 'idlwave-show-matching-quote) | 1251 (define-key idlwave-mode-map "\"" 'idlwave-show-matching-quote) |
1245 (define-key idlwave-mode-map "\C-c;" 'idlwave-toggle-comment-region) | 1252 (define-key idlwave-mode-map "\C-c;" 'idlwave-toggle-comment-region) |
1246 (define-key idlwave-mode-map "\C-\M-a" 'idlwave-beginning-of-subprogram) | 1253 (define-key idlwave-mode-map "\C-\M-a" 'idlwave-beginning-of-subprogram) |
1247 (define-key idlwave-mode-map "\C-\M-e" 'idlwave-end-of-subprogram) | 1254 (define-key idlwave-mode-map "\C-\M-e" 'idlwave-end-of-subprogram) |
1292 ;; See description of the function `idlwave-action-and-binding'. | 1299 ;; See description of the function `idlwave-action-and-binding'. |
1293 ;; Automatically add spaces for the following characters | 1300 ;; Automatically add spaces for the following characters |
1294 (idlwave-action-and-binding "&" '(idlwave-surround -1 -1)) | 1301 (idlwave-action-and-binding "&" '(idlwave-surround -1 -1)) |
1295 (idlwave-action-and-binding "<" '(idlwave-surround -1 -1)) | 1302 (idlwave-action-and-binding "<" '(idlwave-surround -1 -1)) |
1296 (idlwave-action-and-binding ">" '(idlwave-surround -1 -1 '(?-))) | 1303 (idlwave-action-and-binding ">" '(idlwave-surround -1 -1 '(?-))) |
1304 (idlwave-action-and-binding "->" '(idlwave-surround -1 -1 nil 2)) | |
1297 (idlwave-action-and-binding "," '(idlwave-surround 0 -1)) | 1305 (idlwave-action-and-binding "," '(idlwave-surround 0 -1)) |
1298 ;; Automatically add spaces to equal sign if not keyword | 1306 ;; Automatically add spaces to equal sign if not keyword |
1299 (idlwave-action-and-binding "=" '(idlwave-expand-equal -1 -1)) | 1307 (idlwave-action-and-binding "=" '(idlwave-expand-equal -1 -1)) |
1300 | 1308 |
1301 ;;; | 1309 ;;; |
1794 (setq end (cdr end)) | 1802 (setq end (cdr end)) |
1795 (error "Cannot close block"))) | 1803 (error "Cannot close block"))) |
1796 (insert end) | 1804 (insert end) |
1797 (idlwave-newline))) | 1805 (idlwave-newline))) |
1798 | 1806 |
1799 (defun idlwave-surround (&optional before after escape-chars) | 1807 (defun idlwave-surround (&optional before after escape-chars length) |
1800 "Surround the character before point with blanks. | 1808 "Surround the LENGTH characters before point with blanks. |
1809 LENGTH defaults to 1. | |
1801 Optional arguments BEFORE and AFTER affect the behavior before and | 1810 Optional arguments BEFORE and AFTER affect the behavior before and |
1802 after the previous character. See description of `idlwave-make-space'. | 1811 after the characters (see also description of `idlwave-make-space'): |
1812 | |
1813 nil do nothing | |
1814 0 force no spaces | |
1815 integer > 0 force exactly n spaces | |
1816 integer < 0 at least |n| spaces | |
1803 | 1817 |
1804 The function does nothing if any of the following conditions is true: | 1818 The function does nothing if any of the following conditions is true: |
1805 - `idlwave-surround-by-blank' is nil | 1819 - `idlwave-surround-by-blank' is nil |
1806 - the character before point is inside a string or comment | 1820 - the character before point is inside a string or comment |
1807 | 1821 - the char preceeding the string to be surrounded is a member of ESCAPE-CHARS. |
1808 When the character 2 positions before point is a member of | 1822 This hack is used to avoid padding of `>' when it is part of |
1809 ESCAPE-CHARS, BEFORE is forced to nil." | 1823 the '->' operator. In this case, ESCAPE-CHARS would be '(?-)." |
1810 | 1824 |
1811 (if (and idlwave-surround-by-blank | 1825 (setq length (or length 1)) ; establish a default for LENGTH |
1812 (not (idlwave-quoted))) | 1826 |
1813 (progn | 1827 (when (and idlwave-surround-by-blank |
1814 (if (memq (char-after (- (point) 2)) escape-chars) | 1828 (not (idlwave-quoted)) |
1815 (setq before nil)) | 1829 (not (memq (char-after (- (point) (1+ length))) escape-chars))) |
1816 (backward-char 1) | 1830 (backward-char length) |
1817 (save-restriction | 1831 (save-restriction |
1818 (let ((here (point))) | 1832 (let ((here (point))) |
1819 (skip-chars-backward " \t") | 1833 (skip-chars-backward " \t") |
1820 (if (bolp) | 1834 (if (bolp) |
1821 ;; avoid clobbering indent | 1835 ;; avoid clobbering indent |
1822 (progn | 1836 (progn |
1823 (move-to-column (idlwave-calculate-indent)) | 1837 (move-to-column (idlwave-calculate-indent)) |
1824 (if (<= (point) here) | 1838 (if (<= (point) here) |
1825 (narrow-to-region (point) here)) | 1839 (narrow-to-region (point) here)) |
1826 (goto-char here))) | 1840 (goto-char here))) |
1827 (idlwave-make-space before)) | 1841 (idlwave-make-space before)) |
1828 (skip-chars-forward " \t")) | 1842 (skip-chars-forward " \t")) |
1829 (forward-char 1) | 1843 (forward-char length) |
1830 (idlwave-make-space after) | 1844 (idlwave-make-space after) |
1831 ;; Check to see if the line should auto wrap | 1845 ;; Check to see if the line should auto wrap |
1832 (if (and (equal (char-after (1- (point))) ? ) | 1846 (if (and (equal (char-after (1- (point))) ? ) |
1833 (> (current-column) fill-column)) | 1847 (> (current-column) fill-column)) |
1834 (funcall auto-fill-function))))) | 1848 (funcall auto-fill-function)))) |
1835 | 1849 |
1836 (defun idlwave-make-space (n) | 1850 (defun idlwave-make-space (n) |
1837 "Make space at point. | 1851 "Make space at point. |
1838 The space affected is all the spaces and tabs around point. | 1852 The space affected is all the spaces and tabs around point. |
1839 If n is non-nil then point is left abs(n) spaces from the beginning of | 1853 If n is non-nil then point is left abs(n) spaces from the beginning of |
1840 the contiguous space. | 1854 the contiguous space. |
1841 The amount of space at point is determined by N. | 1855 The amount of space at point is determined by N. |
1842 If the value of N is: | 1856 If the value of N is: |
1843 nil - do nothing. | 1857 nil - do nothing. |
1844 c > 0 - exactly c spaces. | 1858 > 0 - exactly N spaces. |
1845 c < 0 - a minimum of -c spaces, i.e., do not change if there are | 1859 < 0 - a minimum of -N spaces, i.e., do not change if there are |
1846 already -c spaces. | 1860 already -N spaces. |
1847 0 - no spaces." | 1861 0 - no spaces (i.e. remove any existing space)." |
1848 (if (integerp n) | 1862 (if (integerp n) |
1849 (let | 1863 (let |
1850 ((start-col (progn (skip-chars-backward " \t") (current-column))) | 1864 ((start-col (progn (skip-chars-backward " \t") (current-column))) |
1851 (left (point)) | 1865 (left (point)) |
1852 (end-col (progn (skip-chars-forward " \t") (current-column)))) | 1866 (end-col (progn (skip-chars-forward " \t") (current-column)))) |
3024 (defun idlwave-template (s1 s2 &optional prompt noindent) | 3038 (defun idlwave-template (s1 s2 &optional prompt noindent) |
3025 "Build a template with optional prompt expression. | 3039 "Build a template with optional prompt expression. |
3026 | 3040 |
3027 Opens a line if point is not followed by a newline modulo intervening | 3041 Opens a line if point is not followed by a newline modulo intervening |
3028 whitespace. S1 and S2 are strings. S1 is inserted at point followed | 3042 whitespace. S1 and S2 are strings. S1 is inserted at point followed |
3029 by S2. Point is inserted between S1 and S2. If optional argument | 3043 by S2. Point is inserted between S1 and S2. The case of S1 and S2 is |
3044 adjusted according to `idlwave-abbrev-change-case'. If optional argument | |
3030 PROMPT is a string then it is displayed as a message in the | 3045 PROMPT is a string then it is displayed as a message in the |
3031 minibuffer. The PROMPT serves as a reminder to the user of an | 3046 minibuffer. The PROMPT serves as a reminder to the user of an |
3032 expression to enter. | 3047 expression to enter. |
3033 | 3048 |
3034 The lines containing S1 and S2 are reindented using `indent-region' | 3049 The lines containing S1 and S2 are reindented using `indent-region' |
3035 unless the optional second argument NOINDENT is non-nil." | 3050 unless the optional second argument NOINDENT is non-nil." |
3051 (cond ((eq idlwave-abbrev-change-case 'down) | |
3052 (setq s1 (downcase s1) s2 (downcase s2))) | |
3053 (idlwave-abbrev-change-case | |
3054 (setq s1 (upcase s1) s2 (upcase s2)))) | |
3036 (let ((beg (save-excursion (beginning-of-line) (point))) | 3055 (let ((beg (save-excursion (beginning-of-line) (point))) |
3037 end) | 3056 end) |
3038 (if (not (looking-at "\\s-*\n")) | 3057 (if (not (looking-at "\\s-*\n")) |
3039 (open-line 1)) | 3058 (open-line 1)) |
3040 (insert s1) | 3059 (insert s1) |
3044 (if (not noindent) | 3063 (if (not noindent) |
3045 (indent-region beg end nil)) | 3064 (indent-region beg end nil)) |
3046 (if (stringp prompt) | 3065 (if (stringp prompt) |
3047 (message prompt)))) | 3066 (message prompt)))) |
3048 | 3067 |
3068 (defun idlwave-rw-case (string) | |
3069 "Make STRING have the case required by `idlwave-reserved-word-upcase'." | |
3070 (if idlwave-reserved-word-upcase | |
3071 (upcase string) | |
3072 string)) | |
3073 | |
3049 (defun idlwave-elif () | 3074 (defun idlwave-elif () |
3050 "Build skeleton IDL if-else block." | 3075 "Build skeleton IDL if-else block." |
3051 (interactive) | 3076 (interactive) |
3052 (idlwave-template "if" | 3077 (idlwave-template |
3053 " then begin\n\nendif else begin\n\nendelse" | 3078 (idlwave-rw-case "if") |
3054 "Condition expression")) | 3079 (idlwave-rw-case " then begin\n\nendif else begin\n\nendelse") |
3080 "Condition expression")) | |
3055 | 3081 |
3056 (defun idlwave-case () | 3082 (defun idlwave-case () |
3057 "Build skeleton IDL case statement." | 3083 "Build skeleton IDL case statement." |
3058 (interactive) | 3084 (interactive) |
3059 (idlwave-template "case" " of\n\nendcase" "Selector expression")) | 3085 (idlwave-template |
3086 (idlwave-rw-case "case") | |
3087 (idlwave-rw-case " of\n\nendcase") | |
3088 "Selector expression")) | |
3060 | 3089 |
3061 (defun idlwave-for () | 3090 (defun idlwave-for () |
3062 "Build skeleton for loop statment." | 3091 "Build skeleton for loop statment." |
3063 (interactive) | 3092 (interactive) |
3064 (idlwave-template "for" " do begin\n\nendfor" "Loop expression")) | 3093 (idlwave-template |
3094 (idlwave-rw-case "for") | |
3095 (idlwave-rw-case " do begin\n\nendfor") | |
3096 "Loop expression")) | |
3065 | 3097 |
3066 (defun idlwave-if () | 3098 (defun idlwave-if () |
3067 "Build skeleton for loop statment." | 3099 "Build skeleton for loop statment." |
3068 (interactive) | 3100 (interactive) |
3069 (idlwave-template "if" " then begin\n\nendif" "Scalar logical expression")) | 3101 (idlwave-template |
3102 (idlwave-rw-case "if") | |
3103 (idlwave-rw-case " then begin\n\nendif") | |
3104 "Scalar logical expression")) | |
3070 | 3105 |
3071 (defun idlwave-procedure () | 3106 (defun idlwave-procedure () |
3072 (interactive) | 3107 (interactive) |
3073 (idlwave-template "pro" "\n\nreturn\nend" "Procedure name")) | 3108 (idlwave-template |
3109 (idlwave-rw-case "pro") | |
3110 (idlwave-rw-case "\n\nreturn\nend") | |
3111 "Procedure name")) | |
3074 | 3112 |
3075 (defun idlwave-function () | 3113 (defun idlwave-function () |
3076 (interactive) | 3114 (interactive) |
3077 (idlwave-template "function" "\n\nreturn\nend" "Function name")) | 3115 (idlwave-template |
3116 (idlwave-rw-case "function") | |
3117 (idlwave-rw-case "\n\nreturn\nend") | |
3118 "Function name")) | |
3078 | 3119 |
3079 (defun idlwave-repeat () | 3120 (defun idlwave-repeat () |
3080 (interactive) | 3121 (interactive) |
3081 (idlwave-template "repeat begin\n\nendrep until" "" "Exit condition")) | 3122 (idlwave-template |
3123 (idlwave-rw-case "repeat begin\n\nendrep until") | |
3124 (idlwave-rw-case "") | |
3125 "Exit condition")) | |
3082 | 3126 |
3083 (defun idlwave-while () | 3127 (defun idlwave-while () |
3084 (interactive) | 3128 (interactive) |
3085 (idlwave-template "while" " do begin\n\nendwhile" "Entry condition")) | 3129 (idlwave-template |
3130 (idlwave-rw-case "while") | |
3131 (idlwave-rw-case " do begin\n\nendwhile") | |
3132 "Entry condition")) | |
3086 | 3133 |
3087 (defun idlwave-split-string (string &optional pattern) | 3134 (defun idlwave-split-string (string &optional pattern) |
3088 "Return a list of substrings of STRING which are separated by PATTERN. | 3135 "Return a list of substrings of STRING which are separated by PATTERN. |
3089 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." | 3136 If PATTERN is omitted, it defaults to \"[ \\f\\t\\n\\r\\v]+\"." |
3090 (or pattern | 3137 (or pattern |
4131 (or (integerp arg) | 4178 (or (integerp arg) |
4132 (symbolp arg))) | 4179 (symbolp arg))) |
4133 (idlwave-make-force-complete-where-list arg module class) | 4180 (idlwave-make-force-complete-where-list arg module class) |
4134 (idlwave-where))) | 4181 (idlwave-where))) |
4135 (what (nth 2 where-list)) | 4182 (what (nth 2 where-list)) |
4136 (idlwave-force-class-query (equal arg '(4))) | 4183 (idlwave-force-class-query (equal arg '(4)))) |
4137 cwin) | |
4138 | 4184 |
4139 (if (and module (string-match "::" module)) | 4185 (if (and module (string-match "::" module)) |
4140 (setq class (substring module 0 (match-beginning 0)) | 4186 (setq class (substring module 0 (match-beginning 0)) |
4141 module (substring module (match-end 0)))) | 4187 module (substring module (match-end 0)))) |
4142 | 4188 |
4143 (cond | 4189 (cond |
4144 | 4190 |
4145 ((and (null arg) | 4191 ((and (null arg) |
4146 (eq (car-safe last-command) 'idlwave-display-completion-list) | 4192 (eq (car-safe last-command) 'idlwave-display-completion-list) |
4147 (setq cwin (get-buffer-window "*Completions*"))) | 4193 (get-buffer-window "*Completions*")) |
4148 (setq this-command last-command) | 4194 (setq this-command last-command) |
4149 (idlwave-scroll-completions)) | 4195 (idlwave-scroll-completions)) |
4150 | 4196 |
4151 ((null what) | 4197 ((null what) |
4152 (error "Nothing to complete here")) | 4198 (error "Nothing to complete here")) |
5609 ("Documentation" | 5655 ("Documentation" |
5610 ["Describe Mode" describe-mode t] | 5656 ["Describe Mode" describe-mode t] |
5611 ["Abbreviation List" idlwave-list-abbrevs t] | 5657 ["Abbreviation List" idlwave-list-abbrevs t] |
5612 "--" | 5658 "--" |
5613 ["Commentary in idlwave.el" idlwave-show-commentary t] | 5659 ["Commentary in idlwave.el" idlwave-show-commentary t] |
5614 ["Commentary in idlwave-shell.el" idlwave-shell-show-commentary t] | 5660 ["Commentary in idlw-shell.el" idlwave-shell-show-commentary t] |
5615 "--" | 5661 "--" |
5616 ["Info" idlwave-info t] | 5662 ["Info" idlwave-info t] |
5617 "--" | 5663 "--" |
5618 ["Launch IDL Help" idlwave-launch-idlhelp t]))) | 5664 ["Launch IDL Help" idlwave-launch-idlhelp t]))) |
5619 | 5665 |
5669 (interactive) | 5715 (interactive) |
5670 (require 'finder) | 5716 (require 'finder) |
5671 (finder-commentary "idlwave.el")) | 5717 (finder-commentary "idlwave.el")) |
5672 | 5718 |
5673 (defun idlwave-shell-show-commentary () | 5719 (defun idlwave-shell-show-commentary () |
5674 "Use the finder to view the file documentation from `idlwave-shell.el'." | 5720 "Use the finder to view the file documentation from `idlw-shell.el'." |
5675 (interactive) | 5721 (interactive) |
5676 (require 'finder) | 5722 (require 'finder) |
5677 (finder-commentary "idlwave-shell.el")) | 5723 (finder-commentary "idlw-shell.el")) |
5678 | 5724 |
5679 (defun idlwave-info () | 5725 (defun idlwave-info () |
5680 "Read documentation for IDLWAVE in the info system." | 5726 "Read documentation for IDLWAVE in the info system." |
5681 (interactive) | 5727 (interactive) |
5682 (require 'info) | 5728 (require 'info) |
5749 | 5795 |
5750 (provide 'idlwave) | 5796 (provide 'idlwave) |
5751 | 5797 |
5752 ;;; idlwave.el ends here | 5798 ;;; idlwave.el ends here |
5753 | 5799 |
5800 | |
5801 |