all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Drew Adams <drew.adams@oracle.com>,
	Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel@gnu.org
Subject: Re: Should mode commands be idempotent?
Date: Sun, 08 Oct 2017 15:28:35 +0000	[thread overview]
Message-ID: <CAArVCkR=UHjHTMtuHfs3g70BxRZXxmUTwGAmjE+zvK6sBjebew@mail.gmail.com> (raw)
In-Reply-To: <m2mv5h2suj.fsf@newartisans.com>


[-- Attachment #1.1: Type: text/plain, Size: 1032 bytes --]

John Wiegley <jwiegley@gmail.com> schrieb am Di., 26. Sep. 2017 um
20:55 Uhr:

> >>>>> Drew Adams <drew.adams@oracle.com> writes:
>
> > Good luck with such a guideline. The state of an Emacs session is _never_
> > exactly the same after each time you turn on a mode - any mode, any
> session.
> > So many things change...
>
> I think we can reduce the scope of what we're saying:
>
> The statement I made only applies if the command is called in immediate
> succession. That is, the function is *itself* idempotent; it doesn't
> guarantee
> that intervening effects are somehow negated.
>
> That is, the following should be functionally equivalent:
>
>     (foo-mode 1)
>     (progn (foo-mode 1) (foo-mode 1))
>
> I don't see what great difficulty this poses. If a mode author is doing
> thing
> inside `foo-mode' like changing the system or the disk, that's exactly the
> sort of thing our guideline seeks to prevent.
>

Given that all current and past maintainers seem to agree, how about the
following patch for the Lisp manual?

[-- Attachment #1.2: Type: text/html, Size: 1474 bytes --]

[-- Attachment #2: 0001-Document-that-mode-commands-should-be-idempotent.txt --]
[-- Type: text/plain, Size: 1363 bytes --]

From 466ee5853a07f90593149e4de07f92845e076170 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sun, 8 Oct 2017 17:25:31 +0200
Subject: [PATCH] Document that mode commands should be idempotent.

* doc/lispref/modes.texi (Major Mode Conventions, Minor Mode
Conventions): Document that the mode commands should be idempotent.
---
 doc/lispref/modes.texi | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi
index f7013da943..f2fc742495 100644
--- a/doc/lispref/modes.texi
+++ b/doc/lispref/modes.texi
@@ -313,6 +313,10 @@ Major Mode Conventions
 Data}, for other possible forms).  The name of the mode appears
 in the mode line.
 
+@item
+Calling the major mode command twice in direct succession should not
+fail and should do the same thing as calling the command only once.
+
 @item
 @cindex functions in modes
 Since all global names are in the same name space, all the global
@@ -1412,6 +1416,10 @@ Minor Mode Conventions
 @noindent
 However, this is not very commonly done.
 
+  Enabling or disabling a minor mode twice in direct succession should
+not fail and should do the same thing as enabling or disabling it only
+once.
+
 @item
 Add an element to @code{minor-mode-alist} for each minor mode
 (@pxref{Definition of minor-mode-alist}), if you want to indicate the
-- 
2.14.2


  reply	other threads:[~2017-10-08 15:28 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-19 19:58 Should mode commands be idempotent? Philipp Stephani
2017-09-19 22:10 ` Clément Pit-Claudel
2017-09-19 22:29   ` Stefan Monnier
2017-09-20  7:24     ` Clément Pit-Claudel
2017-09-20 14:52       ` John Wiegley
2017-09-20 22:30         ` Stefan Monnier
2017-09-20 23:05           ` Drew Adams
2017-10-08 15:09         ` Philipp Stephani
2017-09-20 22:25       ` Stefan Monnier
2017-09-23  8:16         ` Clément Pit-Claudel
2017-09-23 14:17           ` Stefan Monnier
2017-09-23 20:37             ` Stefan Monnier
2017-09-19 22:58 ` Drew Adams
2017-09-20  3:10   ` Stefan Monnier
2017-09-20 17:52     ` Drew Adams
2017-09-21  1:11       ` Stefan Monnier
2017-09-21  5:22         ` Drew Adams
2017-09-21 18:28           ` Richard Stallman
     [not found]         ` <<9f11a3c6-b113-4bf6-9dab-f894b2ad77b5@default>
     [not found]           ` <<E1dv6D1-0006Jr-Fl@fencepost.gnu.org>
2017-09-22 15:54             ` Drew Adams
2017-09-23  0:39               ` Richard Stallman
2017-09-23  8:05               ` Clément Pit-Claudel
2017-09-24 17:26                 ` Drew Adams
2017-09-25  7:03                   ` Clément Pit-Claudel
2017-09-25 13:57                     ` Drew Adams
2017-09-26  0:36                       ` Stefan Monnier
2017-09-26  3:30                         ` John Wiegley
2017-09-26 17:55                           ` Drew Adams
2017-09-26 18:01                             ` John Wiegley
2017-09-26 18:50                               ` Drew Adams
2017-09-26 18:54                                 ` John Wiegley
2017-10-08 15:28                                   ` Philipp Stephani [this message]
2017-10-08 19:04                                     ` Stefan Monnier
2017-10-10  2:10                                       ` John Wiegley
2017-12-21 20:49                                       ` Philipp Stephani
2017-12-22  2:20                                         ` Stefan Monnier
2017-10-10 23:15                                   ` Herring, Davis
     [not found]               ` <<E1dvYUB-0007na-Mx@fencepost.gnu.org>
2017-09-24 17:26                 ` Drew Adams
2017-09-25 22:06                   ` Richard Stallman
2017-09-19 23:50 ` John Wiegley
2017-09-20  3:09   ` Stefan Monnier
2017-09-20 13:01 ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAArVCkR=UHjHTMtuHfs3g70BxRZXxmUTwGAmjE+zvK6sBjebew@mail.gmail.com' \
    --to=p.stephani2@gmail.com \
    --cc=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.