summaryrefslogtreecommitdiff
path: root/elisp/geiser-syntax.el
diff options
context:
space:
mode:
authorAaron Marks <nymacro@gmail.com>2018-11-15 19:34:45 +1000
committerAaron Marks <nymacro@gmail.com>2018-11-28 21:52:41 +1000
commit55984b08032ad23eac6a99a749d9e71d972c0964 (patch)
tree970e44537fdc73f483ccfb75224ae84732fa5335 /elisp/geiser-syntax.el
parent7ef1cca1241a9e4e6faaac99f58cbc0503d350ad (diff)
downloadgeiser-55984b08032ad23eac6a99a749d9e71d972c0964.tar.gz
geiser-55984b08032ad23eac6a99a749d9e71d972c0964.tar.bz2
Change behaviour of REPL output and highlighting
* Narrow font-lock syntax highlighting to only the active REPL input region. * Mark REPL output read-only. This can be changed via the option `geiser-repl-read-only-output-p`. * Mark REPL output with a user-definable face as `geiser-font-lock-repl-output`. Alternatively an option to syntax highlight REPL output is provided via the option `geiser-repl-highlight-output-p`. This applies scheme-mode syntax highlighting to any REPL output. Any additional hooks defined via scheme-mode-hook are also executed for highlighting this region. * Remove some unwanted TABs in source files.
Diffstat (limited to 'elisp/geiser-syntax.el')
-rw-r--r--elisp/geiser-syntax.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el
index 64b366f..3cc875c 100644
--- a/elisp/geiser-syntax.el
+++ b/elisp/geiser-syntax.el
@@ -495,6 +495,42 @@ implementation-specific entries for font-lock-keywords.")
(font-lock-flush beg end)
(with-no-warnings (font-lock-fontify-region beg end)))))
+;; derived from org-src-font-lock-fontify-block (org-src.el)
+(defun geiser-syntax--fontify-syntax-region (start end)
+ "Fontify region as Scheme."
+ (let ((string (buffer-substring-no-properties start end))
+ (modified (buffer-modified-p))
+ (buffer-undo-list t)
+ (geiser-buffer (current-buffer)))
+ (with-current-buffer
+ (get-buffer-create " *geiser-repl-fontification*")
+ (let ((inhibit-modification-hooks nil))
+ (erase-buffer)
+ ;; Add string and a final space to ensure property change.
+ (insert string " "))
+ ;; prevent geiser prompt
+ (let ((geiser-default-implementation
+ (or geiser-default-implementation
+ (car geiser-active-implementations))))
+ (scheme-mode))
+ (font-lock-ensure)
+ (let ((pos (point-min)) next)
+ (while (setq next (next-property-change pos))
+ ;; Handle additional properties from font-lock, so as to
+ ;; preserve, e.g., composition.
+ (dolist (prop (cons 'face font-lock-extra-managed-props))
+ (let ((new-prop (get-text-property pos prop))
+ (start-point (+ start (1- pos)))
+ (end-point (1- (+ start next))))
+ (put-text-property start-point end-point prop new-prop geiser-buffer)))
+ (setq pos next))))
+ (add-text-properties
+ start end
+ '(font-lock-fontified t
+ fontified t
+ font-lock-multiline t))
+ (set-buffer-modified-p modified)))
+
(defun geiser-syntax--scheme-str (str)
(save-current-buffer
(set-buffer (geiser-syntax--font-lock-buffer))