* More convenient editing of recentf files @ 2009-03-15 18:42 B. T. Raven 2009-03-15 19:47 ` Lennart Borgman ` (3 more replies) 0 siblings, 4 replies; 7+ messages in thread From: B. T. Raven @ 2009-03-15 18:42 UTC (permalink / raw) To: help-gnu-emacs In .emacs I have: (add-to-list 'same-window-buffer-names "*Buffer List*") and '(iswitchb-mode t nil (iswitchb)) in custom-set-variables so I can navigate to buffers quickly with C-x b and kill selected ones with C-x C-b via D, SPC, and X keys. Is there a way to do something like this with recentf files? Now I have to use the mousey checkbox interface: menubar > Open Recent > Edit list > check ... check ... check .... move to bottom of list ... check ok Thanks, Ed ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: More convenient editing of recentf files 2009-03-15 18:42 More convenient editing of recentf files B. T. Raven @ 2009-03-15 19:47 ` Lennart Borgman 2009-03-15 22:53 ` Drew Adams ` (2 subsequent siblings) 3 siblings, 0 replies; 7+ messages in thread From: Lennart Borgman @ 2009-03-15 19:47 UTC (permalink / raw) To: B. T. Raven; +Cc: help-gnu-emacs On Sun, Mar 15, 2009 at 7:42 PM, B. T. Raven <nihil@nihilo.net> wrote: > In .emacs I have: > > (add-to-list 'same-window-buffer-names "*Buffer List*") > > and > > '(iswitchb-mode t nil (iswitchb)) in custom-set-variables > > so I can navigate to buffers quickly with C-x b and kill selected ones with > C-x C-b via > > D, SPC, and X keys. Is there a way to do something like this with recentf > files? Now I have to use the mousey checkbox interface: > menubar > Open Recent > Edit list > check ... check ... check .... move to > bottom of list ... check ok Maybe (recentf-open-files)? ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: More convenient editing of recentf files 2009-03-15 18:42 More convenient editing of recentf files B. T. Raven 2009-03-15 19:47 ` Lennart Borgman @ 2009-03-15 22:53 ` Drew Adams 2009-03-15 23:02 ` Drew Adams [not found] ` <mailman.3262.1237146438.31690.help-gnu-emacs@gnu.org> [not found] ` <mailman.3269.1237157595.31690.help-gnu-emacs@gnu.org> 3 siblings, 1 reply; 7+ messages in thread From: Drew Adams @ 2009-03-15 22:53 UTC (permalink / raw) To: 'B. T. Raven', help-gnu-emacs > From: B. T. Raven Sent: Sunday, March 15, 2009 11:43 AM > In .emacs I have: > (add-to-list 'same-window-buffer-names "*Buffer List*") > and '(iswitchb-mode t nil (iswitchb)) in custom-set-variables > so I can navigate to buffers quickly with C-x b and kill > selected ones with C-x C-b via D, SPC, and X keys. > Is there a way to do something like this with recentf files? > Now I have to use the mousey checkbox interface: > menubar > Open Recent > Edit list > check ... check ... check > .... move to bottom of list ... check ok Perhaps someone else will give you an Iswitchb-specific answer for recentf file deletion. If not, the following might help. If you use Icicles, you can use `Remove from Recent Files List' in menu Files > Icicles, or use `M-x icicle-remove-file-from-recentf-list'. During completion, you can filter candidates with your input (e.g. substring, regexp, prefix), and cycle among matches. Use `C-RET' or `C-mouse-2' repeatedly to remove as many individual file names as you like. Use `C-!' to remove all file names that match the current input pattern - use as many patterns as you like. Use `C-~' (complement) to match against all candidates that do *not* match some input pattern. Use `M-SPC' to combine input patterns (logical AND): progessive completion. (And yes, you can use Iswitchb with Icicles.) ---- Without Icicles, you could call, within a loop, a command that reads a single absolute file name using completion (letting the user quit the loop with, e.g., `C-g'). A user would then complete file names to remove them from `recentf-list'. (defun remove-some-recent-files () "Remove some files from the list of recently used files." (interactive) (while recentf-list (call-interactively #'remove-a-recent-file))) Within the loop, call `completing-read' against `recentf-list'. E.g.: (defun remove-a-recent-file (file) "Remove a file from the list of recently used files." (interactive (list (completing-read "Remove from recent files list (`C-g' when done): " (mapcar #'list (progn (unless (boundp 'recentf-list)(require 'recentf)) (when (fboundp 'recentf-mode) (recentf-mode 99)) (unless (consp recentf-list) (error "No recently accessed files")) recentf-list)) nil (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) ; Emacs23. nil 'file-name-history (car recentf-list)))) (setq recentf-list (delete file recentf-list)) (message "`%s' removed from `recentf-list'" file)) If you know you're going to have `recentf.el' loaded and be in `recentf-mode', then you can skip the first part of the `progn'. If you know you have Emacs 22+, you can skip the `mapcar'. If you know you have Emacs 23, you can skip the `fboundp' for `confirm-...'. ---- FYI, a nearly identical definition suffices to define the Icicles multi-command (no loop needed) that lets you remove as many files as you want from the list: (icicle-define-command icicle-remove-file-from-recentf-list "Remove some files from the list of recently used files." icicle-remove-from-recentf-candidate-action "Remove from recent files list: " (mapcar #'list (progn (unless (boundp 'recentf-list) (require 'recentf)) (when (fboundp 'recentf-mode) (recentf-mode 99)) (unless (consp recentf-list) (error "No recently accessed files")) recentf-list)) nil (and (fboundp 'confirm-nonexistent-file-or-buffer) (confirm-nonexistent-file-or-buffer)) nil 'file-name-history (car recentf-list) nil ((icicle-use-candidates-only-once-flag t))) (defun icicle-remove-from-recentf-candidate-action (file) "Action function for `icicle-remove-file-from-recentf-list'." (setq recentf-list (delete file recentf-list)) (message "`%s' removed from `recentf-list'" file)) HTH. ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: More convenient editing of recentf files 2009-03-15 22:53 ` Drew Adams @ 2009-03-15 23:02 ` Drew Adams 0 siblings, 0 replies; 7+ messages in thread From: Drew Adams @ 2009-03-15 23:02 UTC (permalink / raw) To: help-gnu-emacs I said: > Within the loop, call `completing-read' against > `recentf-list'. E.g.: > ... > (progn > (unless (boundp 'recentf-list)(require 'recentf)) > (when (fboundp 'recentf-mode) (recentf-mode 99)) > (unless (consp recentf-list) > (error "No recently accessed files")) > recentf-list)) Obviously, if you choose this approach, you would want to move the recentf tests outside the loop. I wanted to also show how defining an Icicles multi-command mirrors defining an ordinary command that calls `completing-read'. (In Icicles there is no loop - just a single call to `completing-read'.) ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.3262.1237146438.31690.help-gnu-emacs@gnu.org>]
* Re: More convenient editing of recentf files [not found] ` <mailman.3262.1237146438.31690.help-gnu-emacs@gnu.org> @ 2009-03-15 23:01 ` B. T. Raven 0 siblings, 0 replies; 7+ messages in thread From: B. T. Raven @ 2009-03-15 23:01 UTC (permalink / raw) To: help-gnu-emacs Lennart Borgman wrote: > On Sun, Mar 15, 2009 at 7:42 PM, B. T. Raven <nihil@nihilo.net> wrote: >> In .emacs I have: >> >> (add-to-list 'same-window-buffer-names "*Buffer List*") >> >> and >> >> '(iswitchb-mode t nil (iswitchb)) in custom-set-variables >> >> so I can navigate to buffers quickly with C-x b and kill selected ones with >> C-x C-b via >> >> D, SPC, and X keys. Is there a way to do something like this with recentf >> files? Now I have to use the mousey checkbox interface: >> menubar > Open Recent > Edit list > check ... check ... check .... move to >> bottom of list ... check ok > > Maybe (recentf-open-files)? > > No. That works just like (recentf-edit-list). You navigate with Tab and Return rather than with Spacebar, D, and X as in dired. ^ permalink raw reply [flat|nested] 7+ messages in thread
[parent not found: <mailman.3269.1237157595.31690.help-gnu-emacs@gnu.org>]
* Re: More convenient editing of recentf files [not found] ` <mailman.3269.1237157595.31690.help-gnu-emacs@gnu.org> @ 2009-03-16 1:09 ` B. T. Raven 2009-03-16 3:24 ` Drew Adams 0 siblings, 1 reply; 7+ messages in thread From: B. T. Raven @ 2009-03-16 1:09 UTC (permalink / raw) To: help-gnu-emacs Drew Adams wrote: >> From: B. T. Raven Sent: Sunday, March 15, 2009 11:43 AM >> In .emacs I have: >> (add-to-list 'same-window-buffer-names "*Buffer List*") >> and '(iswitchb-mode t nil (iswitchb)) in custom-set-variables >> so I can navigate to buffers quickly with C-x b and kill >> selected ones with C-x C-b via D, SPC, and X keys. > >> Is there a way to do something like this with recentf files? >> Now I have to use the mousey checkbox interface: >> menubar > Open Recent > Edit list > check ... check ... check >> .... move to bottom of list ... check ok > > Perhaps someone else will give you an Iswitchb-specific answer for recentf file > deletion. If not, the following might help. > > If you use Icicles, you can use `Remove from Recent Files List' in menu Files > > Icicles, or use `M-x icicle-remove-file-from-recentf-list'. > > During completion, you can filter candidates with your input (e.g. substring, > regexp, prefix), and cycle among matches. Use `C-RET' or `C-mouse-2' repeatedly > to remove as many individual file names as you like. > > Use `C-!' to remove all file names that match the current input pattern - use as > many patterns as you like. Use `C-~' (complement) to match against all > candidates that do *not* match some input pattern. Use `M-SPC' to combine input > patterns (logical AND): progessive completion. > > (And yes, you can use Iswitchb with Icicles.) > > ---- > > Without Icicles, you could call, within a loop, a command that reads a single > absolute file name using completion (letting the user quit the loop with, e.g., > `C-g'). A user would then complete file names to remove them from > `recentf-list'. > > (defun remove-some-recent-files () > "Remove some files from the list of recently used files." > (interactive) > (while recentf-list > (call-interactively #'remove-a-recent-file))) > > Within the loop, call `completing-read' against `recentf-list'. E.g.: > > (defun remove-a-recent-file (file) > "Remove a file from the list of recently used files." > (interactive > (list > (completing-read > "Remove from recent files list (`C-g' when done): " > (mapcar #'list > (progn > (unless (boundp 'recentf-list)(require 'recentf)) > (when (fboundp 'recentf-mode) (recentf-mode 99)) > (unless (consp recentf-list) > (error "No recently accessed files")) > recentf-list)) > nil (and (fboundp 'confirm-nonexistent-file-or-buffer) > (confirm-nonexistent-file-or-buffer)) ; Emacs23. > nil 'file-name-history (car recentf-list)))) > (setq recentf-list (delete file recentf-list)) > (message "`%s' removed from `recentf-list'" file)) > > If you know you're going to have `recentf.el' loaded and be in `recentf-mode', > then you can skip the first part of the `progn'. If you know you have Emacs 22+, > you can skip the `mapcar'. If you know you have Emacs 23, you can skip the > `fboundp' for `confirm-...'. Thanks, Drew. I called the main defun prune-recentf-list and it worked but with deeply nested file hierarchy, it's still a lot of typing. For now I'll just use: (defalias 'rel 'recentf-edit-list) (defalias 'rof 'recentf-open-files) (defalias 'rsl 'recentf-save-list) so I can avoid the mouse. Does the code below require that Icicles be installed? It looks like it depends on the existence of icicle-define-command. I probably will install icicles someday. It looks intriguing but I need to keep things as close to the standard Emacs install as possible for now. Ed > > ---- > > FYI, a nearly identical definition suffices to define the Icicles multi-command > (no loop needed) that lets you remove as many files as you want from the list: > > (icicle-define-command icicle-remove-file-from-recentf-list > "Remove some files from the list of recently used files." > icicle-remove-from-recentf-candidate-action > "Remove from recent files list: " > (mapcar #'list > (progn > (unless (boundp 'recentf-list) (require 'recentf)) > (when (fboundp 'recentf-mode) (recentf-mode 99)) > (unless (consp recentf-list) > (error "No recently accessed files")) > recentf-list)) > nil (and (fboundp 'confirm-nonexistent-file-or-buffer) > (confirm-nonexistent-file-or-buffer)) > nil 'file-name-history (car recentf-list) nil > ((icicle-use-candidates-only-once-flag t))) > > (defun icicle-remove-from-recentf-candidate-action (file) > "Action function for `icicle-remove-file-from-recentf-list'." > (setq recentf-list (delete file recentf-list)) > (message "`%s' removed from `recentf-list'" file)) > > HTH. > > > ^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: More convenient editing of recentf files 2009-03-16 1:09 ` B. T. Raven @ 2009-03-16 3:24 ` Drew Adams 0 siblings, 0 replies; 7+ messages in thread From: Drew Adams @ 2009-03-16 3:24 UTC (permalink / raw) To: 'B. T. Raven', help-gnu-emacs > From: B. T. Raven Sent: Sunday, March 15, 2009 6:09 PM > > Thanks, Drew. I called the main defun prune-recentf-list and > it worked but with deeply nested file hierarchy, it's still > a lot of typing. I guess you're saying that with a file that has many ancestor directories, you must type a lot, for (absolute file-name) completion to distinguish a unique candidate. Yes, I can see that. That's where Icicles substring or regexp matching comes into play. You can match any parts of the absolute file name. Pick one or more distinctive parts of the name, and match just those parts directly. No need to type the whole prefix up to the significantly different part. That part is not available with the vanilla code I sent, even though the actual code is almost the same. You need Icicles to get the other features. > For now I'll just use: > (defalias 'rel 'recentf-edit-list) > (defalias 'rof 'recentf-open-files) > (defalias 'rsl 'recentf-save-list) > so I can avoid the mouse. > > Does the code below require that Icicles be installed? > It looks like it depends on the existence of icicle-define-command. The first code I sent (`remove-some-recent-files') does not require Icicles. I think it might respond to your need. (I guess that's what you called `prune-recentf-list', above.) The second code I sent (`icicle-remove-file-from-recentf-list') depends on (a) Icicles being installed and (b) your being in Icicle minor mode. It uses Icicles multi-command features. > I probably will install icicles someday. It looks intriguing > but I need to keep things as close to the standard Emacs > install as possible for now. (FWIW, you can toggle Icicle mode off at any time, to return to vanilla Emacs behavior.) Let me be clear. My aim was to: 1. Give you an idea how to code a command that would help you out, using vanilla Emacs (no Icicles). 2. Explain that nearly the same code will define a multi-command in Icicles, which can be even more helpful (but which requires Icicles). The code is about the same, but the effect is more power, because of being able to bring into play other Icicles features (e.g. regexp matching, candidate cycling). Had the aim been just to tell you how to get what you need with Icicles, I would have mentioned foremost that you can remove file names from the recent list on the fly, when you use command `icicle-recent-file' (File > Icicles > Open Recent File) to open recent files. No need to invoke a separate command (`icicle-remove-file-from-recentf-list') just for the removal. How does that work? `icicle-recent-file' is ostensibly for opening one or more recent files, not for removing them from `recentf-list'. But just as you can use `C-RET', `C-mouse-2', etc. with an Icicles multi-command to act on more than one candidate (see previous mail), so, at least with some multi-commands, you can use `C-S-RET', `C-S-mouse-2', etc. to act in some other way on candidates. These are "alternative action" keys, and for `icicle-recent-file' the alternative action is to remove the chosen file name from the recent-files list. So this is a second way to do what you requested using Icicles. If you are already in the process of opening one or more recent files, you can also remove one or more others from the recent list at the same time. HTH. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2009-03-16 3:24 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-03-15 18:42 More convenient editing of recentf files B. T. Raven 2009-03-15 19:47 ` Lennart Borgman 2009-03-15 22:53 ` Drew Adams 2009-03-15 23:02 ` Drew Adams [not found] ` <mailman.3262.1237146438.31690.help-gnu-emacs@gnu.org> 2009-03-15 23:01 ` B. T. Raven [not found] ` <mailman.3269.1237157595.31690.help-gnu-emacs@gnu.org> 2009-03-16 1:09 ` B. T. Raven 2009-03-16 3:24 ` Drew Adams
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).