all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Miles Bader <miles@gnu.org>
Cc: 114@debbugs.gnu.org
Subject: bug#114: Shell-mode: File completion breaks editing previous commands
Date: Mon, 03 Oct 2011 22:14:18 -0400	[thread overview]
Message-ID: <jwvobxxmsir.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <jwvty7pmv77.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 03 Oct 2011 20:57:12 -0400")

[ Hi, Miles, I think you're the "fields in comint" guru; coud you give
  us a hand? ]

>> For anyone like me who had trouble following the recipe:
>> emacs -Q -f shell
>> touch foo bar RET
>> echo foo RET
>> C-u 2 C-p
>> C-u 5 C-f
>> ; point now on "f" of "echo foo"
>> baTAB
>> ; completes so that line reads "echo bar foo", with cursor on "f".
>> RET
>> ; -> tries to run the command "foo"
>> If you type "bar " by hand rather than using tab completion, there is no
>> problem.

> Ah, I guess there's some funny `field' text property going on.

Indeed, the problem is that previous commands are given a `field' text
property of value `input', but since this is a text property, insertion
of text within this line won't have that property unless it's done via
insert-and-inherit.
This can be seen as above with completion, but it also happens with C-y.

Maybe the best fix is to get rid of this `input' field value (the rest
of the text already gets an `output' field value, so a nil value would
still work as a field).

E.g. the patch below seemed to fix the problem, but I'm not sure what
other consequences it might have.


        Stefan


=== modified file 'lisp/comint.el'
--- lisp/comint.el	2011-10-03 16:49:56 +0000
+++ lisp/comint.el	2011-10-04 02:05:59 +0000
@@ -849,8 +849,7 @@
       (and (< pos (field-end pos))
            (setq field (field-at-pos pos))
 	   (setq input (field-string-no-properties pos))))
-    (if (or (null comint-accum-marker)
-	    (not (eq field 'input)))
+    (if (or (null comint-accum-marker) field)
 	;; Fall back to the global definition if (i) the selected
 	;; buffer is not a comint buffer (which can happen if a
 	;; non-comint window was selected and we clicked in a comint
@@ -1803,8 +1802,7 @@
               (add-text-properties
                beg end
                '(mouse-face highlight
-                 help-echo "mouse-2: insert after prompt as new input"
-                 field input))))
+                 help-echo "mouse-2: insert after prompt as new input"))))
           (unless (or no-newline comint-use-prompt-regexp)
             ;; Cover the terminating newline
             (add-text-properties end (1+ end)
@@ -2153,7 +2151,7 @@
 the current line with any initial string matching the regexp
 `comint-prompt-regexp' removed."
   (let ((bof (field-beginning)))
-    (if (eq (get-char-property bof 'field) 'input)
+    (if (null (get-char-property bof 'field)) ;Not `output'.
 	(field-string-no-properties bof)
       (comint-bol)
       (buffer-substring-no-properties (point) (line-end-position)))))
@@ -2473,7 +2471,7 @@
 	      (while (/= n 0)
 		(unless (re-search-backward regexp nil t dir)
 		  (error "Not found"))
-		(when (eq (get-char-property (point) 'field) 'input)
+		(unless (get-char-property (point) 'field)
 		  (setq n (- n dir))))
 	      (field-beginning))))
       (goto-char pos))))
@@ -2520,7 +2518,7 @@
 		 (setq input-pos (point-max)))
 	       ;; stop iterating
 	       (setq n 0))
-	      ((eq (get-char-property pos 'field) 'input)
+	      ((null (get-char-property pos 'field))
 	       (setq n (if (< n 0) (1+ n) (1- n)))
 	       (setq input-pos pos))))
       (when input-pos






  parent reply	other threads:[~2011-10-04  2:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87tzig9es5.fsf@stupidchicken.com>
     [not found] ` <18424.40053.181304.491320@lusitania.rswheeldon.com>
2008-04-07  5:10   ` Shell-mode: File completion breaks editing previous commands Chong Yidong
2008-04-07  9:18     ` Andreas Röhler
2008-04-09 11:29     ` Bob Rogers
2011-09-11  5:23       ` bug#114: " Lars Magne Ingebrigtsen
2011-09-25 13:27         ` Lars Magne Ingebrigtsen
2011-09-26 15:04           ` richard
2011-09-26 19:40             ` Lars Magne Ingebrigtsen
2011-10-03 21:12               ` Glenn Morris
2011-10-04  0:57                 ` Stefan Monnier
2011-10-04  1:51                   ` Glenn Morris
2011-10-04  2:14                   ` Stefan Monnier [this message]
2011-10-04  2:21                     ` Glenn Morris
2011-10-12  4:30                       ` Stefan Monnier
2008-04-04 11:39                         ` richard
2011-10-12  5:27                           ` bug#114: " Glenn Morris
2011-10-12 12:39                             ` Stefan Monnier
2011-10-17 16:34                               ` Stefan Monnier

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=jwvobxxmsir.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=114@debbugs.gnu.org \
    --cc=miles@gnu.org \
    /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.