unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#57042: 28.1.91; c-mode autoindents cweb style lines
@ 2022-08-07 16:16 Van Ly
  2022-08-07 16:31 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Van Ly @ 2022-08-07 16:16 UTC (permalink / raw)
  To: 57042

[-- Attachment #1: Type: text/plain, Size: 887 bytes --]


Hello,

C Mode autoindents CWEB style lines undesirably.

Steps to reproduce
  . starting from 'emacs -Q'
  . open new file 'C-x f /dev/shm/explain.w'
  . enable mode for C 'M-x c-mode'
  . enter the C CWEB style source text below
  . Explanation}
      the last two lines autoindent but I expect them to be without
  . at line 6 below at # position c-set-offset reports 'cpp-macro'
  . at line 0 below at # position c-set-offset reports 'cpp-macro'

Expected result is for lines 6, F and 0 below to be without indent.

```
1 @** Convert 511 decimal to octal.
2 @d _x_number_x_ 511
3 @d _x_banner_x_ "What is the value of %d in octal?"
4 @c
5 #include <stdio.h>
6 #include "u.h"
7 int@/
8 main(void)@/
9 {
A   int n = _x_number_x_;
B   printf (_x_banner_x_, n);
C   printf ("%s! %d decimal is %o octal\n", "Right", n, n);
D }
E @ @(u.h@>=
F     @h
0     #include <stdlib.h>
```

-- 
vl

