[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117581: * lisp/progmodes/python.el (python-shell-fo
From: |
Fabián Ezequiel Gallina |
Subject: |
[Emacs-diffs] trunk r117581: * lisp/progmodes/python.el (python-shell-font-lock-post-command-hook): |
Date: |
Sun, 27 Jul 2014 01:00:46 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117581
revision-id: address@hidden
parent: address@hidden
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: trunk
timestamp: Sat 2014-07-26 22:00:26 -0300
message:
* lisp/progmodes/python.el (python-shell-font-lock-post-command-hook):
Safeguard current point and undo history.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/progmodes/python.el python.el-20091113204419-o5vbwnq5f7feedwu-3008
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-07-26 23:43:51 +0000
+++ b/lisp/ChangeLog 2014-07-27 01:00:26 +0000
@@ -1,3 +1,8 @@
+2014-07-27 Fabián Ezequiel Gallina <address@hidden>
+
+ * progmodes/python.el (python-shell-font-lock-post-command-hook):
+ Safeguard current point and undo history.
+
2014-07-26 Fabián Ezequiel Gallina <address@hidden>
Robust shell syntax highlighting. (Bug#18084, Bug#16875)
=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el 2014-07-26 23:43:51 +0000
+++ b/lisp/progmodes/python.el 2014-07-27 01:00:26 +0000
@@ -2190,24 +2190,32 @@
(when (and (python-util-comint-last-prompt)
(> (point) (cdr (python-util-comint-last-prompt))))
(let ((input (buffer-substring-no-properties
- (cdr (python-util-comint-last-prompt)) (point-max))))
- (delete-region (cdr (python-util-comint-last-prompt)) (point-max))
- (insert
- (python-shell-font-lock-with-font-lock-buffer
- (delete-region (line-beginning-position)
- (line-end-position))
- (insert input)
- ;; Ensure buffer is fontified, keeping it
- ;; compatible with Emacs < 24.4.
- (if (fboundp 'font-lock-ensure)
- (funcall 'font-lock-ensure)
- (font-lock-default-fontify-buffer))
- ;; Replace FACE text properties with FONT-LOCK-FACE so they
- ;; are not overwritten by current buffer's font-lock
- (python-util-text-properties-replace-name
- 'face 'font-lock-face)
- (buffer-substring (line-beginning-position)
- (line-end-position))))))))
+ (cdr (python-util-comint-last-prompt)) (point-max)))
+ (old-input (python-shell-font-lock-with-font-lock-buffer
+ (buffer-substring-no-properties
+ (line-beginning-position) (point-max))))
+ (current-point (point))
+ (buffer-undo-list t))
+ ;; When input hasn't changed, do nothing.
+ (when (not (string= input old-input))
+ (delete-region (cdr (python-util-comint-last-prompt)) (point-max))
+ (insert
+ (python-shell-font-lock-with-font-lock-buffer
+ (delete-region (line-beginning-position)
+ (line-end-position))
+ (insert input)
+ ;; Ensure buffer is fontified, keeping it
+ ;; compatible with Emacs < 24.4.
+ (if (fboundp 'font-lock-ensure)
+ (funcall 'font-lock-ensure)
+ (font-lock-default-fontify-buffer))
+ ;; Replace FACE text properties with FONT-LOCK-FACE so
+ ;; they are not overwritten by comint buffer's font lock.
+ (python-util-text-properties-replace-name
+ 'face 'font-lock-face)
+ (buffer-substring (line-beginning-position)
+ (line-end-position))))
+ (goto-char current-point))))))
(defun python-shell-font-lock-turn-on (&optional msg)
"Turn on shell font-lock.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117581: * lisp/progmodes/python.el (python-shell-font-lock-post-command-hook):,
Fabián Ezequiel Gallina <=