unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* inhibit electric-pair-mode conditionally
@ 2016-04-18 12:50 Mohammed Sadik
  2016-04-18 15:42 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Mohammed Sadik @ 2016-04-18 12:50 UTC (permalink / raw)
  To: emacs-devel

Is there a way to disable electric-pair-mode conditionally?
Say, I have to disable electric-pair on inserting '{', but if the char
before '{' is not space.
Actually, I have even more complicated situation to handle.

It would be enough to connect some function to electric-pair (with
hooks, or so),
such that if the function returns nil, don't do completion, else do.

Is it possible?



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

* Re: inhibit electric-pair-mode conditionally
  2016-04-18 12:50 inhibit electric-pair-mode conditionally Mohammed Sadik
@ 2016-04-18 15:42 ` Stefan Monnier
  2016-04-18 16:02   ` Mohammed Sadik
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2016-04-18 15:42 UTC (permalink / raw)
  To: emacs-devel

> Is there a way to disable electric-pair-mode conditionally?

How 'bout

    electric-pair-inhibit-predicate is a variable defined in ‘elec-pair.el’.
    Its value is ‘electric-pair-default-inhibit’
    
      This variable may be risky if used as a file-local variable.
    
    Documentation:
    Predicate to prevent insertion of a matching pair.
    
    The function is called with a single char (the opening char just inserted).
    If it returns non-nil, then ‘electric-pair-mode’ will not insert a matching
    closer.
    
    You can customize this variable.
    
    This variable was introduced, or its default value was changed, in
    version 24.4 of Emacs.
    
    [back]


-- Stefan




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

* Re: inhibit electric-pair-mode conditionally
  2016-04-18 15:42 ` Stefan Monnier
@ 2016-04-18 16:02   ` Mohammed Sadik
  0 siblings, 0 replies; 3+ messages in thread
From: Mohammed Sadik @ 2016-04-18 16:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

On 4/18/16, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> Is there a way to disable electric-pair-mode conditionally?
>
> How 'bout
>
>     electric-pair-inhibit-predicate is a variable defined in
> ‘elec-pair.el’.
>     Its value is ‘electric-pair-default-inhibit’
>
Thanks. Got it working.



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

end of thread, other threads:[~2016-04-18 16:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-18 12:50 inhibit electric-pair-mode conditionally Mohammed Sadik
2016-04-18 15:42 ` Stefan Monnier
2016-04-18 16:02   ` Mohammed Sadik

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