diff --git a/imapclient/imapclient.py b/imapclient/imapclient.py
index 4452d6f..ebc13dd 100644
--- a/imapclient/imapclient.py
+++ b/imapclient/imapclient.py
@@ -39,11 +39,11 @@ __all__ = ['IMAPClient', 'DELETED', 'SEEN', 'ANSWERED', 'FLAGGED', 'DRAFT', 'REC
 
 # We also offer the gmail-specific XLIST command...
 if 'XLIST' not in imaplib.Commands:
-    imaplib.Commands['XLIST'] = imaplib.Commands['LIST']
+    imaplib.Commands['XLIST'] = ('NONAUTH', 'AUTH', 'SELECTED')
 
 # ...and IDLE
 if 'IDLE' not in imaplib.Commands:
-    imaplib.Commands['IDLE'] = imaplib.Commands['APPEND']
+    imaplib.Commands['IDLE'] = ('NONAUTH', 'AUTH', 'SELECTED')
 
 # ..and STARTTLS
 if 'STARTTLS' not in imaplib.Commands:
@@ -60,6 +60,11 @@ if 'ID' not in imaplib.Commands:
 if 'UNSELECT' not in imaplib.Commands:
     imaplib.Commands['UNSELECT'] = ('AUTH', 'SELECTED')
 
+# .. and ENABLE.
+if 'ENABLE' not in imaplib.Commands:
+    imaplib.Commands['ENABLE'] = ('AUTH',)
+
+
 # System flags
 DELETED = br'\Deleted'
 SEEN = br'\Seen'
@@ -268,6 +273,35 @@ class IMAPClient(object):
         """
         self._imap.shutdown()
 
+    def enable(self, *capabilities):
+        """Activate one or more server side capability extensions.
+
+        Most capabilities do not need to be enabled. This is only
+        required for extensions which introduce backwards incompatible
+        behaviour. Two capabilities which may require enable are
+        ``CONDSTORE`` and ``UTF8=ACCEPT``.
+
+        A list of the requested extensions that were successfully
+        enabled on the server is returned.
+
+        Once enabled each extension remains active until the IMAP
+        connection is closed.
+
+        See :rfc:`5161` for more details.
+        """
+        if self._imap.state != 'AUTH':
+            raise self.Error("ENABLE command illegal in state %s" % self._imap.state)
+
+        resp = self._raw_command_untagged(
+            b'ENABLE',
+            [to_bytes(c) for c in capabilities],
+            uid=False,
+            response_name='ENABLED',
+            unpack=True)
+        if not resp:
+            return []
+        return resp.split()
+
     def id_(self, parameters=None):
         """Issue the ID command, returning a dict of server implementation
         fields.
@@ -1117,16 +1151,18 @@ class IMAPClient(object):
         self._checkok(command, typ, data)
         return data[0], resps
 
-    def _raw_command_untagged(self, command, args, unpack=False):
+    def _raw_command_untagged(self, command, args, response_name=None, unpack=False, uid=True):
         # TODO: eventually this should replace _command_and_check (call it _command)
-        typ, data = self._raw_command(command, args)
-        typ, data = self._imap._untagged_response(typ, data, to_unicode(command))
+        typ, data = self._raw_command(command, args, uid=uid)
+        if response_name is None:
+            response_name = command
+        typ, data = self._imap._untagged_response(typ, data, to_unicode(response_name))
         self._checkok(to_unicode(command), typ, data)
         if unpack:
             return data[0]
         return data
 
-    def _raw_command(self, command, args):
+    def _raw_command(self, command, args, uid=True):
         """Run the specific command with the arguments given. 8-bit arguments
         are sent as literals. The return value is (typ, data).
 
@@ -1150,7 +1186,7 @@ class IMAPClient(object):
 
         tag = self._imap._new_tag()
         prefix = [to_bytes(tag)]
-        if self.use_uid:
+        if uid and self.use_uid:
             prefix.append(b'UID')
         prefix.append(command)
 

Support ENABLE extension
Originally reported by: **Menno Smits (Bitbucket: [mjs0](https://bitbucket.org/mjs0))**

---

https://tools.ietf.org/html/rfc5161

Use this to turn on CONDSTORE in livetests (better than current hack for Dovecot)

---
- Bitbucket: https://bitbucket.org/mjs0/imapclient/issue/139

diff --git a/imapclient/livetest.py b/imapclient/livetest.py
index 6260568..4192716 100644
--- a/imapclient/livetest.py
+++ b/imapclient/livetest.py
@@ -76,8 +76,11 @@ class _TestBase(unittest.TestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.client = create_client_from_config(cls.conf)
-        cls.client.use_uid = cls.use_uid
+        client = create_client_from_config(cls.conf)
+        cls.client = client
+        client.use_uid = cls.use_uid
+        if client.has_capability('ENABLE') and client.has_capability('CONDSTORE'):
+            client.enable('CONDSTORE')
         cls.base_folder = cls.conf.namespace[0] + '__imapclient'
         cls.folder_delimiter = cls.conf.namespace[1]
 
@@ -642,19 +645,6 @@ def createUidTestClass(conf, use_uid):
             if not self.client.has_capability('CONDSTORE'):
                 return self.skipTest("Server doesn't support CONDSTORE")
 
-            if self.is_gmail():
-                return self.skipTest(
-                    "Gmail doesn't seem to return MODSEQ parts in SEARCH responses")
-
-            # A little dance to ensure MODSEQ tracking is turned on.
-            # TODO: use ENABLE for this instead
-            self.client.select_folder(self.base_folder)
-            self.append_msg(SIMPLE_MESSAGE)
-            msg_id = self.client.search()[0]
-            self.client.fetch(msg_id, ["MODSEQ"])
-            self.client.close_folder()
-            self.clear_folder(self.base_folder)
-
             # Remember the initial MODSEQ
             initial_modseq = self.client.select_folder(self.base_folder)[b'HIGHESTMODSEQ']
 
@@ -833,22 +823,10 @@ def createUidTestClass(conf, use_uid):
 
         def test_fetch_modifiers(self):
             # CONDSTORE (RFC 4551) provides a good way to use FETCH
-            # modifiers but it isn't commonly available.
+            # modifiers but it isn't always available.
             if not self.client.has_capability('CONDSTORE'):
                 return self.skipTest("Server doesn't support CONDSTORE")
 
-            # A little dance to ensure MODSEQ tracking is turned on.
-            self.client.select_folder(self.base_folder)
-            self.append_msg(SIMPLE_MESSAGE)
-            msg_id = self.client.search()[0]
-            self.client.fetch(msg_id, ["MODSEQ"])
-            self.client.close_folder()
-            self.clear_folder(self.base_folder)
-
-            #
-            # Actual testing starts here
-            #
-
             # Get the starting MODSEQ
             modseq = self.client.select_folder(self.base_folder)[b'HIGHESTMODSEQ']
 
diff --git a/imapclient/test/test_enable.py b/imapclient/test/test_enable.py
new file mode 100644
index 0000000..2d1fa10
--- /dev/null
+++ b/imapclient/test/test_enable.py
@@ -0,0 +1,70 @@
+# Copyright (c) 2017, Menno Smits
+# Released subject to the New BSD License
+# Please see http://en.wikipedia.org/wiki/BSD_licenses
+
+from __future__ import unicode_literals
+
+from mock import Mock
+
+from imapclient import IMAPClient
+from .imapclient_test import IMAPClientTest
+
+
+class TestEnable(IMAPClientTest):
+
+    def setUp(self):
+        super(TestEnable, self).setUp()
+        self.command = Mock()
+        self.client._raw_command_untagged = self.command
+        self.client._imap.state = 'AUTH'
+
+    def test_success(self):
+        self.command.return_value = b'CONDSTORE'
+
+        resp = self.client.enable('CONDSTORE')
+
+        self.command.assert_called_once_with(
+            b'ENABLE', [b'CONDSTORE'],
+            uid=False, response_name='ENABLED', unpack=True)
+        self.assertEqual(resp, [b'CONDSTORE'])
+
+    def test_failed1(self):
+        # When server returns an empty ENABLED response
+        self.command.return_value = b''
+
+        resp = self.client.enable('FOO')
+
+        self.command.assert_called_once_with(
+            b'ENABLE', [b'FOO'],
+            uid=False, response_name='ENABLED', unpack=True)
+        self.assertEqual(resp, [])
+
+    def test_failed2(self):
+        # When server returns no ENABLED response
+        self.command.return_value = None
+
+        resp = self.client.enable('FOO')
+
+        self.command.assert_called_once_with(
+            b'ENABLE', [b'FOO'],
+            uid=False, response_name='ENABLED', unpack=True)
+        self.assertEqual(resp, [])
+
+    def test_multiple(self):
+        self.command.return_value = b'FOO BAR'
+
+        resp = self.client.enable('FOO', 'BAR')
+
+        self.command.assert_called_once_with(
+            b'ENABLE', [b'FOO', b'BAR'],
+            uid=False, response_name='ENABLED', unpack=True)
+        self.assertEqual(resp, [b'FOO', b'BAR'])
+
+    def test_wrong_state(self):
+        self.client._imap.state = 'SELECTED'
+
+        self.assertRaises(
+            IMAPClient.Error,
+            self.client.enable,
+            'FOO',
+        )

pip install -e .
parse_log_pytest
pytest
mock>=1.3.0 pytest
apt-get update apt-get install -y gcc
3.6
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs @ file:///opt/conda/conda-bld/attrs_1642510447205/work
backports.ssl==0.0.9
certifi==2021.5.30
cffi==1.15.1
cryptography==40.0.2
-e git+https://github.com/mjs/imapclient.git@82d1a275861b00b70bddf1127e1953d4daa93383#egg=IMAPClient
importlib-metadata @ file:///tmp/build/80754af9/importlib-metadata_1631916693255/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
mock==5.2.0
more-itertools @ file:///tmp/build/80754af9/more-itertools_1637733554872/work
packaging @ file:///tmp/build/80754af9/packaging_1637314298585/work
pluggy @ file:///tmp/build/80754af9/pluggy_1615976315926/work
py @ file:///opt/conda/conda-bld/py_1644396412707/work
pycparser==2.21
pyOpenSSL==23.2.0
pyparsing @ file:///tmp/build/80754af9/pyparsing_1635766073266/work
pytest==6.2.4
six==1.17.0
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
typing_extensions @ file:///opt/conda/conda-bld/typing_extensions_1647553014482/work
zipp @ file:///tmp/build/80754af9/zipp_1633618647012/work

name: imapclient
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - attrs=21.4.0=pyhd3eb1b0_0
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - importlib-metadata=4.8.1=py36h06a4308_0
  - importlib_metadata=4.8.1=hd3eb1b0_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - more-itertools=8.12.0=pyhd3eb1b0_0
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - packaging=21.3=pyhd3eb1b0_0
  - pip=21.2.2=py36h06a4308_0
  - pluggy=0.13.1=py36h06a4308_0
  - py=1.11.0=pyhd3eb1b0_0
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pytest=6.2.4=py36h06a4308_2
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - toml=0.10.2=pyhd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zipp=3.6.0=pyhd3eb1b0_0
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - backports-ssl==0.0.9
      - cffi==1.15.1
      - cryptography==40.0.2
      - mock==5.2.0
      - pycparser==2.21
      - pyopenssl==23.2.0
      - six==1.17.0
prefix: /opt/conda/envs/imapclient

imapclient/test/test_enable.py::TestEnable::test_failed1 imapclient/test/test_enable.py::TestEnable::test_failed2 imapclient/test/test_enable.py::TestEnable::test_multiple imapclient/test/test_enable.py::TestEnable::test_success imapclient/test/test_enable.py::TestEnable::test_wrong_state
imapclient/imapclient.py
imapclient/imapclient.py