all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#56148: [PATCH] New command recentf-open
@ 2022-06-22 14:57 Stefan Kangas
  2022-06-22 16:04 ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Kangas @ 2022-06-22 14:57 UTC (permalink / raw)
  To: 56148

[-- Attachment #1: Type: text/plain, Size: 160 bytes --]

Severity: wishlist

In recentf-mode, I think it would be useful to provide a command to
open recent files using the minibuffer.  Please see the attached
patch.

[-- Attachment #2: 0001-New-command-recentf-open.patch --]
[-- Type: text/x-patch, Size: 1831 bytes --]

From 45b08e7b263d5804a18ccc403df2341c025b88ed Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Wed, 22 Jun 2022 16:54:40 +0200
Subject: [PATCH] New command recentf-open

* lisp/recentf.el (recentf-open): New command.
(recentf): New alias.
---
 etc/NEWS        |  5 +++++
 lisp/recentf.el | 19 +++++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index 40658559d7..24028ac213 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1860,6 +1860,11 @@ the project by a VC project based on that VCS.
 They are shortened with 'abbreviate-file-name'.  Customize the user
 option 'recentf-menu-filter' to nil to get unabbreviated file names.
 
+---
+*** New command 'recentf-open'.
+Instead of using a menu, this command prompts for a recently opened
+file in the minibuffer, and visits it.
+
 ---
 ** The autoarg.el library is now marked obsolete.
 This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor
diff --git a/lisp/recentf.el b/lisp/recentf.el
index 1005d4855f..9e8b858bb3 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -465,6 +465,25 @@ recentf-directory-compare
         (recentf-string-lessp (file-name-nondirectory f1)
                               (file-name-nondirectory f2))
       (recentf-string-lessp d1 d2))))
