Subject: 28.2; nroff-mode misshandled quoting

From: Gavin Jaeger-Freeborn <[email-masked]>
Date: Wed, 02 Nov 2022 21:40:45 -0700

Hello everyone,

Currently nroff-mode misidentifies double quotes in string definitions.
Currently all pairs of double quotes are highlighted as a string unless
used in a comment like in most languages. However, nroff/troff has one
special case where its is not the case. The following outlines how it should
work.

In nroff/troff you can define strings with the following format

.ds welcome hello world

This defines a `string` welcome with the contents `hello world'

Now if someone wanted to define a string that started with a space they
would instead use

.ds welcome " hello world

In addition you can call a macro with the same leeding `.` like so

.B "hello world"

This calls the macro `B` with it's first argument being `hello world`

The issue is that at the moment the strings are simply detected with the
code

(modify-syntax-entry ?\" "\"  2" st)

Meaning that (unless it's a comment) its assumed to be a string (at least
that is my understanding). Instead a special case needs to be added to
avoid doing this if the double quote is used in a string definition.

The closest thing to a language specification these languages have is
the troff user manual which defines the ds request as

> .ds xx
>
> Define a string xx containing string. Any initial double quote in string
> is stripped off to permit initial blanks.

The manual can be found at https://www.troff.org/54.pdf

For further examples on how this is used please see
https://raw.githubusercontent.com/aligrudi/neatroff_make/master/tmac/tmac.en

In addition https://github.com/aligrudi/neatroff_make/tree/master/demo
contains multiple other examples.

Thanks in advance!

Gavin

In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)
 of 2022-09-12 built on frederik
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: EndeavourOS

Configured using:
 'configure --with-x-toolkit=gtk3 --with-native-compilation
 --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
 --localstatedir=/var --with-cairo --with-harfbuzz --with-libsystemd
 --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt
 -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug -flto=auto'
 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto''

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

Important settings:
  value of $LC_MONETARY: en_CA.UTF-8
  value of $LC_NUMERIC: en_CA.UTF-8
  value of $LC_TIME: en_CA.UTF-8
  value of $LANG: en_CA.UTF-8
  locale-coding-system: utf-8-unix

Major mode: mu4e:main

Minor modes in effect:
  mu4e-search-minor-mode: t
  mu4e-update-minor-mode: t
  mu4e-context-minor-mode: t
  windmove-mode: t
  display-time-mode: t
  org-yaap-mode: t
  clipmon-mode: t
  treemacs-filewatch-mode: t
  treemacs-follow-mode: t
  treemacs-git-mode: t
  treemacs-fringe-indicator-mode: t
  recentf-mode: t
  global-paren-face-mode: t
  repeat-mode: t
  winner-mode: t
  electric-pair-mode: t
  savehist-mode: t
  global-auto-revert-mode: t
  popper-mode: t
  diff-hl-flydiff-mode: t
  global-diff-hl-mode: t
  global-org-modern-mode: t
  shell-dirtrack-mode: t
  global-hl-line-mode: t
  corfu-history-mode: t
  global-corfu-mode: t
  vertico-mode: t
  marginalia-mode: t
  global-so-long-mode: t
  async-bytecomp-package-mode: t
  dired-async-mode: t
  override-global-mode: t
  apheleia-global-mode: t
  apheleia-mode: t
  puni-global-mode: t
  puni-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  global-prettify-symbols-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  overwrite-mode: overwrite-mode-binary

Load-path shadows:
/home/gavinok/.emacs.d/elpa/transient-20220918.2101/transient hides /usr/share/emacs/28.2/lisp/transient

Features:
(shadow face-remap message-attachment-reminder mu4e mu4e-org mu4e-main
mu4e-view mu4e-headers mu4e-compose mu4e-draft mu4e-actions smtpmail
mu4e-search mu4e-lists mu4e-bookmarks mu4e-mark mu4e-message flow-fill
mu4e-contacts mu4e-update mu4e-folders mu4e-server mu4e-context
mu4e-vars mu4e-helpers mu4e-config ido puni vc-mtn vc-hg vc-bzr vc-src
vc-sccs vc-svn vc-cvs vc-rcs emacsbug sendmail misearch multi-isearch
view windmove sh-script smie tempel time org-duration org-eldoc
org-download org-attach org-id url-http url-auth url-gw org-yaap
diary-lib diary-loaddefs org-clock notifications clipmon writegood-mode
flyspell ispell lsp-zig lsp-steep lsp-svelte lsp-sqls
lsp-ruby-syntax-tree lsp-yaml lsp-xml lsp-vimscript lsp-vhdl lsp-volar
lsp-vetur lsp-html lsp-verilog lsp-vala lsp-v lsp-typeprof lsp-ttcn3
lsp-toml lsp-terraform lsp-tex lsp-tailwindcss lsp-sorbet lsp-solargraph
lsp-rust lsp-rf lsp-remark lsp-racket lsp-r lsp-purescript lsp-pylsp
lsp-pyls lsp-pwsh lsp-php lsp-pls lsp-perlnavigator lsp-perl
lsp-openscad lsp-ocaml lsp-magik lsp-nix lsp-nim lsp-nginx lsp-mint
lsp-marksman lsp-markdown lsp-lua lsp-kotlin lsp-json lsp-javascript
lsp-java-boot dap-java dap-gdb-lldb dap-utils dap-mode dap-tasks
dap-launch posframe dap-overlays lsp-java lsp-idris lsp-haxe lsp-haskell
lsp-groovy lsp-grammarly grammarly websocket bindat request lsp-hack
lsp-graphql lsp-gleam lsp-go lsp-completion lsp-gdscript lsp-fsharp
lsp-fortran lsp-eslint lsp-erlang lsp-emmet lsp-elixir lsp-elm
lsp-dockerfile lsp-docker yaml lsp-dhall lsp-d lsp-css lsp-csharp gnutls
lsp-crystal lsp-cmake lsp-clojure lsp-treemacs lsp-treemacs-generic
lsp-treemacs-themes treemacs-treelib treemacs treemacs-header-line
treemacs-compatibility treemacs-mode treemacs-bookmarks
treemacs-interface treemacs-extensions treemacs-mouse-interface
treemacs-tags treemacs-persistence treemacs-filewatch-mode
treemacs-follow-mode treemacs-rendering treemacs-annotations
treemacs-async treemacs-workspaces treemacs-dom treemacs-visuals
treemacs-fringe-indicator treemacs-scope pulse treemacs-faces
treemacs-icons treemacs-themes treemacs-core-utils pfuture
treemacs-logging treemacs-customization treemacs-macros
lsp-semantic-tokens lsp-clangd lsp-beancount lsp-bash lsp-ansible
lsp-angular lsp-ada lsp-actionscript lsp-pyright lsp-mode lsp-protocol
yasnippet spinner network-stream nsm markdown-mode color lv inline ht f
f-shortdoc shortdoc s dash haskell-doc inf-haskell haskell-decl-scan
imenu haskell haskell-completions haskell-load haskell-commands
highlight-uses-mode haskell-modules haskell-sandbox
haskell-navigate-imports haskell-repl haskell-svg haskell-collapse
haskell-debug haskell-interactive-mode haskell-presentation-mode
haskell-compile haskell-hoogle haskell-process haskell-session
haskell-indent haskell-mode haskell-cabal haskell-utils
haskell-font-lock haskell-indentation haskell-string
haskell-sort-imports haskell-lexeme haskell-align-imports
haskell-complete-module haskell-ghc-support etags fileloop xref dabbrev
haskell-customize org-indent ol-eww eww xdg url-queue mm-url ol-rmail
ol-mhe ol-irc ol-info ol-gnus nnselect gnus-search eieio-opt speedbar
ezimage dframe gnus-art mm-uu mml2015 mm-view mml-smime smime dig
gnus-sum shr kinsoku svg dom gnus-group gnus-undo gnus-start gnus-dbus
dbus xml gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec
gnus-int gnus-range message rmc puny rfc822 mml mml-sec epa derived epg
rfc6068 epg-config mailabbrev gmm-utils mailheader gnus-win gnus
nnheader gnus-util rmail rmail-loaddefs mail-utils ol-docview doc-view
jka-compr image-mode exif ol-bibtex ol-bbdb ol-w3m ol-doi org-link-doi
nroff-mode mule-util orderless cursor-sensor consult-vertico consult
compat-28 recentf tree-widget bookmark server hideshow checkdoc
flymake-proc flymake compile text-property-search thingatpt paren-face
hl-todo compat compat-macs executable vc-git repeaters repeat winner
dired-x elec-pair apheleia disp-table pcase savehist autorevert
filenotify popper project diff-hl-flydiff diff diff-hl log-view
pcvs-util vc-dir ewoc vc vc-dispatcher diff-mode org-protocol org-tempo
tempo org-modern ob-rust ob-forth ob-scheme ob-clojure ob-lisp ob-java
ob-dot ob-lua ob-C cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles
cc-align cc-engine cc-vars cc-defs ob-python python tramp-sh tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat
parse-time ls-lisp ob-shell shell ob-haskell ox-md ox-odt rng-loc
rng-uri rng-parse rng-match rng-dt rng-util rng-pttrn nxml-parse nxml-ns
nxml-enc xmltok nxml-util ox-latex ox-icalendar org-agenda org-refile
ox-html table ox-ascii ox-publish ox org-element avl-tree generator
org-contrib org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro
org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color
ring org-list org-faces org-entities noutline outline org-version
ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601
time-date ol org-keys oc org-compat org-macs org-loaddefs format-spec
find-func cal-menu calendar cal-loaddefs hl-line spaceway-theme cape
corfu-history corfu visual-regexp vertico-directory vertico marginalia
advice cus-edit pp cus-load wid-edit comp comp-cstr warnings rx so-long
pragmatapro-lig fontaine async-bytecomp dired-async async dired-aux
dired dired-loaddefs quelpa-use-package cl-extra quelpa mm-decode
mm-bodies mm-encode lisp-mnt mail-parse rfc2231 rfc2047 rfc2045 mm-util
ietf-drums mail-prsvr help-fns radix-tree help-mode use-package
use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key use-package-core finder-inf cl easy-mmode
edmacro kmacro info package browse-url url url-proxy url-privacy
url-expand url-methods url-history url-cookie url-domsuf url-util
mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs password-cache json subr-x map url-vars seq
byte-opt gv bytecomp byte-compile cconv 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
native-compile emacs)

Memory information:
((conses 16 1884181 93137)
 (symbols 48 61947 21)
 (strings 32 321162 20706)
 (string-bytes 1 9511735)
 (vectors 16 113045)
 (vector-slots 8 2128991 115355)
 (floats 8 1035 778)
 (intervals 56 151390 236)
 (buffers 992 142))