Index: /trunk/roundcubemail/CHANGELOG
===================================================================
--- /trunk/roundcubemail/CHANGELOG	(revision 2539)
+++ /trunk/roundcubemail/CHANGELOG	(revision 2540)
@@ -2,4 +2,5 @@
 ===========================
 
+- Support UID EXPUNGE: remove only moved/deleted messages
 - Add drag cancelling with ESC key (#1484344)
 - Support initial identity name from virtuser_query (#1484003)
Index: /trunk/roundcubemail/program/include/rcube_imap.php
===================================================================
--- /trunk/roundcubemail/program/include/rcube_imap.php	(revision 2539)
+++ /trunk/roundcubemail/program/include/rcube_imap.php	(revision 2540)
@@ -1630,5 +1630,5 @@
       if (!rcmail::get_instance()->config->get('flag_for_deletion', false))
         {
-        $this->_expunge($from_mbox, FALSE);
+        $this->_expunge($from_mbox, FALSE, $a_uids);
         $this->_clear_messagecount($from_mbox);
         $this->_clear_messagecount($to_mbox);
@@ -1689,5 +1689,5 @@
     if ($deleted)
       {
-      $this->_expunge($mailbox, FALSE);
+      $this->_expunge($mailbox, FALSE, $a_uids);
       $this->_clear_messagecount($mailbox);
       unset($this->uid_id_map[$mailbox]);
@@ -1769,9 +1769,18 @@
    *
    * @see rcube_imap::expunge()
-   * @access private
-   */
-  function _expunge($mailbox, $clear_cache=TRUE)
-    {
-    $result = iil_C_Expunge($this->conn, $mailbox);
+   * @param string 	Mailbox name
+   * @param boolean 	False if cache should not be cleared
+   * @param string 	List of UIDs to remove, separated by comma
+   * @return boolean True on success
+   * @access private
+   */
+  function _expunge($mailbox, $clear_cache=TRUE, $uids=NULL)
+    {
+    if ($uids && $this->get_capability('UIDPLUS')) 
+      $a_uids = is_array($uids) ? join(',', $uids) : $uids;
+    else
+      $a_uids = NULL;
+
+    $result = iil_C_Expunge($this->conn, $mailbox, $a_uids);
 
     if ($result>=0 && $clear_cache)
Index: /trunk/roundcubemail/program/lib/imap.inc
===================================================================
--- /trunk/roundcubemail/program/lib/imap.inc	(revision 2539)
+++ /trunk/roundcubemail/program/lib/imap.inc	(revision 2540)
@@ -83,4 +83,5 @@
 		- removed caching functions
 		- handling connection startup response
+		- added UID EXPUNGE support
 
 ********************************************************/
@@ -1864,9 +1865,11 @@
 }
 
-function iil_C_Expunge(&$conn, $mailbox) {
+function iil_C_Expunge(&$conn, $mailbox, $messages=NULL) {
 
 	if (iil_C_Select($conn, $mailbox)) {
 		$c = 0;
-		iil_PutLine($conn->fp, "exp1 EXPUNGE");
+		$command = $messages ? "UID EXPUNGE $messages" : "EXPUNGE";
+
+		iil_PutLine($conn->fp, "exp1 $command");
 		do {
 			$line=chop(iil_ReadLine($conn->fp, 100));
@@ -2031,10 +2034,11 @@
 
 function iil_C_Move(&$conn, $messages, $from, $to) {
-    $fp = $conn->fp;
 
     if (!$from || !$to) {
         return -1;
     }
-    $r = iil_C_Copy($conn, $messages, $from,$to);
+    
+    $r = iil_C_Copy($conn, $messages, $from, $to);
+
     if ($r==0) {
         return iil_C_Delete($conn, $from, $messages);
