From befeff625d2036be72d8d9a3b891925d0fd7b549 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Mon, 19 Jan 2009 03:39:53 +0100 Subject: [PATCH 1/3] FUEL: Ignore paren chars in \, POSTPONE: and stack effects. --- misc/fuel/fuel-font-lock.el | 18 +++++++++++------- misc/fuel/fuel-syntax.el | 3 ++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index fe20024fcd..4db9eee92c 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -84,6 +84,8 @@ (t 'default)))) ((char-equal (char-after (nth 8 state)) ?U) 'factor-font-lock-parsing-word) + ((char-equal (char-after (nth 8 state)) ?\() + 'factor-font-lock-stack-effect) (t 'factor-font-lock-comment))) (defconst fuel-font-lock--font-lock-keywords @@ -135,16 +137,18 @@ ;;; Fontify strings as Factor code: -(defvar fuel-font-lock--font-lock-buffer - (let ((buffer (get-buffer-create " *fuel font lock*"))) - (set-buffer buffer) - (set-syntax-table fuel-syntax--syntax-table) - (fuel-font-lock--font-lock-setup) - buffer)) +(defun fuel-font-lock--font-lock-buffer () + (let ((name " *fuel font lock*")) + (or (get-buffer name) + (let ((buffer (get-buffer-create name))) + (set-buffer buffer) + (set-syntax-table fuel-syntax--syntax-table) + (fuel-font-lock--font-lock-setup) + buffer)))) (defun fuel-font-lock--factor-str (str) (save-current-buffer - (set-buffer fuel-font-lock--font-lock-buffer) + (set-buffer (fuel-font-lock--font-lock-buffer)) (erase-buffer) (insert str) (let ((font-lock-verbose nil)) (font-lock-fontify-buffer)) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 8d2948af58..82df3e07d8 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -240,10 +240,11 @@ (defconst fuel-syntax--syntactic-keywords `(;; CHARs: - ("CHAR: \\(.\\)\\( \\|$\\)" (1 "w")) + ("\\(CHAR:\\|POSTPONE:\\|\\\\\\) \\(.\\)\\( \\|$\\)" (2 "w")) ;; Comments: ("\\_<\\(#?!\\) .*\\(\n\\|$\\)" (1 "<") (2 ">")) ("\\_<\\(#?!\\)\\(\n\\|$\\)" (1 "<") (2 ">")) + ("\\_<\\((\\) \\([^)\n]*?\\) \\()\\)\\_>" (1 "b")) ;; Strings ("\\_<\\(\"\\)\\([^\n\r\f\"]\\|\\\\\"\\)*\\(\"\\)\\_>" (1 "\"") (3 "\"")) ("\\_<<\\(\"\\)\\_>" (1 "\"")) From 5c1d6b12c828f58ce4666b889886624ab62a1662 Mon Sep 17 00:00:00 2001 From: "Jose A. Ortega Ruiz" Date: Mon, 19 Jan 2009 04:18:20 +0100 Subject: [PATCH 2/3] FUEL: Better font lock for <" "> forms. --- misc/fuel/fuel-font-lock.el | 28 ++++++++++++++-------------- misc/fuel/fuel-syntax.el | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/misc/fuel/fuel-font-lock.el b/misc/fuel/fuel-font-lock.el index 4db9eee92c..5b4ae09f25 100644 --- a/misc/fuel/fuel-font-lock.el +++ b/misc/fuel/fuel-font-lock.el @@ -73,20 +73,20 @@ ;;; Font lock: (defun fuel-font-lock--syntactic-face (state) - (cond ((nth 3 state) 'factor-font-lock-string) - ((char-equal (char-after (nth 8 state)) ?\ ) - (save-excursion - (goto-char (nth 8 state)) - (beginning-of-line) - (cond ((looking-at "USING: ") 'factor-font-lock-vocabulary-name) - ((looking-at "\\(TUPLE\\|SYMBOLS\\|VARS\\): ") - 'factor-font-lock-symbol) - (t 'default)))) - ((char-equal (char-after (nth 8 state)) ?U) - 'factor-font-lock-parsing-word) - ((char-equal (char-after (nth 8 state)) ?\() - 'factor-font-lock-stack-effect) - (t 'factor-font-lock-comment))) + (if (nth 3 state) 'factor-font-lock-string + (let ((c (char-after (nth 8 state)))) + (cond ((char-equal c ?\ ) + (save-excursion + (goto-char (nth 8 state)) + (beginning-of-line) + (cond ((looking-at "USING: ") 'factor-font-lock-vocabulary-name) + ((looking-at "\\(TUPLE\\|SYMBOLS\\|VARS\\): ") + 'factor-font-lock-symbol) + (t 'default)))) + ((char-equal c ?U) 'factor-font-lock-parsing-word) + ((char-equal c ?\() 'factor-font-lock-stack-effect) + ((char-equal c ?\") 'factor-font-lock-string) + (t 'factor-font-lock-comment))))) (defconst fuel-font-lock--font-lock-keywords `((,fuel-syntax--stack-effect-regex . 'factor-font-lock-stack-effect) diff --git a/misc/fuel/fuel-syntax.el b/misc/fuel/fuel-syntax.el index 82df3e07d8..880a8eca65 100644 --- a/misc/fuel/fuel-syntax.el +++ b/misc/fuel/fuel-syntax.el @@ -247,8 +247,8 @@ ("\\_<\\((\\) \\([^)\n]*?\\) \\()\\)\\_>" (1 "b")) ;; Strings ("\\_<\\(\"\\)\\([^\n\r\f\"]\\|\\\\\"\\)*\\(\"\\)\\_>" (1 "\"") (3 "\"")) - ("\\_<<\\(\"\\)\\_>" (1 "\"")) - ("\\_<\\(\"\\)>\\_>" (1 "\"")) + ("\\_<<\\(\"\\)\\_>" (1 "\\_>" (1 ">b")) ;; Multiline constructs ("\\_<\\(U\\)SING: \\(;\\)" (1 "b")) ("\\_ Date: Mon, 19 Jan 2009 05:10:47 +0100 Subject: [PATCH 3/3] FUEL: New fuel-switch-to-buffer command family. --- misc/fuel/README | 3 +++ misc/fuel/fuel-edit.el | 26 ++++++++++++++++++++++++++ misc/fuel/fuel-mode.el | 3 +++ 3 files changed, 32 insertions(+) diff --git a/misc/fuel/README b/misc/fuel/README index 706191aaa3..562128dc29 100644 --- a/misc/fuel/README +++ b/misc/fuel/README @@ -74,6 +74,9 @@ beast. - C-cz : switch to listener - C-co : cycle between code, tests and docs factor files + - C-cs : switch to other factor buffer (M-x fuel-switch-to-buffer) + - C-x4s : switch to other factor buffer in other window + - C-x5s : switch to other factor buffer in other frame - M-. : edit word at point in Emacs (see fuel-edit-word-method custom var) - M-, : go back to where M-. was last invoked diff --git a/misc/fuel/fuel-edit.el b/misc/fuel/fuel-edit.el index b0756826f1..0334ab6104 100644 --- a/misc/fuel/fuel-edit.el +++ b/misc/fuel/fuel-edit.el @@ -132,6 +132,32 @@ was last invoked." (pop-tag-mark) (error "No previous location for find word or vocab invokation"))) +(defvar fuel-edit--buffer-history nil) + +(defun fuel-switch-to-buffer (&optional method) + "Switch to any of the existing Factor buffers, with completion." + (interactive) + (let ((buffer (completing-read "Factor buffer: " + (remove (buffer-name) + (mapcar 'buffer-name (buffer-list))) + '(lambda (s) (string-match "\\.factor$" s)) + t + nil + fuel-edit--buffer-history))) + (cond ((eq method 'window) (switch-to-buffer-other-window buffer)) + ((eq method 'frame) (switch-to-buffer-other-frame buffer)) + (t (switch-to-buffer buffer))))) + +(defun fuel-switch-to-buffer-other-window () + "Switch to any of the existing Factor buffers, in other window." + (interactive) + (fuel-switch-to-buffer 'window)) + +(defun fuel-switch-to-buffer-other-frame () + "Switch to any of the existing Factor buffers, in other frame." + (interactive) + (fuel-switch-to-buffer 'frame)) + (provide 'fuel-edit) ;;; fuel-edit.el ends here diff --git a/misc/fuel/fuel-mode.el b/misc/fuel/fuel-mode.el index 9936d052fc..1165b17e60 100644 --- a/misc/fuel/fuel-mode.el +++ b/misc/fuel/fuel-mode.el @@ -177,6 +177,9 @@ interacting with a factor listener is at your disposal. (fuel-mode--key-1 ?l 'fuel-run-file) (fuel-mode--key-1 ?r 'fuel-eval-region) (fuel-mode--key-1 ?z 'run-factor) +(fuel-mode--key-1 ?s 'fuel-switch-to-buffer) +(define-key fuel-mode-map "\C-x4s" 'fuel-switch-to-buffer-other-window) +(define-key fuel-mode-map "\C-x5s" 'fuel-switch-to-buffer-other-frame) (define-key fuel-mode-map "\C-\M-x" 'fuel-eval-definition) (define-key fuel-mode-map "\C-\M-r" 'fuel-eval-extended-region)