unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#18379: 24.3.93; Bash font lock: pretty inconsistent treatment of `` and $()
@ 2014-09-01 14:17 Carlos Pita
  2014-09-01 15:03 ` Andreas Schwab
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Carlos Pita @ 2014-09-01 14:17 UTC (permalink / raw)
  To: 18379; +Cc: occitan

The syntax table treats ` as an string quote character, so

`if [[ $x == x ]]; then echo x; else echo y fi`

$(if [[ $x == x ]]; then echo x; else echo y fi)

are highlighted in a very different way although they are semantically
equivalent.

Related to do above, I don't know whether the different highlighting of
the first word in:

$(if [[ $x == x ]]; then echo x; else echo y fi)

if [[ $x == x ]]; then echo x; else echo y fi

is intended or accidental, but it looks pretty weird. Moreover

$([[ $x == x ]] && echo x)

[[ $x == x ]] && echo x

will highlight exactly equal, which is not consistent with the previous
example.

All in all, I would suggest to:

1) Highlight $(...) and `...` the same way.

2) Don't set the face of the first symbol following $( in any special
way.

Regards
--
Carlos



In GNU Emacs 24.3.93.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
 of 2014-08-27 on carlos
Windowing system distributor `The X.Org Foundation', version 11.0.11600000
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'

Important settings:
  value of $LC_COLLATE: en_US.UTF-8
  value of $LC_CTYPE: en_US.UTF-8
  value of $LC_MESSAGES: en_US.UTF-8
  value of $LC_MONETARY: en_US.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Shell-script

Minor modes in effect:
  shell-dirtrack-mode: t
  sh-electric-here-document-mode: t
  show-paren-mode: t
  eldoc-mode: t
  yas-global-mode: t
  yas-minor-mode: t
  ido-ubiquitous-mode: t
  global-auto-complete-mode: t
  auto-complete-mode: t
  ido-everywhere: t
  winner-mode: t
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
( ( x ) ) SPC & & S-SPC l s SPC " x " ) <return> $ 
( l s <backspace> <backspace> [ [ SPC $ x SPC ] ] SPC 
& & SPC l s SPC " x " ) <return> $ ( <backspace> <backspace> 
<up> C-k C-y <return> <return> C-y C-a " C-e " <up> 
<up> <down> <down> C-a C-SPC <down> M-w <down> C-y 
<up> <right> <right> <right> C-d C-d C-d C-d ( ( <right> 
<right> <right> <right> <backspace> <backspace> <backspace> 
) ) <up> <up> C-x C-s <down> <down> <down> <up> e <return> 
<backspace> <backspace> C-e <return> <up> <up> <up> 
<up> <up> <up> <up> C-SPC <down> <down> <down> <down> 
M-w <down> <return> <return> <up> <up> C-y <up> <up> 
<up> <up> C-v <down> <down> <down> <right> <up> <up> 
<up> <left> <left> C-SPC C-g <down> C-SPC <down> <down> 
<down> <right> <left> C-x r t " <return> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<up> <up> <up> " <down> C-e " <down> C-e " <down> C-e 
" <down> <return> <return> <up> <up> <up> <up> <up> 
<up> <up> <up> C-SPC <down> M-w <down> <down> <down> 
<down> <down> <down> C-y <up> C-e <left> <left> <left> 
<left> <left> <backspace> <backspace> i f <right> <right> 
<right> <right> SPC f i <down> <up> <return> C-/ <left> 
<left> <right> <right> <backspace> <backspace> f i 
C-g <up> <down> <left> <left> <left> <right> <backspace> 
<return> <up> <down> M-^ <up> C-x C-s <down> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> <right> <right> 
<right> <right> <right> <right> <right> ; <down> C-x 
C-s <down> <down> <up> <up> <up> C-SPC <down> M-w <down> 
<up> C-y C-a <up> C-d C-d ` C-e <backspace> ` <down> 
<down> M-x r e p o <tab> r t - e <tab> <return>

Recent messages:
[yas] Snippet 0 exited.
Undo!
Quit
Saving file /tmp/test.sh...
Wrote /tmp/test.sh
Saving file /tmp/test.sh...
Wrote /tmp/test.sh
Mark activated
Mark set
Making completion list...

Load-path shadows:
~/.emacs.d/lisp/rmail hides /usr/share/emacs/24.3.93/lisp/mail/rmail

Features:
(shadow emacsbug xterm descr-text tramp-cache tramp tramp-compat
tramp-loaddefs trampver shell view woman man misearch multi-isearch
cus-edit cus-start cus-load sh-script smie executable gnus-draft
mailalias smtpmail sendmail oauth2 warnings json plstore nnir url-http
url-gw url-auth url-queue face-remap org-colview diary-lib
diary-loaddefs cal-iso org-agenda bookmark thingatpt tabify image-file
org-capture pp rect vc-git org-element org-rmail org-mhe org-irc
org-info org-gnus org-docview doc-view jka-compr image-mode dired
org-bibtex bibtex org-bbdb org-w3m mule-util shr-color color shr
browse-url gnus-dup sort smiley gnus-cite mm-archive mail-extr
gnus-async gnus-bcklg qp gnus-ml disp-table gnus-topic nndraft nnmh
nnfolder utf-7 epa-file epa derived epg gnutls network-stream starttls
nnimap parse-time tls utf7 netrc gnus-agent gnus-srvr gnus-score
score-mode nnvirtual gnus-msg gnus-art mm-uu mml2015 epg-config mm-view
mml-smime smime dig nntp gnus-cache gnus-sum nnoo gnus-group gnus-undo
nnmail mail-source google-contacts-message google-contacts xml url-cache
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf mailcap url-util url-parse auth-source eieio eieio-core
password-cache url-vars google-oauth gnus-start gnus-spec gnus-int
gnus-range message idna rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev gmm-utils
mailheader gnus-win gnus gnus-ems nnheader gnus-util mail-utils mm-util
mail-prsvr wid-edit server flymake compile paredit paren eldoc cl-macs
ob-python ob-R org byte-opt bytecomp byte-compile cconv org-macro
org-footnote org-pcomplete pcomplete org-list org-faces org-entities
time-date noutline outline easy-mmode org-version ob-emacs-lisp ob
ob-tangle org-src ob-ref ob-lob ob-table ob-keys ob-exp ob-comint comint
ansi-color ob-core ob-eval org-compat org-macs org-loaddefs format-spec
find-func cal-menu calendar cal-loaddefs yasnippet help-mode
ido-ubiquitous cl gv advice help-fns auto-complete-config auto-complete
popup imenu-anywhere imenu ido windmove winner ring edmacro kmacro
cl-loaddefs cl-lib info easymenu package wombat-theme tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 618712 75891)
 (symbols 48 57188 0)
 (miscs 40 3530 2211)
 (strings 32 220578 14464)
 (string-bytes 1 4703140)
 (vectors 16 51134)
 (vector-slots 8 1666305 45219)
 (floats 8 1010 1759)
 (intervals 56 28363 1382)
 (buffers 960 89)
 (heap 1024 65685 4604))





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

* bug#18379: 24.3.93; Bash font lock: pretty inconsistent treatment of `` and $()
  2014-09-01 14:17 bug#18379: 24.3.93; Bash font lock: pretty inconsistent treatment of `` and $() Carlos Pita
@ 2014-09-01 15:03 ` Andreas Schwab
       [not found] ` <mailman.8037.1409583857.1147.bug-gnu-emacs@gnu.org>
  2014-09-03  0:23 ` Stefan Monnier
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Schwab @ 2014-09-01 15:03 UTC (permalink / raw)
  To: Carlos Pita; +Cc: occitan, 18379

