unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* An issue with electric mode
@ 2020-04-18 16:38 Angelo Graziosi
  2020-04-18 19:21 ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Angelo Graziosi @ 2020-04-18 16:38 UTC (permalink / raw)
  To: emacs-devel

Maybe this is not an issue but just e feature..

In the init.el I have

(electric-pair-mode 1)

and in an .adoc buffer (it is an Asciidoctor document which Emacs processes in Fundamental mode) I have this text:

_function_ ends (with `return` or with `}`)

Before this line the electric-pair-mode does not work. In short the '(' is matched with the '}' (in violet) so the last ')' is considered unmatched.

Is this the right behavior?

Thanks,
  Angelo.



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

* Re: An issue with electric mode
  2020-04-18 16:38 An issue with electric mode Angelo Graziosi
@ 2020-04-18 19:21 ` João Távora
  2020-04-18 21:03   ` Angelo Graziosi
  0 siblings, 1 reply; 4+ messages in thread
From: João Távora @ 2020-04-18 19:21 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

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

> Is this the right behavior?

Yes, I think so.  Let me try to remember how I reasoned about
this when I implemented this around 2014.

In modes whose syntax table defines different types of paired
delimiters (braces and parenthesis), such as here, you would
want to be notified first and foremost that the closing brace is
unmatched. Which is what happens here.  As soon as you give
the closing brace an opening brace to match against, the
opening and closing parenthesis resume the expected matching.

But what if the closing brace isn't really an element of the
language you're editing, as seems to be the case in your
.adoc files?  Well, in that case, the major mode has to know
about it.  So I suspect that if you change the syntax table to
define the backtick as a string delimiter, things will magically
start working as you intend them.  Let me try:

   (modify-syntax-entry ?` "\"")

Yep. Try that in the buffer.  It should fix it.  Of course such
a line should ideally be in a major mode definition for your
files.  Some:

(define-derived-mode asciidoctor-mode prog-mode "Adoc"
  (modify-syntax-entry ?` "\"")
  ... likely more stuff ...)

Notice that the brace is still unmatched inside the string.
That is also by design.  Because matching delimiters insider
strings and comments follow largely the same logic (but
isolated for that domain).  If the brace really has no special
meaning in your language, the major mode must also
know about that (but by default braces have meaning).

HTH,
João

[-- Attachment #2: Type: text/html, Size: 2134 bytes --]

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

* Re: An issue with electric mode
  2020-04-18 19:21 ` João Távora
@ 2020-04-18 21:03   ` Angelo Graziosi
  2020-04-18 21:05     ` João Távora
  0 siblings, 1 reply; 4+ messages in thread
From: Angelo Graziosi @ 2020-04-18 21:03 UTC (permalink / raw)
  To: João Távora; +Cc: emacs-devel


> Il 18 aprile 2020 alle 21.21 João Távora ha scritto:
> 
> 
> > Is this the right behavior?
> 
> Yes, I think so.  Let me try to remember how I reasoned about
> this when I implemented this around 2014.

Thanks for clarification. The simplest workaround was to change my text   to not using the '`}`'...

Your analysis would be more integrated with an hypothetical adoc-mode.. 


Angelo



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

* Re: An issue with electric mode
  2020-04-18 21:03   ` Angelo Graziosi
@ 2020-04-18 21:05     ` João Távora
  0 siblings, 0 replies; 4+ messages in thread
From: João Távora @ 2020-04-18 21:05 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

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

On Sat, Apr 18, 2020 at 10:03 PM Angelo Graziosi <angelo.g0@libero.it>
wrote:
>
>
> > Yes, I think so.  Let me try to remember how I reasoned about
> > this when I implemented this around 2014.
>
> Thanks for clarification. The simplest workaround was to change my text
to not using the '`}`'...
>
> Your analysis would be more integrated with an hypothetical adoc-mode..

Yes, indeed I didn't realize just getting rid of the } was an option!

João

[-- Attachment #2: Type: text/html, Size: 601 bytes --]

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

end of thread, other threads:[~2020-04-18 21:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-18 16:38 An issue with electric mode Angelo Graziosi
2020-04-18 19:21 ` João Távora
2020-04-18 21:03   ` Angelo Graziosi
2020-04-18 21:05     ` João Távora

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