unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Yuri Khan <yuri.v.khan@gmail.com>
Cc: Emacs developers <emacs-devel@gnu.org>,
	Tino Calancha <tino.calancha@gmail.com>
Subject: Re: Generalize and standarize dired-plural-s
Date: Mon, 19 Sep 2016 04:28:44 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1609190424080.31571@calancha-pc> (raw)
In-Reply-To: <CAP_d_8V2O45T42j+1TOjoXEOyTV-6NBPMiUb_XXvphRhA5sz-w@mail.gmail.com>



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))))))




  reply	other threads:[~2016-09-18 19:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-18 14:00 Generalize and standarize dired-plural-s Tino Calancha
2016-09-18 15:06 ` Kaushal Modi
2016-09-18 15:12 ` Drew Adams
2016-09-18 17:45 ` Yuri Khan
2016-09-18 19:28   ` Tino Calancha [this message]
2016-09-18 20:47     ` Yuri Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1609190424080.31571@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=yuri.v.khan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).