Carlos Pita <carlosjosepita@gmail.com> writes:

> The syntax table treats ` as an string quote character, so
>
> `if [[ $x == x ]]; then echo x; else echo y fi`
>
> $(if [[ $x == x ]]; then echo x; else echo y fi)
>
> are highlighted in a very different way although they are semantically
> equivalent.

They have different quoting rules, with `...` using rules similar to
double quotes, whereas $(...) is a fully nesting construct.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."





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

* bug#18379: 24.3.93; Bash font lock: pretty inconsistent treatment of `` and $()
       [not found] ` <mailman.8037.1409583857.1147.bug-gnu-emacs@gnu.org>
@ 2014-09-01 19:27   ` Carlos Pita
  0 siblings, 0 replies; 4+ messages in thread
From: Carlos Pita @ 2014-09-01 19:27 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: occitan, 18379

Hi Andreas,

> They have different quoting rules, with `...` using rules similar to
> double quotes, whereas $(...) is a fully nesting construct.

True, but both contains bash code for a subshell which is far from being
an uninterpreted string. IMO the important distintion to highlight is
"intepreted code" vs "uninterpreted string", not the ability to nest vs
the inability to nest (due to different quoting rules).

I've been checking how other editors do this. vim works the way I'm
proposing, while scintilla based editors do it the emacs way. Regarding
my second observation before, neither vim nor scintilla treat the
leading word in a command substution in any special way, which I think
is sensible.

Cheers
--
Carlos





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

* bug#18379: 24.3.93; Bash font lock: pretty inconsistent treatment of `` and $()
  2014-09-01 14:17 bug#18379: 24.3.93; Bash font lock: pretty inconsistent treatment of `` and $() Carlos Pita
  2014-09-01 15:03 ` Andreas Schwab
       [not found] ` <mailman.8037.1409583857.1147.bug-gnu-emacs@gnu.org>
@ 2014-09-03  0:23 ` Stefan Monnier
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2014-09-03  0:23 UTC (permalink / raw)
  To: Carlos Pita; +Cc: occitan, 18379

> The syntax table treats ` as an string quote character, so
>
> `if [[ $x == x ]]; then echo x; else echo y fi`
> $(if [[ $x == x ]]; then echo x; else echo y fi)
>
> are highlighted in a very different way although they are semantically
> equivalent.

This is largely historical, I think (with the $(...) highlighting
appearing more recently).  I don't have a strong opinion either way, but
highlighting it differently could be construed as a feature as well
(letting the user choose between the two quoting mechanisms based on
how she likes it to be highlighted).

IOW we could change it, but the motivation to do so is not very high and
it's not "obviously better".

> Related to do above, I don't know whether the different highlighting of
> the first word in:
>
> $(if [[ $x == x ]]; then echo x; else echo y fi)
> if [[ $x == x ]]; then echo x; else echo y fi
>
> is intended or accidental, but it looks pretty weird.

I don't know either, but I agree it's weird.  Patch welcome.


        Stefan





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

end of thread, other threads:[~2014-09-03  0:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-01 14:17 bug#18379: 24.3.93; Bash font lock: pretty inconsistent treatment of `` and $() Carlos Pita
2014-09-01 15:03 ` Andreas Schwab
     [not found] ` <mailman.8037.1409583857.1147.bug-gnu-emacs@gnu.org>
2014-09-01 19:27   ` Carlos Pita
2014-09-03  0:23 ` 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).