[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: electric-pair-mode as a minor mode?

From: João Távora
Subject: Re: electric-pair-mode as a minor mode?
Date: Sun, 29 Mar 2015 21:41:30 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (darwin)

Stefan Monnier <address@hidden> writes:
> It might be a good idea to do it in general (i.e. not as part of
> electric-pair-mode but as part of message-mode for example).  

Yes, that's what I meant. This hack:

   (modify-syntax-entry ?> "<   " message-mode-syntax-table)
   (modify-syntax-entry ?\n ">   " message-mode-syntax-table)
   (add-hook 'message-mode-hook
          (lambda () (setq-local parse-sexp-ignore-comments t)))

could go somewhere into lisp/message.el if it weren't so fragile: the
comment syntax could change according to `message-yank-cited-prefix' and
also I has to be a comment only if it starts in the first column... Do
you follow?  Know any way to handle these cases?

> doesn't change the fact that syntax-ppss is unreliable.  they're
> ... 
> correct.  But for natural language, there's no such perfection.  very
> ...
> dependent on specific conventions used by people, which change
> significantly between communities).

Yes, yes and yes. Of course in natural languages there's no compiler
formally telling you the message is unsyntactic, but I personally will
go for a tool that gets it right almost everytime (some value between
90% and 100%), as long as the price when it gets it wrong is not too
high. And simple syntax changes to help the syntax-ppss heuristic are
the low-hanging fruit.

>>    (add-hook 'text-mode-hook
>>      (lambda () (setq-local electric-pair-preserve-balance nil)))
> Ah, that might do it, indeed.  At least a quick experiment seems to
> handle the cases I mentioned so far.

Not suprising considering that brings back precisely your old
implementation :-)

(oh no an unpaired smiley!)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]