Diff for /gforth/gforth.el between versions 1.49 and 1.52

version 1.49, 2001/05/06 13:42:56 version 1.52, 2001/06/19 14:49:23
Line 171  PARSED-TYPE specifies what kind of text Line 171  PARSED-TYPE specifies what kind of text
          immediate (font-lock-constant-face . 3))           immediate (font-lock-constant-face . 3))
         ))          ))
   
   (defvar forth-use-objects nil 
     "*Non-nil makes forth-mode also hilight words from the \"Objects\" package.")
 (defvar forth-objects-words nil  (defvar forth-objects-words nil
   "Hilighting description for words of the \"Objects\" OOP package")    "Hilighting description for words of the \"Objects\" package")
 (setq forth-objects-words   (setq forth-objects-words 
       '(((":m") definition-starter (font-lock-keyword-face . 1)        '(((":m") definition-starter (font-lock-keyword-face . 1)
          "[ \t\n]" t name (font-lock-function-name-face . 3))           "[ \t\n]" t name (font-lock-function-name-face . 3))
Line 202  PARSED-TYPE specifies what kind of text Line 204  PARSED-TYPE specifies what kind of text
           "methods" "end-methods" "this")             "methods" "end-methods" "this") 
          non-immediate (font-lock-keyword-face . 2))           non-immediate (font-lock-keyword-face . 2))
         (("object") non-immediate (font-lock-type-face . 2))))          (("object") non-immediate (font-lock-type-face . 2))))
 ; (nconc forth-words forth-objects-words)  
   
   (defvar forth-use-oof nil 
     "*Non-nil makes forth-mode also hilight words from the \"OOF\" package.")
 (defvar forth-oof-words nil  (defvar forth-oof-words nil
   "Hilighting description for words of the \"OOF\" OOP package")    "Hilighting description for words of the \"OOF\" package")
 (setq forth-oof-words   (setq forth-oof-words 
       '((("class") non-immediate (font-lock-keyword-face . 2)        '((("class") non-immediate (font-lock-keyword-face . 2)
          "[ \t\n]" t name (font-lock-type-face . 3))           "[ \t\n]" t name (font-lock-type-face . 3))
Line 223  PARSED-TYPE specifies what kind of text Line 226  PARSED-TYPE specifies what kind of text
           "endwith")            "endwith")
          non-immediate (font-lock-keyword-face . 2))           non-immediate (font-lock-keyword-face . 2))
         (("object") non-immediate (font-lock-type-face . 2))))          (("object") non-immediate (font-lock-type-face . 2))))
 ; (nconc forth-words forth-oof-words)  
   
 (defvar forth-local-words nil   (defvar forth-local-words nil 
   "List of Forth words to prepend to `forth-words'. Should be set by a     "List of Forth words to prepend to `forth-words'. Should be set by a 
 forth source, using a local variables list at the end of the file    forth source, using a local variables list at the end of the file 
 (\"Local Variables: ... forth-local-words: ... End:\" construct).")   (\"Local Variables: ... forth-local-words: ... End:\" construct).") 
   
   (defvar forth-custom-words nil
     "List of Forth words to prepend to `forth-words'. Should be set in your
    .emacs.")
   
 (defvar forth-hilight-level 3 "*Level of hilighting of Forth code.")  (defvar forth-hilight-level 3 "*Level of hilighting of Forth code.")
   
 (defvar forth-compiled-words nil "Compiled representation of `forth-words'.")  (defvar forth-compiled-words nil "Compiled representation of `forth-words'.")
   
   
 ; todo:  ; todo:
 ;  ;
   
Line 241  forth source, using a local variables li Line 249  forth source, using a local variables li
 ; `forth-use-oof' could be set to non-nil for automatical adding of those  ; `forth-use-oof' could be set to non-nil for automatical adding of those
 ; word-lists. Using local variable list?  ; word-lists. Using local variable list?
 ;  ;
 ; Anzeige von Screen-Nummern in Status-Zeile (S???)  
 ;  
 ; Konfiguration über customization groups  ; Konfiguration über customization groups
 ;  ;
 ; Bereich nur auf Wortanfang/ende ausweiten, wenn anfang bzw ende in einem   ; Bereich nur auf Wortanfang/ende ausweiten, wenn anfang bzw ende in einem 
Line 251  forth source, using a local variables li Line 257  forth source, using a local variables li
 ; User interface  ; User interface
 ;  ;
 ; 'forth-word' property muss eindeutig sein!  ; 'forth-word' property muss eindeutig sein!
   ;
   ; imenu support schlauer machen
   
 (setq debug-on-error t)  (setq debug-on-error t)
   
 ;; Filter list by predicat. This is a somewhat standard function for   ;; Filter list by predicate. This is a somewhat standard function for 
 ;; functional programming languages. So why isn't it already implemented   ;; functional programming languages. So why isn't it already implemented 
 ;; in Lisp??  ;; in Lisp??
 (defun forth-filter (predicat list)  (defun forth-filter (predicate list)
   (let ((filtered nil))    (let ((filtered nil))
     (mapcar (lambda (item)      (mapcar (lambda (item)
               (when (funcall predicat item)                (when (funcall predicate item)
                 (if filtered                  (if filtered
                     (nconc filtered (list item))                      (nconc filtered (list item))
                   (setq filtered (cons item nil))))                    (setq filtered (cons item nil))))
Line 312  forth source, using a local variables li Line 320  forth source, using a local variables li
 (defun forth-compile-words ()  (defun forth-compile-words ()
   "Compile the the words from `forth-words' and `forth-indent-words' into    "Compile the the words from `forth-words' and `forth-indent-words' into
  the format that's later used for doing the actual hilighting/indentation.   the format that's later used for doing the actual hilighting/indentation.
 Store the resulting compiled wordlists in `forth-compiled-words' and    Store the resulting compiled wordlists in `forth-compiled-words' and 
 `forth-compiled-indent-words', respective"  `forth-compiled-indent-words', respective"
   (setq forth-compiled-words     (setq forth-compiled-words 
         (forth-compile-wordlist           (forth-compile-wordlist 
Line 321  Store the resulting compiled wordlists i Line 329  Store the resulting compiled wordlists i
         (forth-compile-wordlist forth-indent-words)))          (forth-compile-wordlist forth-indent-words)))
   
 (defun forth-hack-local-variables ()  (defun forth-hack-local-variables ()
   "Parse and bind local variables, set in the contens of the current     "Parse and bind local variables, set in the contents of the current 
 forth-mode buffer. Prepend `forth-local-words' to `forth-words' and    forth-mode buffer. Prepend `forth-local-words' to `forth-words' and 
 `forth-local-indent-words' to `forth-local-words'."   `forth-local-indent-words' to `forth-indent-words'."
   (hack-local-variables)    (hack-local-variables)
   (setq forth-words (append forth-local-words forth-words))    (setq forth-words (append forth-local-words forth-words))
   (setq forth-indent-words (append forth-local-indent-words     (setq forth-indent-words (append forth-local-indent-words 
                                    forth-indent-words)))                                     forth-indent-words)))
   
   (defun forth-customize-words ()
     "Add the words from `forth-custom-words' and `forth-custom-indent-words'
    to `forth-words' and `forth-indent-words', respective. Add 
    `forth-objects-words' and/or `forth-oof-words' to `forth-words', if
    `forth-use-objects' and/or `forth-use-oof', respective is set."
     (setq forth-words (append forth-custom-words forth-words
                               (if forth-use-oof forth-oof-words nil)
                               (if forth-use-objects forth-objects-words nil)))
     (setq forth-indent-words (append 
                               forth-custom-indent-words forth-indent-words)))
   
   
   
 ;; get location of first character of previous forth word that's got   ;; get location of first character of previous forth word that's got 
 ;; properties  ;; properties
 (defun forth-previous-start (pos)  (defun forth-previous-start (pos)
Line 437  forth-mode buffer. Prepend `forth-local- Line 458  forth-mode buffer. Prepend `forth-local-
 ;; Search for known Forth words in the range `from' to `to', using   ;; Search for known Forth words in the range `from' to `to', using 
 ;; `forth-next-known-forth-word' and set their properties via   ;; `forth-next-known-forth-word' and set their properties via 
 ;; `forth-set-word-properties'.  ;; `forth-set-word-properties'.
 (defun forth-update-properties (from to)  (defun forth-update-properties (from to &optional loudly)
   (save-excursion    (save-excursion
     (let ((msg-flag nil) (state) (word-descr) (last-location))      (let ((msg-count 0) (state) (word-descr) (last-location))
       (when (> to (+ from 5000))  
         (setq msg-flag t) (message "Parsing Forth code..."))  
       (goto-char (forth-previous-word (forth-previous-start         (goto-char (forth-previous-word (forth-previous-start 
                                        (max (point-min) (1- from)))))                                         (max (point-min) (1- from)))))
       (setq to (forth-next-end (min (point-max) (1+ to))))        (setq to (forth-next-end (min (point-max) (1+ to))))
Line 452  forth-mode buffer. Prepend `forth-local- Line 471  forth-mode buffer. Prepend `forth-local-
       (forth-delete-properties (point) to)        (forth-delete-properties (point) to)
       ;; hilight loop...        ;; hilight loop...
       (while (setq word-descr (forth-next-known-forth-word to))        (while (setq word-descr (forth-next-known-forth-word to))
           (when loudly
             (when (equal 0 (% msg-count 100))
               (message "Parsing Forth code...%s"
                        (make-string (/ msg-count 100) ?.)))
             (setq msg-count (1+ msg-count)))
         (forth-set-word-properties state word-descr)          (forth-set-word-properties state word-descr)
         (when state (put-text-property last-location (point) 'forth-state t))          (when state (put-text-property last-location (point) 'forth-state t))
         (let ((type (car word-descr)))          (let ((type (car word-descr)))
Line 468  forth-mode buffer. Prepend `forth-local- Line 492  forth-mode buffer. Prepend `forth-local-
                                 to 'forth-state (current-buffer) (point-max))))                                  to 'forth-state (current-buffer) (point-max))))
                 (forth-update-properties to extend-to))                  (forth-update-properties to extend-to))
             ))              ))
       (when msg-flag (message "Parsing Forth code...done"))  
       )))        )))
   
 ;; save-buffer-state borrowed from `font-lock.el'  ;; save-buffer-state borrowed from `font-lock.el'
Line 487  forth-mode buffer. Prepend `forth-local- Line 510  forth-mode buffer. Prepend `forth-local-
 ;; Function that is added to the `change-functions' hook. Calls   ;; Function that is added to the `change-functions' hook. Calls 
 ;; `forth-update-properties' and keeps care of disabling undo information  ;; `forth-update-properties' and keeps care of disabling undo information
 ;; and stuff like that.  ;; and stuff like that.
 (defun forth-change-function (from to len)  (defun forth-change-function (from to len &optional loudly)
   (save-match-data    (save-match-data
     (forth-save-buffer-state ()       (forth-save-buffer-state () 
      (unwind-protect        (unwind-protect 
          (progn            (progn 
            (forth-update-properties from to)             (forth-update-properties from to loudly)
            (forth-update-show-screen)             (forth-update-show-screen)
            (forth-update-warn-long-lines))))))             (forth-update-warn-long-lines))))))
   
Line 503  forth-mode buffer. Prepend `forth-local- Line 526  forth-mode buffer. Prepend `forth-local-
   (byte-compile 'forth-delete-properties)    (byte-compile 'forth-delete-properties)
   (byte-compile 'forth-get-regexp-branch))     (byte-compile 'forth-get-regexp-branch)) 
   
   ;;; imenu support
   ;;;
   (defvar forth-defining-words 
     '("VARIABLE" "CONSTANT" "2VARIABLE" "2CONSTANT" "FVARIABLE" "FCONSTANT"
      "USER" "VALUE" "field" "end-struct" "VOCABULARY" "CREATE" ":" "CODE"
      "DEFER" "ALIAS")
     "List of words, that define the following word.\
    Used for imenu index generation")
   
    
   (defun forth-next-definition-starter ()
     (progn
       (let* ((pos (re-search-forward forth-defining-words-regexp (point-max) t)))
         (if pos
             (if (or (text-property-not-all (match-beginning 0) (match-end 0) 
                                            'forth-parsed nil)
                     (text-property-not-all (match-beginning 0) (match-end 0)
                                            'forth-state nil)) 
                 (forth-next-definition-starter)
               t)
           nil))))
   
   (defun forth-create-index ()
     (let* ((forth-defining-words-regexp 
             (concat "\\<\\(" (regexp-opt forth-defining-words) "\\)\\>"))
            (index nil))
       (goto-char (point-min))
       (while (forth-next-definition-starter)
         (if (looking-at "[ \t]*\\([^ \t\n]+\\)")
             (setq index (cons (cons (match-string 1) (point)) index))))
       index))
   
   (require 'speedbar)
   (speedbar-add-supported-extension ".fs")
   (speedbar-add-supported-extension ".fb")
   
 ;; (require 'profile)  ;; (require 'profile)
 ;; (setq profile-functions-list '(forth-set-word-properties forth-next-known-forth-word forth-update-properties forth-delete-properties forth-get-regexp-branch))  ;; (setq profile-functions-list '(forth-set-word-properties forth-next-known-forth-word forth-update-properties forth-delete-properties forth-get-regexp-branch))
   
Line 560  buffer is created. Should be set by a Fo Line 619  buffer is created. Should be set by a Fo
 list at the end of the file (\"Local Variables: ... forth-local-words: ...   list at the end of the file (\"Local Variables: ... forth-local-words: ... 
 End:\" construct).")  End:\" construct).")
   
   (defvar forth-custom-indent-words nil
     "List of Forth words to prepend to `forth-indent-words'. Should be set in
    your .emacs.")
   
 (defvar forth-indent-level 4  (defvar forth-indent-level 4
   "Indentation of Forth statements.")    "Indentation of Forth statements.")
 (defvar forth-minor-indent-level 2  (defvar forth-minor-indent-level 2
Line 838  screen number." Line 901  screen number."
         (setq overlay-arrow-string forth-overlay-arrow-string)          (setq overlay-arrow-string forth-overlay-arrow-string)
         (goto-line first-line)          (goto-line first-line)
         (setq overlay-arrow-position forth-screen-marker)          (setq overlay-arrow-position forth-screen-marker)
         (when (/= forth-screen-marker (point))          (set-marker forth-screen-marker 
           (message "Entered screen #%i" scr)                      (save-excursion (goto-line first-line) (point)))
           (set-marker forth-screen-marker (point)))))))          (setq forth-screen-number-string (format "%d" scr))))))
   
 (add-hook 'forth-motion-hooks 'forth-update-show-screen)  (add-hook 'forth-motion-hooks 'forth-update-show-screen)
   
Line 929  exceeds 64 characters." Line 992  exceeds 64 characters."
   
 (defun forth-find-tag (tagname &optional next-p regexp-p)  (defun forth-find-tag (tagname &optional next-p regexp-p)
   (interactive (find-tag-interactive "Find tag: "))    (interactive (find-tag-interactive "Find tag: "))
   ;  (when (not regexp-p)
   ;      (setq tagname (concat "^\\(" (regexp-opt (list tagname)) 
   ;                           "\\)$"))
   ;      (setq regexp-p t))
   (switch-to-buffer    (switch-to-buffer
    (find-tag-noselect (concat " " tagname " ") next-p regexp-p)))     (find-tag-noselect (concat " " tagname " ") next-p regexp-p)))
   
Line 984  exceeds 64 characters." Line 1051  exceeds 64 characters."
   (make-local-variable 'forth-show-screen)    (make-local-variable 'forth-show-screen)
   (make-local-variable 'forth-screen-marker)    (make-local-variable 'forth-screen-marker)
   (make-local-variable 'forth-warn-long-lines)    (make-local-variable 'forth-warn-long-lines)
     (make-local-variable 'forth-screen-number-string)
     (make-local-variable 'forth-use-oof)
     (make-local-variable 'forth-use-objects) 
   (setq forth-screen-marker (copy-marker 0))    (setq forth-screen-marker (copy-marker 0))
   (add-hook 'after-change-functions 'forth-change-function))    (add-hook 'after-change-functions 'forth-change-function)
     (setq imenu-create-index-function 'forth-create-index))
   
 ;;;###autoload  ;;;###autoload
 (defun forth-mode ()  (defun forth-mode ()
Line 1024  Variables controlling interaction and st Line 1095  Variables controlling interaction and st
 Variables controlling syntax hilighting/recognition of parsed text:  Variables controlling syntax hilighting/recognition of parsed text:
  `forth-words'   `forth-words'
     List of words that have a special parsing behaviour and/or should be      List of words that have a special parsing behaviour and/or should be
     hilighted.      hilighted. Add custom words by setting forth-custom-words in your
       .emacs, or by setting forth-local-words, in source-files' local 
       variables lists.
    forth-use-objects
       Set this variable to non-nil in your .emacs, or a local variables 
       list, to hilight and recognize the words from the \"Objects\" package 
       for object-oriented programming.
    forth-use-oof
       Same as above, just for the \"OOF\" package.
    forth-custom-words
       List of custom Forth words to prepend to `forth-words'. Should be set
       in your .emacs.
  forth-local-words   forth-local-words
     List of words to prepend to `forth-words', whenever a forth-mode      List of words to prepend to `forth-words', whenever a forth-mode
     buffer is created. That variable should be set by Forth sources, using      buffer is created. That variable should be set by Forth sources, using
Line 1035  Variables controlling syntax hilighting/ Line 1117  Variables controlling syntax hilighting/
        forth-local-words: ...         forth-local-words: ...
        End:         End:
     [THEN]      [THEN]
  forth-objects-words  
     Hilighting information for the words of the \"Objects\" package for   
     object-oriented programming. Append it to `forth-words', if you need   
     it.  
  forth-oof-words  
     Hilighting information for the words of the \"OOF\" package.  
  forth-hilight-level   forth-hilight-level
     Controls how much syntax hilighting is done. Should be in the range       Controls how much syntax hilighting is done. Should be in the range 
       0..3
   
 Variables controlling indentation style:  Variables controlling indentation style:
  `forth-indent-words'   `forth-indent-words'
     List of words that influence indentation.      List of words that influence indentation.
  `forth-local-indent-words'   forth-local-indent-words
     List of words to prepend to `forth-indent-words', similar to       List of words to prepend to `forth-indent-words', similar to 
     `forth-local-words'. Should be used for specifying file-specific       forth-local-words. Should be used for specifying file-specific 
     indentation, using a local variables list.      indentation, using a local variables list.
    forth-custom-indent-words
       List of words to prepend to `forth-indent-words'. Should be set in your
       .emacs.    
  forth-indent-level   forth-indent-level
     Indentation increment/decrement of Forth statements.      Indentation increment/decrement of Forth statements.
  forth-minor-indent-level   forth-minor-indent-level
     Minor indentation increment/decrement of Forth statemens.      Minor indentation increment/decrement of Forth statemens.
   
 Variables controlling block-file editing:  Variables controlling block-file editing:
  `forth-show-screen'   forth-show-screen
     Non-nil means, that the start of the current screen is marked by an      Non-nil means, that the start of the current screen is marked by an
     overlay arrow, and motion over screen boundaries displays the number       overlay arrow, and screen numbers are displayed in the mode line.
     of the screen entered. This variable is by default nil for `forth-mode'       This variable is by default nil for `forth-mode' and t for 
     and t for `forth-block-mode'.      `forth-block-mode'.
  `forth-overlay-arrow-string'   forth-overlay-arrow-string
     String to display as the overlay arrow, when `forth-show-screen' is t.      String to display as the overlay arrow, when `forth-show-screen' is t.
     Setting this variable to nil disables the overlay arrow.      Setting this variable to nil disables the overlay arrow.
  `forth-block-base'   forth-block-base
     Screen number of the first block in a block file. Defaults to 1.      Screen number of the first block in a block file. Defaults to 1.
  `forth-warn-long-lines'   forth-warn-long-lines
     Non-nil means that a warning message is displayed whenever you edit or      Non-nil means that a warning message is displayed whenever you edit or
     move over a line that is longer than 64 characters (the maximum line      move over a line that is longer than 64 characters (the maximum line
     length that can be stored into a block file). This variable defaults to      length that can be stored into a block file). This variable defaults to
Line 1104  Variables controling documentation searc Line 1184  Variables controling documentation searc
 ;      (run-forth forth-program-name))  ;      (run-forth forth-program-name))
   (run-hooks 'forth-mode-hook))    (run-hooks 'forth-mode-hook))
   
   ;;;###autoload
 (define-derived-mode forth-block-mode forth-mode "Forth Block Source"   (define-derived-mode forth-block-mode forth-mode "Forth Block Source" 
   "Major mode for editing Forth block source files, derived from     "Major mode for editing Forth block source files, derived from 
 `forth-mode'. Differences to `forth-mode' are:  `forth-mode'. Differences to `forth-mode' are:
Line 1117  echo area and the line is truncated. Line 1198  echo area and the line is truncated.
   
 Another problem is imposed by block files that contain newline or tab   Another problem is imposed by block files that contain newline or tab 
 characters. When Emacs converts such files back to block file format,   characters. When Emacs converts such files back to block file format, 
 it'll translate those characters to a number of spaces. However, whenever  it'll translate those characters to a number of spaces. However, when
 you read such a file, a warning message is displayed in the echo area,  you read such a file, a warning message is displayed in the echo area,
 including a line number that may help you to locate and fix the problem.  including a line number that may help you to locate and fix the problem.
   
Line 1125  So have a look at the *Messages* buffer, Line 1206  So have a look at the *Messages* buffer,
 bell during block file read/write operations."  bell during block file read/write operations."
   (setq buffer-file-format '(forth-blocks))    (setq buffer-file-format '(forth-blocks))
   (setq forth-show-screen t)    (setq forth-show-screen t)
   (setq forth-warn-long-lines t))    (setq forth-warn-long-lines t)
     (setq forth-screen-number-string (format "%d" forth-block-base))
     (setq mode-line-format (append (reverse (cdr (reverse mode-line-format)))
                                    '("--S" forth-screen-number-string "-%-"))))
   
 (add-hook 'forth-mode-hook  (add-hook 'forth-mode-hook
       '(lambda ()         '(lambda () 
          (make-local-variable 'compile-command)           (make-local-variable 'compile-command)
          (setq compile-command "gforth ")           (setq compile-command "gforth ")
          (forth-hack-local-variables)           (forth-hack-local-variables)
            (forth-customize-words)
          (forth-compile-words)           (forth-compile-words)
          (forth-change-function (point-min) (point-max) nil)))           (forth-change-function (point-min) (point-max) nil t)))
   
 (defun forth-fill-paragraph ()   (defun forth-fill-paragraph () 
   "Fill comments (starting with '\'; do not fill code (block style    "Fill comments (starting with '\'; do not fill code (block style
Line 1764  The region is sent terminated by a newli Line 1849  The region is sent terminated by a newli
 ))  ))
   
 ;;; gforth.el ends here  ;;; gforth.el ends here
   

Removed from v.1.49  
changed lines
  Added in v.1.52


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>