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 04:49:57 -0400 Message-ID: References: <4E7993C8.6010609@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1316595008 31395 80.91.229.12 (21 Sep 2011 08:50:08 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 21 Sep 2011 08:50:08 +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 10:50:03 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 1R6IVH-0000dQ-Nt for ged-emacs-devel@m.gmane.org; Wed, 21 Sep 2011 10:50:03 +0200 Original-Received: from localhost ([::1]:46872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6IVG-0005Kb-5k for ged-emacs-devel@m.gmane.org; Wed, 21 Sep 2011 04:50:02 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38987) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6IVD-0005K0-Cx for emacs-devel@gnu.org; Wed, 21 Sep 2011 04:50:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6IVC-0002iT-23 for emacs-devel@gnu.org; Wed, 21 Sep 2011 04:49:59 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]:54658) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6IVB-0002iP-UM for emacs-devel@gnu.org; Wed, 21 Sep 2011 04:49:58 -0400 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1R6IVB-0003dR-LS; Wed, 21 Sep 2011 04:49:57 -0400 In-reply-to: <4E7993C8.6010609@yandex.ru> (message from Dmitry Antipov on Wed, 21 Sep 2011 11:35:36 +0400) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.10 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:144141 Archived-At: > Date: Wed, 21 Sep 2011 11:35:36 +0400 > From: Dmitry Antipov > > there is a simple user/group completion for dired. Thanks. Allow me a few comments. > +DEFUN ("system-users", Fsystem_users, Ssystem_users, 0, 0, 0, > + doc: /* Return a list of user names currently registered in the system. > +On UNIX systems, those are user names listed in /etc/passwd file. > +On other systems, this function always returns nil. */) IMO, the last two sentences are too categorical and too OS-specific. E.g., in the MS-DOS build of Emacs, getpwent and getgrent are available and usable, although MS-DOS is certainly not a Unix system. It should also be possible to write an emulation of these functions for MS-Windows. And even on Unix systems, I'm not sure the information is always on /etc/passwd. And the same goes for groups 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. > + Lisp_Object users = Qnil; We should at least return the single user that is the current user, instead of nil. Emacs always knows who is the current user, on all supported systems, so there's no need to be so restrictive when getpwent is unavailable. > + while ((pw = getpwent ())) > + users = Fcons (build_string (pw->pw_name), users); 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 group name.