diff options
author | Aaron Marks <nymacro@gmail.com> | 2018-11-15 19:34:45 +1000 |
---|---|---|
committer | Aaron Marks <nymacro@gmail.com> | 2018-11-28 21:52:41 +1000 |
commit | b421d3b4693249e2e46095693b41eed1e8161a58 (patch) | |
tree | 1e97e7f693eb0be88ec70e7c17e1d42fd8a8c38d /elisp/geiser-syntax.el | |
parent | dcf754c0b9cdb87ffa5930ef8ffbae9256f2d07d (diff) | |
download | geiser-guile-b421d3b4693249e2e46095693b41eed1e8161a58.tar.gz geiser-guile-b421d3b4693249e2e46095693b41eed1e8161a58.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.el | 36 |
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)) |