From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#54154: Emacs commit ae963e80a79f5a9184daabfc8197f211a39b136d (sieve-manage) Date: Thu, 19 Jan 2023 19:41:13 +0200 Message-ID: <83v8l2o212.fsf@gnu.org> References: <87wnhj5nbk.fsf@tetzco.de> <835yd31wk8.fsf@gnu.org> <874jsngod2.fsf@tetzco.de> <83tu0nynla.fsf@gnu.org> <873586d7ii.fsf@tetzco.de> <834jsmpqf9.fsf@gnu.org> <87bkmua51z.fsf@tetzco.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4340"; mail-complaints-to="usenet@ciao.gmane.io" Cc: herbert@gojira.at, 54154@debbugs.gnu.org, larsi@gnus.org To: Kai Tetzlaff Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jan 19 18:42:19 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIYva-0000qw-Sz for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 19 Jan 2023 18:42:19 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIYvQ-0003mh-QP; Thu, 19 Jan 2023 12:42:08 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIYvK-0003m8-Sm for bug-gnu-emacs@gnu.org; Thu, 19 Jan 2023 12:42:07 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIYvK-0002Ad-ET for bug-gnu-emacs@gnu.org; Thu, 19 Jan 2023 12:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pIYvK-0003bT-4b for bug-gnu-emacs@gnu.org; Thu, 19 Jan 2023 12:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 19 Jan 2023 17:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54154 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 54154-submit@debbugs.gnu.org id=B54154.167415009213815 (code B ref 54154); Thu, 19 Jan 2023 17:42:02 +0000 Original-Received: (at 54154) by debbugs.gnu.org; 19 Jan 2023 17:41:32 +0000 Original-Received: from localhost ([127.0.0.1]:44679 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIYuq-0003al-7O for submit@debbugs.gnu.org; Thu, 19 Jan 2023 12:41:32 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:60060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIYun-0003aX-UE for 54154@debbugs.gnu.org; Thu, 19 Jan 2023 12:41:30 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIYue-00025i-3L; Thu, 19 Jan 2023 12:41:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=UmuGlETW+8Ms8zeUDEK0nZMqh8vmteajtD3Jg2kVfA4=; b=iZDJa5SI2ZYM aYFWTbwOiFNCkNYq/PeA8X6kZnmaWRTuINyUN22uDAGyiiZArXAMm4yNZ+dRRaLKJPtcJuZ0VqWPd e0zb0HkLjIArow8WISV1hjXRCg9Go1QRTWJnVikIaZ/Vjnao/NO1IaB7Yv3m7sGTT7V7JGZDJYm6w 2a1mVISUuI53VgCUcBOTT33cwmW+kPQ2dEh6XeTEjPr2Q59ewFOu64QKMjrHCcqSvi2Zxv1zbZRip VtxrCyYPmIensWgdytlPD6khWfCjv8WewX5z6yXKgXwWfyjxZsMRBi7ubuTh/21wDgYKpRd3R3hul BZFduyfvaGaklIJ8mAMKBA==; Original-Received: from [87.69.77.57] (helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIYua-0002vA-Il; Thu, 19 Jan 2023 12:41:19 -0500 In-Reply-To: <87bkmua51z.fsf@tetzco.de> (message from Kai Tetzlaff on Thu, 19 Jan 2023 16:59:36 +0100) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253720 Archived-At: > From: Kai Tetzlaff > Cc: herbert@gojira.at, larsi@gnus.org, 54154@debbugs.gnu.org > Date: Thu, 19 Jan 2023 16:59:36 +0100 > > >> Yes, true. But since `sieve-manage--set-internal-buffer-properties' is > >> used in two different places, the more elegant solution you suggested > >> above would require duplicating the body of the function in those > >> places. I just didn't see a better way. > > > > I'm not sure why you need to force the encoding of the process buffer, > > when you already set the coding-system to be used for decoding stuff > > from the process. Is that really needed? > > Not sure if it is really needed. But I wanted to make sure that both, > the process buffer and the log buffer use identical settings. Otherwise, > the content of the log buffer might be misleading. I don't think it could mislead, but OK. > > But if you really need this, then just make the insertion of the text > > into the buffer you create optional: then for the process-buffer pass > > nil as the text to insert, and you can do the with-current-buffer > > dance only inside that function. > > Sorry, you lost me there. I don't understand what you want to tell me. > Which (optional) text in which buffer? I meant this: (defun sieve-manage--set-buffer-and-append-text (buffer-name &rest args) (let ((existing-buffer (get-buffer buffer-name)) new-buffer) (if existing-buffer (setq new-buffer existing-buffer) (setq new-buffer (get-buffer-create buffer-name))) (with-current-buffer new-buffer (when (not existing-buffer) (set-buffer-file-coding-system sieve-manage--coding-system) (setq-local after-change-functions nil) (buffer-disable-undo) ; What happened to set-buffer-multibyte? ) (goto-char (point-max)) (apply #'insert args)))) Then you can call it from sieve-manage-make-process-buffer like this: (sieve-manage--set-buffer-and-append-text (format " *sieve %s:%s*" sieve-manage-server sieve-manage-port) "") i.e. with an empty string, so nothing gets inserted into the process buffer. Or you could instead change the signature to accept a single &optional argument that is a list, and then you could make the last two lines in the function above conditional on that argument being non-nil. > > Since you seem to be encoding and decoding to/from UTF-8 by hand in > > sieve-manage-encode/decode, you should use 'binary' as the > > process-codings-system for the network connection to the server, and > > that's it. > > That works. Done. > > > What you should do is call sieve-manage-encode inside > > sieve-manage-send, and count the bytes there after encoding the > > payload. > > Unfortunately, that is too late since the sent data - in case that the > sent text may contain CRLF sequences - contains its own length. So in > order to insert the correct length, I need to encode before sending. > See: > > (defun sieve-manage-putscript (name content &optional buffer) > (with-current-buffer (or buffer (current-buffer)) > (sieve-manage-send (format "PUTSCRIPT \"%s\" {%d+}%s%s" name > (length (sieve-manage-encode content)) > sieve-manage-client-eol content)) > (sieve-manage-parse-oknobye))) This is because you pass both the text and the number to 'format'. But that is not carved in stone: the "%d" part can never produce any non-ASCII characters, so there's no need to encode it together with CONTENT. You could do this instead: (defun sieve-manage-send (command &optional payload) (let ((encoded (if payload (encode-coding-string payload 'utf-8-unix))) size cmdstr) (if encoded (setq size (format " {%d+}%s" (length encoded) sieve-manage-client-eol))) (setq cmdstr (concat command size encoded)) (sieve-manage--append-to-log cmdstr) (process-send-string sieve-manage-process cmdstr))) And then you call this like below: (sieve-manage-send (format "PUTSCRIPT \"%s\"" name) content) (sieve-manage-send (format "HAVESPACE \"%s\" %s" name size)) I hope this clarifies my proposal.