unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Syntax of "-" in shell-mode
@ 2016-06-24 20:48 Dima Kogan
  2016-06-24 20:58 ` Drew Adams
  2016-06-25  7:06 ` Eli Zaretskii
  0 siblings, 2 replies; 11+ messages in thread
From: Dima Kogan @ 2016-06-24 20:48 UTC (permalink / raw)
  To: Emacs developers

Hi. What do people think about giving "-" a syntax of "word" in
shell-mode? The rationale is that in this mode one is generally editing
shell commands where "-" precedes commandline options, and strings such
as "--help" generally represent a single semantic token.

More specifically if I have something like "xxx --yyy" with the point in
the whitespace, and I invoke (transpose-words) I want the result to be
"--yyy xxx" and not "yyy --xxx". The latter means something very
different in a shell command.

dima



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

* RE: Syntax of "-" in shell-mode
  2016-06-24 20:48 Syntax of "-" in shell-mode Dima Kogan
@ 2016-06-24 20:58 ` Drew Adams
  2016-06-24 21:05   ` Dima Kogan
  2016-06-25  7:06 ` Eli Zaretskii
  1 sibling, 1 reply; 11+ messages in thread
From: Drew Adams @ 2016-06-24 20:58 UTC (permalink / raw)
  To: Dima Kogan, Emacs developers

> Hi. What do people think about giving "-" a syntax of "word" in
> shell-mode? The rationale is that in this mode one is generally editing
> shell commands where "-" precedes commandline options, and strings such
> as "--help" generally represent a single semantic token.
> 
> More specifically if I have something like "xxx --yyy" with the point in
> the whitespace, and I invoke (transpose-words) I want the result to be
> "--yyy xxx" and not "yyy --xxx". The latter means something very
> different in a shell command.

Maybe not so simple.  A shell command can involve lots of stuff,
including arguments to commands that use their own syntax (think
`find').



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

* Re: Syntax of "-" in shell-mode
  2016-06-24 20:58 ` Drew Adams
@ 2016-06-24 21:05   ` Dima Kogan
  2016-06-24 21:11     ` Drew Adams
  2016-06-24 21:55     ` Ivan Andrus
  0 siblings, 2 replies; 11+ messages in thread
From: Dima Kogan @ 2016-06-24 21:05 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs developers

Drew Adams <drew.adams@oracle.com> writes:

