Trailing whitepace deleted.
[bpt/emacs.git] / lisp / progmodes / meta-mode.el
index ec53cd1..fc34a2a 100644 (file)
 ;; package or as a separate Emacs Lisp package.
 
 ;; Installation:
-;; 
+;;
 ;; An interface to running Metafont or MetaPost as a shell process
 ;; from within Emacs is currently under development as a separate
 ;; Emacs Lisp package (meta-buf.el).  In order to have that package
 ;; loaded automatically when first entering Metafont or MetaPost mode,
 ;; you might use the load-hook provided in this package by adding
 ;; these lines to your startup file:
-;; 
-;;  (add-hook 'meta-mode-load-hook 
+;;
+;;  (add-hook 'meta-mode-load-hook
 ;;            '(lambda () (require 'meta-buf)))
 ;;
 ;; The add-on package loaded this way may in turn make use of the
@@ -72,7 +72,7 @@
 ;; global-font-lock-mode or font-lock-support-mode, you can also
 ;; activate fontification in Metafont and/or MetaPost mode by adding
 ;; the following lines to your startup file:
-;; 
+;;
 ;;  (add-hook 'meta-common-mode-hook 'turn-on-font-lock)
 ;;  (add-hook 'meta-common-mode-hook 'turn-on-lazy-lock)
 
 ;;                          Improved and debbuged indentation function.
 ;; v 0.4 -- 1997/02/18  UV  Added functions to indent regions for M-C-q,
 ;;                          also added a preliminary mode-specific menu.
-;; v 0.5 -- 1997/02/19  UV  Added functions to skip to next or previous 
+;; v 0.5 -- 1997/02/19  UV  Added functions to skip to next or previous
 ;;                          defun and to re-indent or comment-out defuns.
 ;; v 0.6 -- 1997/02/20  UV  More debugging, testing and clean-up.
 ;; v 0.7 -- 1997/02/22  UV  Use easymenu to define mode-specific menu.
                '((1 font-lock-keyword-face)
                  (2 font-lock-constant-face)))
          ;; embedded Metafont/MetaPost code in comments
-         (cons "|\\([^|]+\\)|" 
+         (cons "|\\([^|]+\\)|"
                '(1 font-lock-constant-face t))
      ))
   "Default expressions to highlight in Metafont or MetaPost mode.")
 ;;   grep '^primitive' texk-7.0/web2c/{mf,mp}.web |\
 ;;   sed 's/primitive(\("[a-zA-Z]*"\).*/\1/' > {mf,mp}_prim.list
 ;;
-;;   grep '\(let\|def\|vardef\|primarydef\|secondarydef\|tertiarydef\)' 
+;;   grep '\(let\|def\|vardef\|primarydef\|secondarydef\|tertiarydef\)'
 ;;     texmf/meta{font,post}/plain.{mf,mp} > {mf,mp}_plain.list
 
-(defconst meta-common-primitives-list 
+(defconst meta-common-primitives-list
   '("ASCII" "addto" "also" "and" "angle" "atleast" "batchmode"
     "begingroup" "boolean" "boundarychar" "char" "charcode" "chardp"
     "charexists" "charext" "charht" "charic" "charlist" "charwd"
     "transform" "transformed" "true" "turningnumber" "uniformdeviate"
     "unknown" "until" "vardef" "warningcheck" "withpen" "xpart"
     "xscaled" "xxpart" "xypart" "year" "ypart" "yscaled" "yxpart"
-    "yypart" "zscaled") 
+    "yypart" "zscaled")
   "List of primitives common to Metafont and MetaPost.")
 
-(defconst metafont-primitives-list 
+(defconst metafont-primitives-list
   '("at" "autorounding" "chardx" "chardy" "cull" "display"
     "dropping" "fillin" "from" "granularity" "hppp" "inwindow"
     "keeping" "numspecial" "openwindow" "proofing" "smoothing"
     "withweight" "xoffset" "yoffset")
   "List of primitives only defined in Metafont.")
 
-(defconst metapost-primitives-list 
+(defconst metapost-primitives-list
   '("arclength" "arctime" "bluepart" "bounded" "btex" "clip"
     "clipped" "color" "dashed" "dashpart" "etex" "filled" "fontpart"
     "fontsize" "greenpart" "infont" "linecap" "linejoin" "llcorner"
     "verbatimtex" "withcolor" "within" "write")
   "List of primitives only defined in MetaPost.")
 
