Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6381153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:21:36+00:00 2026-05-25T02:21:36+00:00

I know how to configure emacs to keep numbered backups. I don’t know the

  • 0

I know how to configure emacs to keep numbered backups. I don’t know the most canonical way to find those numbered backups.

The emacs function “find-backup-file-name” seems like it is the closest. Its documentation states:

This function computes the file name for a new backup file for filename. It may also propose certain existing backup files for deletion. find-backup-file-name returns a list whose CAR is the name for the new backup file and whose CDR is a list of backup files whose deletion is proposed.

However, this is not what I am looking for. I’m looking for a list of ALL previously created backup files. Here’s the code (paraphrased) I have written to accomplish this:

(defvar backup-directory "~/emacs.d/backups/")
(defun get-backup-pattern (file-name)
    (concat "*" (replace-regexp-in-string "\/" "\\!" file-name t t) ".~*"))

(butlast
  (split-string
    (shell-command-to-string
        (concat "find " 
                 backup-directory 
                 " -name \"" 
                 (get-backup-pattern (buffer-file-name)) 
                 "\""))
    "\n"))

This method works fine. However, shelling out to “find” seems a like a hack to me; Especially since this method is platform specific.

Is there a built-in method I should use or at least something more idiomatic?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:21:37+00:00Added an answer on May 25, 2026 at 2:21 am

    So here is the solution I’ve decided on. I went away from using the *nix find command and am using directory-files as suggested.

    (defun get-filter-pattern (file-name)
      (concat (replace-regexp-in-string "\/" "!" file-name t t)
          ".~[0-9]*~*$"))
    
    (defun filter (condp lst)
      (delq nil
        (mapcar (lambda (x) (and (funcall condp x) x)) lst)))
    
    (defun filter-files (backup-directory buffer-file-name)
      (mapcar (lambda (backup-name) (concat backup-directory backup-name))
          (filter (lambda (backup-name)
                (string-match (get-filter-pattern buffer-file-name) backup-name))
              (directory-files backup-directory))))
    

    Perhaps this isn’t quite as optimized as using find. However, it should be platform independent (ie can use on Windows).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can't find javadoc for Hessian lib. I want to know how to configure
I know how to configure aliases in bash, but is there a way to
I am working on jsp. I have eclipse but don't know how to configure
I really don't know how to configure my question because I don't know how
I don't know why but currently emacs opens only one copy of w3m. If
I just wanted to know how to configure FCKEditor to upload files and images
I am trying to reach the following result here I know how to configure
FTPS in IIS 7.5 is cool. Do you know how to configure it?
I'd like to know how I can configure TortoiseHg Workbench so it alawys supplies
Does anyone know of a DB setting in DotNetNuke, where you can configure ALL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.