From 9e4a6ad1c77c62e4a7d5b708567e5a1e23b9cdfd Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Thu, 1 Oct 2015 08:07:40 +0200 Subject: [PATCH] Un- and re-prettification are not exclusive * lisp/progmodes/prog-mode.el (prettify-symbols--post-command-hook): Re-apply prettification to previous symbol also when unprettifying next one. --- lisp/progmodes/prog-mode.el | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lisp/progmodes/prog-mode.el b/lisp/progmodes/prog-mode.el index 90c496f7a3a..6696356a2dc 100644 --- a/lisp/progmodes/prog-mode.el +++ b/lisp/progmodes/prog-mode.el @@ -209,21 +209,23 @@ on the symbol." (when (and (eq prettify-symbols-unprettify-at-point 'right-edge) (not (bobp))) (get-text-property (1- (point)) prop)))))) - (if-let ((c (get-prop-as-list 'composition)) - (s (get-prop-as-list 'prettify-symbols-start)) - (e (get-prop-as-list 'prettify-symbols-end)) - (s (apply #'min s)) - (e (apply #'max e))) - (with-silent-modifications - (setq prettify-symbols--current-symbol-bounds (list s e)) - (remove-text-properties s e '(composition))) - (when (and prettify-symbols--current-symbol-bounds - (or (< (point) (car prettify-symbols--current-symbol-bounds)) - (> (point) (cadr prettify-symbols--current-symbol-bounds)) - (and (not (eq prettify-symbols-unprettify-at-point 'right-edge)) - (= (point) (cadr prettify-symbols--current-symbol-bounds))))) - (apply #'font-lock-flush prettify-symbols--current-symbol-bounds) - (setq prettify-symbols--current-symbol-bounds nil))))) + ;; Re-apply prettification to the previous symbol. + (when (and prettify-symbols--current-symbol-bounds + (or (< (point) (car prettify-symbols--current-symbol-bounds)) + (> (point) (cadr prettify-symbols--current-symbol-bounds)) + (and (not (eq prettify-symbols-unprettify-at-point 'right-edge)) + (= (point) (cadr prettify-symbols--current-symbol-bounds))))) + (apply #'font-lock-flush prettify-symbols--current-symbol-bounds) + (setq prettify-symbols--current-symbol-bounds nil)) + ;; Unprettify the current symbol. + (when-let ((c (get-prop-as-list 'composition)) + (s (get-prop-as-list 'prettify-symbols-start)) + (e (get-prop-as-list 'prettify-symbols-end)) + (s (apply #'min s)) + (e (apply #'max e))) + (with-silent-modifications + (setq prettify-symbols--current-symbol-bounds (list s e)) + (remove-text-properties s e '(composition)))))) ;;;###autoload (define-minor-mode prettify-symbols-mode -- 2.39.2