unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Smartparens documentation question.
@ 2021-04-08 16:34 R. Clayton
  2021-04-11  4:54 ` Michael Heerdegen
  0 siblings, 1 reply; 2+ messages in thread
From: R. Clayton @ 2021-04-08 16:34 UTC (permalink / raw)
  To: help-gnu-emacs

In smartparens I read in the documentation for the function
show-smartparens-mode that

  If called from Lisp, also enable the mode if ARG is omitted or nil, and
  toggle it if ARG is ‘toggle’; disable the mode otherwise.

This strikes me as backwards, because I thought the idiom is nil args turn
things off and non-nil args turn things on, but ok, sure, maybe it's a
minor-mode thing.  However, poking around in smartparens.el shows

  ;;;###autoload
  (defun turn-on-show-smartparens-mode ()
    "Turn on `show-smartparens-mode'."
    (interactive)
    (unless (or (member major-mode sp-ignore-modes-list)
                (and (not (derived-mode-p 'comint-mode))
                     (eq (get major-mode 'mode-class) 'special)))
      (show-smartparens-mode t)))

which seems consistent with the idiom and contradictory to the documentation.

What is the explanation for what's going on here?




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

* Re: Smartparens documentation question.
  2021-04-08 16:34 Smartparens documentation question R. Clayton
@ 2021-04-11  4:54 ` Michael Heerdegen
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen @ 2021-04-11  4:54 UTC (permalink / raw)
  To: R. Clayton; +Cc: help-gnu-emacs

"R. Clayton" <factotum@rclayton.org> writes:

> In smartparens I read in the documentation for the function
> show-smartparens-mode that
>
>   If called from Lisp, also enable the mode if ARG is omitted or nil, and
>   toggle it if ARG is ‘toggle’; disable the mode otherwise.
>
> This strikes me as backwards, because I thought the idiom is nil args turn
> things off and non-nil args turn things on, but ok, sure, maybe it's a
> minor-mode thing.

The (currently) correct idiom is (`define-minor-mode'):

When called from Lisp, the mode command toggles the mode if the
argument is `toggle', disables the mode if the argument is a
non-positive integer, and enables the mode otherwise (including
if the argument is omitted or nil or a positive integer).

>  However, poking around in smartparens.el shows
>
>   ;;;###autoload
>   (defun turn-on-show-smartparens-mode ()
>     "Turn on `show-smartparens-mode'."
>     (interactive)
>     (unless (or (member major-mode sp-ignore-modes-list)
>                 (and (not (derived-mode-p 'comint-mode))
>                      (eq (get major-mode 'mode-class) 'special)))
>       (show-smartparens-mode t)))

That would be correct code if the docstring of `show-smartparens-mode'
is wrong.

AFAIR these details (which arguments exactly turn the mode on and off)
were subject to change in the recent past.  You might want to contact
the author of smartparens so he or she can correct the docstring or
whatever is wrong.

Thanks,

Michael.



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

end of thread, other threads:[~2021-04-11  4:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-08 16:34 Smartparens documentation question R. Clayton
2021-04-11  4:54 ` Michael Heerdegen

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