--- gforth/gforth.el 2007/08/17 22:00:14 1.73 +++ gforth/gforth.el 2010/04/10 13:03:01 1.77 @@ -1,6 +1,6 @@ ;;; gforth.el --- major mode for editing (G)Forth sources -;; Copyright (C) 1995,1996,1997,1998,2000,2001,2003,2004 Free Software Foundation, Inc. +;; Copyright (C) 1995,1996,1997,1998,2000,2001,2003,2004,2007,2008 Free Software Foundation, Inc. ;; This file is part of Gforth. @@ -59,7 +59,7 @@ (if (not (boundp 'emacs-major-version)) (defconst emacs-major-version (progn (string-match "^[0-9]+" emacs-version) - (string-to-int (match-string 0 emacs-version))))) + (string-to-number (match-string 0 emacs-version))))) ;; Code ripped from `subr.el' for compatability with Emacs versions ;; prior to 20.1 @@ -247,6 +247,11 @@ PARSED-TYPE specifies what kind of text "[\n\t ]" t string (font-lock-string-face . 1)) (("included" "required" "thru" "load") non-immediate (font-lock-keyword-face . 1)) + (("code" "abi-code") + non-immediate (font-lock-keyword-face . 1) + "[ \t\n]" t name (font-lock-function-name-face . 3)) + (("end-code") + non-immediate (font-lock-keyword-face . 1)) (("[char]") compile-only (font-lock-keyword-face . 1) "[ \t\n]" t string (font-lock-string-face . 1)) (("char") non-immediate (font-lock-keyword-face . 1) @@ -313,6 +318,8 @@ PARSED-TYPE specifies what kind of text (("struct") non-immediate (font-lock-keyword-face . 2)) ("-?[0-9]+\\(\\.[0-9]*e\\(-?[0-9]+\\)?\\|\\.?[0-9a-f]*\\)" immediate (font-lock-constant-face . 3)) + ("-?\\([&#][0-9]+\\|\\(0x\\|\\$\\)[0-9a-f]+\\|%[01]+\\)" + immediate (font-lock-constant-face . 3)) )) (defvar forth-use-objects nil @@ -420,7 +427,8 @@ INDENT1 and INDENT2 are indentation spec "u-do" "?dup-if" "?dup-0=-if" "case" "of" "try" "iferror" "[if]" "[ifdef]" "[ifundef]" "[begin]" "[for]" "[do]" "[?do]") (0 . 2) (0 . 2)) - ((":" ":noname" "code" "struct" "m:" ":m" "class" "interface") + ((":" ":noname" "code" "abi-code" "struct" "m:" ":m" "class" + "interface") (0 . 2) (0 . 2) non-immediate) ("\\S-+%$" (0 . 2) (0 . 0) non-immediate) ((";" ";m") (-2 . 0) (0 . -2)) @@ -462,12 +470,11 @@ End:\" construct).") ;; in Lisp?? (defun forth-filter (predicate list) (let ((filtered nil)) - (mapcar (lambda (item) + (dolist (item list) (when (funcall predicate item) (if filtered (nconc filtered (list item)) - (setq filtered (cons item nil)))) - nil) list) + (setq filtered (cons item nil))))) filtered)) ;; Helper function for `forth-compile-word': return whether word has to be @@ -488,7 +495,7 @@ End:\" construct).") (regexp (concat "\\(" (cond ((stringp matcher) matcher) ((listp matcher) (regexp-opt matcher)) - (t (error "Invalid matcher `%s'"))) + (t (error "Invalid matcher"))) "\\)")) (depth (regexp-opt-depth regexp)) (description (cdr word))) @@ -699,14 +706,14 @@ End:\" construct).") (eval-when-compile (defmacro forth-save-buffer-state (varlist &rest body) "Bind variables according to VARLIST and eval BODY restoring buffer state." - (` (let* ((,@ (append varlist + `(let* (,@(append varlist '((modified (buffer-modified-p)) (buffer-undo-list t) (inhibit-read-only t) (inhibit-point-motion-hooks t) before-change-functions after-change-functions - deactivate-mark buffer-file-name buffer-file-truename)))) - (,@ body) + deactivate-mark buffer-file-name buffer-file-truename))) + ,@body (when (and (not modified) (buffer-modified-p)) - (set-buffer-modified-p nil)))))) + (set-buffer-modified-p nil))))) ;; Function that is added to the `change-functions' hook. Calls ;; `forth-update-properties' and keeps care of disabling undo information @@ -1385,18 +1392,12 @@ programmers who tend to fill code won't (progn (delete-other-windows) (split-window-vertically - (/ (* (screen-height) forth-percent-height) 100)) + (/ (frame-height) 2)) (other-window 1) (switch-to-buffer buffer) (goto-char (point-max)) (other-window 1)))) -(defun forth-compile (command) - (interactive (list (setq forth-compile-command (read-string "Compile command: " forth-compile-command)))) - (forth-split-1 "*compilation*") - (setq ctools-compile-command command) - (compile1 ctools-compile-command "No more errors")) - ;;; Forth menu ;;; Mikael Karlsson @@ -1616,8 +1617,7 @@ of `forth-program-name'). Runs the hook (forth-end-of-paragraph) (skip-chars-backward "\t\n ") (setq end (point)) - (if (re-search-backward "\n[ \t]*\n" nil t) - (setq start (point)) + (if (null (re-search-backward "\n[ \t]*\n" nil t)) (goto-char (point-min))) (skip-chars-forward "\t\n ") (forth-send-region (point) end)))) @@ -1655,11 +1655,11 @@ With argument, position cursor at end of (push-mark) (goto-char (point-max))))) - (defun forth-send-region-and-go (start end) + (defun forth-send-region-and-go (my-start end) "Send the current region to the inferior Forth process. Then switch to the process buffer." (interactive "r") - (forth-send-region start end) + (forth-send-region my-start end) (forth-switch-to-interactive t)) (defcustom forth-source-modes '(forth-mode forth-block-mode)