unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode
@ 2022-01-22 13:22 Philip Kaludercic
  2022-09-23  7:24 ` Philip Kaludercic
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Kaludercic @ 2022-01-22 13:22 UTC (permalink / raw)
  To: 53446


Open an AWK file, and ensure that electric-pair-mode is enabled.  It
seems that some character pairs like braces or parentheses are
automatically paired, while others like apostrophes or double quotes are
not.


In GNU Emacs 29.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.16.0)
 of 2022-01-21 built on viero
Repository revision: adf00298b60e87f76c64b1ba68c0424df55982e1
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
Configured using:
 'configure CC=gcc
 PKG_CONFIG_PATH=/home/philip/.guix-profile/lib/pkgconfig:/home/philip/.guix-profile/share/pkgconfig'

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

Important settings:
  value of $EMACSLOADPATH: 
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  TeX-PDF-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  auto-revert-mode: t
  shell-dirtrack-mode: t
  bug-reference-prog-mode: t
  outline-minor-mode: t
  flymake-mode: t
  flyspell-mode: t
  recentf-mode: t
  repeat-mode: t
  display-battery-mode: t
  display-time-mode: t
  diff-hl-flydiff-mode: t
  diff-hl-mode: t
  winner-mode: t
  windmove-mode: t
  corfu-global-mode: t
  corfu-mode: t
  vertico-mouse-mode: t
  vertico-multiform-mode: t
  vertico-mode: t
  electric-pair-mode: t
  save-place-mode: t
  savehist-mode: t
  xterm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tab-bar-mode: t
  file-name-shadow-mode: t
  context-menu-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  temp-buffer-resize-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-save-visited-mode: t

Load-path shadows:
/home/philip/Source/sp-tutor/sp-tutor hides /home/philip/.config/emacs/site-lisp/sp-tutor/sp-tutor
/home/philip/Source/sp-tutor/waffel hides /home/philip/.config/emacs/site-lisp/sp-tutor/waffel
/home/philip/.config/emacs/elpa/transient-0.3.7/transient hides /home/philip/Source/emacs/lisp/transient
~/.config/emacs/site-lisp/autoload hides /home/philip/Source/emacs/lisp/emacs-lisp/autoload

Features:
(shadow autocrypt-message emacsbug cc-awk preview tex-buf tex-fold
reftex-dcr reftex-auc reftex reftex-loaddefs reftex-vars font-latex
latex latex-flymake tex-ispell tex-style tex texmathp tex-mode latexenc
doc-view image-mode exif reveal qp gnus-draft nndraft nnmh utf-7
nnfolder epa-file macrostep cl avy orderless tar-mode arc-mode
archive-mode markdown-mode eglot array jsonrpc ert debug make-mode
descr-text cl-print edebug backtrace jka-compr info-look sort smiley
gnus-cite mail-extr textsec uni-scripts idna-mapping ucs-normalize
uni-confusable textsec-check gnus-async gnus-bcklg debbugs-gnu debbugs
soap-client rng-xsd rng-dt rng-util xsd-regexp gnus-agent gnus-srvr
gnus-score score-mode nnvirtual nntp gnus-ml gnus-msg gnus-art mm-uu
mml2015 mm-view mml-smime smime dig autocrypt-gnus autocrypt nndoc
gnus-cache gnus-sum shr pixel-fill kinsoku svg dom gnus-group gnus-undo
gnus-start gnus-dbus gnus-cloud nnimap nnmail mail-source utf7 netrc
nnoo gnus-spec gnus-int gnus-range gnus-win vc-annotate shortdoc python
tramp-sh tramp tramp-loaddefs trampver tramp-integration files-x
tramp-compat parse-time iso8601 ls-lisp whitespace conf-mode reposition
char-fold misearch multi-isearch tabify man magit-extras magit-bookmark
magit-submodule magit-obsolete magit-blame magit-stash magit-reflog
magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote
magit-commit magit-sequence magit-notes magit-worktree magit-tag
magit-merge magit-branch magit-reset magit-files magit-refs magit-status
magit magit-repos magit-apply magit-wip magit-log which-func imenu
magit-diff smerge-mode git-commit log-edit add-log magit-core
magit-autorevert autorevert filenotify magit-margin magit-transient
magit-process with-editor server magit-mode transient edmacro magit-git
magit-section benchmark magit-utils dash flymake-cc yasnippet-snippets
yasnippet cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align
shell pcomplete shell-command+ cc-engine cc-vars cc-defs dired-aux
gnus-dired vc-mtn vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs mm-archive
message yank-media rfc822 mml mml-sec epa mailabbrev gmm-utils
mailheader mm-decode mm-bodies mm-encode mule-util gnutls network-stream
url-http url-gw nsm rmc puny url-cache url-auth epg rfc6068 epg-config
finder-inf vertico-buffer consult-vertico consult kmacro bookmark
display-fill-column-indicator pulse color bug-reference help-fns
find-func xref copyright time-stamp vc-backup derived log-view pcvs-util
crm cus-edit pp cus-start vertico-directory vertico-flat
modus-vivendi-theme cl-extra noutline outline checkdoc help-mode
flymake-proc flymake project warnings thingatpt flyspell ispell
auth-source-pass recentf tree-widget repeat pcase format-spec battery
dbus xml dired-x dired dired-loaddefs time sendmail gnus nnheader
gnus-util time-date mail-utils range wid-edit help-at-pt diff-hl-flydiff
diff diff-hl face-remap vc-hg vc-git vc-dir ewoc vc vc-dispatcher
diff-mode easy-mmode hippie-exp winner windmove rx corfu vertico-mouse
vertico-multiform vertico elec-pair saveplace savehist xt-mouse
modus-operandi-theme modus-themes rot13 disp-table cus-load setup
compile text-property-search comint ansi-color ring autoload radix-tree
lisp-mnt mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr tex-site slime-autoloads 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 map url-vars
seq gv subr-x byte-opt 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 keymap hashtable-print-readable backquote threads
dbusbind inotify 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 1215107 222846)
 (symbols 48 60655 247)
 (strings 32 256698 21930)
 (string-bytes 1 7066956)
 (vectors 16 111765)
 (vector-slots 8 2719715 156221)
 (floats 8 760 822)
 (intervals 56 57632 13530)
 (buffers 992 49))

-- 
	Philip Kaludercic





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

* bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode
  2022-01-22 13:22 bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode Philip Kaludercic
@ 2022-09-23  7:24 ` Philip Kaludercic
  2022-09-23 18:37   ` Alan Mackenzie
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Kaludercic @ 2022-09-23  7:24 UTC (permalink / raw)
  To: 53446; +Cc: Alan Mackenzie

Philip Kaludercic <philipk@posteo.net> writes:

> Open an AWK file, and ensure that electric-pair-mode is enabled.  It
> seems that some character pairs like braces or parentheses are
> automatically paired, while others like apostrophes or double quotes are
> not.

I have managed to narrow this bug to the function 
`c-electric-pair-inhibit-predicate' that is used as
`electric-pair-inhibit-predicate' by cc-mode.  Specifically this check

    (not (equal (c-get-char-property last-quote 'c-fl-syn-tab) '(15)))

fails, because the macro

    (c-get-char-property last-quote 'c-fl-syn-tab)

that expands to

    (get-text-property last-quote 'c-fl-syn-tab)

where `last-quote' is the position of the last quotation mark in a
"logical line", evaluates to nil, not (15).  I do not understand why
this happens, or what the text property `c-fl-syn-tab' is supposed to
indicate.

I have CC'ed Alan to see if he can help.





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

* bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode
  2022-09-23  7:24 ` Philip Kaludercic