[-- Attachment #2: generated details for bug report --]
[-- Type: text/plain, Size: 3264 bytes --]

In GNU Emacs 28.1.91 (build 1, aarch64-unknown-linux-gnu, GTK+ Version 3.24.24, cairo version 1.16.0)
 of 2022-08-08 built on charlie
Repository revision: 059ab47a0664012b4d8cf8cc36b7d8a28b80c614
Repository branch: main
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM GTK3 ZLIB

Important settings:
  value of $LC_ALL: en_AU.UTF-8
  value of $LANG: en_AU.UTF-8
  locale-coding-system: utf-8-unix

Major mode: C/*l

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs
auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs
password-cache json map mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils time-date subr-x bookmark
text-property-search pp seq byte-opt gv bytecomp byte-compile cconv
tutorial vc-git diff-mode easy-mmode vc-dispatcher view dired-aux dired
dired-loaddefs help-fns radix-tree help-mode cc-mode cc-fonts cc-guess
cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode lisp-mode prog-mode register
page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer cl-generic cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932
hebrew greek romanian slovak czech european ethiopic indian cyrillic
chinese composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process emacs)

Memory information:
((conses 16 92389 4478)
 (symbols 48 9389 1)
 (strings 32 29591 1471)
 (string-bytes 1 1078473)
 (vectors 16 18973)
 (vector-slots 8 239472 9959)
 (floats 8 28 46)
 (intervals 56 1556 0)
 (buffers 992 21))

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

* bug#57042: 28.1.91; c-mode autoindents cweb style lines
  2022-08-07 16:16 bug#57042: 28.1.91; c-mode autoindents cweb style lines Van Ly
@ 2022-08-07 16:31 ` Eli Zaretskii
  2022-08-07 18:12   ` Van Ly
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-08-07 16:31 UTC (permalink / raw)
  To: Van Ly; +Cc: 57042

> Date: Sun, 7 Aug 2022 16:16:31 +0000 (UTC)
> From: Van Ly <van.ly@sdf.org>
> 
> C Mode autoindents CWEB style lines undesirably.
> 
> Steps to reproduce
>   . starting from 'emacs -Q'
>   . open new file 'C-x f /dev/shm/explain.w'
>   . enable mode for C 'M-x c-mode'
>   . enter the C CWEB style source text below
>   . Explanation}
>       the last two lines autoindent but I expect them to be without
>   . at line 6 below at # position c-set-offset reports 'cpp-macro'
>   . at line 0 below at # position c-set-offset reports 'cpp-macro'
> 
> Expected result is for lines 6, F and 0 below to be without indent.
> 
> ```
> 1 @** Convert 511 decimal to octal.
> 2 @d _x_number_x_ 511
> 3 @d _x_banner_x_ "What is the value of %d in octal?"
> 4 @c
> 5 #include <stdio.h>
> 6 #include "u.h"
> 7 int@/
> 8 main(void)@/
> 9 {
> A   int n = _x_number_x_;
> B   printf (_x_banner_x_, n);
> C   printf ("%s! %d decimal is %o octal\n", "Right", n, n);
> D }
> E @ @(u.h@>=
> F     @h
> 0     #include <stdlib.h>
> ```

Sorry, I don't understand: why do you expect C Mode to DTRT for CWEB
files?  The above is not valid C code, it's a different language that
needs a dedicated major mode.





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

* bug#57042: 28.1.91; c-mode autoindents cweb style lines
  2022-08-07 16:31 ` Eli Zaretskii
@ 2022-08-07 18:12   ` Van Ly
  2022-08-07 21:58     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 5+ messages in thread
From: Van Ly @ 2022-08-07 18:12 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 57042

On Sun, 7 Aug 2022, Eli Zaretskii wrote:

>
> Sorry, I don't understand: why do you expect C Mode to DTRT for CWEB
> files?  The above is not valid C code, it's a different language that
> needs a dedicated major mode.
>

Yes, there is a dedicated mode for cweb by dek.  I guess it is out of 
date in relation to modern Emacs.  I'm expecting c mode might have 
enough fuzzy heuristic to play well with cweb.  For example, skip the 
lines beginning with @ when autoindenting.  C code validity is a 
moving target.

-- 
vl






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

* bug#57042: 28.1.91; c-mode autoindents cweb style lines
  2022-08-07 18:12   ` Van Ly
@ 2022-08-07 21:58     ` Lars Ingebrigtsen
  2022-08-08  3:50       ` Van Ly
  0 siblings, 1 reply; 5+ messages in thread
From: Lars Ingebrigtsen @ 2022-08-07 21:58 UTC (permalink / raw)
  To: Van Ly; +Cc: 57042, Eli Zaretskii

Van Ly <van.ly@sdf.org> writes:

> Yes, there is a dedicated mode for cweb by dek.  I guess it is out of
> date in relation to modern Emacs.  I'm expecting c mode might have
> enough fuzzy heuristic to play well with cweb.  For example, skip the
> lines beginning with @ when autoindenting.  C code validity is a
> moving target.

c-mode doesn't support the cweb language, and won't do that, either.

It might make sense to add a package for doing that to ELPA, but I
haven't seen anybody request that either, so it seems like there's not
really much demand for it.

In any case, I don't think there's anything actionable here on the
Emacs side, so I'm closing this bug report.





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

* bug#57042: 28.1.91; c-mode autoindents cweb style lines
  2022-08-07 21:58     ` Lars Ingebrigtsen
@ 2022-08-08  3:50       ` Van Ly
  0 siblings, 0 replies; 5+ messages in thread
From: Van Ly @ 2022-08-08  3:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 57042, Eli Zaretskii

On Sun, 7 Aug 2022, Lars Ingebrigtsen wrote:

>
> c-mode doesn't support the cweb language, and won't do that, either.
>
> It might make sense to add a package for doing that to ELPA, but I
> haven't seen anybody request that either, so it seems like there's not
> really much demand for it.
>

But I did when I discovered cweb is out there and working.  I posted a
bug report with  a link to the  cweb mode el file.   I guess ownership
and licensing bureaucratic complication make  it less available and to
keep  current.   Finding that  file  wasn't  easy.  Anyway,  cweb  has
intrinsic value  in as much  Emacs has.  Prog mode doesn't  indent the
second brace right at all which was why I tried the c mode next.

'C-c C-o' can tell c mode to override the autoindent to offset 0.

-- 
vl






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

end of thread, other threads:[~2022-08-08  3:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-07 16:16 bug#57042: 28.1.91; c-mode autoindents cweb style lines Van Ly
2022-08-07 16:31 ` Eli Zaretskii
2022-08-07 18:12   ` Van Ly
2022-08-07 21:58     ` Lars Ingebrigtsen
2022-08-08  3:50       ` Van Ly

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