From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] user/group completion for dired Date: Wed, 21 Sep 2011 18:04:06 +0300 Message-ID: <83sjnqrl7d.fsf@gnu.org> References: <4E7993C8.6010609@yandex.ru> <4E79EDB2.2020300@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: dough.gmane.org 1316617582 32168 80.91.229.12 (21 Sep 2011 15:06:22 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 21 Sep 2011 15:06:22 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 21 17:06:18 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R6ONO-0004ZE-68 for ged-emacs-devel@m.gmane.org; Wed, 21 Sep 2011 17:06:18 +0200 Original-Received: from localhost ([::1]:39206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6ONN-0002rc-4r for ged-emacs-devel@m.gmane.org; Wed, 21 Sep 2011 11:06:17 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:49634) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6ONJ-0002mY-Ut for emacs-devel@gnu.org; Wed, 21 Sep 2011 11:06:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6ONE-00075u-B8 for emacs-devel@gnu.org; Wed, 21 Sep 2011 11:06:13 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:56120) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6ONE-00075a-4a for emacs-devel@gnu.org; Wed, 21 Sep 2011 11:06:08 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0LRV00H00OEIUJ00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Wed, 21 Sep 2011 18:05:07 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([77.127.239.98]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0LRV00HWFOKHLK80@a-mtaout21.012.net.il>; Wed, 21 Sep 2011 18:05:06 +0300 (IDT) In-reply-to: <4E79EDB2.2020300@yandex.ru> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-Received-From: 80.179.55.169 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:144157 Archived-At: > Date: Wed, 21 Sep 2011 17:59:14 +0400 > From: Dmitry Antipov > CC: emacs-devel@gnu.org >=20 > On 09/21/2011 12:49 PM, Eli Zaretskii wrote: >=20 > > IMO, the last two sentences are too categorical and too OS-specif= ic. > > E.g., in the MS-DOS build of Emacs, getpwent and getgrent are > > available and usable, although MS-DOS is certainly not a Unix sys= tem. > > It should also be possible to write an emulation of these functio= ns > > for MS-Windows. And even on Unix systems, I'm not sure the > > information is always on /etc/passwd. And the same goes for grou= ps > > and /etc/groups. > > > > So please make the doc strings more vague; it should be enough to= say > > that if this functionality is not supported, the value is nil, or > > something like that. >=20 > OK. I realize that receiving the list of system users/groups may re= quire > NSS/LDAP/whatever queries. On GNU/Linux system, it should be possib= le > to interface libuser; other systems might have the similar methods, > but I'm not sure it's worth playing with them just for input comple= tion > task. ??? My comment was only about the doc string which referenced /etc/passwd. AFAIK, no matter where the information resides, the functions you used will still be able to get at it. If I'm right, there's no need to change the code regarding that. > > We should at least return the single user that is the current use= r, > > instead of nil. Emacs always knows who is the current user, on a= ll > > supported systems, so there's no need to be so restrictive when > > getpwent is unavailable. >=20 > OK, I guess it should be Vuser_real_login_name. Yes, I think so. > > What happens if the user name includes non-ASCII characters? If = that > > can happen, we should decode the pw_name string, not just call > > build_string on the unibyte string we get. Same issue with the g= roup > > name. >=20 > Comment around build_string() says it should guess about string dat= a > and produce multibyte string if necessary. Why let it guess? You can do it with 100% certainty in this case, because the encoding of strings provided by the OS is known -- it's held in Vlocale_coding_system. See system_process_attributes for an example of how to do this. > On my system (Fedora 15) it was able to decode and represent > t=C3=B5endid=C3=BCtles (no ideas what language it is and what does = it mean :-) > as multibyte string. That's because GNU/Linux systems normally use an encoding that maps 1:1 to the internal Emacs representation of characters. I'm guessing that if you look in a debugger on the string you get from getpwent, you will see it's UTF-8 encoded. If so, it's sheer luck that it worked for you.