@ 2022-09-23 18:37   ` Alan Mackenzie
  2022-09-23 18:57     ` Philip Kaludercic
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Mackenzie @ 2022-09-23 18:37 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: 53446

Hello, Philip.

Sorry I missed this bug in January.

On Fri, Sep 23, 2022 at 07:24:34 +0000, Philip Kaludercic wrote:
> Philip Kaludercic <philipk@posteo.net> writes:

> > Open an AWK file, and ensure that electric-pair-mode is enabled.  It
> > seems that some character pairs like braces or parentheses are
> > automatically paired, while others like apostrophes or double quotes are
> > not.

The reason apostrophes don't work with electric-pair-mode is that they
are not quote characters in AWK.  :-)

> I have managed to narrow this bug to the function 
> `c-electric-pair-inhibit-predicate' that is used as
> `electric-pair-inhibit-predicate' by cc-mode.  Specifically this check

>     (not (equal (c-get-char-property last-quote 'c-fl-syn-tab) '(15)))

> fails, because the macro

>     (c-get-char-property last-quote 'c-fl-syn-tab)

> that expands to

>     (get-text-property last-quote 'c-fl-syn-tab)

> where `last-quote' is the position of the last quotation mark in a
> "logical line", evaluates to nil, not (15).  I do not understand why
> this happens, or what the text property `c-fl-syn-tab' is supposed to
> indicate.

It happens because AWK Mode doesn't use the unterminated string
detection code the other CC Mode modes use.  (It doesn't need to, being
simpler.)  So, rather than temporarily storing its "working"
syntax-table text properties, AWK just lets them be.  So, we can just
test the syntax-table text property for being '(15) (string fence) in
AWK Mode.

> I have CC'ed Alan to see if he can help.

Would you please try out the following patch, and let me know how it
goes.  Thanks!



diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index 9309a546db..679690b33c 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -2714,7 +2714,10 @@ c-electric-pair-inhibit-predicate
 			  (save-excursion
 			    (goto-char (c-point 'eoll))
 			    (search-backward "\"")))))
-	(not (equal (c-get-char-property last-quote 'c-fl-syn-tab) '(15))))
+	(not (equal
+	      (or (c-get-char-property last-quote 'c-fl-syn-tab)
+		  (c-get-char-property last-quote 'syntax-table)) ; for AWK
+	      '(15))))
     (funcall (default-value 'electric-pair-inhibit-predicate) char)))
 
 \f


-- 
Alan Mackenzie (Nuremberg, Germany).





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

* bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode
  2022-09-23 18:37   ` Alan Mackenzie
@ 2022-09-23 18:57     ` Philip Kaludercic
  2022-09-24 12:37       ` Alan Mackenzie
  0 siblings, 1 reply; 5+ messages in thread
From: Philip Kaludercic @ 2022-09-23 18:57 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: 53446

Alan Mackenzie <acm@muc.de> writes:

> Hello, Philip.
>
> Sorry I missed this bug in January.

No problem.

> On Fri, Sep 23, 2022 at 07:24:34 +0000, Philip Kaludercic wrote:
>> Philip Kaludercic <philipk@posteo.net> writes:
>
>> > Open an AWK file, and ensure that electric-pair-mode is enabled.  It
>> > seems that some character pairs like braces or parentheses are
>> > automatically paired, while others like apostrophes or double quotes are
>> > not.
>
> The reason apostrophes don't work with electric-pair-mode is that they
> are not quote characters in AWK.  :-)
>
>> I have managed to narrow this bug to the function 
>> `c-electric-pair-inhibit-predicate' that is used as
>> `electric-pair-inhibit-predicate' by cc-mode.  Specifically this check
>
>>     (not (equal (c-get-char-property last-quote 'c-fl-syn-tab) '(15)))
>
>> fails, because the macro
>
>>     (c-get-char-property last-quote 'c-fl-syn-tab)
>
>> that expands to
>
>>     (get-text-property last-quote 'c-fl-syn-tab)
>
>> where `last-quote' is the position of the last quotation mark in a
>> "logical line", evaluates to nil, not (15).  I do not understand why
>> this happens, or what the text property `c-fl-syn-tab' is supposed to
>> indicate.
>
> It happens because AWK Mode doesn't use the unterminated string
> detection code the other CC Mode modes use.  (It doesn't need to, being
> simpler.)  So, rather than temporarily storing its "working"
> syntax-table text properties, AWK just lets them be.  So, we can just
> test the syntax-table text property for being '(15) (string fence) in
> AWK Mode.
>
>> I have CC'ed Alan to see if he can help.
>
> Would you please try out the following patch, and let me know how it
> goes.  Thanks!

Yes, this does the job.

>
> diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
> index 9309a546db..679690b33c 100644
> --- a/lisp/progmodes/cc-mode.el
> +++ b/lisp/progmodes/cc-mode.el
> @@ -2714,7 +2714,10 @@ c-electric-pair-inhibit-predicate
>  			  (save-excursion
>  			    (goto-char (c-point 'eoll))
>  			    (search-backward "\"")))))
> -	(not (equal (c-get-char-property last-quote 'c-fl-syn-tab) '(15))))
> +	(not (equal
> +	      (or (c-get-char-property last-quote 'c-fl-syn-tab)
> +		  (c-get-char-property last-quote 'syntax-table)) ; for AWK
> +	      '(15))))
>      (funcall (default-value 'electric-pair-inhibit-predicate) char)))
>  
>  \f





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

* bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode
  2022-09-23 18:57     ` Philip Kaludercic
@ 2022-09-24 12:37       ` Alan Mackenzie
  0 siblings, 0 replies; 5+ messages in thread
From: Alan Mackenzie @ 2022-09-24 12:37 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: acm, 53446-done

Hello, Philip.

On Fri, Sep 23, 2022 at 18:57:31 +0000, Philip Kaludercic wrote:
> Alan Mackenzie <acm@muc.de> writes:

> > On Fri, Sep 23, 2022 at 07:24:34 +0000, Philip Kaludercic wrote:
> >> Philip Kaludercic <philipk@posteo.net> writes:

> >> I have CC'ed Alan to see if he can help.

[ .... ]

> > Would you please try out the following patch, and let me know how it
> > goes.  Thanks!

> Yes, this does the job.

Thanks for the testing!  I've actually committed a somewhat different
patch to savannah master, which also fixes one or two other minor things
in the area.  I'm also closing the bug with this post.

[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).





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

end of thread, other threads:[~2022-09-24 12:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-22 13:22 bug#53446: 29.0.50; Issues with awk-mode and electric-pair-mode Philip Kaludercic
2022-09-23  7:24 ` Philip Kaludercic
2022-09-23 18:37   ` Alan Mackenzie
2022-09-23 18:57     ` Philip Kaludercic
2022-09-24 12:37       ` Alan Mackenzie

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