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.help Subject: Re: Coding system to encode arguments to groff? Date: Wed, 29 Sep 2021 15:02:59 +0300 Message-ID: <83o88bio7g.fsf@gnu.org> References: <87v92jyfnb.fsf@vagabond.tim-landscheidt.de> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19505"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 29 14:03:45 2021 Return-path: Envelope-to: geh-help-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 1mVYJM-0004rX-Vh for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 29 Sep 2021 14:03:44 +0200 Original-Received: from localhost ([::1]:56038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVYJL-0001n1-O3 for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 29 Sep 2021 08:03:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mVYIV-0001mm-8i for help-gnu-emacs@gnu.org; Wed, 29 Sep 2021 08:02:51 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:53330) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mVYIV-00027K-1A for help-gnu-emacs@gnu.org; Wed, 29 Sep 2021 08:02:51 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:1324 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 1mVYIU-0000Cz-Jf for help-gnu-emacs@gnu.org; Wed, 29 Sep 2021 08:02:50 -0400 In-Reply-To: <87v92jyfnb.fsf@vagabond.tim-landscheidt.de> (message from Tim Landscheidt on Wed, 29 Sep 2021 08:01:12 +0000) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:133388 Archived-At: > From: Tim Landscheidt > Date: Wed, 29 Sep 2021 08:01:12 +0000 > > I pass text arguments from Emacs Lisp to a groff command > with the "-d" option. For ASCII strings, this is trivial; > for strings with umlauts, I need to use: > > | (encode-coding-string variable-to-pass 'iso-latin-1) What is your default locale's codeset on that system? In general, if the default locale matches the encoding you need to use, the above should happen automagically. > For strings with other Unicode characters like "–" (#x2013), > I need to call groff's preconv like: > > | (shell-command-to-string (concat "preconv -r <(echo " (shell-quote-argument variable-to-pass) ")")) > > which for "ä–ö" returns something like: > > | \[u00E4]\[u2013]\[u00F6] This is just the original "ä–ö" string, so I'm not quite sure what did the above accomplish. > Now in Emacs, this looks very much like what a coding system > would do. The info documentation for elisp just laconically > says: > > | How to define a coding system is an arcane matter, and is not > | documented here. > > Has someone implemented such a coding system for groff so > that something like: > > | (encode-coding-string variable-to-pass 'x-groff) I don't think you should need a new coding-system. But you didn't explain why you need to explicitly encode the command-line arguments, so it's hard to give an accurate advice. What kind of Groff command needs this jumping through hoops from you? E.g., why isn't it enough to bind coding-system-for-write to whatever you need, around the call to call-process or whatever? IOW, please describe in more detail the Groff-related context in which this problem happens, so that we could have an intelligent discussion of the issues you might have.