all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: emacs-devel@gnu.org
Cc: Dmitry Gutov <dgutov@yandex.ru>
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	[thread overview]
Message-ID: <87imubliet.fsf@tcd.ie> (raw)
In-Reply-To: <20190514021212.977E5206A2@vcs0.savannah.gnu.org> (Dmitry Gutov's message of "Mon, 13 May 2019 22:12:11 -0400 (EDT)")

dgutov@yandex.ru (Dmitry Gutov) writes:

> branch: master
> commit e0ee41d155b210327eb9c9ad5334f80ed59439f4
> Author: Dmitry Gutov <dgutov@yandex.ru>
> Commit: Dmitry Gutov <dgutov@yandex.ru>
>
>     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



       reply	other threads:[~2019-05-15 17:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190514021209.16750.6451@vcs0.savannah.gnu.org>
     [not found] ` <20190514021212.977E5206A2@vcs0.savannah.gnu.org>
2019-05-15 17:46   ` Basil L. Contovounesios [this message]
2019-05-15 20:31     ` [Emacs-diffs] master e0ee41d: Allow customizing the display of project file names when reading Dmitry Gutov
2019-05-15 23:11       ` Basil L. Contovounesios
2019-05-16  9:51         ` Basil L. Contovounesios
2019-05-16 13:35           ` Dmitry Gutov
2019-05-16 22:31             ` Basil L. Contovounesios
2019-05-15 21:11     ` Stefan Monnier
2019-05-15 23:12       ` Basil L. Contovounesios

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

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

  git send-email \
    --in-reply-to=87imubliet.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=dgutov@yandex.ru \
    --cc=emacs-devel@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.