>> Hi. What do people think about giving "-" a syntax of "word" in
>> shell-mode? The rationale is that in this mode one is generally editing
>> shell commands where "-" precedes commandline options, and strings such
>> as "--help" generally represent a single semantic token.
>> 
>> More specifically if I have something like "xxx --yyy" with the point in
>> the whitespace, and I invoke (transpose-words) I want the result to be
>> "--yyy xxx" and not "yyy --xxx". The latter means something very
>> different in a shell command.
>
> Maybe not so simple.  A shell command can involve lots of stuff,
> including arguments to commands that use their own syntax (think
> `find').

Of course the true syntax depends on context, but in my experience, in
shell commands "-" is a word far more often than it isn't.



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

* RE: Syntax of "-" in shell-mode
  2016-06-24 21:05   ` Dima Kogan
@ 2016-06-24 21:11     ` Drew Adams
  2016-06-24 21:55     ` Ivan Andrus
  1 sibling, 0 replies; 11+ messages in thread
From: Drew Adams @ 2016-06-24 21:11 UTC (permalink / raw)
  To: Dima Kogan; +Cc: Emacs developers

> >> Hi. What do people think about giving "-" a syntax of "word" in
> >> shell-mode? The rationale is that in this mode one is generally editing
> >> shell commands where "-" precedes commandline options, and strings such
> >> as "--help" generally represent a single semantic token.
> >>
> >> More specifically if I have something like "xxx --yyy" with the point in
> >> the whitespace, and I invoke (transpose-words) I want the result to be
> >> "--yyy xxx" and not "yyy --xxx". The latter means something very
> >> different in a shell command.
> >
> > Maybe not so simple.  A shell command can involve lots of stuff,
> > including arguments to commands that use their own syntax (think
> > `find').
> 
> Of course the true syntax depends on context, but in my experience, in
> shell commands "-" is a word far more often than it isn't.

One thing that could perhaps be done is to set the `syntax-table'
text property on the zone of text up through the last switch.
You might try it.



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

* Re: Syntax of "-" in shell-mode
  2016-06-24 21:05   ` Dima Kogan
  2016-06-24 21:11     ` Drew Adams
@ 2016-06-24 21:55     ` Ivan Andrus
  2016-07-07 17:49       ` Dima Kogan
  1 sibling, 1 reply; 11+ messages in thread
From: Ivan Andrus @ 2016-06-24 21:55 UTC (permalink / raw)
  To: Dima Kogan; +Cc: Drew Adams, Emacs developers

On Fri, Jun 24, 2016 at 3:05 PM, Dima Kogan <lists@dima.secretsauce.net> wrote:
> Drew Adams <drew.adams@oracle.com> writes:
>
>>> Hi. What do people think about giving "-" a syntax of "word" in
>>> shell-mode? The rationale is that in this mode one is generally editing
>>> shell commands where "-" precedes commandline options, and strings such
>>> as "--help" generally represent a single semantic token.

I'm not in favor.  I like the distinction between words and symbols.

>>> More specifically if I have something like "xxx --yyy" with the point in
>>> the whitespace, and I invoke (transpose-words) I want the result to be
>>> "--yyy xxx" and not "yyy --xxx". The latter means something very
>>> different in a shell command.

It's already has symbol syntax which allows transpose-sexps to work.
Personally, I find that I regularly do want to change --yyy xxx to --xxx yyy.
That probably has to do with the style of typos that I commit.

>> Maybe not so simple.  A shell command can involve lots of stuff,
>> including arguments to commands that use their own syntax (think
>> `find').
>
> Of course the true syntax depends on context, but in my experience, in
> shell commands "-" is a word far more often than it isn't.

I disagree.  They are symbols, not words. I don't want forward-word to skip
past dashes, that's a job for forward-sexp.

-Ivan



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

* Re: Syntax of "-" in shell-mode
  2016-06-24 20:48 Syntax of "-" in shell-mode Dima Kogan
  2016-06-24 20:58 ` Drew Adams
@ 2016-06-25  7:06 ` Eli Zaretskii
  2016-06-25  7:12   ` Dima Kogan
  1 sibling, 1 reply; 11+ messages in thread
From: Eli Zaretskii @ 2016-06-25  7:06 UTC (permalink / raw)
  To: Dima Kogan; +Cc: emacs-devel

> From: Dima Kogan <lists@dima.secretsauce.net>
> Date: Fri, 24 Jun 2016 13:48:38 -0700
> 
> Hi. What do people think about giving "-" a syntax of "word" in
> shell-mode? The rationale is that in this mode one is generally editing
> shell commands where "-" precedes commandline options, and strings such
> as "--help" generally represent a single semantic token.
> 
> More specifically if I have something like "xxx --yyy" with the point in
> the whitespace, and I invoke (transpose-words) I want the result to be
> "--yyy xxx" and not "yyy --xxx". The latter means something very
> different in a shell command.

If the problem is with transpose-words, then a possible solution might
be a new shell-transpose-words command, which is smart enough to DTRT
in these cases, at least as a user option?  Would you like to propose
such an addition to sh-script.el?



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

* Re: Syntax of "-" in shell-mode
  2016-06-25  7:06 ` Eli Zaretskii
@ 2016-06-25  7:12   ` Dima Kogan
  2016-06-25  7:27     ` Andreas Schwab
  0 siblings, 1 reply; 11+ messages in thread
From: Dima Kogan @ 2016-06-25  7:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> If the problem is with transpose-words, then a possible solution might
> be a new shell-transpose-words command, which is smart enough to DTRT
> in these cases, at least as a user option? Would you like to propose
> such an addition to sh-script.el?

Now that I lived with this setting for a day, I don't think it's just
(transpose-words): "-" being a word character feels like the right thing
for shell commands. With that setting, the behavior of (forward-word)
and (backward-word) is much more pleasing as well. Arguments like a
standalone -- or - are treated like separate words, which is "right". If
you use shell-mode, try it:

  (modify-syntax-entry ?- "w")



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

* Re: Syntax of "-" in shell-mode
  2016-06-25  7:12   ` Dima Kogan
@ 2016-06-25  7:27     ` Andreas Schwab
  2016-06-25  8:27       ` Eli Zaretskii
  2016-06-26  3:31       ` Dima Kogan
  0 siblings, 2 replies; 11+ messages in thread
From: Andreas Schwab @ 2016-06-25  7:27 UTC (permalink / raw)
  To: Dima Kogan; +Cc: Eli Zaretskii, emacs-devel

Dima Kogan <lists@dima.secretsauce.net> writes:

> Now that I lived with this setting for a day, I don't think it's just
> (transpose-words): "-" being a word character feels like the right thing
> for shell commands. With that setting, the behavior of (forward-word)
> and (backward-word) is much more pleasing as well. Arguments like a
> standalone -- or - are treated like separate words, which is "right".

Use *-sexp instead.  Making - a word characters will break a lot of use
cases.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



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

* Re: Syntax of "-" in shell-mode
  2016-06-25  7:27     ` Andreas Schwab
@ 2016-06-25  8:27       ` Eli Zaretskii
  2016-06-26  3:31       ` Dima Kogan
  1 sibling, 0 replies; 11+ messages in thread
From: Eli Zaretskii @ 2016-06-25  8:27 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: lists, emacs-devel

> From: Andreas Schwab <schwab@linux-m68k.org>
> Cc: Eli Zaretskii <eliz@gnu.org>,  emacs-devel@gnu.org
> Date: Sat, 25 Jun 2016 09:27:12 +0200
> 
> Making - a word characters will break a lot of use cases.

Yes, that was my fear as well, when I proposed to have a special
command.



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

* Re: Syntax of "-" in shell-mode
  2016-06-25  7:27     ` Andreas Schwab
  2016-06-25  8:27       ` Eli Zaretskii
@ 2016-06-26  3:31       ` Dima Kogan
  1 sibling, 0 replies; 11+ messages in thread
From: Dima Kogan @ 2016-06-26  3:31 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Eli Zaretskii, emacs-devel

Andreas Schwab <schwab@linux-m68k.org> writes:

> Dima Kogan <lists@dima.secretsauce.net> writes:
>
> Use *-sexp instead.  Making - a word characters will break a lot of use
> cases.

Oh, that is interesting. The -sexp commands do indeed do what I want
here. I was thinking that changing the syntax of chars such as - was
something we were already doing in some modes, but I can't find those
anymore, so I was probably just confused. OK. Thank you for pointing
that out.

dima



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

* Re: Syntax of "-" in shell-mode
  2016-06-24 21:55     ` Ivan Andrus
@ 2016-07-07 17:49       ` Dima Kogan
  0 siblings, 0 replies; 11+ messages in thread
From: Dima Kogan @ 2016-07-07 17:49 UTC (permalink / raw)
  To: Ivan Andrus; +Cc: Drew Adams, Emacs developers

Ivan Andrus <darthandrus@gmail.com> writes:

> On Fri, Jun 24, 2016 at 3:05 PM, Dima Kogan <lists@dima.secretsauce.net> wrote:
>
>> Of course the true syntax depends on context, but in my experience, in
>> shell commands "-" is a word far more often than it isn't.
>
> I disagree.  They are symbols, not words. I don't want forward-word to skip
> past dashes, that's a job for forward-sexp.

OK. So I lived with this for a while, using xxx-sexp functions to
interact with cmdline arguments in shell-mode. This works better than
xxx-word functions because of its handling of - as you said. But -sexp
functions treat . as a separator, so this still isn't ideal.

I think it would be useful to have something (-word, -sexp, whatever) be
able to operate on cmdline arguments in shell mode. Would it be more
acceptable to adjust the internals of -sexp instead of -word in this
context?

dima



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

end of thread, other threads:[~2016-07-07 17:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24 20:48 Syntax of "-" in shell-mode Dima Kogan
2016-06-24 20:58 ` Drew Adams
2016-06-24 21:05   ` Dima Kogan
2016-06-24 21:11     ` Drew Adams
2016-06-24 21:55     ` Ivan Andrus
2016-07-07 17:49       ` Dima Kogan
2016-06-25  7:06 ` Eli Zaretskii
2016-06-25  7:12   ` Dima Kogan
2016-06-25  7:27     ` Andreas Schwab
2016-06-25  8:27       ` Eli Zaretskii
2016-06-26  3:31       ` Dima Kogan

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