-(defconst meta-common-plain-macros-list 
+(defconst meta-common-plain-macros-list
   '( "abs" "bot" "bye" "byte" "ceiling" "clear_pen_memory"
      "clearit" "clearpen" "clearxy" "counterclockwise" "cutdraw" "decr"
      "dir" "direction" "directionpoint" "div" "dotprod" "downto" "draw"
      "unitvector" "upto" "whatever")
   "List of macros common to plain Metafont and MetaPost.")
 
-(defconst metafont-plain-macros-list 
+(defconst metafont-plain-macros-list
   '("beginchar" "change_width" "culldraw" "cullit" "cutoff"
     "define_blacker_pixels" "define_corrected_pixels"
     "define_good_x_pixels" "define_good_y_pixels"
     "mode_proof" "mode_setup" "mode_smoke" "nodisplays" "notransforms"
     "openit" "penrazor" "pensquare" "proofoffset" "proofrule"
     "proofrulethickness" "screenchars" "screenrule" "screenstrokes"
-    "showit" "slantfont" "smode" "titlefont" "vround") 
+    "showit" "slantfont" "smode" "titlefont" "vround")
   "List of macros only defined in plain Metafont.")
 
-(defconst metapost-plain-macros-list 
+(defconst metapost-plain-macros-list
   '("arrowhead" "bbox" "beginfig" "buildcycle" "center" "cutafter"
     "cutbefore" "dashpattern" "dotlabel" "dotlabels" "drawarrow"
     "drawdblarrow" "drawoptions" "endfig" "image" "label" "off" "on"
-    "thelabel") 
+    "thelabel")
   "List of macros only defined in plain MetaPost.")
 
-(defconst metapost-graph-macros-list 
-  '("augment" "auto.x" "auto.y" "autogrid" "begingraph" "endgraph" 
-    "format" "frame" "gdata" "gdotlabel" "gdraw" "gdrawarrow" 
-    "gdrawdblarrow" "gfill" "glabel" "grid" "itick" "otick" "plot" 
+(defconst metapost-graph-macros-list
+  '("augment" "auto.x" "auto.y" "autogrid" "begingraph" "endgraph"
+    "format" "frame" "gdata" "gdotlabel" "gdraw" "gdrawarrow"
+    "gdrawdblarrow" "gfill" "glabel" "grid" "itick" "otick" "plot"
     "setcoords" "setrange")
   "List of macros only defined in MetaPost \"graph\" package.")
-  
-(defconst metapost-boxes-macros-list 
+
+(defconst metapost-boxes-macros-list
   '("boxit" "boxjoin" "bpath" "circleit" "drawboxed" "drawboxes"
     "drawunboxed" "fixpos" "fixsize" "pic" "rboxit")
   "List of macros only defined in MetaPost \"boxes\" package.")
 (defvar meta-symbol-list nil
   "List of known symbols to complete in Metafont or MetaPost mode.")
 
