* recentf function to manually add files to recentf-save-file
@ 2017-04-18 21:35 John Magolske
0 siblings, 0 replies; only message in thread
From: John Magolske @ 2017-04-18 21:35 UTC (permalink / raw)
To: help-gnu-emacs
The behaviour I'd like for adding files to recentf is to have a
function bound to a key that places the current file in the buffer
into the recentf-save-file. This way recentf would keep track of
only the files that I explicitly tell it to, one keypress at a time.
In this scenario, the *only* time any file would be added to the
recentf-save-file would be when this function is run. I'd rather not
bother with running something every so often that places files that
happen to be open at that time into the recentf-save-file, figuring
out what files to exclude, synchronizing between different instances
of Emacs, etc.
Below is what I've come up with so far. The current file in buffer
is placed into the recentf-save-file whenever I press my "save" key.
Not sure if there's a better way to go about this or if I overlooked
something...any suggestions/perspectives are welcome.
;;;; elisp ;;;;
(require 'recentf)
(require 'sync-recentf)
(setq recentf-save-file (expand-file-name "recentf" user-emacs-directory)
recentf-max-saved-items 1000)
(recentf-mode 1)
(defun jfm-add-buffer-file-to-recentf ()
"add file in buffer to the recent list, cleanup the list (remove
duplicates, excluded files, etc.) and save to recentf-save-file"
(interactive)
(when (buffer-file-name)
(recentf-add-file (buffer-file-name))
(recentf-cleanup)
(recentf-save-list))
nil)
(global-set-key (kbd "<f8>")
(lambda ()
(interactive)
(jfm-add-buffer-file-to-recentf) (save-buffer)))
(defalias 'rel 'recentf-edit-list)
;;;; end elisp ;;;;
Regards,
John
--
John Magolske
http://b79.net/contact
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-04-18 21:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-18 21:35 recentf function to manually add files to recentf-save-file John Magolske
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).