all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Carlos Pita <carlosjosepita@gmail.com>
To: 19650@debbugs.gnu.org
Cc: Fabian Ezequiel Gallina <galli.87@gmail.com>
Subject: bug#19650:
Date: Thu, 22 Jan 2015 13:42:01 -0300	[thread overview]
Message-ID: <CAELgYhcukq69kOQ8ZTktKT97Vy-vjf4wkgUjvNeX1_aw-OEQPw@mail.gmail.com> (raw)
In-Reply-To: <CAELgYhfgE6WGj0_FjUzb=k=PvNihTbVirWV31syFmi_iAaoSEw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1076 bytes --]

I've been doing my homework:

1) Changing insert for insert-before-markers is problematic because it
somehow wreaks havoc with font locking. I guess some other markers are
being moved around besides he-string-end, maybe the one pointing to
the end of the prompt or something like that (since everything gets
colored the same the prompt is). Moreover, the he-string-beg marker
would still point to the wrong place no matter what its type were.

2) This will work for the end marker: (set-marker-insertion-type
he-string-end t), but it's too invasive regarding hippie-expand. Also,
it assumes the user is indeed using hippie-expand. But maybe changing
the insertion type of he-string-end just around the
delete-region/insert and just in case hippie-expand is currently
provided will do the dirty job. Again, this doesn't fix the
he-string-beg marker at all.

3) Same as (2) above, but saving/restoring the *positions*  of both
he-string-beg and he-string-end. This is the best solution I could
figure out till now. Take a look at the attached patch, please.

What do you think?

[-- Attachment #2: py.diff --]
[-- Type: text/plain, Size: 2459 bytes --]

--- py1.el	2015-01-22 13:34:02.863974265 -0300
+++ py2.el	2015-01-22 13:34:18.143826873 -0300
@@ -16,21 +16,28 @@
             (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))))))
+          (let ((beg) (end))
+            (when (featurep 'hippie-exp)
+              (setq beg (marker-position he-string-beg)
+                    end (marker-position he-string-end)))
+            (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))))
+            (when (featurep 'hippie-exp)
+              (set-marker he-string-beg beg)
+              (set-marker he-string-end end))
+            (goto-char current-point)))))))

  reply	other threads:[~2015-01-22 16:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-21 22:47 bug#19650: 25.0.50; python-shell-font-lock-post-command-hook breaks hippie-expand Carlos Pita
2015-01-22 16:42 ` Carlos Pita [this message]
     [not found]   ` <jwvpp8eujc3.fsf-monnier+emacsbugs@gnu.org>
2015-03-13  1:19     ` bug#19650: Stefan Monnier
2015-02-02 19:29 ` bug#19650: Carlos Pita
2015-02-08  3:28 ` bug#19650: 25.0.50; python-shell-font-lock-post-command-hook breaks hippie-expand Fabián Ezequiel Gallina
     [not found] ` <handler.19650.D19650.142336612525392.notifdone@debbugs.gnu.org>
2015-02-09 14:12   ` bug#19650: closed (25.0.50; python-shell-font-lock-post-command-hook breaks hippie-expand) Carlos Pita
2015-02-10  2:45 ` bug#19650: 25.0.50; python-shell-font-lock-post-command-hook breaks hippie-expand Fabián Ezequiel Gallina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAELgYhcukq69kOQ8ZTktKT97Vy-vjf4wkgUjvNeX1_aw-OEQPw@mail.gmail.com \
    --to=carlosjosepita@gmail.com \
    --cc=19650@debbugs.gnu.org \
    --cc=galli.87@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.