Mercurial > emacs
comparison lisp/progmodes/idlwave.el @ 70572:d6353257b05e
(idlwave-push-mark): Removed obsolete compatibility function (Emacs 18/19).
(idlwave-is-continuation-line): Always return point at start of previous
non-blank continuation line.
`keyword-parameters': Fix continued comment font-lock matcher.
(idlwave-font-lock-fontify-region): Written, use as
font-lock-fontify-region-function, to fix continued keyword
fontification issues.
author | J.D. Smith <jdsmith@as.arizona.edu> |
---|---|
date | Wed, 10 May 2006 18:24:15 +0000 |
parents | 84de63539ab8 |
children | 81a55a7dc3c3 b6689e223e2f 146cd8369025 |
comparison
equal
deleted
inserted
replaced
70571:8d0fb9ce2523 | 70572:d6353257b05e |
---|---|
1206 ;; Keyword parameters, like /xlog or ,xrange=[] | 1206 ;; Keyword parameters, like /xlog or ,xrange=[] |
1207 ;; This is anchored to the comma preceeding the keyword. | 1207 ;; This is anchored to the comma preceeding the keyword. |
1208 ;; Treats continuation lines, works only during whole buffer | 1208 ;; Treats continuation lines, works only during whole buffer |
1209 ;; fontification. Slow, use it only in fancy fontification. | 1209 ;; fontification. Slow, use it only in fancy fontification. |
1210 (keyword-parameters | 1210 (keyword-parameters |
1211 '("\\(,\\|[a-zA-Z0-9_](\\)[ \t]*\\(\\$[ \t]*\\(;.*\\)?\\(\n[ \t]*;.*\\)*\n[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)" | 1211 '("\\(,\\|[a-zA-Z0-9_](\\)[ \t]*\\(\\$[ \t]*\\(;.*\\)?\n\\([ \t]*\\(;.*\\)?\n\\)*[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)" |
1212 (5 font-lock-reference-face))) | 1212 (6 font-lock-reference-face))) |
1213 | 1213 |
1214 ;; System variables start with a bang. | 1214 ;; System variables start with a bang. |
1215 (system-variables | 1215 (system-variables |
1216 '("\\(![a-zA-Z_0-9]+\\(\\.\\sw+\\)?\\)" | 1216 '("\\(![a-zA-Z_0-9]+\\(\\.\\sw+\\)?\\)" |
1217 (1 font-lock-variable-name-face))) | 1217 (1 font-lock-variable-name-face))) |
1913 (make-local-variable idlwave-comment-indent-function) | 1913 (make-local-variable idlwave-comment-indent-function) |
1914 (set idlwave-comment-indent-function 'idlwave-comment-hook) | 1914 (set idlwave-comment-indent-function 'idlwave-comment-hook) |
1915 | 1915 |
1916 (set (make-local-variable 'comment-start-skip) ";+[ \t]*") | 1916 (set (make-local-variable 'comment-start-skip) ";+[ \t]*") |
1917 (set (make-local-variable 'comment-start) ";") | 1917 (set (make-local-variable 'comment-start) ";") |
1918 (set (make-local-variable 'comment-add) 1) ; ";;" for new and regions | |
1918 (set (make-local-variable 'require-final-newline) t) | 1919 (set (make-local-variable 'require-final-newline) t) |
1919 (set (make-local-variable 'abbrev-all-caps) t) | 1920 (set (make-local-variable 'abbrev-all-caps) t) |
1920 (set (make-local-variable 'indent-tabs-mode) nil) | 1921 (set (make-local-variable 'indent-tabs-mode) nil) |
1921 (set (make-local-variable 'completion-ignore-case) t) | 1922 (set (make-local-variable 'completion-ignore-case) t) |
1922 | 1923 |
1945 | 1946 |
1946 ;; Font-lock additions - originally Phil Williams, then Ulrik Dickow | 1947 ;; Font-lock additions - originally Phil Williams, then Ulrik Dickow |
1947 ;; Following line is for Emacs - XEmacs uses the corresponding property | 1948 ;; Following line is for Emacs - XEmacs uses the corresponding property |
1948 ;; on the `idlwave-mode' symbol. | 1949 ;; on the `idlwave-mode' symbol. |
1949 (set (make-local-variable 'font-lock-defaults) idlwave-font-lock-defaults) | 1950 (set (make-local-variable 'font-lock-defaults) idlwave-font-lock-defaults) |
1951 (set (make-local-variable 'font-lock-mark-block-function) | |
1952 'idlwave-mark-subprogram) | |
1953 (set (make-local-variable 'font-lock-fontify-region-function) | |
1954 'idlwave-font-lock-fontify-region) | |
1950 | 1955 |
1951 ;; Imenu setup | 1956 ;; Imenu setup |
1952 (set (make-local-variable 'imenu-create-index-function) | 1957 (set (make-local-variable 'imenu-create-index-function) |
1953 'imenu-default-create-index-function) | 1958 'imenu-default-create-index-function) |
1954 (set (make-local-variable 'imenu-extract-index-name-function) | 1959 (set (make-local-variable 'imenu-extract-index-name-function) |
1955 'idlwave-unit-name) | 1960 'idlwave-unit-name) |
1956 (set (make-local-variable 'imenu-prev-index-position-function) | 1961 (set (make-local-variable 'imenu-prev-index-position-function) |
1957 'idlwave-prev-index-position) | 1962 'idlwave-prev-index-position) |
1963 | |
1964 ;; HideShow setup | |
1965 (add-to-list 'hs-special-modes-alist | |
1966 (list 'idlwave-mode | |
1967 idlwave-begin-block-reg | |
1968 idlwave-end-block-reg | |
1969 ";" | |
1970 'idlwave-forward-block nil)) | |
1971 | |
1958 | 1972 |
1959 ;; Make a local post-command-hook and add our hook to it | 1973 ;; Make a local post-command-hook and add our hook to it |
1960 ;; NB: `make-local-hook' needed for older/alternative Emacs compatibility | 1974 ;; NB: `make-local-hook' needed for older/alternative Emacs compatibility |
1961 ;; (make-local-hook 'post-command-hook) | 1975 ;; (make-local-hook 'post-command-hook) |
1962 (add-hook 'post-command-hook 'idlwave-command-hook nil 'local) | 1976 (add-hook 'post-command-hook 'idlwave-command-hook nil 'local) |
1998 idlwave-path-file | 2012 idlwave-path-file |
1999 idlwave-config-directory)) | 2013 idlwave-config-directory)) |
2000 (idlwave-read-paths) ; we may need these early | 2014 (idlwave-read-paths) ; we may need these early |
2001 (setq idlwave-setup-done t))) | 2015 (setq idlwave-setup-done t))) |
2002 | 2016 |
2017 (defun idlwave-font-lock-fontify-region (beg end &optional verbose) | |
2018 "Fontify continuation lines correctly." | |
2019 (let (pos) | |
2020 (save-excursion | |
2021 (goto-char beg) | |
2022 (forward-line -1) | |
2023 (when (setq pos (idlwave-is-continuation-line)) | |
2024 (goto-char pos) | |
2025 (idlwave-beginning-of-statement) | |
2026 (setq beg (point))))) | |
2027 (font-lock-default-fontify-region beg end verbose)) | |
2028 | |
2003 ;; | 2029 ;; |
2004 ;; Code Formatting ---------------------------------------------------- | 2030 ;; Code Formatting ---------------------------------------------------- |
2005 ;; | 2031 ;; |
2006 | |
2007 (defun idlwave-push-mark (&rest rest) | |
2008 "Push mark for compatibility with Emacs 18/19." | |
2009 (if (fboundp 'iconify-frame) | |
2010 (apply 'push-mark rest) | |
2011 (push-mark))) | |
2012 | 2032 |
2013 (defun idlwave-hard-tab () | 2033 (defun idlwave-hard-tab () |
2014 "Inserts TAB in buffer in current position." | 2034 "Inserts TAB in buffer in current position." |
2015 (interactive) | 2035 (interactive) |
2016 (insert "\t")) | 2036 (insert "\t")) |
2401 "Mark current IDL statement." | 2421 "Mark current IDL statement." |
2402 (interactive) | 2422 (interactive) |
2403 (idlwave-end-of-statement) | 2423 (idlwave-end-of-statement) |
2404 (let ((end (point))) | 2424 (let ((end (point))) |
2405 (idlwave-beginning-of-statement) | 2425 (idlwave-beginning-of-statement) |
2406 (idlwave-push-mark end nil t))) | 2426 (push-mark end nil t))) |
2407 | 2427 |
2408 (defun idlwave-mark-block () | 2428 (defun idlwave-mark-block () |
2409 "Mark containing block." | 2429 "Mark containing block." |
2410 (interactive) | 2430 (interactive) |
2411 (idlwave-end-of-statement) | 2431 (idlwave-end-of-statement) |
2412 (idlwave-backward-up-block -1) | 2432 (idlwave-backward-up-block -1) |
2413 (idlwave-end-of-statement) | 2433 (idlwave-end-of-statement) |
2414 (let ((end (point))) | 2434 (let ((end (point))) |
2415 (idlwave-backward-block) | 2435 (idlwave-backward-block) |
2416 (idlwave-beginning-of-statement) | 2436 (idlwave-beginning-of-statement) |
2417 (idlwave-push-mark end nil t))) | 2437 (push-mark end nil t))) |
2418 | 2438 |
2419 | 2439 |
2420 (defun idlwave-mark-subprogram () | 2440 (defun idlwave-mark-subprogram () |
2421 "Put mark at beginning of program, point at end. | 2441 "Put mark at beginning of program, point at end. |
2422 The marks are pushed." | 2442 The marks are pushed." |
2423 (interactive) | 2443 (interactive) |
2424 (idlwave-end-of-statement) | 2444 (idlwave-end-of-statement) |
2425 (idlwave-beginning-of-subprogram) | 2445 (idlwave-beginning-of-subprogram) |
2426 (let ((beg (point))) | 2446 (let ((beg (point))) |
2427 (idlwave-forward-block) | 2447 (idlwave-forward-block) |
2428 (idlwave-push-mark beg nil t)) | 2448 (push-mark beg nil t)) |
2429 (exchange-point-and-mark)) | 2449 (exchange-point-and-mark)) |
2430 | 2450 |
2431 (defun idlwave-backward-up-block (&optional arg) | 2451 (defun idlwave-backward-up-block (&optional arg) |
2432 "Move to beginning of enclosing block if prefix ARG >= 0. | 2452 "Move to beginning of enclosing block if prefix ARG >= 0. |
2433 If prefix ARG < 0 then move forward to enclosing block end." | 2453 If prefix ARG < 0 then move forward to enclosing block end." |
2444 "Go to the beginning of the current block." | 2464 "Go to the beginning of the current block." |
2445 (interactive) | 2465 (interactive) |
2446 (idlwave-block-jump-out 1 'nomark) | 2466 (idlwave-block-jump-out 1 'nomark) |
2447 (backward-word 1)) | 2467 (backward-word 1)) |
2448 | 2468 |
2449 (defun idlwave-forward-block () | 2469 (defun idlwave-forward-block (&optional arg) |
2450 "Move across next nested block." | 2470 "Move across next nested block." |
2451 (interactive) | 2471 (interactive) |
2452 (if (idlwave-down-block 1) | 2472 (let ((arg (or arg 1))) |
2453 (idlwave-block-jump-out 1 'nomark))) | 2473 (if (idlwave-down-block arg) |
2474 (idlwave-block-jump-out arg 'nomark)))) | |
2454 | 2475 |
2455 (defun idlwave-backward-block () | 2476 (defun idlwave-backward-block () |
2456 "Move backward across previous nested block." | 2477 "Move backward across previous nested block." |
2457 (interactive) | 2478 (interactive) |
2458 (if (idlwave-down-block -1) | 2479 (if (idlwave-down-block -1) |
2494 (progn | 2515 (progn |
2495 (setq beg (progn (beginning-of-line) (point))) | 2516 (setq beg (progn (beginning-of-line) (point))) |
2496 (if (re-search-forward idlwave-doclib-end nil t) | 2517 (if (re-search-forward idlwave-doclib-end nil t) |
2497 (progn | 2518 (progn |
2498 (forward-line 1) | 2519 (forward-line 1) |
2499 (idlwave-push-mark beg nil t) | 2520 (push-mark beg nil t) |
2500 (message "Could not find end of doc library header."))) | 2521 (message "Could not find end of doc library header."))) |
2501 (message "Could not find doc library header start.") | 2522 (message "Could not find doc library header start.") |
2502 (goto-char here))))) | 2523 (goto-char here))))) |
2503 | |
2504 | 2524 |
2505 (defun idlwave-current-routine () | 2525 (defun idlwave-current-routine () |
2506 "Return (NAME TYPE CLASS) of current routine." | 2526 "Return (NAME TYPE CLASS) of current routine." |
2507 (idlwave-routines) | 2527 (idlwave-routines) |
2508 (save-excursion | 2528 (save-excursion |
3192 | 3212 |
3193 (defun idlwave-is-continuation-line () | 3213 (defun idlwave-is-continuation-line () |
3194 "Tests if current line is continuation line. | 3214 "Tests if current line is continuation line. |
3195 Blank or comment-only lines following regular continuation lines (with | 3215 Blank or comment-only lines following regular continuation lines (with |
3196 `$') count as continuations too." | 3216 `$') count as continuations too." |
3197 (save-excursion | 3217 (let (p) |
3198 (or | 3218 (save-excursion |
3199 (idlwave-look-at "\\<\\$") | 3219 (or |
3200 (catch 'loop | 3220 (idlwave-look-at "\\<\\$") |
3201 (while (and (looking-at "^[ \t]*\\(;.*\\)?$") | 3221 (catch 'loop |
3202 (eq (forward-line -1) 0)) | 3222 (while (and (looking-at "^[ \t]*\\(;.*\\)?$") |
3203 (if (idlwave-look-at "\\<\\$") (throw 'loop t))))))) | 3223 (eq (forward-line -1) 0)) |
3224 (if (setq p (idlwave-look-at "\\<\\$")) (throw 'loop p)))))))) | |
3204 | 3225 |
3205 (defun idlwave-is-comment-line () | 3226 (defun idlwave-is-comment-line () |
3206 "Tests if the current line is a comment line." | 3227 "Tests if the current line is a comment line." |
3207 (save-excursion | 3228 (save-excursion |
3208 (beginning-of-line 1) | 3229 (beginning-of-line 1) |