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: Generalize and standarize dired-plural-s Date: Sun, 18 Sep 2016 23:00:21 +0900 (JST) Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1474207247 11574 195.159.176.226 (18 Sep 2016 14:00:47 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 18 Sep 2016 14:00:47 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: tino.calancha@gmail.com To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Sep 18 16:00:43 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 1blce7-0001tw-40 for ged-emacs-devel@m.gmane.org; Sun, 18 Sep 2016 16:00:39 +0200 Original-Received: from localhost ([::1]:50208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blce5-0005zt-BL for ged-emacs-devel@m.gmane.org; Sun, 18 Sep 2016 10:00:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:60473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blcdz-0005yd-5i for emacs-devel@gnu.org; Sun, 18 Sep 2016 10:00:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1blcdu-0001X9-KR for emacs-devel@gnu.org; Sun, 18 Sep 2016 10:00:29 -0400 Original-Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:33926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1blcdu-0001WM-Ed for emacs-devel@gnu.org; Sun, 18 Sep 2016 10:00:26 -0400 Original-Received: by mail-pa0-x229.google.com with SMTP id wk8so40042752pab.1 for ; Sun, 18 Sep 2016 07:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:message-id:user-agent:mime-version; bh=qCbMl5Am9zq5sklotyAOKyIJU1ooOWy3irv9tC19nN4=; b=yYL7PFIY/VeO8re1Q65aMgG8xGuwiZhE0SIJhEx6FsPWs6zgCik5k16J47U+PYmAWu 8MCJNCrfC3WQnxafkPMpb6WzBDHXB6IUsu7LrkZ7nFpshK3Qa81JPXWTK73+aiUaX9zZ axanNaYQjGeyi0x+DTdIIkYuFuIEVANKfDvFNmW9kZI62Pmgn9EujTArnv8W1l71qtJx GJiTZg5x0uKiWQnc5TPlG6Ojm/jLtsTCOfD34atKiPuNw6B7VHpF6OXpaRxVAB+7BYnX 8BLIisKdYw/EMNInLtRkYM+vtQvQT0YM4FA26MAfr6ujLo09Pe+6lyZ8sLyXyUa3Zsml JwSQ== 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:message-id:user-agent :mime-version; bh=qCbMl5Am9zq5sklotyAOKyIJU1ooOWy3irv9tC19nN4=; b=Q0AZ7zyfWgM9aN01sREWZFGjcu4ijILGHgER65bfbUtXL730M0/O4ZJ49kwwOrHGtq mQZGzsQ1626wEqSaOrnkhgckn8L4a9sh/NPWzr/inQWVOt/bpV1uKC/jZAtamUR61E0o HsVPM1dn69JcqTacVwTqgjgphVi9xdijN6RNKutphk8u5IM2EoLoA7dVj+mK4A6qzJbG UHM+R+Y67b3gGERK7AyO4nrflvNMgpnwfBPxZ9cW0WowT5MHzeOsm9hHqYiOXykXoeBQ rumJK+heFdh1l3107Piy6Mmh4izTtsO8je4qVdk0GWuwtUgRpaGAZMJOfN4SusI1cjUT aRog== X-Gm-Message-State: AE9vXwPW/zxuw1z4VcTIk3tkupN15OqgycJ+4SuTqwCzOdkm763OYwJkw5LoG2S8qf51eQ== X-Received: by 10.66.19.197 with SMTP id h5mr19225934pae.142.1474207225673; Sun, 18 Sep 2016 07:00:25 -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 o5sm64745165pfb.9.2016.09.18.07.00.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Sep 2016 07:00:25 -0700 (PDT) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c03::229 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:207545 Archived-At: Hi, I) dired.el introduces the function `dired-plural-s' to pluralize correctly output messages as: (format "Kill Dired buffer%s of %s, too? " (dired-plural-s (length buf-list)) (file-name-nondirectory fn)) In this example, it returns "s" if (length buf-list) > 1. Otherwise, it returns "". Of course, this task is not exclusive of Dired: many other packages in Emacs source code do the same thing. II) As you know, for some words the plural is different that just appending "s" to the end. For instance, in message.el: (format "Really use %s possibly unknown group%s: %s? " (if (= (length errors) 1) "this" "these") (if (= (length errors) 1) "" "s") (mapconcat 'identity errors ", ")) "this" -> "these" is not handled by `dired-plural-s'. I am wondering if it has sense to add a standard function, `string-plural-s', covering both cases: I), II). Then, we might do `dired-plural-s' and alias for the new function. We might update all the 'plularizations' in Emacs source code to use the new function as well. Following function could do the job: (defun string-plural-s (arg &optional string plural) "\ 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. Optional arg PLURAL is the plural of STRING. If STRING is nil, return \"s\" or \"\"." (let ((single (or string "")) (plural (if (and string plural) plural (apply #'string (append string "s" nil))))) (cond ((natnump arg) (if (= arg 1) single plural)) ((null arg) plural) ((consp arg) (if (null (cdr arg)) single plural)) ((arrayp arg) (if (= (length arg) 1) single plural)) (t (signal 'wrong-type-argument (list arg 'natnump 'listp 'arrayp)))))) What do you think about this idea? Regards, Tino