changeset 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 8d0fb9ce2523
children b79a60a5fdeb
files lisp/progmodes/idlwave.el
diffstat 1 files changed, 44 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/progmodes/idlwave.el	Wed May 10 18:22:56 2006 +0000
+++ b/lisp/progmodes/idlwave.el	Wed May 10 18:24:15 2006 +0000
@@ -1208,8 +1208,8 @@
        ;; Treats continuation lines, works only during whole buffer
        ;; fontification.  Slow, use it only in fancy fontification.
        (keyword-parameters
-	'("\\(,\\|[a-zA-Z0-9_](\\)[ \t]*\\(\\$[ \t]*\\(;.*\\)?\\(\n[ \t]*;.*\\)*\n[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)"
-	  (5 font-lock-reference-face)))
+	'("\\(,\\|[a-zA-Z0-9_](\\)[ \t]*\\(\\$[ \t]*\\(;.*\\)?\n\\([ \t]*\\(;.*\\)?\n\\)*[ \t]*\\)?\\(/[a-zA-Z_]\\sw*\\|[a-zA-Z_]\\sw*[ \t]*=\\)"
+	  (6 font-lock-reference-face)))
 
        ;; System variables start with a bang.
        (system-variables
@@ -1915,6 +1915,7 @@
   
   (set (make-local-variable 'comment-start-skip) ";+[ \t]*")
   (set (make-local-variable 'comment-start) ";")
+  (set (make-local-variable 'comment-add) 1) ; ";;" for new and regions
   (set (make-local-variable 'require-final-newline) t)
   (set (make-local-variable 'abbrev-all-caps) t)
   (set (make-local-variable 'indent-tabs-mode) nil)
@@ -1947,6 +1948,10 @@
   ;; Following line is for Emacs - XEmacs uses the corresponding property
   ;; on the `idlwave-mode' symbol.
   (set (make-local-variable 'font-lock-defaults) idlwave-font-lock-defaults)
+  (set (make-local-variable 'font-lock-mark-block-function)
+       'idlwave-mark-subprogram)
+  (set (make-local-variable 'font-lock-fontify-region-function)
+       'idlwave-font-lock-fontify-region)
 
   ;; Imenu setup
   (set (make-local-variable 'imenu-create-index-function)
@@ -1956,6 +1961,15 @@
   (set (make-local-variable 'imenu-prev-index-position-function)
        'idlwave-prev-index-position)
 
+  ;; HideShow setup
+  (add-to-list 'hs-special-modes-alist
+	       (list 'idlwave-mode
+		     idlwave-begin-block-reg
+		     idlwave-end-block-reg
+		     ";"
+		     'idlwave-forward-block nil))
+  
+
   ;; Make a local post-command-hook and add our hook to it
   ;; NB: `make-local-hook' needed for older/alternative Emacs compatibility
   ;; (make-local-hook 'post-command-hook)
@@ -2000,16 +2014,22 @@
     (idlwave-read-paths)  ; we may need these early
     (setq idlwave-setup-done t)))
 
+(defun idlwave-font-lock-fontify-region (beg end &optional verbose)
+  "Fontify continuation lines correctly."
+  (let (pos)
+    (save-excursion
+      (goto-char beg)
+      (forward-line -1)
+      (when (setq pos (idlwave-is-continuation-line))
+	(goto-char pos)
+	(idlwave-beginning-of-statement)
+	(setq beg (point)))))
+  (font-lock-default-fontify-region beg end verbose))
+
 ;;
 ;; Code Formatting ----------------------------------------------------
 ;; 
 
-(defun idlwave-push-mark (&rest rest)
-  "Push mark for compatibility with Emacs 18/19."
-  (if (fboundp 'iconify-frame)
-      (apply 'push-mark rest)
-    (push-mark)))
-
 (defun idlwave-hard-tab ()
   "Inserts TAB in buffer in current position."
   (interactive)
@@ -2403,7 +2423,7 @@
   (idlwave-end-of-statement)
   (let ((end (point)))
     (idlwave-beginning-of-statement)
-    (idlwave-push-mark end nil t)))
+    (push-mark end nil t)))
 
 (defun idlwave-mark-block ()
   "Mark containing block."
@@ -2414,7 +2434,7 @@
   (let ((end (point)))
     (idlwave-backward-block)
     (idlwave-beginning-of-statement)
-    (idlwave-push-mark end nil t)))
+    (push-mark end nil t)))
 
 
 (defun idlwave-mark-subprogram ()
@@ -2425,7 +2445,7 @@
   (idlwave-beginning-of-subprogram)
   (let ((beg (point)))
     (idlwave-forward-block)
-    (idlwave-push-mark beg nil t))
+    (push-mark beg nil t))
   (exchange-point-and-mark))
 
 (defun idlwave-backward-up-block (&optional arg)
@@ -2446,11 +2466,12 @@
   (idlwave-block-jump-out 1 'nomark)
   (backward-word 1))
 
-(defun idlwave-forward-block ()
+(defun idlwave-forward-block (&optional arg)
   "Move across next nested block."
   (interactive)
-  (if (idlwave-down-block 1)
-      (idlwave-block-jump-out 1 'nomark)))
+  (let ((arg (or arg 1)))
+    (if (idlwave-down-block arg)
+	(idlwave-block-jump-out arg 'nomark))))
 
 (defun idlwave-backward-block ()
   "Move backward across previous nested block."
@@ -2496,12 +2517,11 @@
 	  (if (re-search-forward idlwave-doclib-end nil t)
 	      (progn
 		(forward-line 1)
-		(idlwave-push-mark beg nil t)
+		(push-mark beg nil t)
 		(message "Could not find end of doc library header.")))
 	  (message "Could not find doc library header start.")
 	  (goto-char here)))))
 
-
 (defun idlwave-current-routine ()
   "Return (NAME TYPE CLASS) of current routine."
   (idlwave-routines)
@@ -3194,13 +3214,14 @@
   "Tests if current line is continuation line.
 Blank or comment-only lines following regular continuation lines (with
 `$') count as continuations too."
-  (save-excursion
-    (or 
-     (idlwave-look-at "\\<\\$")
-     (catch 'loop
-       (while (and (looking-at "^[ \t]*\\(;.*\\)?$") 
-		   (eq (forward-line -1) 0))
-	 (if (idlwave-look-at "\\<\\$") (throw 'loop t)))))))
+  (let (p)
+    (save-excursion
+      (or 
+       (idlwave-look-at "\\<\\$")
+       (catch 'loop
+	 (while (and (looking-at "^[ \t]*\\(;.*\\)?$") 
+		     (eq (forward-line -1) 0))
+	   (if (setq p (idlwave-look-at "\\<\\$")) (throw 'loop p))))))))
 
 (defun idlwave-is-comment-line ()
   "Tests if the current line is a comment line."