Mercurial > hg > xemacs-beta
comparison lisp/modes/eiffel3.el @ 2:ac2d302a0011 r19-15b2
Import from CVS: tag r19-15b2
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:46:35 +0200 |
parents | 376386a54a3c |
children | 27bc7f280385 |
comparison
equal
deleted
inserted
replaced
1:c0c6a60d29db | 2:ac2d302a0011 |
---|---|
1 ;;; $Id: eiffel3.el,v 1.1.1.1 1996/12/18 03:30:45 steve Exp $ | 1 ;;; $Id: eiffel3.el,v 1.1.1.2 1996/12/18 03:44:36 steve Exp $ |
2 ;;;-------------------------------------------------------------------------- | 2 ;;;-------------------------------------------------------------------------- |
3 ;;; TowerEiffel -- Copyright (c) 1993,1994 Tower Technology Corporation. | 3 ;;; TowerEiffel -- Copyright (c) 1993-1996 Tower Technology Corporation. |
4 ;;; All Rights Reserved. | 4 ;;; All Rights Reserved. |
5 ;;; | 5 ;;; |
6 ;;; Use, duplication, or disclosure is subject to restrictions as set forth | 6 ;;; Use, duplication, or disclosure is subject to restrictions as set forth |
7 ;;; in subdivision (c)(1)(ii) of the Rights in Technical Data and Computer | 7 ;;; in subdivision (c)(1)(ii) of the Rights in Technical Data and Computer |
8 ;;; Software clause at DFARS 252.227-7013. | 8 ;;; Software clause at DFARS 252.227-7013. |
10 ;;; This file is made available for use and distribution under the same terms | 10 ;;; This file is made available for use and distribution under the same terms |
11 ;;; as GNU Emacs. Such availability of this elisp file should not be construed | 11 ;;; as GNU Emacs. Such availability of this elisp file should not be construed |
12 ;;; as granting such availability to the rest of TowerEiffel. | 12 ;;; as granting such availability to the rest of TowerEiffel. |
13 ;;;-------------------------------------------------------------------------- | 13 ;;;-------------------------------------------------------------------------- |
14 ;;; Portions of the file, as indicated below, were derived from "eiffel.el" | 14 ;;; Portions of the file, as indicated below, were derived from "eiffel.el" |
15 ;;; and "eif-mult-fmt.el | 15 ;;; (developed by Stephen Omohundro, ISE and Bob Weiner) and "eif-mult-fmt.el" |
16 ;;; Copyright (C) 1989, 1990 Free Software Foundation, Inc. and Bob Weiner | 16 ;;; (developed by Bob Weiner): |
17 ;;; Available for use and distribution under the same terms as GNU Emacs. | 17 ;;; eiffel.el and eif-mult-fmt.el are Copyright (C) 1989, 1990 |
18 ;;; Free Software Foundation, Inc. and Bob Weiner | |
19 ;;; Available for use and distribution under the same terms as GNU Emacs. | |
18 | 20 |
19 ;;; Synched up with: Not in FSF. | 21 ;;; Synched up with: Not in FSF. |
20 | 22 |
21 ;;;-------------------------------------------------------------------------- | 23 ;;;-------------------------------------------------------------------------- |
22 ;;; Adapted the file for the XEmacs 19.12 distribution. -- jasa (1995/03/11) | 24 ;;; Adapted the file for the XEmacs 19.12 distribution. -- jasa (1995/03/11) |
456 (copy-face 'eif-comment 'font-lock-comment-face) | 458 (copy-face 'eif-comment 'font-lock-comment-face) |
457 (copy-face 'eif-string 'font-lock-string-face) | 459 (copy-face 'eif-string 'font-lock-string-face) |
458 (defconst eiffel-font-lock-keywords | 460 (defconst eiffel-font-lock-keywords |
459 (purecopy | 461 (purecopy |
460 '(;; major keywords | 462 '(;; major keywords |
461 ("\\(^[ \t]*\\|[ \t]+\\)creation\\|^deferred[ \t]+class\\|^expanded[ \t]+class\\|^class\\|^feature\\|^indexing\\|\\(^[ \t]*\\|[ \t]+\\)inherit\\|^obsolete" 0 eif-major-keyword nil) | 463 ("\\(\\(^[ \t]*\\|[ \t]+\\)creation\\|^deferred[ \t]+class\\|^expanded[ \t]+class\\|^class\\|^feature\\|^indexing\\|\\(^[ \t]*\\|[ \t]+\\)inherit\\|^obsolete\\)[ \t\n]" 0 eif-major-keyword nil) |
462 ;; assertions | 464 ;; assertions |
463 ("\\(^\\|[^_\n]\\<\\)\\(check\\|ensure then\\|ensure\\|invariant\\|require else\\|require\\|variant\\)\\($\\|\\>[^_\n]\\)" 2 eif-assertion nil) | 465 ("\\(^\\|[^_\n]\\<\\)\\(check\\|ensure then\\|ensure\\|invariant\\|require else\\|require\\|variant\\)\\($\\|\\>[^_\n]\\)" 2 eif-assertion nil) |
464 ;; minor keywords | 466 ;; minor keywords |
465 ("\\(^\\|[^_\n]\\<\\)\\(alias\\|all\\|and not\\|and then\\|and\\|as\\|debug\\|deferred\\|do\\|else\\|elseif\\|end\\|export\\|external\\|from\\|frozen\\|if not\\|if\\|implies not\\|implies\\|infix\\|inspect\\|is deferred\\|is unique\\|is\\|like\\|local\\|loop\\|not\\|obsolete\\|old\\|once\\|or else\\|or not\\|or\\|prefix\\|redefine\\|rename\\|rescue\\|retry\\|select\\|strip\\|then\\|undefine\\|unique\\|until\\|when\\|xor\\)\\($\\|\\>[^_\n]\\)" 2 eif-minor-keyword nil) | 467 ("\\(^\\|[^_\n]\\<\\)\\(alias\\|all\\|and not\\|and then\\|and\\|as\\|debug\\|deferred\\|do\\|else\\|elseif\\|end\\|export\\|external\\|from\\|frozen\\|if not\\|if\\|implies not\\|implies\\|infix\\|inspect\\|is deferred\\|is unique\\|is\\|like\\|local\\|loop\\|not\\|obsolete\\|old\\|once\\|or else\\|or not\\|or\\|prefix\\|redefine\\|rename\\|rescue\\|retry\\|select\\|strip\\|then\\|undefine\\|unique\\|until\\|when\\|xor\\)\\($\\|\\>[^_\n]\\)" 2 eif-minor-keyword nil) |
466 ;; hidden comments | 468 ;; hidden comments |
1343 keyword | 1345 keyword |
1344 ) | 1346 ) |
1345 ) | 1347 ) |
1346 ) | 1348 ) |
1347 | 1349 |
1348 (defun eif-current-line-indent () | |
1349 "Return the indentation of the line containing the point." | |
1350 (save-excursion | |
1351 (let ((line-end 0) | |
1352 (indent 0) | |
1353 ) | |
1354 (end-of-line) | |
1355 (setq line-end (point)) | |
1356 (beginning-of-line) | |
1357 (re-search-forward eif-white-space-regexp line-end t) | |
1358 (setq indent (current-column)) | |
1359 ) | |
1360 ) | |
1361 ) | |
1362 | |
1363 (defun eif-line-contains-close-paren () | 1350 (defun eif-line-contains-close-paren () |
1364 "This function returns t if the current line contains a close paren and | 1351 "This function returns t if the current line contains a close paren and |
1365 nil otherwise. If a close paren is found, the point is placed immediately | 1352 nil otherwise. If a close paren is found, the point is placed immediately |
1366 after the last close paren on the line. If no paren is found, the point is | 1353 after the last close paren on the line. If no paren is found, the point is |
1367 placed at the beginning of the line." | 1354 placed at the beginning of the line." |
1392 ;;; ;; by a '%' or include a '\"'. It must either end with a '%' character | 1379 ;;; ;; by a '%' or include a '\"'. It must either end with a '%' character |
1393 ;;; ;; or must include a second '\"' character. | 1380 ;;; ;; or must include a second '\"' character. |
1394 ;;; (looking-at "^\\([ \t]*%\\|[^\"\n]*\"\\)[^\"\n]*\\(%$\\|\"\\)") | 1381 ;;; (looking-at "^\\([ \t]*%\\|[^\"\n]*\"\\)[^\"\n]*\\(%$\\|\"\\)") |
1395 ;;; ) | 1382 ;;; ) |
1396 ;;;) | 1383 ;;;) |
1397 | |
1398 (defun eif-in-quoted-string-p (&optional non-strict-p) | |
1399 "t if point is in a quoted string. Optional argument NON-STRICT-P if true | |
1400 causes the function to return true even if the point is located in leading | |
1401 white space on a continuation line. Normally leading white space is not | |
1402 considered part of the string." | |
1403 (let ((initial-regexp "^[ \t]*%\\|[^%]\"\\|%[ \t]*$") | |
1404 (search-limit (point)) | |
1405 (count 0) | |
1406 ) | |
1407 (save-excursion | |
1408 ;; Line must either start with optional whitespace immediately followed | |
1409 ;; by a '%' or include a '\"' before the search-limit. | |
1410 (beginning-of-line) | |
1411 (while (re-search-forward initial-regexp search-limit t) | |
1412 (setq count (1+ count)) | |
1413 (if (= count 1) (setq search-limit (1+ search-limit))) | |
1414 ) | |
1415 ;; If the number of quotes (including continuation line markers) is odd, | |
1416 ;; then we are inside of a string. Also if non-strict-p and we are in | |
1417 ;; the leading white space of a continuation line, then we are in a quote. | |
1418 (if (= (% count 2) 1) | |
1419 t | |
1420 (beginning-of-line) | |
1421 (if non-strict-p | |
1422 (if (looking-at "^[ \t]*%") | |
1423 t | |
1424 nil | |
1425 ) | |
1426 nil | |
1427 );; if | |
1428 );; if | |
1429 );; save-excursion | |
1430 );; let | |
1431 );; e-in-quoted-string | |
1432 | 1384 |
1433 (defvar eif-opening-regexp | 1385 (defvar eif-opening-regexp |
1434 "\\<\\(external\\|check\\|deferred\\|do\\|once\\|from\\|if\\|inspect\\)\\>" | 1386 "\\<\\(external\\|check\\|deferred\\|do\\|once\\|from\\|if\\|inspect\\)\\>" |
1435 "Keywords that open eiffel nesting constructs." | 1387 "Keywords that open eiffel nesting constructs." |
1436 ) | 1388 ) |
1482 (end-of-line) | 1434 (end-of-line) |
1483 (setq search-end (point)) | 1435 (setq search-end (point)) |
1484 (beginning-of-line) | 1436 (beginning-of-line) |
1485 ;; Set starting state: If direction was specified use it. | 1437 ;; Set starting state: If direction was specified use it. |
1486 ;; If direction is nil, search for a keyword on the current line | 1438 ;; If direction is nil, search for a keyword on the current line |
1487 ;; If the keyword in in eif-opening-regexp, set the search | 1439 ;; If the keyword is in eif-opening-regexp, set the search |
1488 ;; direction to 'forward, if the keyword on the current line is `end' | 1440 ;; direction to 'forward, if the keyword on the current line is `end' |
1489 ;; set the search direction to 'backward. | 1441 ;; set the search direction to 'backward. |
1490 (cond ((eq direction 'forward) | 1442 (cond ((eq direction 'forward) |
1491 (end-of-line);; So we wont see any keywords on the current line | 1443 (end-of-line);; So we wont see any keywords on the current line |
1492 (setq nesting-level 1) | 1444 (setq nesting-level 1) |
1828 (if eiffel-mode-map | 1780 (if eiffel-mode-map |
1829 nil | 1781 nil |
1830 (setq eiffel-mode-map (make-sparse-keymap)) | 1782 (setq eiffel-mode-map (make-sparse-keymap)) |
1831 (define-key eiffel-mode-map "\t" 'eif-indent-line) | 1783 (define-key eiffel-mode-map "\t" 'eif-indent-line) |
1832 (define-key eiffel-mode-map "\C-j" 'eif-newline) | 1784 (define-key eiffel-mode-map "\C-j" 'eif-newline) |
1785 (if (and (boundp 'eif-cr-function) eif-cr-function) | |
1786 (define-key eiffel-mode-map "\C-m" eif-cr-function) | |
1787 ) | |
1833 (define-key eiffel-mode-map "\177" 'backward-delete-char-untabify) | 1788 (define-key eiffel-mode-map "\177" 'backward-delete-char-untabify) |
1834 (define-key eiffel-mode-map "\M-\C-q" 'eif-indent-construct) | 1789 (define-key eiffel-mode-map "\M-\C-q" 'eif-indent-construct) |
1835 (define-key eiffel-mode-map "\M-'" 'eif-feature-quote) | 1790 (define-key eiffel-mode-map "\M-'" 'eif-feature-quote) |
1836 (define-key eiffel-mode-map "\M-q" 'eif-fill-paragraph) | 1791 (define-key eiffel-mode-map "\M-q" 'eif-fill-paragraph) |
1837 ) | 1792 ) |
1880 (save-excursion | 1835 (save-excursion |
1881 (and (/= (point) (point-max)) (forward-char 1)) | 1836 (and (/= (point) (point-max)) (forward-char 1)) |
1882 (search-backward "--" (save-excursion (beginning-of-line) (point)) t))) | 1837 (search-backward "--" (save-excursion (beginning-of-line) (point)) t))) |
1883 | 1838 |
1884 | 1839 |
1840 ;; ENHANCEME: Currently eif-beginning-of-feature only works for routines. | |
1841 ;; It should be made more general. | |
1842 ;; | |
1843 | |
1844 (defun eif-beginning-of-feature (&optional arg) | |
1845 "Move backward to next feature beginning. With argument, do this that many | |
1846 times. Returns t unless search stops due to beginning of buffer." | |
1847 (interactive "p") | |
1848 (and arg (< arg 0) (forward-char 1)) | |
1849 (if (or (re-search-backward eif-multiline-routine-is-keyword-regexp | |
1850 nil t (or arg 1)) | |
1851 (re-search-backward eif-is-keyword-regexp | |
1852 nil 'move (or arg 1)) | |
1853 ) | |
1854 (progn | |
1855 (backward-sexp 1) | |
1856 (if (looking-at "(") | |
1857 (backward-word 1) | |
1858 ) | |
1859 (beginning-of-line) | |
1860 ) | |
1861 nil | |
1862 ) | |
1863 ) | |
1864 | |
1865 (defun eif-current-line-indent () | |
1866 "Return the indentation of the line containing the point." | |
1867 (save-excursion | |
1868 (let ((line-end 0) | |
1869 (indent 0) | |
1870 ) | |
1871 (end-of-line) | |
1872 (setq line-end (point)) | |
1873 (beginning-of-line) | |
1874 (re-search-forward eif-white-space-regexp line-end t) | |
1875 (setq indent (current-column)) | |
1876 ) | |
1877 ) | |
1878 ) | |
1879 | |
1880 (defun eif-in-quoted-string-p (&optional non-strict-p) | |
1881 "t if point is in a quoted string. Optional argument NON-STRICT-P if true | |
1882 causes the function to return true even if the point is located in leading | |
1883 white space on a continuation line. Normally leading white space is not | |
1884 considered part of the string." | |
1885 (let ((initial-regexp "^[ \t]*%\\|[^%]\"\\|%[ \t]*$") | |
1886 (search-limit (point)) | |
1887 (count 0) | |
1888 ) | |
1889 (save-excursion | |
1890 ;; Line must either start with optional whitespace immediately followed | |
1891 ;; by a '%' or include a '\"' before the search-limit. | |
1892 (beginning-of-line) | |
1893 (while (re-search-forward initial-regexp search-limit t) | |
1894 (setq count (1+ count)) | |
1895 (if (= count 1) (setq search-limit (1+ search-limit))) | |
1896 ) | |
1897 ;; If the number of quotes (including continuation line markers) is odd, | |
1898 ;; then we are inside of a string. Also if non-strict-p and we are in | |
1899 ;; the leading white space of a continuation line, then we are in a quote. | |
1900 (if (= (% count 2) 1) | |
1901 t | |
1902 (beginning-of-line) | |
1903 (if non-strict-p | |
1904 (if (looking-at "^[ \t]*%") | |
1905 t | |
1906 nil | |
1907 ) | |
1908 nil | |
1909 );; if | |
1910 );; if | |
1911 );; save-excursion | |
1912 );; let | |
1913 );; e-in-quoted-string | |
1914 | |
1915 ;;; ---------------------------------------------------------------------- | |
1916 ;;; End of portion derived from "eiffel.el" | |
1917 ;;; ---------------------------------------------------------------------- | |
1918 | |
1885 (defun eif-comment-prefix () | 1919 (defun eif-comment-prefix () |
1886 "Prefix that starts a comment that begins a line. | 1920 "Prefix that starts a comment that begins a line. |
1887 Comments that are not the only thing on a line return nil as their prefix." | 1921 Comments that are not the only thing on a line return nil as their prefix." |
1888 (save-excursion | 1922 (save-excursion |
1889 (end-of-line) | 1923 (end-of-line) |
1908 ) | 1942 ) |
1909 ) | 1943 ) |
1910 | 1944 |
1911 | 1945 |
1912 (defun eif-auto-fill () | 1946 (defun eif-auto-fill () |
1913 (if (> (current-column) fill-column) | 1947 (let ((fill-prefix (eif-comment-prefix)) (pm (point-marker))) |
1914 (let ((fill-prefix (eif-comment-prefix)) (pm (point-marker))) | 1948 (if (and (> (current-column) fill-column) fill-prefix) |
1915 (if fill-prefix | 1949 (if (string-match "^[ \t]*%" fill-prefix) |
1916 (if (string-match "^[ \t]*%" fill-prefix) | 1950 (progn |
1917 (progn | |
1918 (backward-char 1) | |
1919 (re-search-backward "[^][a-zA-Z0-9]" nil t) | |
1920 (forward-char 1) | |
1921 (insert "%\n") | |
1922 (insert fill-prefix) | |
1923 (goto-char pm) | |
1924 ) | |
1925 ;; (do-auto-fill) | |
1926 (backward-char 1) | 1951 (backward-char 1) |
1927 (re-search-backward "\\s-" nil t) | 1952 (re-search-backward "[^][a-zA-Z0-9]" nil t) |
1928 (forward-char 1) | 1953 (forward-char 1) |
1929 (insert "\n") | 1954 (insert "%\n") |
1930 (insert fill-prefix) | 1955 (insert fill-prefix) |
1931 (goto-char pm) | 1956 (goto-char pm) |
1932 ) | 1957 ) |
1958 ;; (do-auto-fill) | |
1959 (backward-char 1) | |
1960 (re-search-backward "\\s-" nil t) | |
1961 (forward-char 1) | |
1962 (insert "\n") | |
1963 (insert fill-prefix) | |
1964 (goto-char pm) | |
1933 ) | 1965 ) |
1934 ) | 1966 ) |
1935 ) | 1967 ) |
1936 ) | 1968 ) |
1937 | 1969 |
1938 (defun eif-fill-paragraph () | 1970 (defun eif-fill-paragraph () |
1939 "Textually fills Eiffel comments ala fill-paragraph" | 1971 "Textually fills Eiffel comments ala fill-paragraph" |
1989 (interactive) | 2021 (interactive) |
1990 (insert "\n") | 2022 (insert "\n") |
1991 (eif-indent-line) | 2023 (eif-indent-line) |
1992 ) | 2024 ) |
1993 | 2025 |
2026 (defun eif-indent-and-newline () | |
2027 "Indent the current line. Insert a newline and indent the new line." | |
2028 (interactive) | |
2029 (eif-indent-line) | |
2030 (insert "\n") | |
2031 (eif-indent-line) | |
2032 ) | |
2033 | |
1994 (defun eif-indent-line (&optional whole-exp) | 2034 (defun eif-indent-line (&optional whole-exp) |
1995 "Indent the current line as Eiffel code. | 2035 "Indent the current line as Eiffel code. |
1996 With argument, indent any additional lines of the same clause | 2036 With argument, indent any additional lines of the same clause |
1997 rigidly along with this one (not implemented yet)." | 2037 rigidly along with this one (not implemented yet)." |
1998 (interactive "p") | 2038 (interactive "p") |
2007 ) | 2047 ) |
2008 ) | 2048 ) |
2009 ) | 2049 ) |
2010 ) | 2050 ) |
2011 (skip-chars-forward " \t")) | 2051 (skip-chars-forward " \t")) |
2012 | |
2013 ;; ENHANCEME: Currently eif-beginning-of-feature only works for routines. | |
2014 ;; It should be made more general. | |
2015 ;; | |
2016 | |
2017 (defun eif-beginning-of-feature (&optional arg) | |
2018 "Move backward to next feature beginning. With argument, do this that many | |
2019 times. Returns t unless search stops due to beginning of buffer." | |
2020 (interactive "p") | |
2021 (and arg (< arg 0) (forward-char 1)) | |
2022 (if (or (re-search-backward eif-multiline-routine-is-keyword-regexp | |
2023 nil t (or arg 1)) | |
2024 (re-search-backward eif-is-keyword-regexp | |
2025 nil 'move (or arg 1)) | |
2026 ) | |
2027 (progn | |
2028 (backward-sexp 1) | |
2029 (if (looking-at "(") | |
2030 (backward-word 1) | |
2031 ) | |
2032 (beginning-of-line) | |
2033 ) | |
2034 nil | |
2035 ) | |
2036 ) | |
2037 | 2052 |
2038 (defun eif-move-to-prev-non-blank () | 2053 (defun eif-move-to-prev-non-blank () |
2039 "Moves point to previous line excluding blank lines. | 2054 "Moves point to previous line excluding blank lines. |
2040 Returns t if successful, nil if not." | 2055 Returns t if successful, nil if not." |
2041 (beginning-of-line) | 2056 (beginning-of-line) |
2157 indent | 2172 indent |
2158 ) | 2173 ) |
2159 ) | 2174 ) |
2160 | 2175 |
2161 ;;; ---------------------------------------------------------------------- | 2176 ;;; ---------------------------------------------------------------------- |
2162 ;;; The portion of the file below this point is derived from "eif-mult-fmt.el" | 2177 ;;; The function below is derived from "eif-mult-fmt.el" |
2163 ;;; Copyright (C) 1985 Free Software Foundation, Inc. | 2178 ;;; Copyright (C) 1985 Free Software Foundation, Inc. |
2164 ;;; Copyright (C) 1990 Bob Weiner, Motorola Inc. | 2179 ;;; Copyright (C) 1990 Bob Weiner, Motorola Inc. |
2165 ;;; Available for use and distribution under the same terms as GNU Emacs. | 2180 ;;; Available for use and distribution under the same terms as GNU Emacs. |
2166 ;;; ---------------------------------------------------------------------- | 2181 ;;; ---------------------------------------------------------------------- |
2167 | 2182 |