-(defvar meta-symbol-changed nil 
+(defvar meta-symbol-changed nil
   "Flag indicating whether `meta-symbol-list' has been initialized.")
 
 (defvar meta-complete-list nil
@@ -517,7 +517,7 @@ If the list was changed, sort the list and remove duplicates first."
   ;; utility function used in `meta-complete-symbol'
   (let ((pos (point)))
     (save-excursion
-      (and (re-search-backward 
+      (and (re-search-backward
             regexp (if limit (max (point-min) (- (point) limit))) t)
            (eq (match-end 0) pos)))))
 
@@ -585,7 +585,7 @@ If the list was changed, sort the list and remove duplicates first."
            (looking-at meta-left-comment-regexp))
       (current-column)
     (skip-chars-backward "\t ")
-    (max (if (bolp) 0 (1+ (current-column))) 
+    (max (if (bolp) 0 (1+ (current-column)))
          comment-column)))
 
 (defun meta-indent-line ()
@@ -605,7 +605,7 @@ If the list was changed, sort the list and remove duplicates first."
   "Return the indentation of current line of Metafont or MetaPost source."
   (save-excursion
     (back-to-indentation)
-    (cond 
+    (cond
       ;; Comments to the left margin.
      ((and meta-left-comment-regexp
            (looking-at meta-left-comment-regexp))
@@ -615,15 +615,15 @@ If the list was changed, sort the list and remove duplicates first."
            (looking-at meta-right-comment-regexp))
       comment-column)
      ;; Comments best left alone.
-     ((and meta-ignore-comment-regexp 
+     ((and meta-ignore-comment-regexp
            (looking-at meta-ignore-comment-regexp))
       (current-indentation))
      ;; Backindent at end of environments.
-     ((looking-at 
+     ((looking-at
        (concat "\\<" meta-end-environment-regexp "\\>"))
       (- (meta-indent-calculate-last) meta-indent-level))
      ;; Backindent at keywords within environments.
-     ((looking-at 
+     ((looking-at
        (concat "\\<" meta-within-environment-regexp "\\>"))
       (- (meta-indent-calculate-last) meta-indent-level))
      (t (meta-indent-calculate-last)))))
@@ -645,11 +645,11 @@ If the list was changed, sort the list and remove duplicates first."
            (meta-indent-level-count)
            (cond
             ;; Compensate for backindent at end of environments.
-            ((looking-at 
+            ((looking-at
               (concat "\\<"meta-end-environment-regexp "\\>"))
              meta-indent-level)
             ;; Compensate for backindent within environments.
-            ((looking-at 
+            ((looking-at
               (concat "\\<" meta-within-environment-regexp "\\>"))
              meta-indent-level)
             (t 0)))))
@@ -660,7 +660,7 @@ If the list was changed, sort the list and remove duplicates first."
   (save-excursion
     (save-restriction
       (let ((count 0))
-        (narrow-to-region 
+        (narrow-to-region
          (point) (save-excursion
                    (re-search-forward "[^\\\\\"]%\\|\n\\|\\'" nil t)
                    (backward-char) (point)))
@@ -669,12 +669,12 @@ If the list was changed, sort the list and remove duplicates first."
             (goto-char (match-beginning 0))
             (cond
              ;; Count number of begin-end keywords within line.
-             ((looking-at 
+             ((looking-at
                (concat "\\<" meta-begin-environment-regexp "\\>"))
               (setq count (+ count meta-indent-level)))
-             ((looking-at 
+             ((looking-at
                (concat "\\<" meta-end-environment-regexp "\\>"))
-              (setq count (- count meta-indent-level)))     
+              (setq count (- count meta-indent-level)))
              ;; Count number of open-close parentheses within line.
              ((looking-at "(")
               (setq count (+ count meta-indent-level)))
@@ -704,9 +704,9 @@ and initial semicolons."
        ;; A line with nothing but a comment on it?
        ((looking-at (concat "[ \t]*" comment-start-skip))
         (setq has-comment t)
-        (setq comment-fill-prefix 
+        (setq comment-fill-prefix
               (buffer-substring (match-beginning 0) (match-end 0))))
-       ;; A line with some code, followed by a comment?  
+       ;; A line with some code, followed by a comment?
        ((condition-case nil
             (save-restriction
               (narrow-to-region (point-min)
@@ -718,7 +718,7 @@ and initial semicolons."
                  ((eq (char-after (point)) ?\") (forward-sexp 1))))
               (looking-at comment-start-skip))
           (error nil))
-        (setq has-comment t 
+        (setq has-comment t
               has-code-and-comment t)
         (setq comment-fill-prefix
               (concat (make-string (/ (current-column) 8) ?\t)
@@ -736,7 +736,7 @@ and initial semicolons."
            (save-excursion
              (while (and (zerop (forward-line -1))
                          (looking-at (concat "^[ \t]*" comment-start))))
-             (or (looking-at (concat ".*" comment-start)) 
+             (or (looking-at (concat ".*" comment-start))
                  (forward-line 1))
              (point))
            ;; Find the beginning of the first line past the region to fill.
@@ -744,9 +744,9 @@ and initial semicolons."
              (while (progn (forward-line 1)
                            (looking-at (concat "^[ \t]*" comment-start))))
              (point)))
-          (let* ((paragraph-start 
+          (let* ((paragraph-start
                   (concat paragraph-start "\\|[ \t%]*$"))
-                 (paragraph-separate  
+                 (paragraph-separate
                   (concat paragraph-start "\\|[ \t%]*$"))
                  (paragraph-ignore-fill-prefix nil)
                  (fill-prefix comment-fill-prefix)
@@ -789,21 +789,21 @@ and initial semicolons."
 
 (defun meta-beginning-of-defun (&optional arg)
   "Move backward to beginnning of a defun in Metafont or MetaPost code.
-With numeric argument, do it that many times.  
+With numeric argument, do it that many times.
 Negative arg -N means move forward to Nth following beginning of defun.
 Returns t unless search stops due to beginning or end of buffer."
   (interactive "p")
   (if (or (null arg) (= 0 arg)) (setq arg 1))
   (and arg (< arg 0) (not (eobp)) (forward-char 1))
-  (and (re-search-backward 
+  (and (re-search-backward
         (concat "\\<" meta-begin-defun-regexp "\\>") nil t arg)
        (progn (goto-char (match-beginning 0))
               (skip-chars-backward "%")
               (skip-chars-backward " \t") t)))
-      
+
 (defun meta-end-of-defun (&optional arg)
   "Move forward to end of a defun in Metafont or MetaPost code.
-With numeric argument, do it that many times. 
+With numeric argument, do it that many times.
 Negative argument -N means move back to Nth preceding end of defun.
 Returns t unless search stops due to beginning or end of buffer."
   (interactive "p")
@@ -926,7 +926,7 @@ The environment marked is the one that contains point or follows point."
     ()
   (setq meta-mode-map (make-sparse-keymap))
   (define-key meta-mode-map "\t"        'meta-indent-line)
-  (define-key meta-mode-map "\C-m"      'reindent-then-newline-and-indent)  
+  (define-key meta-mode-map "\C-m"      'reindent-then-newline-and-indent)
   ;; Comment Paragraphs:
 ; (define-key meta-mode-map "\M-a"      'backward-sentence)
 ; (define-key meta-mode-map "\M-e"      'forward-sentence)
@@ -950,11 +950,11 @@ The environment marked is the one that contains point or follows point."
   (define-key meta-mode-map "\M-\t"     'meta-complete-symbol)
   ;; Shell Commands:
 ; (define-key meta-mode-map "\C-c\C-c"  'meta-command-file)
-; (define-key meta-mode-map "\C-c\C-k"  'meta-kill-job)            
+; (define-key meta-mode-map "\C-c\C-k"  'meta-kill-job)
 ; (define-key meta-mode-map "\C-c\C-l"  'meta-recenter-output)
   )
 
-(easy-menu-define 
+(easy-menu-define
  meta-mode-menu meta-mode-map
  "Menu used in Metafont or MetaPost mode."
  (list "Meta"
@@ -963,15 +963,15 @@ The environment marked is the one that contains point or follows point."
        "--"
        ["Indent Line"                   meta-indent-line t]
        ["Indent Environment"            meta-indent-defun t]
-       ["Indent Region"                 meta-indent-region 
+       ["Indent Region"                 meta-indent-region
         :active (meta-mark-active)]
        ["Indent Buffer"                 meta-indent-buffer t]
        "--"
        ["Comment Out Environment"       meta-comment-defun t]
        ["Uncomment Environment"         meta-uncomment-defun t]
-       ["Comment Out Region"            meta-comment-region 
+       ["Comment Out Region"            meta-comment-region
         :active (meta-mark-active)]
-       ["Uncomment Region"              meta-uncomment-region 
+       ["Uncomment Region"              meta-uncomment-region
         :active (meta-mark-active)]
        "--"
        ["Complete Symbol"               meta-complete-symbol t]
@@ -1019,9 +1019,9 @@ The environment marked is the one that contains point or follows point."
 
   (make-local-variable 'paragraph-start)
   (make-local-variable 'paragraph-separate)
-  (setq paragraph-start 
+  (setq paragraph-start
         (concat page-delimiter "\\|$"))
-  (setq paragraph-separate 
+  (setq paragraph-separate
         (concat page-delimiter "\\|$"))
 
   (make-local-variable 'paragraph-ignore-fill-prefix)