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 543245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:31:52+00:00 2026-05-13T10:31:52+00:00

GNU 23.1.1 By clicking the F5 button I can compile my project. However, I

  • 0

GNU 23.1.1

By clicking the F5 button I can compile my project. However, I want to extend this so that any unsaved work would be saved and then compiled.

Normally I just do C-x-s to save then click F5. But can I add a line that will save without having to ask me do I want to save then it will compile, all done automatically?

; Compile program using <F5>
; Save all unsaved files here, then compile
(global-set-key [f5] 'compile)

Hope you understand me?

Many thanks for any advice,

  • 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-13T10:31:52+00:00Added an answer on May 13, 2026 at 10:31 am

    You can use (save-some-buffers 1) to save all buffers containing changes.

    Wrap it up with a function together with compile like so:

    (defun save-all-and-compile ()
      (save-some-buffers 1)
      (compile compile-command))
    

    Then set F5 to run this function instead of plain compile.

    Use (save-some-buffers) (no argument) if you prefer Emacs to ask you about each buffer to be saved. Also, you might want to make the compilation-command customisable, as it is with compile… I’ll leave that to you though.


    Getting it to work

    You also have to add (interactive), see full example below.

    (defun save-all-and-compile ()
      (interactive)
      (save-some-buffers 1)
      (compile compile-command))
    (global-set-key [f5] 'save-all-and-compile)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The application will stop responding to any touch events after clicking on either button.
In the GNU make docs, '%' is documented to match any nonempty substring. However,
I want to use GNU screen in such a way that the user doesn't
I'm using GNU autotools for the build system on a particular project. I want
GNU Emacs 23.1 I am using iswitchb. However, when I press C-x b I
When trying to compile GNU software on HP-UX (binutils for example) I'm getting error
My gdb is GNU gdb Red Hat Linux (6.3.0.0-1.162.el4rh) and I can't debug templates.
GNU Emacs 23.1.1 Fedora 13 I can select the colour theme by M-x color-theme-select
The GNU C library uses DWARF2 unwinding for pthread cancellation these days, so that
I have the GNU GCC compiler for Windows. I read that it is able

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.