From 0a3d6ca624332470f406e579f3ed5912169273ea Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 12 Jun 2016 18:32:48 +0200 Subject: Real fix fontification on scheme switch --- elisp/geiser-base.el | 10 +++++++++- elisp/geiser-mode.el | 4 +++- elisp/geiser-syntax.el | 13 ++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) (limited to 'elisp') diff --git a/elisp/geiser-base.el b/elisp/geiser-base.el index 4d303db..ee30770 100644 --- a/elisp/geiser-base.el +++ b/elisp/geiser-base.el @@ -1,6 +1,6 @@ ;;; geiser-base.el --- shared bits -;; Copyright (C) 2009, 2010, 2012, 2013, 2015 Jose Antonio Ortega Ruiz +;; Copyright (C) 2009, 2010, 2012, 2013, 2015, 2016 Jose Antonio Ortega Ruiz ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the Modified BSD License. You should @@ -27,6 +27,14 @@ (let ((inhibit-changing-match-data t)) (looking-at regexp)))) +(when (not (fboundp 'font-lock-ensure)) + (defun font-lock-ensure (&optional beg end) + (with-no-warnings (font-lock-fontify-region (or beg (point-min)) + (or end (point-max)))))) + +(when (not (fboundp 'font-lock-flush)) + (defun font-lock-flush (&optional beg end))) + ;;; Utilities: (defsubst geiser--chomp (str) diff --git a/elisp/geiser-mode.el b/elisp/geiser-mode.el index 5747f40..4ca8af2 100644 --- a/elisp/geiser-mode.el +++ b/elisp/geiser-mode.el @@ -198,7 +198,9 @@ With prefix, recursively macro-expand the resulting expression." (geiser-syntax--remove-kws) (let ((impl (geiser-impl--read-impl))) (geiser-impl--set-buffer-implementation impl) - (geiser-repl--set-up-repl impl))) + (geiser-repl--set-up-repl impl) + (geiser-syntax--add-kws) + (geiser-syntax--fontify))) (defun geiser-mode-switch-to-repl (arg) "Switches to Geiser REPL. diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el index 0abd03c..fb579e7 100644 --- a/elisp/geiser-syntax.el +++ b/elisp/geiser-syntax.el @@ -487,16 +487,19 @@ implementation-specific entries for font-lock-keywords.") (scheme-mode))) buffer)) +(defun geiser-syntax--fontify (&optional beg end) + (let ((font-lock-verbose nil) + (beg (or beg (point-min))) + (end (or end (point-max)))) + (font-lock-flush beg end) + (font-lock-ensure beg end))) + (defun geiser-syntax--scheme-str (str) (save-current-buffer (set-buffer (geiser-syntax--font-lock-buffer)) (erase-buffer) (insert str) - (let ((font-lock-verbose nil)) - (if (fboundp 'font-lock-ensure) - (font-lock-ensure) - (with-no-warnings - (font-lock-fontify-buffer)))) + (geiser-syntax--fontify) (buffer-string))) -- cgit v1.2.3