From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Re: Generalize and standarize dired-plural-s Date: Mon, 19 Sep 2016 04:28:44 +0900 (JST) Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Trace: blaine.gmane.org 1474231019 27164 195.159.176.226 (18 Sep 2016 20:36:59 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 18 Sep 2016 20:36:59 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Emacs developers , Tino Calancha To: Yuri Khan Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 18 22:36:55 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1blipX-000617-T7 for ged-emacs-devel@m.gmane.org; Sun, 18 Sep 2016 22:36:52 +0200 Original-Received: from localhost ([::1]:51375 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blipW-0000kH-0c for ged-emacs-devel@m.gmane.org; Sun, 18 Sep 2016 16:36:50 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56148) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blipN-0000k6-Ck for emacs-devel@gnu.org; Sun, 18 Sep 2016 16:36:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blipI-0002dX-Gn for emacs-devel@gnu.org; Sun, 18 Sep 2016 16:36:41 -0400 Original-Received: from mail-pf0-f180.google.com ([209.85.192.180]:32797) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blipI-0002dT-B8 for emacs-devel@gnu.org; Sun, 18 Sep 2016 16:36:36 -0400 Original-Received: by mail-pf0-f180.google.com with SMTP id 21so32831626pfy.0 for ; Sun, 18 Sep 2016 13:36:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=g9wXSw+Ycw5F5KF/6CTdd9lCYgopHR1P/UOez01fAbE=; b=Fz8DLcJ5694suqSnQIlf9SO6J4ZLNVOjstBRttL8e2g81Cb2gMFBjd4Fmu1IhUZ9Xu +2GjzukKuXH0WHTVJGdw87NPTqyAMpffsmGJcH9WHciw9FzFqTEj9U6alf2/DkNCvQqE zpssLcNEZGx3M/97r9l6/3JMlxalc+l58khL06MflE5a9r+SKpAREKBMyuzw1N8OafV3 VStN7qH0t2qHyTaVkbSkWULr58tdpo3HsuWl6lGIV40w8UtrDXsJkenxKt58c/cvW2UP itH+EwHILULkR9gbf50L96KeX3vi74E5FyiqWu4YSTz/7bTKBVg5cJVPSYn2PRDPpLtB qFVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=g9wXSw+Ycw5F5KF/6CTdd9lCYgopHR1P/UOez01fAbE=; b=YJFTUPeIYflgCBMzIz+rFwJY9hFMHZrVPF4YB/tgFIA/j2n7I0YYU7yF6mq3+qec6O KZEOusRUVMavng/WTrVCrQYGwg0LT6xDueoXFXgqoMsv8Fw6YjCQ1uVxcKJOyekzBqHI xPGXC2JOyR+vUT1mxiXtkaUIj9OBopawz9JnQ/xJKy3C0d0rqaWLzQFu37colOfb9jar Iow2INkmr/vXZa2Yw3Djz0IOzKSuXqtZprBn+k4SAUhK1bktWB6pvyy8ZpqhoO2ndueV XVd5Zx4goVJ2v6L73XFjiu3CzW9rPoPoSFm2TFtLCM1tFJwbsWQaIxshEuXP2j7e0Eag uXow== X-Gm-Message-State: AE9vXwMRaR4Mfy7ESNHyV+bPiMrp456bi2pRJrGqN6ZO35DXtS3G5RejYh4p6Dp0DATloQ== X-Received: by 10.98.88.131 with SMTP id m125mr40225353pfb.63.1474226927333; Sun, 18 Sep 2016 12:28:47 -0700 (PDT) Original-Received: from calancha-pc (57.92.100.220.dy.bbexcite.jp. [220.100.92.57]) by smtp.gmail.com with ESMTPSA id k80sm27761358pfk.27.2016.09.18.12.28.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Sep 2016 12:28:46 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.192.180 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:207585 Archived-At: On Sun, 18 Sep 2016, Yuri Khan wrote: > It is also easier to extend to other languages, if and when we deem it > necessary. (It would require passing an additional argument to specify > language, and more forms (singular, dual, trial, paucal, plural).) > > I also suggest that the function be split in two: a core function > dealing with integers only, and a convenience wrapper that also > accepts sequences. Thank you Yuri for your suggstions. Something like this? With the additional forms and the language argument keep unimplemented: (defsubst string--plural-s-1 (arg singular plural _dual _trial _paucal _lang) (if (= arg 1) singular plural)) (defun string--plural-s-2 (arg singular plural _dual _trial _paucal _lang) (cond ((null arg) plural) ((consp arg) (if (null (cdr arg)) singular plural)) ((arrayp arg) (if (= (length arg) 1) singular plural)))) (defun string-plural-s (arg &optional string plural dual trial paucal lang) "\ Return plural of STRING if ARG is nil, or an integer >1, or a seq of length >1. If ARG is =1 or a sequence of length =1, return STRING. If STRING is nil, return \"s\" or \"\". Optional arg PLURAL is the plural of STRING. Optional arg DUAL is the =dual of STRING. Optional arg TRIAL is the trial of STRING. Optional arg PAUCAL is the paucal of STRING. Optional arg LANG is the language of STRING. Default to english." (let ((sin (or string "")) (plu (if (and string plural) plural (apply #'string (append string "s" nil))))) (cond ((natnump arg) (string--plural-s-1 arg sin plu dual trial paucal lang)) ((sequencep arg) (string--plural-s-2 arg sin plu dual trial paucal lang)) (t (signal 'wrong-type-argument (list arg 'natnump 'listp 'arrayp))))))