+
+\f
+;;; Open files
+;;
+
+(defun recentf-open (file)
+  "Prompt for FILE in `recentf-list' and visit it.
+Enable `recentf-mode' if it isn't already."
+  (interactive
+   (list
+    (progn (unless recentf-mode (recentf-mode 1))
+           (completing-read (format-prompt "Open recent file" nil)
+                            (mapcar #'abbreviate-file-name recentf-list)
+                            nil t))))
+  (when file
+    (funcall recentf-menu-action file)))
+
+(defalias 'recentf 'recentf-open)
+
 \f
 ;;; Menu building
 ;;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#56148: [PATCH] New command recentf-open
  2022-06-22 14:57 bug#56148: [PATCH] New command recentf-open Stefan Kangas
@ 2022-06-22 16:04 ` Eli Zaretskii
  2022-06-23 11:19   ` Stefan Kangas
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-06-22 16:04 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 56148

> From: Stefan Kangas <stefan@marxist.se>
> Date: Wed, 22 Jun 2022 16:57:43 +0200
> 
> In recentf-mode, I think it would be useful to provide a command to
> open recent files using the minibuffer.  Please see the attached
> patch.

Thanks.

> +(defun recentf-open (file)
> +  "Prompt for FILE in `recentf-list' and visit it.
> +Enable `recentf-mode' if it isn't already."
> +  (interactive
> +   (list
> +    (progn (unless recentf-mode (recentf-mode 1))
> +           (completing-read (format-prompt "Open recent file" nil)
> +                            (mapcar #'abbreviate-file-name recentf-list)

Shouldn't you apply abbreviate-file-name only if recentf-menu-filter
is set to abbreviate them in the menu?

This mode is also described in the user manual; shouldn't this new
command be documented there?





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#56148: [PATCH] New command recentf-open
  2022-06-22 16:04 ` Eli Zaretskii
@ 2022-06-23 11:19   ` Stefan Kangas
  2022-06-23 12:56     ` Eli Zaretskii
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Kangas @ 2022-06-23 11:19 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56148

[-- Attachment #1: Type: text/plain, Size: 726 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

> > +                            (mapcar #'abbreviate-file-name recentf-list)
>
> Shouldn't you apply abbreviate-file-name only if recentf-menu-filter
> is set to abbreviate them in the menu?

Good question, however this was fixed in a different way in Bug#56123
so this is no longer necessary.  I've removed the mapcar and use
recentf-list directly instead.

> This mode is also described in the user manual; shouldn't this new
> command be documented there?

Yes, I saw a need for a rethink of the documentation, which was very
menu-centric.  So I rewrote it slightly to be less menu-centric; I
hope it now makes more sense.

Please find attached a new patch, and thanks for reviewing.

[-- Attachment #2: 0001-New-command-recentf-open.patch --]
[-- Type: text/x-patch, Size: 5391 bytes --]

From 7ba148ff7f57242e9d28fb882ce6ebc2f1c224a5 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <stefan@marxist.se>
Date: Wed, 22 Jun 2022 16:54:40 +0200
Subject: [PATCH] New command recentf-open

* lisp/recentf.el (recentf-open): New command.
(recentf): New alias.
(recentf, recentf-mode): Update documentation to focus more on the
list of recently opened files and ways of accessing it, instead of
focusing on the menu bar only.
(recentf-list, recentf-enabled-p): Minor doc fixes.

* doc/emacs/files.texi (File Conveniences): Update documentation.
---
 doc/emacs/files.texi | 13 +++++++-----
 etc/NEWS             |  5 +++++
 lisp/recentf.el      | 49 ++++++++++++++++++++++++++++++++++++--------
 3 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 062185fb4a..5236eb0b50 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -2222,13 +2222,16 @@ File Conveniences
 
 @findex recentf-mode
 @vindex recentf-mode
+@findex recentf-open
 @findex recentf-save-list
 @findex recentf-edit-list
-  If you enable Recentf mode, with @kbd{M-x recentf-mode}, the
-@samp{File} menu includes a submenu containing a list of recently
-opened files.  @kbd{M-x recentf-save-list} saves the current
-@code{recentf-list} to a file, and @kbd{M-x recentf-edit-list} edits
-it.
+  If you enable Recentf mode, with @kbd{M-x recentf-mode}, Emacs
+maintains a list of recently opened files.  To open a file from this
+list, use the @kbd{M-x recentf-open} command.  When this mode is
+enabled, the @samp{File} menu will include a submenu containing a list
+of recently opened files.  @kbd{M-x recentf-save-list} saves the
+current @code{recentf-list} to a file, and @kbd{M-x recentf-edit-list}
+edits it.
 
 @c FIXME partial-completion-mode (complete.el) is obsolete.
   The @kbd{M-x ffap} command generalizes @code{find-file} with more
diff --git a/etc/NEWS b/etc/NEWS
index 6c04ae164c..85a538bcfa 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1861,6 +1861,11 @@ This means that e.g. "/home/foo/bar" is now displayed as "~/bar".
 Customize the user option 'recentf-filename-handlers' to nil to get
 back the old behavior.
 
+---
+*** New command 'recentf-open'.
+This command prompts for a recently opened file in the minibuffer, and
+visits it.
+
 ---
 ** The autoarg.el library is now marked obsolete.
 This library provides the 'autoarg-mode' and 'autoarg-kp-mode' minor
diff --git a/lisp/recentf.el b/lisp/recentf.el
index b31aafc9dc..e940259b00 100644
--- a/lisp/recentf.el
+++ b/lisp/recentf.el
@@ -1,4 +1,4 @@
-;;; recentf.el --- setup a menu of recently opened files  -*- lexical-binding: t -*-
+;;; recentf.el --- keep track of recently opened files  -*- lexical-binding: t -*-
 
 ;; Copyright (C) 1999-2022 Free Software Foundation, Inc.
 
@@ -23,10 +23,19 @@
 
 ;;; Commentary:
 
-;; This package maintains a menu for visiting files that were operated
-;; on recently.  When enabled a new "Open Recent" submenu is
-;; displayed in the "File" menu.  The recent files list is
-;; automatically saved across Emacs sessions.
+;; This package maintains a list of recently opened files and makes it
+;; easy to visit them.  The recent files list is automatically saved
+;; across Emacs sessions.
+
+;; There are three ways to access recent files:
+;;
+;; (1) `M-x recentf-open' prompts for a recently opened file.
+;;
+;; (2) When this mode is enabled, a new "Open Recent" submenu is
+;;     displayed in the "File" menu.
+;;
+;; (3) `M-x recentf-open-files' lists recently visited files in a
+;;     buffer.
 
 ;; You can customize the number of recent files displayed, the
 ;; location of the menu and other options.  Type:
@@ -45,17 +54,17 @@
 ;;; Internal data
 ;;
 (defvar recentf-list nil
-  "List of recently opened files.")
+  "List of recently opened files for `recentf-mode'.")
 
 (defun recentf-enabled-p ()
-  "Return non-nil if recentf mode is currently enabled."
+  "Return non-nil if `recentf-mode' is currently enabled."
   (memq 'recentf-save-list kill-emacs-hook))
 
 \f
 ;;; Customization
 ;;
 (defgroup recentf nil
-  "Maintain a menu of recently opened files."
+  "Maintain a list of recently opened files."
   :version "21.1"
   :group 'files)
 
@@ -463,6 +472,24 @@ recentf-directory-compare
         (recentf-string-lessp (file-name-nondirectory f1)
                               (file-name-nondirectory f2))
       (recentf-string-lessp d1 d2))))
+
+\f
+;;; Open files
+;;
+
+(defun recentf-open (file)
+  "Prompt for FILE in `recentf-list' and visit it.
+Enable `recentf-mode' if it isn't already."
+  (interactive
+   (list
+    (progn (unless recentf-mode (recentf-mode 1))
+           (completing-read (format-prompt "Open recent file" nil)
+                            recentf-list nil t))))
+  (when file
+    (funcall recentf-menu-action file)))
+
+(defalias 'recentf 'recentf-open)
+
 \f
 ;;; Menu building
 ;;
@@ -1343,6 +1370,12 @@ recentf-mode-map
 ;;;###autoload
 (define-minor-mode recentf-mode
   "Toggle \"Open Recent\" menu (Recentf mode).
+This mode maintains a list of recently opened files and makes it
+easy to visit them.  The recent files list is automatically saved
+across Emacs sessions.
+
+You can use `recentf-open' or `recentf-open-files' to visit
+files.
 
 When Recentf mode is enabled, a \"Open Recent\" submenu is
 displayed in the \"File\" menu, containing a list of files that
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#56148: [PATCH] New command recentf-open
  2022-06-23 11:19   ` Stefan Kangas
@ 2022-06-23 12:56     ` Eli Zaretskii
  2022-06-25 11:01       ` Stefan Kangas
  0 siblings, 1 reply; 5+ messages in thread
From: Eli Zaretskii @ 2022-06-23 12:56 UTC (permalink / raw)
  To: Stefan Kangas; +Cc: 56148

> From: Stefan Kangas <stefan@marxist.se>
> Date: Thu, 23 Jun 2022 13:19:04 +0200
> Cc: 56148@debbugs.gnu.org
> 
> +                                               When this mode is
> +enabled, the @samp{File} menu will include a submenu containing a list
> +of recently opened files.

I think this sentence should end with "which you can use to visit one
of these files."





^ permalink raw reply	[flat|nested] 5+ messages in thread

* bug#56148: [PATCH] New command recentf-open
  2022-06-23 12:56     ` Eli Zaretskii
@ 2022-06-25 11:01       ` Stefan Kangas
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Kangas @ 2022-06-25 11:01 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 56148

close 56148 29.1
thanks

Eli Zaretskii <eliz@gnu.org> writes:

> I think this sentence should end with "which you can use to visit one
> of these files."

Thanks, pushed to master with that change (commit 3d3029353b).





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-06-25 11:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-22 14:57 bug#56148: [PATCH] New command recentf-open Stefan Kangas
2022-06-22 16:04 ` Eli Zaretskii
2022-06-23 11:19   ` Stefan Kangas
2022-06-23 12:56     ` Eli Zaretskii
2022-06-25 11:01       ` Stefan Kangas

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.