unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* Shell-mode: File completion breaks editing previous commands
@ 2008-04-04 11:39                         ` richard
  2011-10-12  5:27                           ` bug#114: " Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: richard @ 2008-04-04 11:39 UTC (permalink / raw)
  To: bug-gnu-emacs


Emacs shell mode allows editing of previous commands. These can then
be executed by pressing return. Shell mode also allows tab completion
to expand filenames. These do not work together. If we try to modify
a previously executed command (to re-execute it with different params)
and attempt to use filename completion, the beginning of the command
is lost.

For example, the following sequence:

touch foo bar
echo bar
Edit the echo command to "touch foo bar" and press return.

produces the following output:

% touch foo bar
% echo bar foo 
foo
% foo 
bash: ./foo: Permission denied
% 

This behaviour worked under Emacs 21.

Richard


In GNU Emacs 22.2.1 (i686-pc-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2008-03-31 on belgrano
Windowing system distributor `The X.Org Foundation', version 11.0.10300000
configured using `configure  '--with-x' '--without-sound''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: en_GB.UTF-8
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Shell

Minor modes in effect:
  shell-dirtrack-mode: t
  delete-selection-mode: t
  pc-selection-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:

SPC SPC SPC SPC SPC SPC SPC <escape> x s h e l l <return> 
t o u c h SPC f o o b a <backspace> <backspace> SPC 
b a r <return> e c h o SPC f o <tab> <return> <up> 
<up> <right> <right> <right> <right> <right> b a <tab> 
<return> <escape> x <up> <up> <return>

Recent messages:
Completed
Completing file name...
Completed
Making completion list... [2 times]
Loading emacsbug...done
Mark set [2 times]
Completing file name...
Completed
Completing file name...
Completed





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
       [not found]     ` <18428.43150.358991.358580@rgrjr.rgrjr.dyndns.org>
@ 2011-09-11  5:23       ` Lars Magne Ingebrigtsen
  2011-09-25 13:27         ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-11  5:23 UTC (permalink / raw)
  To: Bob Rogers; +Cc: richard, Chong Yidong, 114

Bob Rogers <rogers-emacs@rgrjr.dyndns.org> writes:

>    >>> Emacs shell mode allows editing of previous commands. These can then
>    >>> be executed by pressing return. Shell mode also allows tab completion
>    >>> to expand filenames. These do not work together. If we try to modify
>    >>> a previously executed command (to re-execute it with different params)
>    >>> and attempt to use filename completion, the beginning of the command
>    >>> is lost.

[...]

> I have seen this intermittently for a long time now, but still haven't
> been able to reproduce it reliably.

Is this still a problem?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-09-11  5:23       ` bug#114: Shell-mode: File completion breaks editing previous commands Lars Magne Ingebrigtsen
@ 2011-09-25 13:27         ` Lars Magne Ingebrigtsen
  2011-09-26 15:04           ` richard
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-25 13:27 UTC (permalink / raw)
  To: Bob Rogers; +Cc: richard, 114

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

>> I have seen this intermittently for a long time now, but still haven't
>> been able to reproduce it reliably.
>
> Is this still a problem?

More information, but was apparently not given, so I'm closing this bug
report.  If this is still a problem, please reopen the bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-09-25 13:27         ` Lars Magne Ingebrigtsen
@ 2011-09-26 15:04           ` richard
  2011-09-26 19:40             ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 14+ messages in thread
From: richard @ 2011-09-26 15:04 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: richard, 114, Bob Rogers

Lars Magne Ingebrigtsen writes:
 > Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
 > >> I have seen this intermittently for a long time now, but still haven't
 > >> been able to reproduce it reliably.
 > >
 > > Is this still a problem?
 > 
 > More information, but was apparently not given, so I'm closing this bug
 > report.  If this is still a problem, please reopen the bug report.

This is still broken in Emacs 23 at least. I'm happy to provide any extra
info you need,

Richard

GNU Emacs 23.2.1 (x86_64-slackware-linux-gnu, GTK+ Version 2.18.9) of 2010-05-08 on midas64





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-09-26 15:04           ` richard
@ 2011-09-26 19:40             ` Lars Magne Ingebrigtsen
  2011-10-03 21:12               ` Glenn Morris
  0 siblings, 1 reply; 14+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-26 19:40 UTC (permalink / raw)
  To: richard; +Cc: 114, Bob Rogers

richard@rswheeldon.com writes:

> This is still broken in Emacs 23 at least.

Ok; I'll reopen the report.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-09-26 19:40             ` Lars Magne Ingebrigtsen
@ 2011-10-03 21:12               ` Glenn Morris
  2011-10-04  0:57                 ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2011-10-03 21:12 UTC (permalink / raw)
  To: 114


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.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  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
  0 siblings, 2 replies; 14+ messages in thread
From: Stefan Monnier @ 2011-10-04  0:57 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 114

> 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.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-10-04  0:57                 ` Stefan Monnier
@ 2011-10-04  1:51                   ` Glenn Morris
  2011-10-04  2:14                   ` Stefan Monnier
  1 sibling, 0 replies; 14+ messages in thread
From: Glenn Morris @ 2011-10-04  1:51 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 114

Stefan Monnier wrote:

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

I think you guess correctly. Looks like the completion does not put an
`input' property on the text that it inserts.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-10-04  0:57                 ` Stefan Monnier
  2011-10-04  1:51                   ` Glenn Morris
@ 2011-10-04  2:14                   ` Stefan Monnier
  2011-10-04  2:21                     ` Glenn Morris
  1 sibling, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2011-10-04  2:14 UTC (permalink / raw)
  To: Miles Bader; +Cc: 114

[ 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






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-10-04  2:14                   ` Stefan Monnier
@ 2011-10-04  2:21                     ` Glenn Morris
  2011-10-12  4:30                       ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2011-10-04  2:21 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 114, Miles Bader

Stefan Monnier wrote:

> 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.

For one, it leaves the help echo ("mouse-2: insert after prompt as new
input") and mouse highlight properties broken in two on either side of
the portion inserted by completion.





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-10-04  2:21                     ` Glenn Morris
@ 2011-10-12  4:30                       ` Stefan Monnier
  2008-04-04 11:39                         ` richard
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2011-10-12  4:30 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 114, Miles Bader

>> 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.

> For one, it leaves the help echo ("mouse-2: insert after prompt as new
> input") and mouse highlight properties broken in two on either side of
> the portion inserted by completion.

But that's also the case before my patch, right?  So it's not
a consequence of my patch.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2008-04-04 11:39                         ` richard
@ 2011-10-12  5:27                           ` Glenn Morris
  2011-10-12 12:39                             ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Glenn Morris @ 2011-10-12  5:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 114, Miles Bader

Stefan Monnier wrote:

> But that's also the case before my patch, right?  So it's not
> a consequence of my patch.

OK then, pretend I said:

I'm also not sure what consequences simply removing this field property
will have.

However, I noticed that your patch leaves the help-echo and mouse-face
properties missing on the completed text, which is a little unaesthetic.
An alternative solution that avoids this issue would be if callers of
completion could optionally request that it insert-and-inherit the
completed text rather than just insert it. I could imagine that other
callers of completion might need such a feature. But I have no idea if
this is feasible.






^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-10-12  5:27                           ` bug#114: " Glenn Morris
@ 2011-10-12 12:39                             ` Stefan Monnier
  2011-10-17 16:34                               ` Stefan Monnier
  0 siblings, 1 reply; 14+ messages in thread
From: Stefan Monnier @ 2011-10-12 12:39 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 114, Miles Bader

>> But that's also the case before my patch, right?  So it's not
>> a consequence of my patch.

> OK then, pretend I said:

> I'm also not sure what consequences simply removing this field property
> will have.

> However, I noticed that your patch leaves the help-echo and mouse-face
> properties missing on the completed text, which is a little unaesthetic.
> An alternative solution that avoids this issue would be if callers of
> completion could optionally request that it insert-and-inherit the
> completed text rather than just insert it. I could imagine that other
> callers of completion might need such a feature. But I have no idea if
> this is feasible.

I think there are two issues:
1- handling the `insert' case as well as possible, because a lot of code
   uses just `insert' (tho in practice very few cases seem to show up:
   yank, completion, any other?).
2- changing (some) users of `insert' such as completion to use
   insert-and-inherit.

(2) might be good, indeed, tho I'm not completely sure what are the consequences.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

* bug#114: Shell-mode: File completion breaks editing previous commands
  2011-10-12 12:39                             ` Stefan Monnier
@ 2011-10-17 16:34                               ` Stefan Monnier
  0 siblings, 0 replies; 14+ messages in thread
From: Stefan Monnier @ 2011-10-17 16:34 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 114-done, Miles Bader

> I think there are two issues:
> 1- handling the `insert' case as well as possible, because a lot of code
>    uses just `insert' (tho in practice very few cases seem to show up:
>    yank, completion, any other?).

I've installed the patch that makes comint use nil rather than `input'
for the field property.

> 2- changing (some) users of `insert' such as completion to use
>    insert-and-inherit.

And I've also installed a patch that makes completion use
insert-and-inherit for good measure.


        Stefan





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-10-17 16:34 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <87tzig9es5.fsf@stupidchicken.com>
     [not found] ` <18424.40053.181304.491320@lusitania.rswheeldon.com>
     [not found]   ` <878wzq2qtv.fsf@stupidchicken.com>
     [not found]     ` <18428.43150.358991.358580@rgrjr.rgrjr.dyndns.org>
2011-09-11  5:23       ` bug#114: Shell-mode: File completion breaks editing previous commands 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
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).