GNU bug report logs -
#78596
30.1; recentf-open ought to use a completion table and category
Previous Next
Full log
Message #8 received at 78596 <at> debbugs.gnu.org (full text, mbox):
Hi,
dino chiesa <dpchiesa <at> hotmail.com> writes:
> This isn't a bug report, more of an enhancement request.
>
> Summary
> I would like recentf-open to use "Programmed Completion" via
> a completion function. (see 21.6.7 Programmed Completion)
> That function ought to return metadata with a category that
> is specific to recentf.
Good idea. Could you please check if the following patch works for you?
diff --git a/lisp/recentf.el b/lisp/recentf.el
index a773ea9ec01..006b3159bb9 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -505,7 +505,9 @@ recentf-open
(list
(progn (unless recentf-mode (recentf-mode 1))
(completing-read (format-prompt "Open recent file" nil)
- recentf-list nil t))))
+ (completion-table-with-metadata
+ recentf-list '((category . recentf)))
+ nil t))))
(when file
(funcall recentf-menu-action file)))
The completion-table-with-metadata function is a new helper function
that is very useful when we just want to enrich some existing completion
table with some metadata.
We should probably document it in the manual, BTW. Here's a draft:
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 3cc206d2e1d..2e91f2c21b4 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -2123,6 +2123,15 @@ Programmed Completion
when a slow operation is involved, such as calling an external process.
@end defun
+@defun completion-table-with-metadata table metadata
+This function creates a completion table that behaves like the existing
+completion table @var{table}, except with additional metadata given in
+@var{metadata}, which is an alist of completion metadata. If
+@var{table} already provides completion metadata, it is merged with
+@var{metadata}, giving precedence to @var{metadata} if an entry appears
+both in @var{metadata} and in the metadata that @var{table} produces.
+@end defun
+
@node Completion in Buffers
@subsection Completion in Ordinary Buffers
@cindex inline completion
Best,
Eshel
This bug report was last modified 66 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.