* bug#17333: sh-mode: File local variables for setting shell variant
@ 2014-04-24 0:40 Ben Finney
2014-04-29 14:21 ` Glenn Morris
0 siblings, 1 reply; 6+ messages in thread
From: Ben Finney @ 2014-04-24 0:40 UTC (permalink / raw)
To: 17333
Package: emacs
Version: 24.3.1
Severity: normal
Howdy,
The ‘sh-mode’ appears to have no means for allowing a non-executable
file to declare, in its local variables, the shell variant to use for
syntax.
Emacs allows me to specify that a shell include file should be opened
in sh mode, by setting a local variable in the editor hints::
# Local variables:
# coding: utf-8
# mode: sh
# End:
# vim: fileencoding=utf-8 filetype=bash :
I can specify to Vim that the file's shell variant is specifically
Bash, and it obeys the editor hint to present specific Bash syntax
highlighting. But Emacs has ‘sh’ mode which covers all shell variants.
The ‘sh’ mode will properly interpret such a file if it has a shebang
line (e.g. #! /bin/bash). But some files are not stand-alone programs,
so I do not want those to have a shebang line.
Emacs ‘sh’ mode treats those files as Posix shell syntax, which they
are not. ‘sh’ mode has the concept of “variant” of shell syntax; but
I'm unable to find out how to specify, in the file's editor hints,
which variant to use for the file.
How can I set the Emacs editor hints in the file such that, when the
file is opened, ‘sh’ mode knows that its syntax is Bash, or Zsh, etc.?
--
\ “If consumers even know there's a DRM, what it is, and how it |
`\ works, we've already failed.” —Peter Lee, Disney corporation, |
_o__) 2005 |
Ben Finney <ben@benfinney.id.au>
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#17333: sh-mode: File local variables for setting shell variant
2014-04-24 0:40 bug#17333: sh-mode: File local variables for setting shell variant Ben Finney
@ 2014-04-29 14:21 ` Glenn Morris
2014-04-29 15:40 ` Stefan Monnier
2014-04-30 1:01 ` Ben Finney
0 siblings, 2 replies; 6+ messages in thread
From: Glenn Morris @ 2014-04-29 14:21 UTC (permalink / raw)
To: Ben Finney; +Cc: 17333
Ben Finney wrote:
> The 'sh-mode' appears to have no means for allowing a non-executable
> file to declare, in its local variables, the shell variant to use for
> syntax.
I'd also like a way to do this.
In the past I've used
-*- mode: sh; eval: (sh-set-shell "tcsh" nil nil) -*-
but it is not great.
Ideas that come to mind are a bunch of aliases (sh-bash-mode etc) that
DTRT (yuck?); or sh-mode could add something to
hack-local-variables-hook that respects a file-local `sh-buffer-shell'
or somesuch.
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#17333: sh-mode: File local variables for setting shell variant
2014-04-29 14:21 ` Glenn Morris
@ 2014-04-29 15:40 ` Stefan Monnier
2014-04-30 1:17 ` Ben Finney
2014-05-22 20:42 ` Glenn Morris
2014-04-30 1:01 ` Ben Finney
1 sibling, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2014-04-29 15:40 UTC (permalink / raw)
To: Glenn Morris; +Cc: Ben Finney, 17333
>> The 'sh-mode' appears to have no means for allowing a non-executable
>> file to declare, in its local variables, the shell variant to use for
>> syntax.
> I'd also like a way to do this.
> In the past I've used
> -*- mode: sh; eval: (sh-set-shell "tcsh" nil nil) -*-
> but it is not great.
> Ideas that come to mind are a bunch of aliases (sh-bash-mode etc) that
> DTRT (yuck?);
Actually I think having sh-csh-mode, sh-sh-mode, and sh-rc-mode would be
a good idea.
> or sh-mode could add something to hack-local-variables-hook that
> respects a file-local `sh-buffer-shell' or somesuch.
The var's name is `sh-shell', and I guess this could make sense for the
"fine tuning" (e.g. distinguish between csh and tcsh), tho I'm not sure
it's worth the trouble.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#17333: sh-mode: File local variables for setting shell variant
2014-04-29 15:40 ` Stefan Monnier
@ 2014-04-30 1:17 ` Ben Finney
2014-05-22 20:42 ` Glenn Morris
1 sibling, 0 replies; 6+ messages in thread
From: Ben Finney @ 2014-04-30 1:17 UTC (permalink / raw)
To: Stefan Monnier; +Cc: 17333
[-- Attachment #1: Type: text/plain, Size: 680 bytes --]
On 29-Apr-2014, Stefan Monnier wrote:
> The var's name is `sh-shell', and I guess this could make sense for the
> "fine tuning" (e.g. distinguish between csh and tcsh), tho I'm not sure
> it's worth the trouble.
Having access, via the file's local variables, to set that variable
(or something equivalent like “shell-variant”) is exactly what this
bug report is about. So yes, that would be ideal.
--
\ “It's all in the mind, you know.” —The Goon Show |
`\ |
_o__) |
Ben Finney <ben@benfinney.id.au>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#17333: sh-mode: File local variables for setting shell variant
2014-04-29 15:40 ` Stefan Monnier
2014-04-30 1:17 ` Ben Finney
@ 2014-05-22 20:42 ` Glenn Morris
1 sibling, 0 replies; 6+ messages in thread
From: Glenn Morris @ 2014-05-22 20:42 UTC (permalink / raw)
To: Ben Finney, 17333
You can apparently do this now in the Emacs trunk, by setting `sh-shell'
as a file-local variable. So this is something that should appear in
the-Emacs-after-24.4.
(There's no NEWS entry.)
^ permalink raw reply [flat|nested] 6+ messages in thread
* bug#17333: sh-mode: File local variables for setting shell variant
2014-04-29 14:21 ` Glenn Morris
2014-04-29 15:40 ` Stefan Monnier
@ 2014-04-30 1:01 ` Ben Finney
1 sibling, 0 replies; 6+ messages in thread
From: Ben Finney @ 2014-04-30 1:01 UTC (permalink / raw)
To: Glenn Morris; +Cc: 17333
[-- Attachment #1: Type: text/plain, Size: 1371 bytes --]
On 29-Apr-2014, Glenn Morris wrote:
> Ben Finney wrote:
>
> > The 'sh-mode' appears to have no means for allowing a
> > non-executable file to declare, in its local variables, the shell
> > variant to use for syntax.
>
> I'd also like a way to do this.
> In the past I've used
>
> -*- mode: sh; eval: (sh-set-shell "tcsh" nil nil) -*-
>
> but it is not great.
Partly because, AIUI, having ‘eval’ in the file's local variables is a
security hole, and is often disabled.
> Ideas that come to mind are a bunch of aliases (sh-bash-mode etc) that
> DTRT (yuck?); or sh-mode could add something to
> hack-local-variables-hook that respects a file-local `sh-buffer-shell'
> or somesuch.
I'd expect to be able to set the shell variant similar to the way that
I can set the SQL dialect::
# Local variables:
# coding: utf-8
# mode: sql
# sql-product: postgres
# End:
So, for example::
# Local variables:
# coding: utf-8
# mode: sh
# shell-variant: bash
# End:
would be a good interface for this feature, IMO.
--
\ “I went to the cinema, it said ‘Adults: $5.00, Children $2.50’. |
`\ So I said ‘Give me two boys and a girl.’” —Steven Wright |
_o__) |
Ben Finney <ben@benfinney.id.au>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-05-22 20:42 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-24 0:40 bug#17333: sh-mode: File local variables for setting shell variant Ben Finney
2014-04-29 14:21 ` Glenn Morris
2014-04-29 15:40 ` Stefan Monnier
2014-04-30 1:17 ` Ben Finney
2014-05-22 20:42 ` Glenn Morris
2014-04-30 1:01 ` Ben Finney
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.