From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] master e0ee41d: Allow customizing the display of project file names when reading Date: Wed, 15 May 2019 18:46:50 +0100 Message-ID: <87imubliet.fsf@tcd.ie> References: <20190514021209.16750.6451@vcs0.savannah.gnu.org> <20190514021212.977E5206A2@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="180832"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Dmitry Gutov To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 15 19:49:39 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hQy26-000kvJ-DH for ged-emacs-devel@m.gmane.org; Wed, 15 May 2019 19:49:38 +0200 Original-Received: from localhost ([127.0.0.1]:40496 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQy25-0008GQ-5k for ged-emacs-devel@m.gmane.org; Wed, 15 May 2019 13:49:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:48610) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hQxzV-0007Ye-BN for emacs-devel@gnu.org; Wed, 15 May 2019 13:46:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hQxzU-0006gc-5Y for emacs-devel@gnu.org; Wed, 15 May 2019 13:46:57 -0400 Original-Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]:34138) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hQxzT-0006fW-P4 for emacs-devel@gnu.org; Wed, 15 May 2019 13:46:56 -0400 Original-Received: by mail-ed1-x52f.google.com with SMTP id p27so1064286eda.1 for ; Wed, 15 May 2019 10:46:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=pGBz+hwlozpAIucffJOEB82kA+hA+7g2RTBnykFTDe0=; b=lQooW0qzjU1PK6BCPueSNqy3bRLlFesnxdSykohGa0JcRf30OeDfi5xazZ69YeiE2N IbbW710QfsLPHd8Cc4o7kJkpY+U9F1RSdDftxfilFcr4VXA1StraB+ATBs2mUlj97r4k sHVq3m70wOIvyJhVPwH1+Ly2uAmk5jX2vCU1FRfuS0GINNW6Z4FDOL7ZNDGFDQ5fN43Z w1AxIj6KafICGosKdSlJ/6crXHxKT3qTapULk7bP4PZncb3CwxPru+7Za8ggR3ID2LDB 2/3l2lNXbfG8Zf8h7iVNXdpl9VUHdQGRaRI+gcIWZu/1afdSAeXu/u/t0Zt8V8KGZuIQ SKIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=pGBz+hwlozpAIucffJOEB82kA+hA+7g2RTBnykFTDe0=; b=pqtpiwBNSuzC9zXw2mUZjp7E9tkyyyOPzcNsXDRzs5ZglceyN7LC7cRqw1LltDap8U TiFC4K7ohGYUxYBBdyoxwGmmpIyb/Hv85jaWjdb6VXwMY6YoM/hGycq1fw9yaqxDtAeL 5X7oCH3uFnXwEHQtYdTuTpaQ8wouGhIW1go4891R323aCsG36Z7tYT8Uoehf8uFK+TBH Jq+5tJjyhc3iem8WY71bevwaUPPhs1Y4zgxNGx79cQasVZEqJCrWKP+fzlzd8PLPpjrY 4Qga+8tI5XJdX+kqBqGjsnFStlLsLSFF398YXZWUfEsg2Q+F417+q+HHlXVjhmiWORq+ /e7A== X-Gm-Message-State: APjAAAU2vJJti0L5wIqclQdi4VGJt4PWbl8Sbil+GBoKAB7EkQ+cp0mQ n67AbwOj+vgpCqwh0B//GZf5KBinwIE= X-Google-Smtp-Source: APXvYqxQL2gX+zlrWvmLzeKwyVe5AK35AXJRLqbjaXVcJCrectVpkaIXFLDUBlaFSNrX7u7tQOBxoQ== X-Received: by 2002:a17:906:1e0f:: with SMTP id g15mr34506547ejj.241.1557942413387; Wed, 15 May 2019 10:46:53 -0700 (PDT) Original-Received: from localhost ([82.141.252.179]) by smtp.gmail.com with ESMTPSA id d26sm584474ejd.47.2019.05.15.10.46.51 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 15 May 2019 10:46:52 -0700 (PDT) In-Reply-To: <20190514021212.977E5206A2@vcs0.savannah.gnu.org> (Dmitry Gutov's message of "Mon, 13 May 2019 22:12:11 -0400 (EDT)") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::52f 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:236546 Archived-At: dgutov@yandex.ru (Dmitry Gutov) writes: > branch: master > commit e0ee41d155b210327eb9c9ad5334f80ed59439f4 > Author: Dmitry Gutov > Commit: Dmitry Gutov > > Allow customizing the display of project file names when reading > > To hopefully resolve a long-running discussion > (https://lists.gnu.org/archive/html/emacs-devel/2019-05/msg00162.html). > > * lisp/progmodes/project.el (project-read-file-name-function): > New variable. > (project--read-file-absolute, project--read-file-cpd-relative): > New functions, possible values for the above. > (project-find-file-in): Use the introduced variable. > (project--completing-read-strict): Retain just the logic that fits > the name. [...] > diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el > index 7c8ca15..ddb4f33 100644 > --- a/lisp/progmodes/project.el > +++ b/lisp/progmodes/project.el > @@ -470,55 +464,72 @@ recognized." > (project-external-roots pr)))) > (project-find-file-in (thing-at-point 'filename) dirs pr))) > > +(defcustom project-read-file-name-function #'project--read-file-cpd-relative > + "Function to call to read a file name from a list. > +For the arguments list, see `project--read-file-cpd-relative'." > + :type '(repeat (choice (const :tag "Read with completion from relative names" > + project--read-file-cpd-relative) > + (const :tag "Read with completion from absolute names" > + project--read-file-absolute) > + (function :tag "custom function" nil)))) > + > +(defun project--read-file-cpd-relative (prompt > + all-files &optional predicate > + hist default) > + (let* ((common-parent-directory > + (let ((common-prefix (try-completion "" all-files))) > + (if (> (length common-prefix) 0) > + (file-name-directory common-prefix)))) > + (cpd-length (length common-parent-directory)) > + (prompt (if (zerop cpd-length) > + prompt > + (concat prompt (format " in %s" common-parent-directory)))) > + (substrings (mapcar (lambda (s) (substring s cpd-length)) all-files)) > + (new-collection (project--file-completion-table substrings)) > + (res (project--completing-read-strict prompt > + new-collection > + predicate > + hist default))) > + (concat common-parent-directory res))) Sorry if this has been discussed before, and maybe it's just me, but I don't think it makes sense to offer internal double hyphen functions as alternatives for a user option, let alone to point the user to such an internal function which lacks a docstring, "for the argument list". Thanks, -- Basil